rankOverview.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <!--
  2. [报名] 样式2 - 排名总览
  3. http://localhost:5173/card/#/pages/bm/style2/rankOverview
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style2/rankOverview
  5. -->
  6. <template>
  7. <view class="body">
  8. <view v-if="pageReady" class="content">
  9. <view class="uni-column" :class="cssTop">
  10. <my-topbar :mcName="mcName" :class="cssTopbarColor"
  11. @btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
  12. <view class="topbtm uni-column">
  13. <text class="topbtm-name">姓名:{{nickName}}</text>
  14. </view>
  15. </view>
  16. <view class="top-oval">
  17. <!-- <text class="top-oval-text" @click="onOverviewClick('totalNum')">点击查看排行榜</text> -->
  18. </view>
  19. <view class="mid uni-column">
  20. <view class="mid-1 uni-row uni-jcsb">
  21. <view class="overview-1 uni-column" @click="onOverviewClick('totalDistanct')">
  22. <text class="ovline1">总距离 {{fmtDistanct(totalDistanct)}} km</text>
  23. <text class="ovline2">第 {{totalDistanctRankNum > 0 ? totalDistanctRankNum : '- -'}} 名</text>
  24. </view>
  25. <view class="overview-2 uni-column" @click="onOverviewClick('totalNum')">
  26. <text class="">总场次 {{totalNum}}</text>
  27. </view>
  28. <view class="overview-3 uni-column" @click="onOverviewClick('totalCp')">
  29. <text class="ovline1">总打点数 {{totalCp}} 个</text>
  30. <text class="ovline2">第 {{totalCpRankNum > 0 ? totalCpRankNum : '- -'}} 名</text>
  31. </view>
  32. </view>
  33. <view class="mid-2 uni-row uni-jcse">
  34. <view class="overview-4 uni-column" @click="onOverviewClick('totalSysPoint')">
  35. <text class="ovline1">总百味豆 {{totalSysPoint}} 个</text>
  36. <text class="ovline2">第 {{totalSysPointRankNum > 0 ? totalSysPointRankNum : '- -'}} 名</text>
  37. </view>
  38. <view class="overview-5 uni-column" @click="onOverviewClick('fastPace')">
  39. <text class="ovline1">最快配速 {{fmtPace(fastPace)}}</text>
  40. <text class="ovline2">第 {{fastPaceRankNum > 0 ? fastPaceRankNum : '- -'}} 名</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="main uni-column">
  45. <text class="main-title">选择比赛路线</text>
  46. <my-pathList :style="pathListStyle.style" :pathList="pathList" :mcState="mcState"
  47. :showLine="pathListStyle.showLine"></my-pathList>
  48. </view>
  49. <my-popup ref="mypopup" :config="popupRuleConfig" :dataList="popupDataList" :acttime="acttime"></my-popup>
  50. <!-- <my-popup-map ref="mypopupmap" :point="navPoint"></my-popup-map> -->
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import tools from '/common/tools';
  56. import {
  57. defaultPopUpDataList,
  58. defaultPopUpDataList2
  59. } from '/common/define';
  60. import {
  61. token,
  62. apiMatchRsDetailQuery,
  63. apiCardConfigQuery,
  64. checkResCode
  65. } from '/common/api';
  66. export default {
  67. data() {
  68. return {
  69. pageReady: false,
  70. // audioSrc: "/static/audio/2.mp3",
  71. // audioSrc: "https://oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
  72. // audioSrc: "http://t-oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
  73. pageName: "rankOverview",
  74. firstEnterKey: 'firstEnter-bm-style2',
  75. rankKey: "rank-bm-style2",
  76. queryObj: {},
  77. queryString: "",
  78. token: "",
  79. ecId: 0, // 卡片id
  80. mcId: 0, // 赛事id
  81. mcType: 0,
  82. mcName: "", // 赛事名称
  83. acttime: "", // 活动时间
  84. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  85. endSecond: null, // 活动或赛事结束时间戳,单位秒
  86. nickName: "", // 昵称
  87. totalNum: null, // 总场次
  88. totalDistanct: null, // 总距离,单位米
  89. totalDistanctRankNum: null, // 总距离排名
  90. totalCp: null, // 总打点数
  91. totalCpRankNum: null, // 总打点数排名
  92. totalSysPoint: null, // 总百味豆
  93. totalSysPointRankNum: null, // 总百味豆排名
  94. fastPace: null, // 个人最快配速
  95. fastPaceRankNum: null, // 个人最快配速排名
  96. ocaRs: [], // 卡片对应活动集合
  97. interval: null,
  98. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  99. cssTop: "",
  100. cssTopbarColor: "",
  101. pathList: {},
  102. pathListStyle: {},
  103. popupRuleConfig: {}, // 规则弹窗配置
  104. popupDataList: [],
  105. navPoint: {},
  106. }
  107. },
  108. computed: {
  109. pathListLen() {
  110. return Object.keys(this.pathList).length;
  111. }
  112. },
  113. onLoad(query) { // 类型非必填,可自动推导
  114. // console.log("query:", query);
  115. this.queryObj = query;
  116. this.queryString = tools.objectToQueryString(this.queryObj);
  117. // console.log(queryString);
  118. this.token = query["token"] ?? token;
  119. this.ecId = query["id"] ?? 0;
  120. this.firstEnterKey += "-" + this.ecId;
  121. console.log("firstEnterKey:", this.firstEnterKey);
  122. this.rankKey += "-" + this.ecId;
  123. console.log("rankKey:", this.rankKey);
  124. tools.removeCssCode();
  125. this.getCardConfigQuery();
  126. },
  127. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  128. onReady() {
  129. // this.dealFirstEnter();
  130. // this.playMusic();
  131. },
  132. onShow() {
  133. // uni.showToast({
  134. // icon: "none",
  135. // title: "[rankOverview] onShow"
  136. // })
  137. // if (this.$audio.audioStatus == 2 && this.$audio.audioSrc == this.audioSrc) {
  138. // this.$audio.play();
  139. // }
  140. },
  141. onUnload() {
  142. this.clear();
  143. },
  144. methods: {
  145. playMusic() {
  146. return;
  147. // uni.showToast({
  148. // title: 'playMusic',
  149. // icon: 'none',
  150. // duration: 2000
  151. // });
  152. // if (this.$audio.audioStatus == 0 || this.$audio.audioSrc != this.audioSrc) {
  153. // this.$audio.playAudio(this.audioSrc);
  154. // }
  155. },
  156. dealNotice(rank) {
  157. // console.log('[dealFirstEnter]');
  158. let that = this;
  159. uni.getStorage({
  160. key: that.rankKey,
  161. success: (res) => {
  162. console.log('[getStorage]', that.rankKey, res.data);
  163. const oldRank = res.data;
  164. if (oldRank != rank) {
  165. // that.notice = true;
  166. that.setRankValue(rank);
  167. }
  168. },
  169. fail: (e) => {
  170. console.log('[getStorage] fail', that.rankKey, e);
  171. // that.notice = false;
  172. that.setRankValue(rank);
  173. },
  174. })
  175. },
  176. setRankValue(data) {
  177. let that = this;
  178. uni.setStorage({
  179. key: that.rankKey,
  180. data: data,
  181. success: () => {
  182. console.log('[setStorage] success', that.rankKey, data);
  183. },
  184. fail: (e) => {
  185. console.log('[setStorage] fail', that.rankKey, e);
  186. },
  187. })
  188. },
  189. dealFirstEnter() {
  190. // console.log('[dealFirstEnter]');
  191. let that = this;
  192. uni.getStorage({
  193. key: that.firstEnterKey,
  194. success: (res) => {
  195. console.log('[getStorage]', that.firstEnterKey, res.data);
  196. },
  197. fail: (e) => {
  198. console.log('[getStorage] fail', that.firstEnterKey, e);
  199. that.btnInfo();
  200. that.setFirstEnterValue(true);
  201. },
  202. })
  203. },
  204. setFirstEnterValue(data) {
  205. let that = this;
  206. uni.setStorage({
  207. key: that.firstEnterKey,
  208. data: data,
  209. success: () => {
  210. console.log('[setStorage] success', that.firstEnterKey, data);
  211. },
  212. fail: (e) => {
  213. console.log('[setStorage] fail', that.firstEnterKey, e);
  214. },
  215. })
  216. },
  217. clear() {
  218. if (this.interval != null) {
  219. clearInterval(this.interval);
  220. this.interval = null;
  221. }
  222. },
  223. loadConfig(config) {
  224. // console.log("config", config);
  225. // 加载CSS样式
  226. const css = config.css;
  227. if (css != undefined && css.length > 0) {
  228. tools.loadCssCode(css);
  229. if (css.indexOf(".top{") >= 0) {
  230. this.cssTop = "top";
  231. }
  232. if (css.indexOf(".topbar-color{") >= 0) {
  233. this.cssTopbarColor = "topbar-color";
  234. }
  235. }
  236. if (this.cssTop == "") {
  237. this.cssTop = "top-default";
  238. }
  239. if (this.cssTopbarColor == "") {
  240. this.cssTopbarColor = "topbar-color-default";
  241. }
  242. console.log("[loadConfig] cssTop:", this.cssTop);
  243. console.log("[loadConfig] cssTopbarColor:", this.cssTopbarColor);
  244. // 加载比赛路线数据
  245. const pathList = config.pathList;
  246. // console.log("[loadConfig] pathList:", pathList);
  247. if (pathList != undefined) {
  248. this.pathList = pathList;
  249. }
  250. // 加载比赛路线样式
  251. const pathListStyle = config.pathListStyle;
  252. // console.log("[loadConfig] pathList:", pathList);
  253. if (pathListStyle != undefined) {
  254. this.pathListStyle = pathListStyle;
  255. }
  256. // 加载规则弹窗配置
  257. const popupRuleConfig = config.popupRuleConfig;
  258. if (popupRuleConfig != undefined) {
  259. this.popupRuleConfig = popupRuleConfig;
  260. }
  261. // console.log("[loadConfig] popupRuleConfig:", this.popupRuleConfig);
  262. // 加载弹窗数据
  263. const popupDataList = config.popupDataList;
  264. // console.log("[loadConfig] popupDataList:", popupDataList);
  265. if (popupDataList != undefined && popupDataList.length > 0) {
  266. for (var i = 0; i < popupDataList.length; i++) {
  267. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  268. if (popupDataList[i] == 'default') {
  269. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  270. this.popupDataList.push(defaultPopUpDataList[j]);
  271. }
  272. } else if (popupDataList[i] == 'default2') {
  273. for (var j = 0; j < defaultPopUpDataList2.length; j++) {
  274. this.popupDataList.push(defaultPopUpDataList2[j]);
  275. }
  276. } else {
  277. this.popupDataList.push(popupDataList[i]);
  278. }
  279. }
  280. } else {
  281. this.popupDataList = defaultPopUpDataList;
  282. console.log("[loadConfig] popupDataList 加载默认列表");
  283. }
  284. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  285. this.pageReady = true;
  286. },
  287. // 获取倒计时
  288. getCountdown() {
  289. // console.log(this.endSecond)
  290. if (this.endSecond > 0) {
  291. const now = Date.now() / 1000;
  292. const dif = this.endSecond - now;
  293. // const dif = 3600*24 - 60;
  294. if (dif > 0) {
  295. this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
  296. } else {
  297. this.countdown = "活动已结束";
  298. }
  299. // this.countdown = tools.convertSecondsToHMS(dif);
  300. } else {
  301. this.countdown = "距结束 --天--小时";
  302. }
  303. },
  304. // 格式化 距离
  305. fmtDistanct(val) {
  306. if (val < 1000)
  307. return Math.round(val * 10 / 1000) / 10;
  308. else
  309. return Math.round(val / 1000);
  310. },
  311. // 格式化 配速
  312. fmtPace(val) {
  313. return tools.convertSecondsToHMS(val, 2);
  314. },
  315. fmtMcTime(timestamp) {
  316. return tools.fmtMcTime(timestamp);
  317. },
  318. // 获取活动时间
  319. getActtime() {
  320. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  321. },
  322. getCardConfigQuery() {
  323. uni.request({
  324. url: apiCardConfigQuery,
  325. header: {
  326. "Content-Type": "application/x-www-form-urlencoded",
  327. "token": this.token,
  328. },
  329. method: "POST",
  330. data: {
  331. ecId: this.ecId,
  332. pageName: this.pageName
  333. },
  334. success: (res) => {
  335. // console.log("getCardConfigQuery", res)
  336. const data = res.data.data;
  337. // console.log("configJson", data.configJson);
  338. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  339. // console.log("configJson", data.configJson);
  340. /* const config = {
  341. "css": `
  342. .top{
  343. position: relative;
  344. z-index: 10;
  345. width: 100%;
  346. height: 300px;
  347. padding-top: 36px;
  348. justify-content: space-between;
  349. background-image: url('static/backgroud/top_bg_sea.png');
  350. background-repeat: no-repeat;
  351. background-position-x: center;
  352. background-position-y: bottom;
  353. background-size: cover;
  354. }
  355. `,
  356. "pathList": {
  357. "row1": [{
  358. "type": 2,
  359. "img": "/static/common/dhdqdwz.png",
  360. "point": {
  361. "longitude": 117.022194,
  362. "latitude": 36.661612,
  363. "name": "小飞龙定向赛起始点"
  364. }
  365. },
  366. {
  367. "type": 1,
  368. "img": "/static/common/cjlx12dw.png",
  369. "path": {
  370. "ocaId": 1,
  371. "mcType": 3
  372. }
  373. }
  374. ],
  375. "row2": [{
  376. "type": 1,
  377. "img": "/static/common/zjlx16dw.png",
  378. "path": {
  379. "ocaId": 2,
  380. "mcType": 3
  381. }
  382. },
  383. {
  384. "type": 1,
  385. "img": "/static/common/gjlx20dw.png",
  386. "path": {
  387. "ocaId": 3,
  388. "mcType": 3
  389. }
  390. }
  391. ]
  392. },
  393. "pathListStyle" : {
  394. "showLine" : false,
  395. "style": "justify-content: space-evenly;"
  396. },
  397. "popupDataList": [{
  398. "type": 1,
  399. "data": {
  400. "title": "小飞龙定向赛",
  401. "img": "/static/logo/xfl.png",
  402. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  403. }
  404. },
  405. {
  406. "type": 2,
  407. "data": {
  408. "title": "规则",
  409. "img": "/static/common/guize.png"
  410. }
  411. }, {
  412. "type": 2,
  413. "data": {
  414. "title": "奖励",
  415. "img": "/static/common/jiangli.png"
  416. }
  417. },
  418. "default"
  419. ]
  420. }; */
  421. this.loadConfig(config);
  422. this.matchRsDetailQuery();
  423. setTimeout(this.dealFirstEnter, 500);
  424. },
  425. fail: (err) => {
  426. console.log("getCardConfigQuery err", err)
  427. },
  428. });
  429. },
  430. // 卡片对应线上赛多个活动查询
  431. matchRsDetailQuery() {
  432. uni.request({
  433. url: apiMatchRsDetailQuery,
  434. header: {
  435. "Content-Type": "application/x-www-form-urlencoded",
  436. "token": this.token,
  437. },
  438. method: "POST",
  439. data: {
  440. ecId: this.ecId
  441. },
  442. success: (res) => {
  443. console.log("matchRsDetailQuery", res);
  444. if (checkResCode(res)) {
  445. const data = res.data.data;
  446. this.mcType = data.mcType;
  447. this.mcId = data.mcId;
  448. this.mcName = data.mcName;
  449. this.beginSecond = data.beginSecond;
  450. this.endSecond = data.endSecond;
  451. this.nickName = data.nickName;
  452. this.totalNum = data.totalNum;
  453. this.totalDistanct = data.totalDistanct;
  454. this.totalDistanctRankNum = data.totalDistanctRankNum;
  455. this.totalCp = data.totalCp;
  456. this.totalCpRankNum = data.totalCpRankNum;
  457. this.totalSysPoint = data.totalSysPoint;
  458. this.totalSysPointRankNum = data.totalSysPointRankNum;
  459. this.fastPace = data.fastPace;
  460. this.fastPaceRankNum = data.fastPaceRankNum;
  461. this.ocaRs = data.ocaRs;
  462. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  463. const rank = JSON.stringify(data);
  464. this.dealNotice(rank);
  465. this.getCountdown();
  466. this.getActtime();
  467. this.clear();
  468. this.interval = setInterval(this.getCountdown, 60000);
  469. }
  470. },
  471. fail: (err) => {
  472. console.log("matchRsDetailQuery err", err)
  473. },
  474. });
  475. },
  476. btnBack() {
  477. // window.history.back();
  478. // const url = `action://to_home/`;
  479. // tools.appAction(url);
  480. // uni.navigateTo({
  481. // url: "/pages/bm/style2/rankList?" + this.queryString
  482. // });
  483. const url = "/pages/bm/style2/rankList?" + this.queryString;
  484. tools.appAction(url, "uni.navigateTo");
  485. },
  486. btnInfo() {
  487. // console.log(this.$refs.mypopup);
  488. this.$refs.mypopup.popupOpen();
  489. },
  490. onOverviewClick(ovtype) {
  491. this.queryObj.ovtype = ovtype;
  492. this.queryString = tools.objectToQueryString(this.queryObj);
  493. // uni.navigateTo({
  494. // url: "/pages/bm/style2/rankList?" + this.queryString
  495. // });
  496. const url = "/pages/bm/style2/rankList?" + this.queryString;
  497. tools.appAction(url, "uni.navigateTo");
  498. },
  499. }
  500. }
  501. </script>
  502. <style scoped>
  503. .content {
  504. width: 100vw;
  505. height: 100vh;
  506. overflow-x: hidden;
  507. }
  508. .top-default {
  509. position: relative;
  510. z-index: 10;
  511. width: 100%;
  512. height: 300px;
  513. padding-top: 36px;
  514. justify-content: space-between;
  515. background-image: url("/static/backgroud/top_bg_aoti2.png");
  516. background-repeat: no-repeat;
  517. background-position-x: center;
  518. background-position-y: bottom;
  519. /* background-size: 100% 100%; */
  520. background-size: cover;
  521. }
  522. .top-oval {
  523. position: relative;
  524. z-index: 0;
  525. margin-top: -180px;
  526. margin-left: -10%;
  527. width: 120%;
  528. height: 280px;
  529. background: linear-gradient(180deg, #ffffff 12.18%, #eeeeee 100%);
  530. border-radius: 50%;
  531. text-align: center;
  532. }
  533. .top-oval-text {
  534. color: #333333;
  535. font-size: 13px;
  536. line-height: 386px;
  537. pointer-events: auto;
  538. }
  539. .topbar-color-default {
  540. color: #5b9100;
  541. }
  542. .topbtm {
  543. width: 100%;
  544. /* height: 60rpx; */
  545. margin-bottom: 40px;
  546. justify-content: space-evenly;
  547. }
  548. .topbtm-name {
  549. /* width: 320rpx; */
  550. /* height: 28px; */
  551. padding: 5px 12px;
  552. background-color: #9fda39;
  553. border-radius: 5px;
  554. /* backdrop-filter: blur(30px); */
  555. text-align: center;
  556. font-weight: 500;
  557. color: #497400;
  558. font-size: 14px;
  559. }
  560. .mid {
  561. position: relative;
  562. z-index: 20;
  563. margin-top: -130px;
  564. pointer-events: none;
  565. }
  566. .mid-1 {
  567. width: 92%;
  568. }
  569. .mid-2 {
  570. width: 66%;
  571. }
  572. .overview-1 {
  573. width: 111px;
  574. height: 54px;
  575. background: #ffb40b;
  576. border-radius: 50%;
  577. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  578. pointer-events: auto;
  579. }
  580. .overview-2 {
  581. margin-top: -43px;
  582. color: #ffffff;
  583. font-size: 18px;
  584. pointer-events: auto;
  585. }
  586. .overview-3 {
  587. width: 111px;
  588. height: 54px;
  589. background: #f39509;
  590. border-radius: 50%;
  591. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  592. pointer-events: auto;
  593. }
  594. .overview-4 {
  595. width: 111px;
  596. height: 54px;
  597. background: #81cd00;
  598. border-radius: 50%;
  599. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  600. pointer-events: auto;
  601. }
  602. .overview-5 {
  603. width: 111px;
  604. height: 54px;
  605. background: #64cbb0;
  606. border-radius: 50%;
  607. box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
  608. pointer-events: auto;
  609. }
  610. .ovline1 {
  611. margin-top: 9px;
  612. color: #ffffff;
  613. font-size: 12px;
  614. }
  615. .ovline2 {
  616. color: #ffffff;
  617. font-size: 16px;
  618. }
  619. .main {
  620. width: 100%;
  621. margin-top: 36px;
  622. margin-bottom: 10px;
  623. /* height: 70vh; */
  624. justify-content: space-around;
  625. /* justify-content: space-between; */
  626. }
  627. .main-title {
  628. margin-bottom: 10px;
  629. font-weight: 550;
  630. color: #333333;
  631. font-size: 16px;
  632. }
  633. </style>