rankOverview.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <!--
  2. [模板] 样式1 - 排名总览
  3. http://localhost:5173/card/#/pages/tpl/style1/rankOverview
  4. https://oss-mbh5.colormaprun.com/card/#/pages/tpl/style1/rankOverview
  5. -->
  6. <template>
  7. <view class="body">
  8. <view v-if="pageReady" class="content uni-column">
  9. <view class="uni-column page-top">
  10. <my-topbar :mcName="mcName" class="topbar-color"
  11. @btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
  12. </view>
  13. <view class="mid uni-column uni-jcc">
  14. <view class="mid-1 uni-row uni-jcsb">
  15. <text>排名:<text style="color: #ff0045;">{{totalSysPointRankNum}}</text></text>
  16. <text class="mid-1-name">{{nickName}}</text>
  17. <text>场次:<text style="color: #ff0045;">{{totalNum}}</text></text>
  18. </view>
  19. <view class="mid-2 uni-row uni-jcsa">
  20. <view class="uni-column">
  21. <text class="mid-2-value">{{totalSysPoint}}</text>
  22. <text class="mid-2-text">百味豆</text>
  23. </view>
  24. <view class="mid-line"></view>
  25. <view class="uni-column">
  26. <text class="mid-2-value">{{fmtDistanct(totalDistanct)}}</text>
  27. <text class="mid-2-text">里程 km</text>
  28. </view>
  29. <view class="mid-line"></view>
  30. <view class="uni-column">
  31. <text class="mid-2-value">{{totalCp}}</text>
  32. <text class="mid-2-text">打点数</text>
  33. </view>
  34. <view class="mid-line"></view>
  35. <view class="uni-column">
  36. <text class="mid-2-value">{{fmtPace(fastPace)}}</text>
  37. <text class="mid-2-text">最快配速</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="main uni-column">
  42. <text class="main-title">选择比赛路线</text>
  43. <my-pathList ref="myPathList" :style="pathListStyle.style" :pathList="pathList" :mcState="mcState"
  44. :showLine="pathListStyle.showLine" :isNewUser="isNewUser" @onNewUserPathClick="onNewUserPathClick"></my-pathList>
  45. <!-- <button class="btnGuide" @click="btnGuide">新手引导</button> -->
  46. </view>
  47. <my-popup ref="mypopup" :config="cardConfigData.popupRuleConfig" :dataList="cardConfigData.popupRuleList" :acttime="acttime"></my-popup>
  48. <my-guide ref="myGuide" @popup-close="onGuideClose"></my-guide>
  49. <!-- <my-popup-map ref="mypopupmap" :point="navPoint"></my-popup-map> -->
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import tools from '/common/tools';
  55. import cardfunc from '../../../common/cardfunc';
  56. import { localCardConfig } from "./cardconfig/test.js";
  57. import {
  58. token,
  59. apiMatchRsDetailQuery,
  60. checkResCode
  61. } from '/common/api';
  62. export default {
  63. data() {
  64. return {
  65. cardConfigData: cardfunc.cardConfigData,
  66. pageReady: false,
  67. // audioSrc: "/static/audio/2.mp3",
  68. // audioSrc: "https://oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
  69. // audioSrc: "http://t-oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
  70. pageName: "rankOverview",
  71. firstEnterKey: 'firstEnter-tpl-style1',
  72. rankKey: "rank-tpl-style1",
  73. queryObj: {},
  74. queryString: "",
  75. token: "",
  76. isNewUser: false,
  77. ecId: 0, // 卡片id
  78. mcId: 0, // 赛事id
  79. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  80. mcName: "", // 赛事名称
  81. acttime: "", // 活动时间
  82. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  83. endSecond: null, // 活动或赛事结束时间戳,单位秒
  84. nickName: "", // 昵称
  85. totalNum: null, // 总场次
  86. totalDistanct: null, // 总距离,单位米
  87. totalDistanctRankNum: null, // 总距离排名
  88. totalCp: null, // 总打点数
  89. totalCpRankNum: null, // 总打点数排名
  90. totalSysPoint: null, // 总百味豆
  91. totalSysPointRankNum: null, // 总百味豆排名
  92. fastPace: null, // 个人最快配速
  93. fastPaceRankNum: null, // 个人最快配速排名
  94. ocaRs: [], // 卡片对应活动集合
  95. interval: null,
  96. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  97. pathList: {},
  98. pathListStyle: {},
  99. selectedPath: null,
  100. navPoint: {},
  101. }
  102. },
  103. computed: {
  104. pathListLen() {
  105. return Object.keys(this.pathList).length;
  106. }
  107. },
  108. onLoad(query) { // 类型非必填,可自动推导
  109. // console.log("query:", query);
  110. this.queryObj = query;
  111. this.queryString = tools.objectToQueryString(this.queryObj);
  112. // console.log(queryString);
  113. this.token = query["token"] ?? token;
  114. this.ecId = query["id"] ?? 0;
  115. this.firstEnterKey += "-" + this.ecId;
  116. console.log("firstEnterKey:", this.firstEnterKey);
  117. this.rankKey += "-" + this.ecId;
  118. console.log("rankKey:", this.rankKey);
  119. cardfunc.init(this, this.token, this.ecId);
  120. cardfunc.getCardConfig(this.cardConfigQueryCallback, localCardConfig);
  121. cardfunc.isNewUserQuery(this.isNewUserQueryCallback);
  122. },
  123. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  124. onReady() {
  125. // this.dealFirstEnter();
  126. },
  127. onShow() {
  128. },
  129. onUnload() {
  130. this.clear();
  131. },
  132. methods: {
  133. dealNotice(rank) {
  134. // console.log('[dealFirstEnter]');
  135. let that = this;
  136. uni.getStorage({
  137. key: that.rankKey,
  138. success: (res) => {
  139. // console.log('[getStorage]', that.rankKey, res.data);
  140. const oldRank = res.data;
  141. if (oldRank != rank) {
  142. // that.notice = true;
  143. that.setRankValue(rank);
  144. }
  145. },
  146. fail: (e) => {
  147. console.log('[getStorage] fail', that.rankKey, e);
  148. // that.notice = false;
  149. that.setRankValue(rank);
  150. },
  151. })
  152. },
  153. setRankValue(data) {
  154. let that = this;
  155. uni.setStorage({
  156. key: that.rankKey,
  157. data: data,
  158. success: () => {
  159. console.log('[setStorage] success', that.rankKey, data);
  160. },
  161. fail: (e) => {
  162. console.log('[setStorage] fail', that.rankKey, e);
  163. },
  164. })
  165. },
  166. dealFirstEnter() {
  167. // console.log('[dealFirstEnter]');
  168. let that = this;
  169. uni.getStorage({
  170. key: that.firstEnterKey,
  171. success: (res) => {
  172. console.log('[getStorage]', that.firstEnterKey, res.data);
  173. },
  174. fail: (e) => {
  175. console.log('[getStorage] fail', that.firstEnterKey, e);
  176. that.btnInfo();
  177. that.setFirstEnterValue(true);
  178. },
  179. })
  180. },
  181. setFirstEnterValue(data) {
  182. let that = this;
  183. uni.setStorage({
  184. key: that.firstEnterKey,
  185. data: data,
  186. success: () => {
  187. console.log('[setStorage] success', that.firstEnterKey, data);
  188. },
  189. fail: (e) => {
  190. console.log('[setStorage] fail', that.firstEnterKey, e);
  191. },
  192. })
  193. },
  194. clear() {
  195. if (this.interval != null) {
  196. clearInterval(this.interval);
  197. this.interval = null;
  198. }
  199. },
  200. cardConfigQueryCallback(cardconfig) {
  201. this.loadConfig(cardconfig);
  202. this.matchRsDetailQuery();
  203. setTimeout(this.dealFirstEnter, 500);
  204. },
  205. isNewUserQueryCallback(isNewUser) {
  206. this.isNewUser = isNewUser;
  207. },
  208. loadConfig(cardconfig) {
  209. cardconfig = cardfunc.parseCardConfig(cardconfig);
  210. // console.log("[loadCardConfig] cardconfig:", cardconfig);
  211. // 加载卡片通用配置
  212. if (cardconfig.common != undefined) {
  213. cardfunc.loadCardCommonConfig(cardconfig.common);
  214. }
  215. // -------- 加载当前页面的配置 --------
  216. const config = cardfunc.parseCardConfig(cardconfig[this.pageName]);
  217. // console.log("[loadConfig] config_page:", config); if (config == undefined || config == null) {
  218. this.pageReady = true; return; }
  219. // 加载CSS样式
  220. const css = config.css;
  221. if (css != undefined && css.length > 0) {
  222. tools.loadCssCode(css);
  223. }
  224. // 加载比赛路线数据
  225. const pathList = config.pathList;
  226. // console.log("[loadConfig] pathList:", pathList);
  227. if (pathList != undefined) {
  228. this.pathList = pathList;
  229. }
  230. // 加载比赛路线样式
  231. const pathListStyle = config.pathListStyle;
  232. // console.log("[loadConfig] pathList:", pathList);
  233. if (pathListStyle != undefined) {
  234. this.pathListStyle = pathListStyle;
  235. }
  236. this.pageReady = true;
  237. },
  238. // 获取倒计时
  239. getCountdown() {
  240. // console.log(this.endSecond)
  241. if (this.endSecond > 0) {
  242. const now = Date.now() / 1000;
  243. const dif = this.endSecond - now;
  244. // const dif = 3600*24 - 60;
  245. if (dif > 0) {
  246. this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
  247. } else {
  248. this.countdown = "活动已结束";
  249. }
  250. // this.countdown = tools.convertSecondsToHMS(dif);
  251. } else {
  252. this.countdown = "距结束 --天--小时";
  253. }
  254. },
  255. // 格式化 距离
  256. fmtDistanct(val) {
  257. if (val < 1000)
  258. return Math.round(val * 10 / 1000) / 10;
  259. else
  260. return Math.round(val / 1000);
  261. },
  262. // 格式化 配速
  263. fmtPace(val) {
  264. return tools.convertSecondsToHMS(val, 2);
  265. },
  266. fmtMcTime(timestamp) {
  267. return tools.fmtMcTime(timestamp);
  268. },
  269. // 获取活动时间
  270. getActtime() {
  271. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  272. },
  273. // 卡片对应线上赛多个活动查询
  274. matchRsDetailQuery() {
  275. uni.request({
  276. url: apiMatchRsDetailQuery,
  277. header: {
  278. "Content-Type": "application/x-www-form-urlencoded",
  279. "token": this.token,
  280. },
  281. method: "POST",
  282. data: {
  283. ecId: this.ecId
  284. },
  285. success: (res) => {
  286. // console.log("matchRsDetailQuery", res);
  287. if (checkResCode(res)) {
  288. const data = res.data.data;
  289. this.mcType = data.mcType;
  290. this.mcId = data.mcId;
  291. this.mcName = data.mcName;
  292. this.beginSecond = data.beginSecond;
  293. this.endSecond = data.endSecond;
  294. this.nickName = data.nickName;
  295. this.totalNum = data.totalNum;
  296. this.totalDistanct = data.totalDistanct;
  297. this.totalDistanctRankNum = data.totalDistanctRankNum;
  298. this.totalCp = data.totalCp;
  299. this.totalCpRankNum = data.totalCpRankNum;
  300. this.totalSysPoint = data.totalSysPoint;
  301. this.totalSysPointRankNum = data.totalSysPointRankNum;
  302. this.fastPace = data.fastPace;
  303. this.fastPaceRankNum = data.fastPaceRankNum;
  304. this.ocaRs = data.ocaRs;
  305. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  306. const rank = JSON.stringify(data);
  307. this.dealNotice(rank);
  308. this.getCountdown();
  309. this.getActtime();
  310. this.clear();
  311. this.interval = setInterval(this.getCountdown, 60000);
  312. }
  313. },
  314. fail: (err) => {
  315. console.log("matchRsDetailQuery err", err)
  316. },
  317. });
  318. },
  319. btnBack() {
  320. const url = "/pages/tpl/style1/rankList?" + this.queryString;
  321. tools.appAction(url, "uni.navigateTo");
  322. },
  323. btnInfo() {
  324. // console.log(this.$refs.mypopup);
  325. this.$refs.mypopup.popupOpen();
  326. },
  327. // btnGuide() {
  328. // this.$refs.myGuide.popupOpen();
  329. // },
  330. onOverviewClick(ovtype) {
  331. this.queryObj.ovtype = ovtype;
  332. this.queryString = tools.objectToQueryString(this.queryObj);
  333. const url = "/pages/tpl/style1/rankList?" + this.queryString;
  334. tools.appAction(url, "uni.navigateTo");
  335. },
  336. onNewUserPathClick(data) {
  337. // console.log("onNewUserPathClick:", data);
  338. this.selectedPath = data;
  339. this.$refs.myGuide.popupOpen();
  340. },
  341. onGuideClose() {
  342. if (this.isNewUser && this.selectedPath != null) {
  343. this.$refs.myPathList.to_detail(this.selectedPath);
  344. this.selectedPath = null;
  345. }
  346. }
  347. }
  348. }
  349. </script>
  350. <style scoped>
  351. .content {
  352. width: 100vw;
  353. /* height: 100vh; */
  354. overflow-x: scroll;
  355. }
  356. .page-top {
  357. position: relative;
  358. z-index: 10;
  359. width: 100%;
  360. height: 270px;
  361. padding-top: 36px;
  362. justify-content: space-between;
  363. background-image: url("/static/backgroud/top_bg_egg2.png");
  364. background-repeat: no-repeat;
  365. background-position-x: center;
  366. background-position-y: center;
  367. /* background-position-y: -8px; */
  368. /* background-size: 100% 100%; */
  369. background-size: cover;
  370. }
  371. .topbar-color {
  372. color: #333333;
  373. }
  374. .topbtm {
  375. width: 100%;
  376. margin-bottom: 40px;
  377. justify-content: space-evenly;
  378. }
  379. .topbtm-name {
  380. padding: 5px 12px;
  381. background-color: #9fda39;
  382. border-radius: 5px;
  383. /* backdrop-filter: blur(30px); */
  384. text-align: center;
  385. font-weight: 500;
  386. color: #497400;
  387. font-size: 14px;
  388. }
  389. .mid {
  390. width: 90%;
  391. height: 120px;
  392. position: relative;
  393. z-index: 20;
  394. margin-top: -100px;
  395. background: #ffffff;
  396. border-radius: 9px;
  397. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  398. font-family: Source Han Sans CN;
  399. }
  400. .mid-1 {
  401. width: 90%;
  402. /* margin: 12px; */
  403. margin-bottom: 12px;
  404. font-weight: 500;
  405. color: #8e8e8e;
  406. font-size: 14px;
  407. }
  408. .mid-1-name {
  409. max-width: 310rpx;
  410. white-space: nowrap;
  411. overflow: hidden;
  412. text-overflow: ellipsis;
  413. }
  414. .mid-2 {
  415. width: 92%;
  416. /* margin: 0 10px; */
  417. }
  418. .mid-2-value {
  419. font-weight: 900;
  420. font-size: 22px;
  421. }
  422. .mid-2-text {
  423. color: #989898;
  424. font-size: 12px;
  425. }
  426. .mid-line {
  427. width: 0px;
  428. height: 45.04px;
  429. border: 1px solid;
  430. border-color: #e6e6e6;
  431. }
  432. .overview-1 {
  433. width: 111px;
  434. height: 54px;
  435. background: #ffb40b;
  436. border-radius: 50%;
  437. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  438. pointer-events: auto;
  439. }
  440. .overview-2 {
  441. margin-top: -43px;
  442. color: #ffffff;
  443. font-size: 18px;
  444. pointer-events: auto;
  445. }
  446. .overview-3 {
  447. width: 111px;
  448. height: 54px;
  449. background: #f39509;
  450. border-radius: 50%;
  451. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  452. pointer-events: auto;
  453. }
  454. .overview-4 {
  455. width: 111px;
  456. height: 54px;
  457. background: #81cd00;
  458. border-radius: 50%;
  459. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  460. pointer-events: auto;
  461. }
  462. .overview-5 {
  463. width: 111px;
  464. height: 54px;
  465. background: #64cbb0;
  466. border-radius: 50%;
  467. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  468. pointer-events: auto;
  469. }
  470. .ovline1 {
  471. margin-top: 9px;
  472. color: #ffffff;
  473. font-size: 12px;
  474. }
  475. .ovline2 {
  476. color: #ffffff;
  477. font-size: 16px;
  478. }
  479. .main {
  480. width: 100%;
  481. margin-top: 20px;
  482. margin-bottom: 10px;
  483. /* height: 70vh; */
  484. justify-content: space-around;
  485. /* justify-content: space-between; */
  486. }
  487. .main-title {
  488. margin-bottom: 10px;
  489. font-weight: 550;
  490. color: #333333;
  491. font-size: 16px;
  492. }
  493. </style>