game-video.vue 13 KB

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