game-video.vue 12 KB

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