123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- <template>
- <view>
- <!-- rgba(116, 172, 240, 1)-->
- <uni-nav-bar id="nav-bar" status-bar="true" backgroundColor="rgba(153, 150, 252, 255)" @clickLeft="showClickEvent('DrawerModalL')"
- @clickRight="onNavHome" title="娱乐" color="#FFFFFF" fixed="true">
- <view slot="left">
- <view class=" flex align-center margin-left">
- <image class="png-more" src="../../../static/more.png"></image>
- </view>
- </view>
- <view slot="right">
- <view class=" flex align-center " style="margin-right: 10rpx;">
- <view class="cuIcon-home text-20px-before"></view>
- </view>
- </view>
- </uni-nav-bar>
- <view class="scrollX">
- <scroll-view scroll-x class="bg-white nav solid-bottom scrollX-padding" scroll-with-animation :scroll-left="scrollLeft">
- <view class="cu-item text-18px" :class="index == TabCur ? 'make-text-bPurple cur' : 'cu-color'" v-for="(item, index) in tabList"
- :key="index" @tap="tabSelect" :data-id="index" :data-category_id="item.categoryType" v-if="item.categoryType !== 0">
- {{ item.categoryName }}
- </view>
- </scroll-view>
- <view class="png-search">
- <!-- <image style="width: 50rpx; height: 50rpx;" src="/static/search.png" @tap="onNavSearch"></image> -->
- </view>
- </view>
- <scroll-view scroll-y="true" :style="{ height: scrollviewHigh + 'px' }" @scrolltolower="lower">
- <view v-if="(cIndex != -1 && gameShow)||ConnectBindingDevice" class="game-item card-view" v-for="(item, index) in gameList" :key="index" :data-id="index">
- <view @tap="onNavToWebviewGame(item)">
- <view class="game-image-container">
- <image mode="aspectFill" class="game-item-image" :src="item.gamePicture"></image>
- <image class="head-image" :src="item.gameIcon"></image>
- <view class="play-bg-image">
- <image class="play-image" src="/static/play.png"></image>
- </view>
- </view>
- <view class="cu-list menu-avatar">
- <view class="cu-item">
- <view class="content flex-sub">
- <view>{{ item.gameName }}</view>
- <view class='flex flex-wrap ' style="margin: 10rpx 0;">
- <view style="padding-right:5rpx;" v-for="(item,index) in item.gameTags" :key="index">
- <view class='cu-tag line-purple radius'>{{item.tagName}}</view>
- </view>
- </view>
- <!-- <view class="text-sm flex justify-between" style="color:rgba(201, 201, 201, 1);">{{item.createTime}}</view> -->
- </view>
- </view>
- </view>
- </view>
- <view class="text-gray text-sm text-center padding flex flex-direction" style="width: 100%;">
- <view @tap="onFavoriteAdd(item)">
- <image class="margin-lr-xs right-png" style="margin: 25px 0;" :src="item.gameFavorite?'/static/favorite_r.png':'/static/favorite_g.png'"
- mode="aspectFill"></image>
- </view>
- <view style="margin-top: 30px;" @tap="onNavComment">
- <!-- <image class="margin-lr-xs right-png" style="margin: 20px 0;" src="/static/info_g.png" mode="aspectFill"></image> -->
- </view>
- <view style="margin-top: 60px;" @tap="onNavDetail(item)">
- <view class="cuIcon-moreandroid margin-lr-xs" style="font-size: 20px; margin: 10px 0; color: #d6d6d6;"></view>
- </view>
- </view>
- </view>
- <view v-if="(cIndex == -1 && !gameShow) || gameList.length == 0 || ConnectBindingDevice == null" class="text-16px text-gray text-center margin">没有更多数据</view>
- <view style="height: 17px;"></view>
- </scroll-view>
- <!-- <view class="float-png">
- <image src="/static/conversion@2x.png" mode="aspectFit" @tap="onNavConver"></image>
- </view> -->
- <round-menu @trigger="onRoundTrigger"></round-menu>
- <sideBar ref="sideBar"></sideBar>
- </view>
- </template>
- <script>
- import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
- import sideBar from '@/components/side-bar/side-bar.vue';
- import config from '../../../common/config.js';
- import reqUtil from '../../../util/util-js/requstUtil.js';
- import roundMenu from "@/components/round-menu/round-menu.vue";
- import {
- mapState,
- mapMutations
- } from 'vuex';
- export default {
- components: {
- uniNavBar,
- sideBar,
- roundMenu
- },
- computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'cIndex','versionCodeState','platform','gamePlatform']),
- data() {
- return {
- tabList: [],
- TabCur: 0,
- Category: 0,
- scrollLeft: 0,
- scrollviewHigh: '',
- bDontUpdate: false,
- //游戏列表
- gameList: [],
- gamePage: 1,
- gameSize: 10,
-
- //默认显示
- gameShow: true,
- //编码的item
- encodeItem: '',
- };
- },
- onLoad(option) {
- let _this = this;
- console.log("option========:", option);
- let _index = 1;
- if (option && option.type) {
- if (option.type == "game") {
- _index = 1;
- } else if (option.type == "video") {
- _index = 2;
- }
- }
- //获得游戏类目
- reqUtil.requestData(config.URL.GAMECATEGORY).then(
- res => {
- console.log('GAMECATEGORY =====', res);
- if (res.code == 0) {
- this.tabList = res.data;
- this.TabCur = _index;
- this.categoryType = this.tabList[_index].categoryType;
- this.getGameList(this.categoryType);
- }
- },
- e => {
- console.log(e);
- }
- );
- },
- onReady() {
- let _this = this;
- uni.getSystemInfo({
- success(res) {
- // 计算组件的高度
- let view = uni.createSelectorQuery().select('#nav-bar');
- view.boundingClientRect(data => {
- let navHeight = data.height;
- let scrollXHight = uni.upx2px(90);
- _this.scrollviewHigh = res.windowHeight - navHeight - scrollXHight;
- }).exec();
- }
- });
- },
- methods: {
- ...mapMutations(['glimitPlayGame']),
- // 跳转转换页面
- onNavConver() {
- uni.reLaunch({
- url: '../../conversion-page/conversion/conversion',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- //跳转回主页
- onNavHome() {
- uni.reLaunch({
- url: '../../personal-page/personal/personal',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- tabSelect(e) {
- if (this.TabCur != e.currentTarget.dataset.id) {
- //重新设置参数
- this.bDontUpdate = false;
- this.gameList = [];
- this.gamePage = 1;
- this.gameSize = 10;
- this.TabCur = e.currentTarget.dataset.id;
- this.categoryType = e.currentTarget.dataset.category_id;
- this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
- this.getGameList(this.categoryType);
- }
- },
- showClickEvent() {
- this.$refs.sideBar.showModal();
- },
- onNavSearch() {
- uni.showToast({
- title: '功能尚未开放',
- icon: 'none'
- })
- return;
- uni.navigateTo({
- url: '../game-search/game-search',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- //收藏
- onFavoriteAdd(item) {
- //添加收藏
- let favoritesTemp = {
- 'fObjectId': item.gameId,
- 'favoritesType': 0,
- }
- reqUtil.requestData(config.URL.FAVORITESMODIFY, favoritesTemp).then(res => {
- console.log('FAVORITESMODIFY =====', res);
- if (res.code == 0) {
- if (!res.data.bHas) {
- item.gameFavorite = false;
- uni.showToast({
- title: "取消收藏",
- icon: "none"
- })
- } else {
- uni.showToast({
- title: "收藏成功",
- icon: "none"
- })
- item.gameFavorite = true;
- }
- }
- },
- e => {
- console.log(e)
- });
- },
- onNavComment() {
- uni.showToast({
- title: '功能尚未开放',
- icon: 'none'
- })
- return;
- uni.navigateTo({
- url: '../game-comment/game-comment',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- onNavDetail(item) {
- // console.log(item);
- let temItem = encodeURIComponent(JSON.stringify(item));
- // return;
- uni.navigateTo({
- url: '../game-detail/game-detail?item=' + temItem,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- onNavToWebviewGame(item) {
- // console.log("====item == ",item);
- // if (!this.BLEConnectDevice || this.cIndex == -1) {
- // uni.showToast({
- // title: "没有连接绑带,请连接后重试!",
- // icon: "none"
- // })
- // return;
- // }
- //1.先判断模式
- //如果都不存在,返回
- this.glimitPlayGame({
- gameTags: item.gameTags,
- callback: () => {
- reqUtil.requestData(config.URL.GAMEDETAIL, item).then(res => {
- console.log('GAMEDETAIL =====', res);
- if (res.code == 0) {
- this.encodeItem = encodeURIComponent(JSON.stringify(res.data.gameInfo));
- // #ifdef APP-PLUS
- uni.navigateTo({
- url: '../game-play-sub/game-play-sub?item=' + this.encodeItem,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- // #endif
- // #ifdef H5
- uni.navigateTo({
- url: '../game-play/game-play-web?item=' + this.encodeItem,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- // #endif
- }
- },
- e => {
- console.log(e)
- });
- }
- });
- },
- getGameList(categoryType) {
- uni.showToast({
- icon: "loading",
- title: "",
- mask: true,
- duration: 10000
- })
- //获得游戏列表
- reqUtil.requestData(
- config.URL.GAMELIST_FROM_CATEGORY_PLATFORM, {
- categoryType: categoryType,
- //endTime 可以不设置,服务器默认设置一个值
- endTime: config.endTime,
- page: this.gamePage,
- size: this.gameSize
- }
- ).then(res => {
- console.log('GAMELIST_FROM_CATEGORY_PLATFORM =====', res);
- if (res.code == 0) {
- uni.hideToast();
- if (res.data.length < this.gameSize) {
- this.bDontUpdate = true;
- }
- if (res.data.length != 0) {
- uni.showToast({
- icon: "none",
- title: "更新成功",
- })
- } else {
- uni.showToast({
- icon: "none",
- title: "没数据啦",
- })
- }
- this.gameList = this.gameList.concat(res.data);
-
- if (categoryType == 1) {
- //game
- this.gameShow = this.versionCodeState.showGame;
-
- } else if (categoryType == 2) {
- //game
- this.gameShow = this.versionCodeState.showVideo;
- }
- }
- },
- e => {
- console.log(e);
- uni.showToast({
- icon: "none",
- title: "更新出错",
- })
- }
- );
- },
- onRoundTrigger(data) {
- console.log("onRoundTrigger==", data);
- // return;
- let url = '';
- switch (data.item.type) {
- case "personal":
- //个人中心页面
- url = '../../personal-page/personal/personal';
- break;
- case "game":
- url = '../../game-page/game/game';
- break;
- default:
- url = '../../personal-page/personal/personal';
- break;
- }
- uni.reLaunch({
- url: url,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- lower(e) {
- if (this.bDontUpdate) return;
- console.log(e);
- this.gamePage++;
- this.getGameList(this.categoryType);
- }
- }
- };
- </script>
- <style>
- page {
- background-color: #fff;
- }
- .float-png {
- position: absolute;
- right: 15px;
- bottom: 200px;
- width: 56px;
- height: 56px;
- }
- .png-search {
- width: 50rpx;
- height: 100%;
- position: absolute;
- right: 20px;
- top: 0;
- bottom: 0;
- margin: auto;
- display: flex;
- justify-content: center;
- align-items: center;
- /* border: 1rpx solid #000000; */
- }
- .scrollX {
- position: relative;
- width: 100%;
- height: 90upx;
- /* border: 1rpx solid #000000; */
- }
- .scrollX-padding {
- padding: 0 74px 0 20px;
- }
- .game-item {
- display: flex;
- justify-content: flex-start;
- flex-direction: row;
- background-color: white;
- margin: 17px 14px 0 17px;
- /* border-bottom: 1rpx solid rgba(240, 240, 240, 1); */
- }
- .game-item-image {
- width: 542rpx;
- height: 542rpx;
- z-index: 99;
- }
- .head-image {
- position: absolute;
- bottom: -20px;
- left: 0;
- margin-left: 17px;
- width: 80rpx;
- height: 80rpx;
- border: 2px solid white;
- border-radius: 100px;
- z-index: 100;
- }
- .play-bg-image {
- position: absolute;
- bottom: 0;
- left: 0;
- top: 0;
- right: 0;
- width: 112rpx;
- height: 112rpx;
- margin: auto;
- background: rgba(0, 0, 0, 0.25);
- /* opacity: 0.25; */
- border-radius: 100px;
- z-index: 100;
- }
- .play-image {
- position: absolute;
- bottom: 0;
- left: 0;
- top: 0;
- right: 0;
- width: 44rpx;
- height: 54rpx;
- margin: auto;
- z-index: 100;
- }
- .game-image-container {
- position: relative;
- }
- .game-index {
- z-index: 300;
- }
- .cu-color {
- color: rgba(191, 191, 193, 1);
- }
- .right-png {
- width: 36rpx;
- height: 32rpx;
- }
- </style>
|