rankList.vue 18 KB

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