game-video.vue 12 KB

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