rankOverview.vue 18 KB

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