| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- <!--
- 每月挑战 - 月排名列表
- http://localhost:5173/card/#/pages/mytz/rankList
- https://oss-mbh5.colormaprun.com/card/#/pages/mytz/rankList
- -->
- <template>
- <view class="body">
- <view v-if="pageReady" class="content uni-column">
- <view class="page-top uni-column">
- <my-topbar :mcName="ecName" class="topbar-color" @btnBackClick="btnBack"
- @btnInfoClick="btnInfo"></my-topbar>
- <view class="topContent uni-row uni-jcse">
- <view class="tc-month">{{curMonth}}</view>
- <view class="tc-count uni-column">
- <text>挑战次数</text>
- <text>{{realNum}}/{{targetNum}}</text>
- </view>
- <view class="tc-cup" :style="getCupStyle('cup')">
- <view class="cup-gray" :style="getCupStyle('cup-gray')"></view>
- </view>
- </view>
- </view>
- <view class="main uni-column">
- <my-tab ref="tab" :tabItems="tabItems" :tabItemsMark="tabItemsMark" :type="0"
- :initActIndex="configParam.tabInitActIndex" @onTabClick="onTabClick" :fontSize="12"></my-tab>
- <view class="tab-view uni-column">
- <template v-for="(item, index) in rankRsList" :key="index">
- <my-ranklist v-show="tabCurrent === index" :rankRs="rankList[item]"
- :rank-type="rankTypeList[index]"></my-ranklist>
- </template>
- </view>
- </view>
- <my-popup ref="mypopup" :config="cardConfigData.popupRuleConfig"
- :dataList="cardConfigData.popupRuleList"></my-popup>
- </view>
- </view>
- </template>
- <script>
- import tools from '/common/tools';
- import cardfunc from '/common/cardfunc';
- import {
- localCardConfig
- } from "./cardconfig/test.js";
- import {
- token,
- apiCardBaseQuery,
- apiCurrentMonthlyChallengeQuery,
- apiMonthRankDetailQuery,
- checkResCode,
- checkToken
- } from '/common/api';
- export default {
- data() {
- return {
- cardConfigData: cardfunc.cardConfigData,
- pageReady: false,
- pageName: "rankList",
- firstEnterKey: 'firstEnter-mytz',
- rankKey: "rank-mytz",
- queryObj: {},
- queryString: "",
- token: "",
- tokenValid: false,
- ecId: 0, // 卡片id
- ecName: '', // 卡片名称
- ecDesc: '', // 卡片简介
- month: '', // 月名称
- realNum: 0, // 实际完赛次数
- targetNum: 0, // 要求完赛次数
- cupProgress: 100, // 奖杯进度 (100 - 实际进度,初始值为100)
- dispArrStr: "grad,mapNum", // 要显示的集合范围
- tabItems: ["积分排名", "通关场地排名"],
- rankTypeList: ["grad", "mapNum"],
- tabCurrent: 0,
- tabItemsMark: [],
- rankRsList: ["gradRs", "mapNumRs"],
- rankList: [], // 排名列表
- configParam: {
- tabInitActIndex: 0
- }
- }
- },
- computed: {
- curMonth() {
- var currentDate = new Date();
- var currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
- return `${currentMonth}月`;
- }
- },
- onLoad(query) { // 类型非必填,可自动推导
- // console.log(query);
- this.queryObj = query;
- this.queryString = tools.objectToQueryString(this.queryObj);
- // console.log(queryString);
- this.token = query["token"] ?? token;
- this.ecId = query["id"] ?? 0;
- this.firstEnterKey += "-" + this.ecId;
- console.log("firstEnterKey:", this.firstEnterKey);
- this.rankKey += "-" + this.ecId;
- console.log("rankKey:", this.rankKey);
- cardfunc.init(this, this.token, this.ecId);
- cardfunc.getCardConfig(this.cardConfigQueryCallback, localCardConfig);
- },
- // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
- onReady() {},
- onUnload() {},
- methods: {
- cardConfigQueryCallback(cardconfig) {
- this.loadConfig(cardconfig);
- this.getCardBaseQuery();
- this.getCurrentMonthlyChallengeQuery();
- this.monthRankDetailQuery();
- setTimeout(this.dealFirstEnter, 500);
- },
- loadConfig(cardconfig) {
- cardconfig = cardfunc.parseCardConfig(cardconfig);
- // console.log("[loadCardConfig] cardconfig:", cardconfig);
- // 加载卡片通用配置
- if (cardconfig.common != undefined) {
- cardfunc.loadCardCommonConfig(cardconfig.common);
- }
- // -------- 加载当前页面的配置 --------
- const config = cardfunc.parseCardConfig(cardconfig[this.pageName]);
- // console.log("[loadConfig] config_page:", config);
- if (config == undefined || config == null) {
- this.pageReady = true;
- return;
- }
- // 加载CSS样式
- const css = config.css;
- if (css != undefined && css.length > 0) {
- tools.loadCssCode(css);
- }
- // 加载成绩参数
- const rankParam = config.rankParam;
- if (rankParam != undefined) {
- if (rankParam.tabItemsMark != undefined) {
- this.tabItemsMark = rankParam.tabItemsMark;
- }
- if (rankParam.dispArrStr != undefined && rankParam.dispArrStr.length > 0) {
- this.dispArrStr = rankParam.dispArrStr;
- // console.log("[loadConfig] dispArrStr:", rankParam.dispArrStr);
- }
- if (rankParam.tabItems != undefined && rankParam.tabItems.length > 0) {
- this.tabItems = rankParam.tabItems;
- // console.log("[loadConfig] tabItems:", rankParam.tabItems);
- }
- if (rankParam.rankTypeList != undefined && rankParam.rankTypeList.length > 0) {
- this.rankTypeList = rankParam.rankTypeList;
- }
- if (rankParam.rankRsList != undefined && rankParam.rankRsList.length > 0) {
- this.rankRsList = rankParam.rankRsList;
- }
- }
- // console.log("[loadConfig] rankParam:", rankParam);
- // 加载页面参数
- const param = config.param;
- if (param != undefined) {
- if (param.tabInitActIndex != undefined && param.tabInitActIndex >= 0) {
- this.configParam.tabInitActIndex = param.tabInitActIndex;
- this.tabCurrent = param.tabInitActIndex;
- }
- }
- this.pageReady = true;
- },
- dealNotice(rank) {
- // console.log('[dealFirstEnter]');
- let that = this;
- uni.getStorage({
- key: that.rankKey,
- success: (res) => {
- console.log('[getStorage]', that.rankKey, res.data);
- const oldRank = res.data;
- if (oldRank != rank) {
- // that.notice = true;
- that.setRankValue(rank);
- }
- },
- fail: (e) => {
- console.log('[getStorage] fail', that.rankKey, e);
- // that.notice = false;
- that.setRankValue(rank);
- },
- })
- },
- setRankValue(data) {
- let that = this;
- uni.setStorage({
- key: that.rankKey,
- data: data,
- success: () => {
- console.log('[setStorage] success', that.rankKey, data);
- },
- fail: (e) => {
- console.log('[setStorage] fail', that.rankKey, e);
- },
- })
- },
- dealFirstEnter() {
- // console.log('[dealFirstEnter]');
- let that = this;
- uni.getStorage({
- key: that.firstEnterKey,
- success: (res) => {
- console.log('[getStorage]', that.firstEnterKey, res.data);
- },
- fail: (e) => {
- console.log('[getStorage] fail', that.firstEnterKey, e);
- that.btnInfo();
- that.setFirstEnterValue(true);
- },
- })
- },
- setFirstEnterValue(data) {
- let that = this;
- uni.setStorage({
- key: that.firstEnterKey,
- data: data,
- success: () => {
- console.log('[setStorage] success', that.firstEnterKey, data);
- },
- fail: (e) => {
- console.log('[setStorage] fail', that.firstEnterKey, e);
- },
- })
- },
- getCupProgress() {
- if (this.targetNum > 0 && this.realNum > 0) {
- if (this.realNum < this.targetNum) {
- const progress = this.realNum / this.targetNum * 100;
- this.cupProgress = 100 - progress;
- } else {
- this.cupProgress = 0;
- }
- } else {
- this.cupProgress = 100;
- }
- // console.log("cupProgress:", this.cupProgress);
- },
- getCupStyle(type) {
- if (!(this.month > 0)) {
- return '';
- }
- let group = 1;
- if (type == 'cup') {
- return `background-image: url("static/cup/${group}/${this.month}.png")`;
- } else if (type == 'cup-gray') {
- return `background-image: url("static/cup/${group}/${this.month}h.png"); height:${this.cupProgress}% ;`;
- }
- },
- // 卡片基本信息查询
- getCardBaseQuery() {
- uni.request({
- url: apiCardBaseQuery,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token,
- },
- method: "POST",
- data: {
- ecId: this.ecId
- },
- success: (res) => {
- // console.log("getCardBaseQuery", res);
- const data = res.data.data;
- this.ecName = data.ecName;
- this.ecDesc = data.ecDesc;
- },
- fail: (err) => {
- console.log("getCardBaseQuery err", err);
- },
- });
- },
- // 玩家当前月挑战记录查询
- getCurrentMonthlyChallengeQuery() {
- uni.request({
- url: apiCurrentMonthlyChallengeQuery,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token,
- },
- method: "POST",
- data: {},
- success: (res) => {
- // console.log("getCurrentMonthlyChallengeQuery", res);
- if (checkResCode(res)) {
- if (res.statusCode == 401) { // 未登录
- this.tokenValid = false;
- } else {
- this.tokenValid = true;
- }
- const data = res.data.data;
- this.month = data.month;
- this.realNum = data.realNum;
- // this.realNum = 2;
- this.targetNum = data.targetNum;
- this.dealNotice(this.realNum);
- this.getCupProgress();
- }
- },
- fail: (err) => {
- console.log("getCurrentMonthlyChallengeQuery err", err);
- },
- });
- },
- // 月挑战排名查询
- monthRankDetailQuery() {
- uni.request({
- url: apiMonthRankDetailQuery,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token,
- },
- method: "POST",
- data: {
- dispArrStr: this.dispArrStr
- },
- success: (res) => {
- // console.log("monthRankDetailQuery", res);
- const rankdata = res.data.data;
- this.rankList = rankdata;
- },
- fail: (err) => {
- console.log("monthRankDetailQuery err", err);
- },
- });
- },
- btnBack() {
- // window.history.back();
- const url = `action://to_home/`;
- tools.appAction(url);
- },
- btnInfo() {
- this.$refs.mypopup.popupOpen();
- },
- onTabClick(val) {
- // console.log("onTabClick: ", val);
- this.tabCurrent = val;
- }
- }
- }
- </script>
- <style scoped>
- .content {
- width: 100vw;
- height: 100vh;
- }
- .page-top {
- width: 100%;
- height: 150px;
- padding-top: 36px;
- justify-content: space-between;
- background-image: url("/static/backgroud/top_run.png"), linear-gradient(180deg, #178bff 0%, #004d9b 100%);
- background-repeat: no-repeat;
- background-position: 25px 36px, 0px 0px;
- background-size: auto 150px, contain;
- }
- .topbar-color {
- color: #ffffff;
- }
- .topContent {
- width: 90%;
- height: 130px;
- }
- .tc-month {
- width: 80px;
- height: 80px;
- background: url("/static/mytz/month_bg.png") no-repeat center;
- background-size: contain;
- color: #ff870d;
- font-size: 22px;
- font-weight: 700;
- text-align: center;
- line-height: 100px;
- }
- .tc-count {
- font-size: 14px;
- font-weight: 500;
- color: #FFFFFF;
- }
- .tc-cup {
- width: 70px;
- height: 70px;
- border-radius: 3px;
- border: solid #FFFFFF 1px;
- background-position-x: center;
- background-repeat: no-repeat;
- background-size: 70px auto;
- }
- .cup-gray {
- width: 70px;
- background-position-x: center;
- background-repeat: no-repeat;
- background-size: 70px auto;
- overflow: hidden;
- }
- .main {
- width: 100%;
- flex-grow: 1;
- justify-content: space-around;
- }
- .main-tab {
- width: 90%;
- margin-top: 20rpx;
- }
- .tab-view {
- width: 100%;
- flex-grow: 1;
- }
- </style>
|