game-list.vue 12 KB

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