game-detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="game-content">
  3. <!-- 自定义导航栏 -->
  4. <uni-nav-bar id="nav-bar" status-bar="true" @clickRight="onNavHome" @clickLeft="showClickEvent('DrawerModalL')" title="视频"
  5. color="#FFFFFF" fixed="true" backgroundColor="rgba(153, 150, 252, 255)">
  6. <view slot="left">
  7. <view class=" flex align-center margin-left">
  8. <image class="png-more" src="/static/more.png"></image>
  9. </view>
  10. </view>
  11. <!-- <view slot="right">
  12. <view class=" flex align-center " style="margin-right: 10rpx;">
  13. <image class="png-more" src="/static/mConver.png"></image>
  14. </view>
  15. </view> -->
  16. <view slot="right">
  17. <view class=" flex align-center " style="margin-right: 10rpx;">
  18. <view class="cuIcon-home text-20px-before"></view>
  19. </view>
  20. </view>
  21. </uni-nav-bar>
  22. <scroll-view v-if="decodeItem" class="scroll-class" scroll-y="true" :style="{'height':scrollviewHigh+'px'}">
  23. <view class="cu-bar back-class">
  24. <view class="action round" style="background-color: rgba(0,0,0,0.35);" @tap="onBack">
  25. <text class="cuIcon-back text-white" style="padding: 10rpx 0 10rpx 20rpx;"></text>
  26. </view>
  27. <!-- <view class="content text-bold">
  28. 操作条
  29. </view> -->
  30. </view>
  31. <swiper class="screen-swiper" style="height: 456px;" :class="dotStyle?'square-dot':'round-dot'" :indicator-dots="true"
  32. :circular="true" :autoplay="true" interval="5000" duration="500">
  33. <swiper-item v-for="(item,index) in swiperList" :key="index">
  34. <image :src="item" mode="aspectFill"></image>
  35. </swiper-item>
  36. </swiper>
  37. <view class="game-child-content">
  38. <view class="text-gray text-df">{{decodeItem.createTime}}</view>
  39. <view class="margin-top-sm text-bold text-xl">{{decodeItem.gameName}}</view>
  40. <view class="margin-top-sm text-content text-df">
  41. {{decodeItem.gameDescription}}
  42. </view>
  43. <view class='flex flex-wrap ' style="margin: 10rpx 0;">
  44. <view style="padding-right:5rpx;" v-for="(item,index) in gameTags" :key="index">
  45. <view class='cu-tag line-purple radius'>{{item.tagName}}</view>
  46. </view>
  47. </view>
  48. <view class="flex padding justify-around plan-Tip-child">
  49. <view>
  50. <image class="margin-lr-xs right-png" :src="gameFavorite?'/static/favorite_r.png':'/static/favorite_g.png'" mode="aspectFill"
  51. @tap="onFavoriteAdd"></image>
  52. </view>
  53. <view>
  54. <!-- <image class="margin-lr-xs right-png" src="/static/info_g.png" mode="aspectFill" @tap="onNavComment"></image> -->
  55. </view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. <view class="bottom-container">
  60. <view class="cu-bar tabbar" style="height: 100%;">
  61. <button class="cu-btn make-bg-bPurple text-white lg margin-lg" style="width: 100%;" @tap="onNavToWebviewGame">马上去玩</button>
  62. </view>
  63. </view>
  64. <sideBarD ref="sideBarDetail">
  65. </sideBarD>
  66. <!-- <button @tap="onNavToMiniGame">跳转小游戏</button> -->
  67. <!-- <button @tap="onNavToWebviewGame">跳转webview游戏</button> -->
  68. </view>
  69. </template>
  70. <script>
  71. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue";
  72. import sideBarD from "@/components/side-bar/side-bar.vue";
  73. import reqUtil from "@/util/util-js/requstUtil.js"
  74. import config from "@/common/config.js"
  75. import {
  76. mapState,
  77. mapMutations
  78. } from 'vuex';
  79. export default {
  80. components: {
  81. uniNavBar,
  82. sideBarD
  83. },
  84. computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'cIndex']),
  85. data() {
  86. return {
  87. //解编码item
  88. decodeItem: '',
  89. //编码的item
  90. encodeItem: '',
  91. cardCur: 0,
  92. swiperList: [],
  93. gameTags: [],
  94. dotStyle: false,
  95. towerStart: 0,
  96. direction: '',
  97. scrollviewHigh: 500,
  98. gameFavorite: false,
  99. }
  100. },
  101. onLoad(option) {
  102. if (option.item) {
  103. console.log('option:', option);
  104. // this.encodeItem = option.item;
  105. // this.decodeItem = JSON.parse(decodeURIComponent(option.item));
  106. let item = JSON.parse(decodeURIComponent(option.item));
  107. // console.log("==",item);
  108. this.gameFavorite = item.gameFavorite;
  109. reqUtil.requestData(config.URL.GAMEDETAIL, item).then(res => {
  110. console.log('GAMEDETAIL =====', res);
  111. if (res.code == 0) {
  112. this.encodeItem = encodeURIComponent(JSON.stringify(res.data.gameInfo));
  113. this.decodeItem = res.data.gameInfo;
  114. this.swiperList = res.data.gamePicturesList;
  115. this.gameTags = res.data.gameTags;
  116. }
  117. },
  118. e => {
  119. console.log(e)
  120. });
  121. }
  122. },
  123. onReady() {
  124. let _this = this;
  125. uni.getSystemInfo({
  126. success(res) {
  127. // 计算组件的高度
  128. // console.log("组件高度:", res);
  129. let view = uni.createSelectorQuery().select("#nav-bar")
  130. view.boundingClientRect(data => {
  131. // console.log("data:", data);
  132. let navHeight = data.height;
  133. _this.scrollviewHigh = res.windowHeight - 58 - navHeight;
  134. }).exec()
  135. // _this.scrollviewHigh = res.windowHeight- uni.getSystemInfoSync().screenWidth / 750 * (300); //像素
  136. }
  137. })
  138. },
  139. methods: {
  140. ...mapMutations(['glimitPlayGame']),
  141. // 跳转转换页面
  142. onNavConver() {
  143. uni.navigateTo({
  144. url: '../../conversion-page/conversion/conversion',
  145. success: res => {},
  146. fail: () => {},
  147. complete: () => {}
  148. });
  149. },
  150. //跳转回主页
  151. onNavHome() {
  152. uni.reLaunch({
  153. url: '../../personal-page/personal/personal',
  154. success: res => {},
  155. fail: () => {},
  156. complete: () => {}
  157. });
  158. },
  159. showClickEvent() {
  160. this.$refs.sideBarDetail.showModal();
  161. },
  162. onBack() {
  163. uni.navigateBack({
  164. delta: 1
  165. })
  166. },
  167. onNavToMiniGame() {
  168. uni.navigateToMiniProgram({
  169. appId: 'wx6898b48e0760935c',
  170. path: '',
  171. extraData: {
  172. 'data1': 'test'
  173. },
  174. success(res) {
  175. // 打开成功
  176. console.log(res);
  177. },
  178. fail(fail) {
  179. console.error(fail);
  180. }
  181. })
  182. },
  183. onNavToWebviewGame() {
  184. //1.先判断模式
  185. //如果都不存在,返回
  186. this.glimitPlayGame({
  187. gameTags: this.gameTags,
  188. callback: () => {
  189. // #ifdef APP-PLUS
  190. uni.navigateTo({
  191. url: '../game-play-sub/game-play-sub?item=' + this.encodeItem,
  192. success: res => {},
  193. fail: () => {},
  194. complete: () => {}
  195. });
  196. // #endif
  197. // #ifdef H5
  198. uni.navigateTo({
  199. url: '../game-play/game-play-web?item=' + this.encodeItem,
  200. success: res => {},
  201. fail: () => {},
  202. complete: () => {}
  203. });
  204. // #endif
  205. }
  206. })
  207. },
  208. onNavComment() {
  209. uni.showToast({
  210. title: '功能尚未开放',
  211. icon: 'none'
  212. })
  213. return;
  214. uni.navigateTo({
  215. url: '../game-comment/game-comment',
  216. success: res => {},
  217. fail: () => {},
  218. complete: () => {}
  219. });
  220. },
  221. //收藏
  222. onFavoriteAdd() {
  223. //添加收藏
  224. let favoritesTemp = {
  225. 'fObjectId': this.decodeItem.gameId,
  226. 'favoritesType': 0,
  227. }
  228. reqUtil.requestData(config.URL.FAVORITESMODIFY, favoritesTemp).then(res => {
  229. console.log('FAVORITESMODIFY =====', res);
  230. if (res.code == 0) {
  231. if (!res.data.bHas) {
  232. this.gameFavorite = false;
  233. uni.showToast({
  234. title: "取消收藏",
  235. icon: "none"
  236. })
  237. } else {
  238. this.gameFavorite = true;
  239. uni.showToast({
  240. title: "收藏成功",
  241. icon: "none"
  242. })
  243. }
  244. }
  245. },
  246. e => {
  247. console.log(e)
  248. });
  249. },
  250. }
  251. }
  252. </script>
  253. <style>
  254. .game-content {
  255. position: fixed;
  256. height: 100%;
  257. width: 100%;
  258. background: #FFFFFF;
  259. /* display: flex; */
  260. /* flex-direction: column; */
  261. /* align-items: center; */
  262. /*垂直居中*/
  263. /* justify-content: center; */
  264. /*水平居中*/
  265. /* border: 1rpx solid #39B54A; */
  266. }
  267. .game-child-content {
  268. margin: 20px;
  269. }
  270. .bottom-container {
  271. position: absolute;
  272. left: 0;
  273. bottom: 0;
  274. width: 100%;
  275. height: 58px;
  276. /* border: 1rpx solid #39B54A; */
  277. }
  278. .scroll-class {
  279. /* background-color: #007AFF; */
  280. /* border: 1rpx solid #007AFF; */
  281. position: relative;
  282. }
  283. .back-class {
  284. position: absolute;
  285. left: 0;
  286. top: 0;
  287. z-index: 10;
  288. }
  289. .plan-Tip {
  290. height: 90rpx;
  291. margin: 60rpx 0;
  292. }
  293. .plan-Tip-child {
  294. background-color: #F8F8F8;
  295. border-radius: 30px;
  296. width: 100%;
  297. height: 90rpx;
  298. margin: 50rpx 0;
  299. }
  300. .plan-litle-img {
  301. width: 32rpx;
  302. height: 32rpx;
  303. margin-right: 32rpx;
  304. }
  305. .plan-m-img {
  306. width: 1rpx;
  307. height: 110rpx;
  308. border: 1rpx dashed rgba(151, 151, 255, 1);
  309. }
  310. /* 图标大小 */
  311. .data-png {
  312. width: 16px;
  313. height: 16px;
  314. margin: 5rpx;
  315. }
  316. .right-png {
  317. width: 32rpx;
  318. height: 28rpx;
  319. }
  320. </style>