game-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view>
  3. <!-- rgba(116, 172, 240, 1) -->
  4. <uni-nav-bar id="nav-bar" status-bar="true" backgroundColor="rgba(153, 150, 252, 255)" <!-- #ifdef APP-PLUS -->
  5. @clickLeft="showDrawer()"
  6. <!-- #endif -->
  7. <!-- #ifdef H5 || MP-WEIXIN -->
  8. @clickLeft="showClickEvent('DrawerModalL')"
  9. <!-- #endif -->
  10. @clickRight="onNavHome" title="游戏" color="#FFFFFF" fixed="true">
  11. <view slot="left">
  12. <view class=" flex align-center margin-left">
  13. <image class="png-more" src="../../../static/more.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. <!-- v-if="(cIndex != -1 && gameShow)||ConnectBindingDevice" -->
  23. <scroll-view scroll-y="true" :style="{ height: scrollviewHight + 'px' }" @scrolltolower="lower">
  24. <view class="game-item card-view" v-for="(item, index) in gameList" :key="index" :data-id="index">
  25. <view @tap="onNavToWebviewGame(item)">
  26. <view class="game-image-container">
  27. <image mode="aspectFill" class="game-item-image" :src="item.gamePicture"></image>
  28. <image class="head-image" :src="item.gameIcon"></image>
  29. <view class="play-bg-image">
  30. <image class="play-image" src="/static/play.png"></image>
  31. </view>
  32. </view>
  33. <view class="cu-list menu-avatar">
  34. <view class="cu-item">
  35. <view class="content flex-sub">
  36. <view>{{ item.gameName }}</view>
  37. <view class='flex flex-wrap ' style="margin: 10rpx 0;">
  38. <view style="padding-right:5rpx;" v-for="(item,index) in item.gameTags"
  39. :key="index">
  40. <view class='cu-tag line-purple radius'>{{item.tagName}}</view>
  41. </view>
  42. </view>
  43. <!-- <view class="text-sm flex justify-between" style="color:rgba(201, 201, 201, 1);">{{item.createTime}}</view> -->
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="text-gray text-sm text-center padding flex flex-direction" style="width: 100%;">
  49. <view @tap="onFavoriteAdd(item)">
  50. <image class="margin-lr-xs right-png" style="margin: 25px 0;"
  51. :src="item.gameFavorite?'/static/favorite_r.png':'/static/favorite_g.png'"
  52. mode="aspectFill"></image>
  53. </view>
  54. <view style="margin-top: 30px;" @tap="onNavComment">
  55. <!-- <image class="margin-lr-xs right-png" style="margin: 20px 0;" src="/static/info_g.png" mode="aspectFill"></image> -->
  56. </view>
  57. <view style="margin-top: 60px;" @tap="onNavDetail(item)">
  58. <view class="cuIcon-moreandroid margin-lr-xs"
  59. style="font-size: 20px; margin: 10px 0; color: #d6d6d6;"></view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- (cIndex == -1 && !gameShow) ||gameList.length == 0 || ConnectBindingDevice == null-->
  64. <view v-if="gameList.length == 0" class="text-16px text-gray text-center margin">没有更多数据</view>
  65. <view style="height: 17px;"></view>
  66. </scroll-view>
  67. <!-- <view class="float-png">
  68. <image src="/static/conversion@2x.png" mode="aspectFit" @tap="onNavConver"></image>
  69. </view> -->
  70. <!-- <round-menu @trigger="onRoundTrigger"></round-menu> -->
  71. <sideBar ref="sideBar"></sideBar>
  72. </view>
  73. </template>
  74. <script>
  75. import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
  76. import sideBar from '@/components/side-bar/side-bar.vue';
  77. import config from '../../../common/config.js';
  78. import reqUtil from '../../../util/util-js/requstUtil.js';
  79. // import roundMenu from "@/components/round-menu/round-menu.vue";
  80. import {
  81. mapState,
  82. mapMutations
  83. } from 'vuex';
  84. export default {
  85. components: {
  86. uniNavBar,
  87. sideBar
  88. },
  89. computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'currentModeIndex', 'cIndex', 'versionCodeState',
  90. 'platform',
  91. 'gamePlatform', 'systemInfo', 'navHeight', 'tabbarHeight'
  92. ]),
  93. data() {
  94. return {
  95. tabList: [],
  96. TabCur: 0,
  97. Category: 0,
  98. scrollLeft: 0,
  99. scrollviewHight: '',
  100. bDontUpdate: false,
  101. //游戏列表
  102. gameList: [],
  103. gamePage: 1,
  104. gameSize: 10,
  105. //默认显示
  106. gameShow: true,
  107. //编码的item
  108. encodeItem: '',
  109. };
  110. },
  111. onLoad(option) {
  112. let _this = this;
  113. },
  114. onReady() {
  115. let phoneHeight = this.systemInfo.windowHeight;
  116. // 计算组件的高度
  117. this.scrollviewHight = phoneHeight - this.navHeight - this.tabbarHeight - this.systemInfo.statusBarHeight;
  118. },
  119. onShow() {
  120. let _index = 1;
  121. this.bDontUpdate = false;
  122. this.gameList = [];
  123. this.gamePage = 1;
  124. if (this.tabList.length == 0) {
  125. //获得游戏类目
  126. reqUtil.requestData(config.URL.GAMECATEGORY).then(
  127. res => {
  128. console.log('GAMECATEGORY =====', res);
  129. if (res.code == 0) {
  130. this.tabList = res.data;
  131. this.TabCur = _index; //game
  132. this.categoryType = this.tabList[_index].categoryType;
  133. this.getGameList(this.categoryType);
  134. }
  135. },
  136. e => {
  137. console.log(e);
  138. }
  139. );
  140. } else {
  141. //如果存在分类
  142. this.getGameList(this.categoryType);
  143. }
  144. },
  145. methods: {
  146. ...mapMutations(['glimitPlayGame', 'showDrawerById']),
  147. // 跳转转换页面
  148. onNavConver() {
  149. uni.reLaunch({
  150. url: '../../conversion-page/conversion/conversion',
  151. success: res => {},
  152. fail: () => {},
  153. complete: () => {}
  154. });
  155. },
  156. //跳转回主页
  157. onNavHome() {
  158. uni.reLaunch({
  159. url: '../../personal-page/personal/personal',
  160. success: res => {},
  161. fail: () => {},
  162. complete: () => {}
  163. });
  164. },
  165. tabSelect(e) {
  166. if (this.TabCur != e.currentTarget.dataset.id) {
  167. //重新设置参数
  168. this.bDontUpdate = false;
  169. this.gameList = [];
  170. this.gamePage = 1;
  171. this.gameSize = 10;
  172. this.TabCur = e.currentTarget.dataset.id;
  173. this.categoryType = e.currentTarget.dataset.category_id;
  174. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  175. this.getGameList(this.categoryType);
  176. }
  177. },
  178. showClickEvent() {
  179. this.$refs.sideBar.showModal();
  180. },
  181. onNavSearch() {
  182. uni.showToast({
  183. title: '功能尚未开放',
  184. icon: 'none'
  185. })
  186. return;
  187. uni.navigateTo({
  188. url: '../game-search/game-search',
  189. success: res => {},
  190. fail: () => {},
  191. complete: () => {}
  192. });
  193. },
  194. //收藏
  195. onFavoriteAdd(item) {
  196. //添加收藏
  197. let favoritesTemp = {
  198. 'fObjectId': item.gameId,
  199. 'favoritesType': 0,
  200. }
  201. reqUtil.requestData(config.URL.FAVORITESMODIFY, favoritesTemp).then(res => {
  202. console.log('FAVORITESMODIFY =====', res);
  203. if (res.code == 0) {
  204. if (!res.data.bHas) {
  205. item.gameFavorite = false;
  206. uni.showToast({
  207. title: "取消收藏",
  208. icon: "none"
  209. })
  210. } else {
  211. uni.showToast({
  212. title: "收藏成功",
  213. icon: "none"
  214. })
  215. item.gameFavorite = true;
  216. }
  217. }
  218. },
  219. e => {
  220. console.log(e)
  221. });
  222. },
  223. onNavComment() {
  224. uni.showToast({
  225. title: '功能尚未开放',
  226. icon: 'none'
  227. })
  228. return;
  229. uni.navigateTo({
  230. url: '../game-comment/game-comment',
  231. success: res => {},
  232. fail: () => {},
  233. complete: () => {}
  234. });
  235. },
  236. onNavDetail(item) {
  237. // console.log(item);
  238. let temItem = encodeURIComponent(JSON.stringify(item));
  239. // return;
  240. uni.navigateTo({
  241. url: '../game-detail/game-detail?item=' + temItem + "&type=game",
  242. success: res => {},
  243. fail: () => {},
  244. complete: () => {}
  245. });
  246. },
  247. onNavToWebviewGame(item) {
  248. // console.log("====item == ",item);
  249. // if (!this.BLEConnectDevice || this.cIndex == -1) {
  250. // uni.showToast({
  251. // title: "没有连接绑带,请连接后重试!",
  252. // icon: "none"
  253. // })
  254. // return;
  255. // }
  256. //1.先判断模式
  257. //如果都不存在,返回
  258. this.glimitPlayGame({
  259. gameTags: item.gameTags,
  260. callback: () => {
  261. reqUtil.requestData(config.URL.GAMEDETAIL, item).then(res => {
  262. console.log('GAMEDETAIL =====', res);
  263. if (res.code == 0) {
  264. this.encodeItem = encodeURIComponent(JSON.stringify(res.data
  265. .gameInfo));
  266. // #ifdef APP-PLUS
  267. uni.navigateTo({
  268. url: '../game-play-sub/game-play-sub?item=' + this
  269. .encodeItem,
  270. success: res => {},
  271. fail: () => {},
  272. complete: () => {}
  273. });
  274. // #endif
  275. // #ifdef H5
  276. uni.navigateTo({
  277. url: '../game-play/game-play-web?item=' + this.encodeItem,
  278. success: res => {},
  279. fail: () => {},
  280. complete: () => {}
  281. });
  282. // #endif
  283. }
  284. },
  285. e => {
  286. console.log(e)
  287. });
  288. }
  289. });
  290. },
  291. getGameList(categoryType) {
  292. uni.showToast({
  293. icon: "loading",
  294. title: "",
  295. mask: true,
  296. duration: 10000
  297. })
  298. let tagId = 3; //默认是普通模式,普通模式可以用手机直接玩
  299. if (this.BLEConnectDevice != null) {
  300. if (1 === this.currentModeIndex) {
  301. //关卡是跳绳
  302. tagId = 4; // rope 标签
  303. } else if (0 === this.currentModeIndex) {
  304. //关卡是拳击
  305. tagId = 1; //hotman模式 标签
  306. }
  307. }
  308. //获得游戏列表
  309. reqUtil.requestData(
  310. config.URL.GAMELISTBYTAG, {
  311. categoryType: categoryType,
  312. //endTime 可以不设置,服务器默认设置一个值
  313. // endTime: config.endTime,
  314. tagId: tagId,
  315. page: this.gamePage,
  316. size: this.gameSize
  317. }, "POST"
  318. ).then(res => {
  319. console.log('GAMELISTBYTAG =====', res);
  320. if (res.code == 0) {
  321. uni.hideToast();
  322. if (res.data.length < this.gameSize) {
  323. this.bDontUpdate = true;
  324. }
  325. if (res.data.length != 0) {
  326. uni.showToast({
  327. icon: "none",
  328. title: "更新成功",
  329. })
  330. } else {
  331. uni.showToast({
  332. icon: "none",
  333. title: "没数据啦",
  334. })
  335. }
  336. this.gameList = this.gameList.concat(res.data);
  337. if (categoryType == 1) {
  338. //game
  339. this.gameShow = this.versionCodeState.showGame;
  340. } else if (categoryType == 2) {
  341. //game
  342. this.gameShow = this.versionCodeState.showVideo;
  343. }
  344. }
  345. },
  346. e => {
  347. console.log(e);
  348. uni.showToast({
  349. icon: "none",
  350. title: "更新出错",
  351. })
  352. }
  353. );
  354. },
  355. onRoundTrigger(data) {
  356. console.log("onRoundTrigger==", data);
  357. // return;
  358. let url = '';
  359. switch (data.item.type) {
  360. case "personal":
  361. //个人中心页面
  362. url = '../../personal-page/personal/personal';
  363. break;
  364. case "game":
  365. url = '../../game-page/game/game';
  366. break;
  367. default:
  368. url = '../../personal-page/personal/personal';
  369. break;
  370. }
  371. uni.reLaunch({
  372. url: url,
  373. success: res => {},
  374. fail: () => {},
  375. complete: () => {}
  376. });
  377. },
  378. lower(e) {
  379. if (this.bDontUpdate) return;
  380. console.log(e);
  381. this.gamePage++;
  382. this.getGameList(this.categoryType);
  383. },
  384. showDrawer() {
  385. // uni.getSubNVueById('game-list-drawer').show('slide-in-left', 200); {id:'game-list-drawer'}
  386. this.showDrawerById();
  387. }
  388. }
  389. };
  390. </script>
  391. <style>
  392. page {
  393. background-color: #fff;
  394. }
  395. .float-png {
  396. position: absolute;
  397. right: 15px;
  398. bottom: 200px;
  399. width: 56px;
  400. height: 56px;
  401. }
  402. .png-search {
  403. width: 50rpx;
  404. height: 100%;
  405. position: absolute;
  406. right: 20px;
  407. top: 0;
  408. bottom: 0;
  409. margin: auto;
  410. display: flex;
  411. justify-content: center;
  412. align-items: center;
  413. /* border: 1rpx solid #000000; */
  414. }
  415. .scrollX {
  416. position: relative;
  417. width: 100%;
  418. height: 90upx;
  419. /* border: 1rpx solid #000000; */
  420. }
  421. .scrollX-padding {
  422. padding: 0 74px 0 20px;
  423. }
  424. .game-item {
  425. display: flex;
  426. justify-content: flex-start;
  427. flex-direction: row;
  428. background-color: white;
  429. margin: 17px 14px 0 17px;
  430. /* border-bottom: 1rpx solid rgba(240, 240, 240, 1); */
  431. }
  432. .game-item-image {
  433. width: 542rpx;
  434. height: 542rpx;
  435. z-index: 99;
  436. }
  437. .head-image {
  438. position: absolute;
  439. bottom: -20px;
  440. left: 0;
  441. margin-left: 17px;
  442. width: 80rpx;
  443. height: 80rpx;
  444. border: 2px solid white;
  445. border-radius: 100px;
  446. z-index: 100;
  447. }
  448. .play-bg-image {
  449. position: absolute;
  450. bottom: 0;
  451. left: 0;
  452. top: 0;
  453. right: 0;
  454. width: 112rpx;
  455. height: 112rpx;
  456. margin: auto;
  457. background: rgba(0, 0, 0, 0.25);
  458. /* opacity: 0.25; */
  459. border-radius: 100px;
  460. z-index: 100;
  461. }
  462. .play-image {
  463. position: absolute;
  464. bottom: 0;
  465. left: 0;
  466. top: 0;
  467. right: 0;
  468. width: 44rpx;
  469. height: 54rpx;
  470. margin: auto;
  471. z-index: 100;
  472. }
  473. .game-image-container {
  474. position: relative;
  475. }
  476. .game-index {
  477. z-index: 300;
  478. }
  479. .cu-color {
  480. color: rgba(191, 191, 193, 1);
  481. }
  482. .right-png {
  483. width: 36rpx;
  484. height: 32rpx;
  485. }
  486. </style>