rankOverview.vue 17 KB

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