rankOverview.vue 13 KB

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