game-detail.vue 8.8 KB

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