game-list.vue 12 KB

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