rankList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <!--
  2. [报名] 样式2 - 排名列表
  3. http://localhost:5173/card/#/pages/bm/style2/rankList
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style2/rankList
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content uni-column">
  9. <view class="uni-column" :class="cssTop">
  10. <view class="topbar uni-row" :class="cssTopbarColor">
  11. <!-- <image mode="aspectFit" class="topbar-back" @click="btnBack" src="/static/default/back.png"></image> -->
  12. <text class="topbar-back" @click="btnBack">&lt;</text>
  13. <text class="mcName">{{mcName}}</text>
  14. <text class="topbar-rule" @click="btnInfo">规则</text>
  15. <!-- <image mode="aspectFit" class="topbar-info" @click="btnInfo" src="/static/default/info.png"></image> -->
  16. </view>
  17. <view class="topbtm uni-column">
  18. <text class="topbtm-name">姓名:{{nickName}}</text>
  19. </view>
  20. </view>
  21. <view class="main uni-column">
  22. <uni-segmented-control class="main-tab" :current="tabCurrent" :values="tabItems"
  23. @clickItem="onClickTabItem" styleType="button" activeColor="#81cd00"></uni-segmented-control>
  24. <view class="tab-view uni-column">
  25. <!-- 总距离 -->
  26. <my-ranklist v-show="tabCurrent === 0" :rankRs="rankList.totalDistanceRs" rank-type="totalDistance"></my-ranklist>
  27. <!-- 打点数 -->
  28. <my-ranklist v-show="tabCurrent === 1" :rankRs="rankList.totalCpRs" rank-type="totalCp"></my-ranklist>
  29. <!-- 百味豆 -->
  30. <my-ranklist v-show="tabCurrent === 2" :rankRs="rankList.totalSysPointRs" rank-type="totalSysPoint"></my-ranklist>
  31. <!-- 配速 -->
  32. <my-ranklist v-show="tabCurrent === 3" :rankRs="rankList.fastPaceRs" rank-type="fastPace"></my-ranklist>
  33. </view>
  34. <button class="btnBack" @click="btnBack">返回</button>
  35. </view>
  36. <my-popup ref="mypopup" :dataList="popupDataList" :acttime="acttime"></my-popup>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import tools from '/common/tools';
  42. import { teamName, defaultPopUpDataList } from '/common/define';
  43. import {
  44. token,
  45. apiMatchRsDetailQuery,
  46. apiCardRankDetailQuery,
  47. apiCardConfigQuery,
  48. apiUserCurrentRankNumQuery,
  49. apiIsAllowMcSignUp,
  50. checkResCode
  51. } from '/common/api';
  52. export default {
  53. data() {
  54. return {
  55. pageName: "rankList",
  56. firstEnterKey: 'firstEnter-bm-style2',
  57. rankKey: "rank-bm-style2",
  58. queryObj: {},
  59. queryString: "",
  60. token: "",
  61. ovtype: "",
  62. ecId: 0, // 卡片id
  63. mcId: 0, // 赛事id
  64. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  65. mcName: "", // 赛事名称
  66. acttime: "", // 活动时间
  67. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  68. endSecond: null, // 活动或赛事结束时间戳,单位秒
  69. ocaId: 0, // 关联id,带入到App活动详情页面
  70. nickName: "", // 昵称
  71. // totalNum: null, // 总场次
  72. // totalDistanct: null, // 总距离,单位米
  73. // totalDistanctRankNum: null, // 总距离排名
  74. // totalCp: null, // 总打点数
  75. // totalCpRankNum: null, // 总打点数排名
  76. // totalSysPoint: null, // 总百味豆
  77. // totalSysPointRankNum: null, // 总百味豆排名
  78. // fastPace: null, // 个人最快配速
  79. // fastPaceRankNum: null, // 个人最快配速排名
  80. // ocaRs: [], // 卡片对应活动集合
  81. mcState: 0 , // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  82. allowMcSignUp: false, // 是否允许重新分组
  83. countdown: "", // 倒计时
  84. rankList: { // 排名列表
  85. totalDistanceRs: [],
  86. totalCpRs: [],
  87. totalSysPointRs: [],
  88. fastPaceRs: []
  89. },
  90. interval: null,
  91. teamType: 0, // 队伍类型
  92. dispArrStr: "totalDistance,totalCp,totalSysPoint,fastPace", // 要显示的集合范围
  93. tabItems: ["总距离", "打点数", "百味豆", "配速"],
  94. tabCurrent: 0,
  95. cssTop: "",
  96. cssTopbarColor: "",
  97. popupDataList: [],
  98. }
  99. },
  100. computed: {},
  101. onLoad(query) { // 类型非必填,可自动推导
  102. // console.log(query);
  103. this.queryObj = query;
  104. this.queryString = tools.objectToQueryString(this.queryObj);
  105. // console.log(queryString);
  106. this.token = query["token"] ?? token;
  107. this.ecId = query["id"] ?? 0;
  108. this.ovtype = query["ovtype"] ?? "";
  109. this.firstEnterKey += "-" + this.ecId;
  110. console.log("firstEnterKey:", this.firstEnterKey);
  111. this.rankKey += "-" + this.ecId;
  112. console.log("rankKey:", this.rankKey);
  113. tools.removeCssCode();
  114. this.getCardConfigQuery();
  115. this.dealOvtype();
  116. },
  117. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  118. onReady() {
  119. // this.dealFirstEnter();
  120. },
  121. onUnload() {
  122. this.clear();
  123. },
  124. methods: {
  125. dealOvtype() {
  126. if (this.ovtype == "totalDistance") {
  127. this.tabCurrent = 0;
  128. } else if (this.ovtype == "totalCp") {
  129. this.tabCurrent = 1;
  130. } else if (this.ovtype == "totalSysPoint") {
  131. this.tabCurrent = 2;
  132. } else if (this.ovtype == "fastPace") {
  133. this.tabCurrent = 3;
  134. }
  135. console.log(`dealOvtype: ${this.ovtype} tabCurrent: ${this.tabCurrent}`);
  136. },
  137. dealNotice(rank) {
  138. // console.log('[dealFirstEnter]');
  139. let that = this;
  140. uni.getStorage({
  141. key: that.rankKey,
  142. success: (res) => {
  143. console.log('[getStorage]', that.rankKey, res.data);
  144. const oldRank = res.data;
  145. if (oldRank != rank) {
  146. // that.notice = true;
  147. that.setRankValue(rank);
  148. }
  149. },
  150. fail: (e) => {
  151. console.log('[getStorage] fail', that.rankKey, e);
  152. // that.notice = false;
  153. that.setRankValue(rank);
  154. },
  155. })
  156. },
  157. setRankValue(data) {
  158. let that = this;
  159. uni.setStorage({
  160. key: that.rankKey,
  161. data: data,
  162. success: () => {
  163. console.log('[setStorage] success', that.rankKey, data);
  164. },
  165. fail: (e) => {
  166. console.log('[setStorage] fail', that.rankKey, e);
  167. },
  168. })
  169. },
  170. dealFirstEnter() {
  171. // console.log('[dealFirstEnter]');
  172. let that = this;
  173. uni.getStorage({
  174. key: that.firstEnterKey,
  175. success: (res) => {
  176. console.log('[getStorage]', that.firstEnterKey, res.data);
  177. },
  178. fail: (e) => {
  179. console.log('[getStorage] fail', that.firstEnterKey, e);
  180. that.btnInfo();
  181. that.setFirstEnterValue(true);
  182. },
  183. })
  184. },
  185. setFirstEnterValue(data) {
  186. let that = this;
  187. uni.setStorage({
  188. key: that.firstEnterKey,
  189. data: data,
  190. success: () => {
  191. console.log('[setStorage] success', that.firstEnterKey, data);
  192. },
  193. fail: (e) => {
  194. console.log('[setStorage] fail', that.firstEnterKey, e);
  195. },
  196. })
  197. },
  198. clear() {
  199. if (this.interval != null) {
  200. clearInterval(this.interval);
  201. this.interval = null;
  202. }
  203. },
  204. loadConfig(config) {
  205. // console.log("config", config);
  206. // 加载CSS样式
  207. const css = config.css;
  208. if (css != undefined && css.length > 0) {
  209. tools.loadCssCode(css);
  210. if (css.indexOf(".top{") >= 0) {
  211. this.cssTop = "top";
  212. }
  213. if (css.indexOf(".topbar-color{") >= 0) {
  214. this.cssTopbarColor = "topbar-color";
  215. }
  216. }
  217. if (this.cssTop == "") {
  218. this.cssTop = "top-default";
  219. }
  220. if (this.cssTopbarColor == "") {
  221. this.cssTopbarColor = "topbar-color-default";
  222. }
  223. console.log("[loadConfig] cssTop:", this.cssTop);
  224. console.log("[loadConfig] cssTopbarColor:", this.cssTopbarColor);
  225. // 加载弹窗数据
  226. const popupDataList = config.popupDataList;
  227. // console.log("[loadConfig] popupDataList:", popupDataList);
  228. if (popupDataList != undefined && popupDataList.length > 0) {
  229. for (var i = 0; i < popupDataList.length; i++) {
  230. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  231. if (popupDataList[i] == 'default') {
  232. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  233. this.popupDataList.push(defaultPopUpDataList[j]);
  234. }
  235. } else {
  236. this.popupDataList.push(popupDataList[i]);
  237. }
  238. }
  239. } else {
  240. this.popupDataList = defaultPopUpDataList;
  241. console.log("[loadConfig] popupDataList 加载默认列表");
  242. }
  243. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  244. },
  245. // 获取倒计时
  246. getCountdown() {
  247. // console.log(this.endSecond)
  248. if (this.endSecond > 0) {
  249. const now = Date.now() / 1000;
  250. const dif = this.endSecond - now;
  251. // const dif = 3600*24 - 60;
  252. if (dif > 0) {
  253. this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
  254. } else {
  255. this.countdown = "活动已结束";
  256. }
  257. // this.countdown = tools.convertSecondsToHMS(dif);
  258. } else {
  259. this.countdown = "距结束 --天--小时";
  260. }
  261. },
  262. fmtMcTime(timestamp) {
  263. var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  264. // var Y = date.getFullYear() + '-';
  265. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  266. var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
  267. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  268. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  269. // var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  270. const timeStr = M + D + h + m;
  271. // console.log("timeStr", timeStr);
  272. return timeStr;
  273. },
  274. // 获取活动时间
  275. getActtime() {
  276. this.acttime = this.fmtMcTime(this.beginSecond) + " 至 " + this.fmtMcTime(this.endSecond);
  277. },
  278. getTeamName(teamType, teamIndex) {
  279. return teamName[teamType][teamIndex];
  280. },
  281. getCardConfigQuery() {
  282. uni.request({
  283. url: apiCardConfigQuery,
  284. header: {
  285. "Content-Type": "application/x-www-form-urlencoded",
  286. "token": this.token,
  287. },
  288. method: "POST",
  289. data: {
  290. ecId: this.ecId,
  291. pageName: this.pageName
  292. },
  293. success: (res) => {
  294. // console.log("getCardConfigQuery", res)
  295. const data = res.data.data;
  296. // console.log("configJson", data.configJson);
  297. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  298. // console.log("configJson", data.configJson);
  299. /* const config = {
  300. "css": `
  301. .top{
  302. width: 100%;
  303. height: 170px;
  304. padding-top: 36px;
  305. justify-content: space-between;
  306. background-image: url("static/backgroud/top_bg_aoti3.png");
  307. background-repeat: no-repeat;
  308. background-position: center;
  309. background-size: cover;
  310. }
  311. `,
  312. "popupDataList": [{
  313. "type": 1,
  314. "data": {
  315. "title": "小飞龙定向赛",
  316. "img": "/static/logo/xfl.png",
  317. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  318. }
  319. },
  320. "default"
  321. ]
  322. }; */
  323. this.loadConfig(config);
  324. this.matchRsDetailQuery();
  325. setTimeout(this.dealFirstEnter, 500);
  326. },
  327. fail: (err) => {
  328. console.log("getCardConfigQuery err", err)
  329. },
  330. });
  331. },
  332. // 卡片对应活动或赛事详情查询
  333. // getCardDetailQuery() {
  334. // uni.request({
  335. // url: apiCardDetailQuery,
  336. // header: {
  337. // "Content-Type": "application/x-www-form-urlencoded",
  338. // "token": this.token,
  339. // },
  340. // method: "POST",
  341. // data: {
  342. // ecId: this.ecId
  343. // },
  344. // success: (res) => {
  345. // // console.log("getCardDetailQuery", res)
  346. // const data = res.data.data;
  347. // this.mcType = data.mcType;
  348. // this.mcId = data.mcId;
  349. // this.mcName = data.mcName;
  350. // this.beginSecond = data.beginSecond;
  351. // this.endSecond = data.endSecond;
  352. // this.coiName = data.coiName;
  353. // this.teamNum = data.teamNum;
  354. // this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  355. // this.getCountdown();
  356. // this.getActtime();
  357. // this.getCardRankDetailQuery();
  358. // this.clear();
  359. // this.interval = setInterval(this.getCountdown, 60000);
  360. // },
  361. // fail: (err) => {
  362. // console.log("getCardDetailQuery err", err)
  363. // },
  364. // });
  365. // },
  366. // 卡片对应线上赛多个活动查询
  367. matchRsDetailQuery() {
  368. uni.request({
  369. url: apiMatchRsDetailQuery,
  370. header: {
  371. "Content-Type": "application/x-www-form-urlencoded",
  372. "token": this.token,
  373. },
  374. method: "POST",
  375. data: {
  376. ecId: this.ecId
  377. },
  378. success: (res) => {
  379. // console.log("matchRsDetailQuery", res);
  380. if (checkResCode(res)) {
  381. const data = res.data.data;
  382. this.mcType = data.mcType;
  383. this.mcId = data.mcId;
  384. this.mcName = data.mcName;
  385. this.beginSecond = data.beginSecond;
  386. this.endSecond = data.endSecond;
  387. this.nickName = data.nickName;
  388. // this.totalNum = data.totalNum;
  389. // this.totalDistanct = data.totalDistanct;
  390. // this.totalDistanctRankNum = data.totalDistanctRankNum;
  391. // this.totalCp = data.totalCp;
  392. // this.totalCpRankNum = data.totalCpRankNum;
  393. // this.totalSysPoint = data.totalSysPoint;
  394. // this.totalSysPointRankNum = data.totalSysPointRankNum;
  395. // this.fastPace = data.fastPace;
  396. // this.fastPaceRankNum = data.fastPaceRankNum;
  397. // this.ocaRs = data.ocaRs;
  398. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  399. this.getCountdown();
  400. this.getActtime();
  401. this.getCardRankDetailQuery();
  402. this.clear();
  403. this.interval = setInterval(this.getCountdown, 60000);
  404. }
  405. },
  406. fail: (err) => {
  407. console.log("matchRsDetailQuery err", err)
  408. },
  409. });
  410. },
  411. // 排名查询
  412. getCardRankDetailQuery() {
  413. uni.request({
  414. url: apiCardRankDetailQuery,
  415. header: {
  416. "Content-Type": "application/x-www-form-urlencoded",
  417. "token": this.token,
  418. },
  419. method: "POST",
  420. data: {
  421. mcIdListStr: this.mcId,
  422. mcType: this.mcType,
  423. dispArrStr: this.dispArrStr
  424. },
  425. success: (res) => {
  426. // console.log("getCardRankDetailQuery", res);
  427. const rankdata = res.data.data;
  428. this.rankList.totalDistanceRs = rankdata.totalDistanceRs;
  429. this.rankList.totalCpRs = rankdata.totalCpRs;
  430. this.rankList.totalSysPointRs = rankdata.totalSysPointRs;
  431. this.rankList.fastPaceRs = rankdata.fastPaceRs;
  432. },
  433. fail: (err) => {
  434. console.log("getCardRankDetailQuery err", err)
  435. },
  436. });
  437. },
  438. // 卡片用户当前排名查询
  439. // getUserCurrentRankNumQuery() {
  440. // uni.request({
  441. // url: apiUserCurrentRankNumQuery,
  442. // header: {
  443. // "Content-Type": "application/x-www-form-urlencoded",
  444. // "token": this.token,
  445. // },
  446. // method: "POST",
  447. // data: {
  448. // ecId: this.ecId
  449. // },
  450. // success: (res) => {
  451. // // console.log("getUserCurrentRankNumQuery", res)
  452. // if (res.data.code == 0) {
  453. // const data = res.data.data;
  454. // const rankNum = data.rankNum;
  455. // this.dealNotice(rankNum);
  456. // }
  457. // },
  458. // fail: (err) => {
  459. // console.log("getUserCurrentRankNumQuery err", err)
  460. // },
  461. // });
  462. // },
  463. // 是否允许重新分组(报名)
  464. isAllowMcSignUp() {
  465. uni.request({
  466. url: apiIsAllowMcSignUp,
  467. header: {
  468. "Content-Type": "application/x-www-form-urlencoded",
  469. "token": this.token,
  470. },
  471. method: "POST",
  472. data: {
  473. ecId: this.ecId
  474. },
  475. success: (res) => {
  476. // console.log("isAllowMcSignUp", res)
  477. if (res.data.code == 0) {
  478. const data = res.data.data;
  479. this.allowMcSignUp = data.allowSignUp;
  480. }
  481. },
  482. fail: (err) => {
  483. console.log("isAllowMcSignUp err", err)
  484. },
  485. });
  486. },
  487. btnBack() {
  488. // window.history.back();
  489. // window.location.href = `action://to_home/`;
  490. uni.navigateTo({
  491. url: "/pages/bm/style2/rankOverview?" + this.queryString
  492. });
  493. },
  494. // btnReGroup() {
  495. // uni.navigateTo({
  496. // url: '/pages/bm/style1/signup?from=rankList&' + this.queryString
  497. // });
  498. // },
  499. // btnStart() {
  500. // window.location.href = `action://to_detail/?id=${this.ocaId}&matchType=${this.mcType}`;
  501. // },
  502. btnInfo() {
  503. // console.log(this.$refs.mypopup);
  504. this.$refs.mypopup.popupOpen();
  505. },
  506. onClickTabItem(e) {
  507. if (this.tabCurrent != e.currentIndex) {
  508. this.tabCurrent = e.currentIndex;
  509. }
  510. }
  511. }
  512. }
  513. </script>
  514. <style scoped>
  515. .content {
  516. width: 100vw;
  517. height: 100vh;
  518. }
  519. .top-default {
  520. width: 100%;
  521. height: 170px;
  522. padding-top: 36px;
  523. justify-content: space-between;
  524. background-image: url("/static/backgroud/top_bg_aoti3.png");
  525. background-repeat: no-repeat;
  526. background-position: center;
  527. background-size: cover;
  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. /* opacity: 0; */
  540. font-size: 50rpx;
  541. }
  542. .topbar-info {
  543. width: 46rpx;
  544. height: 46rpx;
  545. }
  546. .topbar-rule {
  547. font-size: 32rpx;
  548. }
  549. .mcName {
  550. font-size: 40rpx;
  551. font-weight: 550;
  552. }
  553. .topbtm {
  554. width: 100%;
  555. margin-bottom: 5px;
  556. justify-content: space-evenly;
  557. }
  558. .topbtm-name {
  559. padding: 3px 12px;
  560. background-color: #9fda39;
  561. border-radius: 5px;
  562. text-align: center;
  563. font-weight: 500;
  564. color: #497400;
  565. font-size: 14px;
  566. }
  567. .cal {
  568. width: 46rpx;
  569. height: 46rpx;
  570. margin-right: 20rpx;
  571. }
  572. .main {
  573. width: 100%;
  574. /* height: 70vh; */
  575. flex-grow: 1;
  576. justify-content: space-around;
  577. /* justify-content: space-between; */
  578. }
  579. .main-tab {
  580. width: 90%;
  581. margin-top: 20rpx;
  582. }
  583. .tab-view {
  584. width: 100%;
  585. /* height: 69vh; */
  586. flex-grow: 1;
  587. }
  588. .btnBack {
  589. width: 70%;
  590. /* height: 6vh; */
  591. height: 80rpx;
  592. /* margin-bottom: 1vh; */
  593. margin-bottom: 20rpx;
  594. /* font-weight: bold; */
  595. color: white;
  596. font-size: 32rpx;
  597. line-height: 80rpx;
  598. border-radius: 27px;
  599. background-color: #81cd00;
  600. }
  601. </style>