rankOverview.vue 13 KB

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