rankOverview.vue 18 KB

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