rankOverview.vue 17 KB

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