game-ranking.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack" :title="pageTitle" backgroundColor="rgba(151, 151, 255, 1)"
  4. color="#FFFFFF" fixed="true" :border="false">
  5. <view slot="left">
  6. <view class=" flex align-center margin-left">
  7. <image class="w-left-arrow" src="../../../static/m-icon/leftBack.png"></image>
  8. </view>
  9. </view>
  10. </uni-nav-bar>
  11. <view class="make-bg-bPurple rankingTop">
  12. <view style="position:absolute;left:0; right:0; top:-100px; bottom:0;margin:auto;" class="flex justify-center align-center">
  13. <image style="width: 337px;height: 337px;" src="/static/ranking-light.png"></image>
  14. </view>
  15. <!-- 底部领奖台 -->
  16. <view class="flex justify-center rankingImageContainer">
  17. <image style="height: 94px; width: 100%; margin: 0 37rpx;" src="/static/ranking-plat.png"></image>
  18. </view>
  19. <view class="rankingImageContainer">
  20. <view class="text-white text-bold text-15px text-center" style="margin-top: 66px;width: 160rpx;">{{rankInfo?rankInfo.rankScoreList[1]:''}}</view>
  21. <view class="text-white text-bold text-15px text-center" style="margin: 38px 75rpx 0; width: 160rpx;">{{rankInfo?rankInfo.rankScoreList[0]:''}}</view>
  22. <view class="text-white text-bold text-15px text-center" style="margin-top: 66px;width: 160rpx;">{{rankInfo?rankInfo.rankScoreList[2]:''}}</view>
  23. </view>
  24. <!-- 头像部分 -->
  25. <view class="rankingHeadContainer">
  26. <view class="flex justify-around margin-left margin-right" style="margin-top: 40px; width: 100%;">
  27. <!-- 排名2 -->
  28. <view class="text-white flex justify-center flex-direction align-center" style="margin-top: 25px;width: 160rpx;height: 100%;">
  29. <view v-if="rankUserInfo[1].bShow" class="rankHeadMin" style="border: 3px solid #dee2e5; ">
  30. <image class="rankHead" mode="aspectFill" :src="rankUserInfo[1].avatarUrl"></image>
  31. <view class="flex justify-center rankingNum">
  32. <view style="background-color: #dee2e5;" class="flex justify-center align-center rankingNumChild">
  33. 2
  34. </view>
  35. </view>
  36. </view>
  37. {{rankUserInfo[1].username}}
  38. </view>
  39. <!-- 排名1 -->
  40. <view class="text-white flex justify-center flex-direction align-center" style="height: 100%;width: 160rpx;">
  41. <view v-if="rankUserInfo[0].bShow" class="rankHeadBig">
  42. <image class="rankHead" mode="aspectFill" :src="rankUserInfo[0].avatarUrl"></image>
  43. <view style="position: absolute;top:-14px;left: 0; width: 100%;height: 16px; " class="flex justify-center">
  44. <image style=" width: 22px;height: 16px;" src="../../../static/ranking-crown.png"></image>
  45. </view>
  46. <view class="flex justify-center rankingNumOne">
  47. <view style=" background-color: #fed642;" class="flex justify-center align-center rankingNumOneChild">
  48. 1
  49. </view>
  50. </view>
  51. </view>
  52. {{rankUserInfo[0].username}}
  53. </view>
  54. <!-- 排名3 -->
  55. <view class="text-white flex justify-center flex-direction align-center" style="margin-top: 25px;width: 160rpx;height: 100%;">
  56. <view v-if="rankUserInfo[2].bShow" class="rankHeadMin" style="border: 3px solid #fdaf41;">
  57. <image class="rankHead" mode="aspectFill" :src="rankUserInfo[2].avatarUrl"></image>
  58. <view class="flex justify-center rankingNum">
  59. <view style=" background-color: #fdaf41;" class="flex justify-center align-center rankingNumChild">
  60. 3
  61. </view>
  62. </view>
  63. </view>
  64. {{rankUserInfo[2].username}}
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 切换游戏信息和分类部分 -->
  70. <view style="background-color: #FFFFFF; box-shadow: 0px 0px 3px 2px rgba(113, 113, 219, 0.23);">
  71. <view class="flex justify-between padding">
  72. <view class="flex justify-center align-center ">
  73. <image style="width:50px;height: 50px; background-color: #eeeeee; border-radius: 8px;" :src="rankSelectedGame?rankSelectedGame.gameIcon:''"></image>
  74. <view style="margin-left: 22rpx;">{{rankSelectedGame?rankSelectedGame.gameName:''}}</view>
  75. </view>
  76. <view class="button-fav" @tap="showModal" data-target="bottomModal">切换</view>
  77. </view>
  78. <view class="nav flex justify-around align-center ">
  79. <view style="width: 200rpx; margin: 0 40rpx;" class="cu-item text-bold text-18px text-center" :class="0==TabCur?'make-text-bPurple cur':''"
  80. data-id="0" @tap="tabSelect">
  81. 全国
  82. </view>
  83. <view style="height: 30px; border-right: 1rpx solid #AAAAAA;"></view>
  84. <view style="width: 200rpx; margin: 0 40rpx;" class="cu-item text-bold text-18px text-center text-cut" :class="1==TabCur?'make-text-bPurple cur':''"
  85. data-id="1" @tap="tabSelect">
  86. {{cityName}}
  87. </view>
  88. </view>
  89. </view>
  90. <!-- 滚动部分 style="height: 300px; margin-bottom: 87px;"-->
  91. <view >
  92. <scroll-view style="max-height:300px; width: 100%; padding: 22rpx; box-sizing: border-box;" scroll-y="true">
  93. <view class="flex justify-between align-center bg-white" style="height: 73px; width: 100%; border-radius: 8px; margin-bottom:14rpx ; "
  94. v-for="(item,index) in otherUserInfoList" v-bind:key="index">
  95. <view class="flex justify-center align-center " style="margin-left: 68rpx;">
  96. <view class="text-13px margin-right flex justify-center align-center text-bold" style="background-color: #f6f3f7; width: 27px;height: 27px; border-radius: 45px;">{{index+1}}</view>
  97. <image class="head-image-50" :src="item.avatarUrl"></image>
  98. <view class="text-16px text-bold margin-left">{{item.username}}</view>
  99. </view>
  100. <view class="text-bold text-16px" style="margin-right: 68rpx;">{{otherScoreList[index]}}</view>
  101. </view>
  102. <view v-if="otherUserInfoList.length == 0 " class="text-center text-gray">没有其他排名数据~</view>
  103. <view style="height: 73px; "></view>
  104. </scroll-view>
  105. </view>
  106. <view class="flex justify-between align-center bg-white" style="position: fixed;bottom: 0;height: 73px; width: 100%;">
  107. <view class="flex justify-center align-center " style="margin-left: 68rpx;">
  108. <view class="text-13px margin-right text-gray">{{rankInfo&&rankInfo.userRank>3?'名落孙山':'金榜题名'}}</view>
  109. <image class="head-image-50" :src="rankInfo?rankInfo.userInfo.avatarUrl:''"></image>
  110. <view class="text-16px text-bold margin-left">{{rankInfo?rankInfo.userInfo.username:''}}</view>
  111. </view>
  112. <view class="text-bold text-16px" style="margin-right: 68rpx;">{{rankInfo&&rankInfo.userScore?rankInfo.userScore:0}}</view>
  113. </view>
  114. <view class="cu-modal bottom-modal" :class="modalName=='bottomModal'?'show':''" @tap="hideModal">
  115. <view class="cu-dialog bg-white" style=" border-radius: 15px;" @tap.stop="">
  116. <view class="flex justify-center align-center" style="width: 100%; height: 60rpx;" @tap="hideModal">
  117. <view class="text-blue" style="width: 80rpx; height: 2px; background-color: #AAAAAA;"></view>
  118. </view>
  119. <view class="article" style="position: relative; ">
  120. <view class="title">
  121. 最近在玩
  122. </view>
  123. <view class="cu-item">
  124. <view class="cu-form-group margin-top">
  125. <view v-if="playRankingGames.length!=0" class="grid col-4 homepage-grid-square flex-sub ">
  126. <view v-for="(item,index) in playRankingGames" :key="index" v-if="index<4" @tap="onChangeGame(item)">
  127. <block v-if="platform == gamePlatform[item.platform] || item.platform == 2">
  128. <image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
  129. <view class="border text-center text-cut">{{item.gameName}}</view>
  130. </block>
  131. </view>
  132. </view>
  133. <view v-else class="text-center text-gray" :style="{width:'100%'}">去玩游戏吧~</view>
  134. </view>
  135. </view>
  136. </view>
  137. <view class="article" style="position: relative; ">
  138. <view class="title">
  139. 总榜
  140. </view>
  141. <scroll-view scroll-y="true" class="cu-item">
  142. <view class="cu-form-group ">
  143. <view class="grid col-4 homepage-grid-square flex-sub ">
  144. <view v-if="calorieGame" @tap="onChangeGame(calorieGame)">
  145. <image class="item-img" :src="calorieGame.gameIcon" mode="aspectFill"></image>
  146. <view class="border text-center margin-bottom text-cut">{{calorieGame.gameName}}</view>
  147. </view>
  148. </view>
  149. </view>
  150. </scroll-view>
  151. </view>
  152. <view class="article" style="height: 270px; position: relative; bottom: 10px;">
  153. <view class="title">
  154. 全部游戏
  155. </view>
  156. <scroll-view scroll-y="true" style="height: 250px;" class="cu-item">
  157. <view class="cu-form-group ">
  158. <view v-if="versionCodeState&&versionCodeState.showGame&&allGames.length!=0" class="grid col-4 homepage-grid-square flex-sub ">
  159. <view v-if="platform == gamePlatform[item.platform] || item.platform == 2" v-for="(item,index) in allGames" :key="index" @tap="onChangeGame(item)">
  160. <image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
  161. <view class="border text-center margin-bottom text-cut">{{item.gameName}}</view>
  162. </view>
  163. </view>
  164. <view v-else class="text-center text-gray" :style="{width:'100%'}">去玩游戏吧~</view>
  165. </view>
  166. </scroll-view>
  167. </view>
  168. </view>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. import config from '../../../common/config.js';
  174. import reqUtil from "@/util/util-js/requstUtil.js";
  175. import {
  176. mapState,
  177. mapMutations
  178. } from 'vuex'
  179. export default {
  180. computed: mapState(['rankSelectedGame', 'rankInfo', 'cityName', 'city', 'playRankingGames', 'playGames', 'hasLogin', 'allGames','platform','gamePlatform','versionCodeState']),
  181. data() {
  182. return {
  183. pageTitle: '排行榜',
  184. TabCur: 0,
  185. rankUserInfo: [{
  186. bShow: false,
  187. avatarUrl: '',
  188. username: '',
  189. },
  190. {
  191. bShow: false,
  192. avatarUrl: '',
  193. username: '',
  194. },
  195. {
  196. bShow: false,
  197. avatarUrl: '',
  198. username: '',
  199. }
  200. ],
  201. //除去前三名的数据
  202. otherUserInfoList: [],
  203. otherScoreList: [],
  204. modalName: null,
  205. scrollviewHight: 0,
  206. //卡路里游戏
  207. calorieGame: null,
  208. }
  209. },
  210. onLoad() {
  211. let that = this;
  212. //获得全部游戏列表
  213. that.getAllGame(() => {
  214. reqUtil.requestData(config.URL.GETRANKGAME).then(res => {
  215. console.warn('GETRANKGAME =====', res);
  216. // 如果玩家有记录显示的游戏,
  217. if (res.data !== null) {
  218. that.$store.state.rankSelectedGame = res.data;
  219. that.onGetRank();
  220. reqUtil.requestData(config.URL.GAMEDETAIL, {
  221. gameId: '1'
  222. }).then(res => {
  223. that.calorieGame = res.data.gameInfo;
  224. },
  225. e => {
  226. console.log(e)
  227. });
  228. } else {
  229. // //如果没有记录到用户的选择数据,给一个游戏显示
  230. // if (that.allGames.length == 0) {
  231. // console.warn("allGames 没有任何游戏!");
  232. // return;
  233. // }
  234. // //设置第一个游戏给显示
  235. // that.$store.state.rankSelectedGame = that.allGames[0];
  236. // console.log("this.getAllGame rankSelectedGame", that.rankSelectedGame);
  237. // that.onGetRank();
  238. reqUtil.requestData(config.URL.GAMEDETAIL, {
  239. gameId: '1'
  240. }).then(res => {
  241. console.log("*************", res);
  242. that.calorieGame = res.data.gameInfo;
  243. that.$store.state.rankSelectedGame = that.calorieGame;
  244. that.onGetRank();
  245. },
  246. e => {
  247. console.log(e)
  248. });
  249. }
  250. },
  251. e => {
  252. console.log(e)
  253. });
  254. });
  255. //获取最近玩的游戏列表
  256. reqUtil.requestData(config.URL.RECENTLYPLAYINGGETBYPLATFORM).then(res => {
  257. console.log('RECENTLYPLAYINGGETBYPLATFORM =====', res);
  258. if (res.code == 0 && res.data.gameList) {
  259. // that.$store.state.playRankingGames = res.data.gameList;
  260. let _arry = [];
  261. for(let i=0;i<res.data.gameList.length;i++){
  262. if(res.data.gameList[i].gameRankingShow){
  263. _arry.push(res.data.gameList[i]);
  264. }
  265. }
  266. that.$store.state.playRankingGames = _arry;
  267. that.onGetRank();
  268. }
  269. },
  270. e => {
  271. console.log(e)
  272. });
  273. },
  274. onReady() {
  275. let that = this;
  276. uni.getSystemInfo({
  277. success(res) {
  278. // 计算组件的高度
  279. let view = uni.createSelectorQuery().select('#nav-bar');
  280. view.boundingClientRect(data => {
  281. let navHeight = data.height;
  282. let scrollXHight = uni.upx2px(90);
  283. that.scrollviewHight = res.windowHeight - navHeight - 265-125-73;
  284. }).exec();
  285. }
  286. });
  287. },
  288. methods: {
  289. ...mapMutations(['getRankGame', 'getAllGame']),
  290. tabSelect(e) {
  291. this.TabCur = e.currentTarget.dataset.id;
  292. if (this.TabCur == 1 && this.city.cityCode == "") {
  293. console.warn("选择城市时候,cityCode 不能为空");
  294. return;
  295. }
  296. this.onGetRank();
  297. },
  298. onBack() {
  299. uni.navigateBack({
  300. delta: 1
  301. })
  302. },
  303. showModal(e) {
  304. this.modalName = e.currentTarget.dataset.target
  305. },
  306. hideModal(e) {
  307. this.modalName = null
  308. },
  309. onChangeGame(item) {
  310. uni.showToast({
  311. title: '',
  312. icon: "loading",
  313. duration: 10000
  314. })
  315. // console.log(item);
  316. //这里切换游戏
  317. let that = this;
  318. //切换游戏,修改一次用户记录的数据
  319. reqUtil.requestData(config.URL.MOTIFYRANKGAME, {
  320. gameId: item.gameId,
  321. score: 111
  322. }, "POST").then(res => {
  323. console.log('MOTIFYRANKGAME =====', res, item);
  324. //设置当前显示的游戏数据
  325. that.$store.state.rankSelectedGame = item;
  326. that.hideModal();
  327. that.onGetRank();
  328. },
  329. e => {
  330. console.log(e)
  331. });
  332. },
  333. onGetRank() {
  334. uni.showToast({
  335. title: '',
  336. icon: "loading",
  337. duration: 10000
  338. })
  339. // console.log( this.rankSelectedGame);
  340. if(!this.rankSelectedGame)return;
  341. this.getRankGame({
  342. param: {
  343. type: this.TabCur == 0 ? "china" : "city",
  344. cityCode: this.city.cityCode,
  345. gameId: this.rankSelectedGame.gameId
  346. },
  347. callback: (res) => {
  348. uni.hideToast();
  349. if (res.data == null) return;
  350. for (let i = 0; i < 3; i++) {
  351. if (this.rankInfo.rankingList[i]) {
  352. this.rankUserInfo[i] = Object.assign({
  353. bShow: true
  354. }, this.rankInfo.rankingList[i])
  355. // console.log("=====", this.rankUserInfo[i]);
  356. } else {
  357. this.rankUserInfo[i] = Object.assign({
  358. bShow: false,
  359. avatarUrl: '',
  360. username: '',
  361. })
  362. }
  363. }
  364. //.slice(3)
  365. this.otherUserInfoList = this.rankInfo.rankingList;
  366. this.otherScoreList = this.rankInfo.rankScoreList;
  367. }
  368. });
  369. }
  370. }
  371. }
  372. </script>
  373. <style>
  374. .rankingTop {
  375. position: relative;
  376. width: 100%;
  377. height: 265px;
  378. }
  379. .rankingImageContainer {
  380. position: absolute;
  381. left: 0;
  382. bottom: 0;
  383. height: 94px;
  384. width: 100%;
  385. display: flex;
  386. justify-content: center;
  387. }
  388. .rankingNum {
  389. position: absolute;
  390. bottom: -10px;
  391. left: 0;
  392. width: 100%;
  393. height: 20px;
  394. }
  395. .rankingNumChild {
  396. width: 20px;
  397. height: 20px;
  398. border-radius: 45px;
  399. }
  400. .rankingNumOne {
  401. position: absolute;
  402. bottom: -12px;
  403. left: 0;
  404. width: 100%;
  405. height: 24px;
  406. }
  407. .rankingNumOneChild {
  408. width: 24px;
  409. height: 24px;
  410. border-radius: 45px;
  411. }
  412. .rankingHeadContainer {
  413. position: absolute;
  414. top: 0;
  415. left: 0;
  416. height: 172px;
  417. width: 100%;
  418. display: flex;
  419. justify-content: center;
  420. /* border: 1rpx solid #000000; */
  421. }
  422. .button-fav {
  423. background-color: rgba(153, 150, 252, 255);
  424. color: #FFFFFF;
  425. border-radius: 10px;
  426. width: 184rpx;
  427. height: 90rpx;
  428. display: flex;
  429. justify-content: center;
  430. text-align: center;
  431. align-items: center;
  432. }
  433. .head-image-50 {
  434. width: 50px;
  435. height: 50px;
  436. background-color: #eeeeee;
  437. border-radius: 45px;
  438. }
  439. .title {
  440. text-align: justify;
  441. /* padding: 40rpx 30rpx; */
  442. font-size: 15px;
  443. position: relative;
  444. height: 30px;
  445. line-height: 60upx;
  446. margin: 20rpx 40rpx;
  447. font-weight: 400;
  448. color: rgba(26, 26, 26, 1);
  449. }
  450. .homepage-grid-square {
  451. width: 250rpx;
  452. /* height: 250rpx; */
  453. align-items: start;
  454. }
  455. .homepage-grid-square image {
  456. width: 144rpx;
  457. height: 144rpx;
  458. }
  459. .item-img {
  460. border-radius: 20rpx;
  461. box-shadow: 0px 1px 2px 0px rgba(113, 113, 219, 0.23);
  462. }
  463. .rankHead {
  464. width: 100%;
  465. height: 100%;
  466. border-radius: 45px;
  467. flex-shrink: 0;
  468. }
  469. .rankHeadMin {
  470. display: flex;
  471. position: relative;
  472. width: 55px;
  473. height: 55px;
  474. border-radius: 45px;
  475. box-sizing: border-box;
  476. margin-bottom: 21px;
  477. }
  478. .rankHeadBig {
  479. display: flex;
  480. position: relative;
  481. width: 73px;
  482. height: 73px;
  483. border: 3px solid #fed642;
  484. border-radius: 45px;
  485. box-sizing: border-box;
  486. margin-bottom: 21px;
  487. }
  488. </style>