rankList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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. return tools.fmtMcTime(timestamp);
  269. },
  270. // 获取活动时间
  271. getActtime() {
  272. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  273. },
  274. getTeamName(teamType, teamIndex) {
  275. return teamName[teamType][teamIndex];
  276. },
  277. getCardConfigQuery() {
  278. uni.request({
  279. url: apiCardConfigQuery,
  280. header: {
  281. "Content-Type": "application/x-www-form-urlencoded",
  282. "token": this.token,
  283. },
  284. method: "POST",
  285. data: {
  286. ecId: this.ecId,
  287. pageName: this.pageName
  288. },
  289. success: (res) => {
  290. // console.log("getCardConfigQuery", res)
  291. const data = res.data.data;
  292. // console.log("configJson", data.configJson);
  293. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  294. // console.log("configJson", data.configJson);
  295. /* const config = {
  296. "css": `
  297. .top{
  298. width: 100%;
  299. height: 170px;
  300. padding-top: 36px;
  301. justify-content: space-between;
  302. background-image: url("static/backgroud/top_bg_aoti3.png");
  303. background-repeat: no-repeat;
  304. background-position: center;
  305. background-size: cover;
  306. }
  307. `,
  308. "tabActiveColor": "#ff870d",
  309. "popupDataList": [{
  310. "type": 1,
  311. "data": {
  312. "title": "小飞龙定向赛",
  313. "img": "/static/logo/xfl.png",
  314. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  315. }
  316. },
  317. "default"
  318. ]
  319. }; */
  320. this.loadConfig(config);
  321. this.matchRsDetailQuery();
  322. setTimeout(this.dealFirstEnter, 500);
  323. },
  324. fail: (err) => {
  325. console.log("getCardConfigQuery err", err)
  326. },
  327. });
  328. },
  329. // 卡片对应活动或赛事详情查询
  330. // getCardDetailQuery() {
  331. // uni.request({
  332. // url: apiCardDetailQuery,
  333. // header: {
  334. // "Content-Type": "application/x-www-form-urlencoded",
  335. // "token": this.token,
  336. // },
  337. // method: "POST",
  338. // data: {
  339. // ecId: this.ecId
  340. // },
  341. // success: (res) => {
  342. // // console.log("getCardDetailQuery", res)
  343. // const data = res.data.data;
  344. // this.mcType = data.mcType;
  345. // this.mcId = data.mcId;
  346. // this.mcName = data.mcName;
  347. // this.beginSecond = data.beginSecond;
  348. // this.endSecond = data.endSecond;
  349. // this.coiName = data.coiName;
  350. // this.teamNum = data.teamNum;
  351. // this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  352. // this.getCountdown();
  353. // this.getActtime();
  354. // this.getCardRankDetailQuery();
  355. // this.clear();
  356. // this.interval = setInterval(this.getCountdown, 60000);
  357. // },
  358. // fail: (err) => {
  359. // console.log("getCardDetailQuery err", err)
  360. // },
  361. // });
  362. // },
  363. // 卡片对应线上赛多个活动查询
  364. matchRsDetailQuery() {
  365. uni.request({
  366. url: apiMatchRsDetailQuery,
  367. header: {
  368. "Content-Type": "application/x-www-form-urlencoded",
  369. "token": this.token,
  370. },
  371. method: "POST",
  372. data: {
  373. ecId: this.ecId
  374. },
  375. success: (res) => {
  376. // console.log("matchRsDetailQuery", res);
  377. if (checkResCode(res)) {
  378. const data = res.data.data;
  379. this.mcType = data.mcType;
  380. this.mcId = data.mcId;
  381. this.mcName = data.mcName;
  382. this.beginSecond = data.beginSecond;
  383. this.endSecond = data.endSecond;
  384. this.nickName = data.nickName;
  385. // this.totalNum = data.totalNum;
  386. // this.totalDistanct = data.totalDistanct;
  387. // this.totalDistanctRankNum = data.totalDistanctRankNum;
  388. // this.totalCp = data.totalCp;
  389. // this.totalCpRankNum = data.totalCpRankNum;
  390. // this.totalSysPoint = data.totalSysPoint;
  391. // this.totalSysPointRankNum = data.totalSysPointRankNum;
  392. // this.fastPace = data.fastPace;
  393. // this.fastPaceRankNum = data.fastPaceRankNum;
  394. // this.ocaRs = data.ocaRs;
  395. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  396. this.getCountdown();
  397. this.getActtime();
  398. this.getCardRankDetailQuery();
  399. this.clear();
  400. this.interval = setInterval(this.getCountdown, 60000);
  401. }
  402. },
  403. fail: (err) => {
  404. console.log("matchRsDetailQuery err", err)
  405. },
  406. });
  407. },
  408. // 排名查询
  409. getCardRankDetailQuery() {
  410. uni.request({
  411. url: apiCardRankDetailQuery,
  412. header: {
  413. "Content-Type": "application/x-www-form-urlencoded",
  414. "token": this.token,
  415. },
  416. method: "POST",
  417. data: {
  418. mcIdListStr: this.mcId,
  419. mcType: this.mcType,
  420. dispArrStr: this.dispArrStr
  421. },
  422. success: (res) => {
  423. // console.log("getCardRankDetailQuery", res);
  424. const rankdata = res.data.data;
  425. this.rankList.totalDistanceRs = rankdata.totalDistanceRs;
  426. this.rankList.totalCpRs = rankdata.totalCpRs;
  427. this.rankList.totalSysPointRs = rankdata.totalSysPointRs;
  428. this.rankList.fastPaceRs = rankdata.fastPaceRs;
  429. },
  430. fail: (err) => {
  431. console.log("getCardRankDetailQuery err", err)
  432. },
  433. });
  434. },
  435. // 卡片用户当前排名查询
  436. // getUserCurrentRankNumQuery() {
  437. // uni.request({
  438. // url: apiUserCurrentRankNumQuery,
  439. // header: {
  440. // "Content-Type": "application/x-www-form-urlencoded",
  441. // "token": this.token,
  442. // },
  443. // method: "POST",
  444. // data: {
  445. // ecId: this.ecId
  446. // },
  447. // success: (res) => {
  448. // // console.log("getUserCurrentRankNumQuery", res)
  449. // if (res.data.code == 0) {
  450. // const data = res.data.data;
  451. // const rankNum = data.rankNum;
  452. // this.dealNotice(rankNum);
  453. // }
  454. // },
  455. // fail: (err) => {
  456. // console.log("getUserCurrentRankNumQuery err", err)
  457. // },
  458. // });
  459. // },
  460. // 是否允许重新分组(报名)
  461. isAllowMcSignUp() {
  462. uni.request({
  463. url: apiIsAllowMcSignUp,
  464. header: {
  465. "Content-Type": "application/x-www-form-urlencoded",
  466. "token": this.token,
  467. },
  468. method: "POST",
  469. data: {
  470. ecId: this.ecId
  471. },
  472. success: (res) => {
  473. // console.log("isAllowMcSignUp", res)
  474. if (res.data.code == 0) {
  475. const data = res.data.data;
  476. this.allowMcSignUp = data.allowSignUp;
  477. }
  478. },
  479. fail: (err) => {
  480. console.log("isAllowMcSignUp err", err)
  481. },
  482. });
  483. },
  484. btnBack() {
  485. // window.history.back();
  486. // uni.navigateTo({
  487. // url: "/pages/bm/style2/rankOverview?" + this.queryString
  488. // });
  489. const url = `action://to_home/`;
  490. // window.location.href = url;
  491. tools.appAction(url);
  492. },
  493. btnStartGame() {
  494. uni.navigateTo({
  495. url: "/pages/bm/style2/rankOverview?" + this.queryString
  496. });
  497. },
  498. btnInfo() {
  499. // console.log(this.$refs.mypopup);
  500. this.$refs.mypopup.popupOpen();
  501. },
  502. onClickTabItem(e) {
  503. if (this.tabCurrent != e.currentIndex) {
  504. this.tabCurrent = e.currentIndex;
  505. }
  506. }
  507. }
  508. }
  509. </script>
  510. <style scoped>
  511. .content {
  512. width: 100vw;
  513. height: 100vh;
  514. }
  515. .top-default {
  516. width: 100%;
  517. height: 170px;
  518. padding-top: 36px;
  519. justify-content: space-between;
  520. background-image: url("/static/backgroud/top_bg_aoti3.png");
  521. background-repeat: no-repeat;
  522. background-position: center;
  523. background-size: cover;
  524. }
  525. .topbar {
  526. width: 90%;
  527. justify-content: space-between;
  528. }
  529. .topbar-color-default {
  530. color: #5b9100;
  531. }
  532. .topbar-back {
  533. width: 43rpx;
  534. height: 43rpx;
  535. color: inherit !important;
  536. font-size: 48rpx !important;
  537. /* opacity: 0; */
  538. }
  539. .topbar-info {
  540. width: 46rpx;
  541. height: 46rpx;
  542. }
  543. .topbar-rule {
  544. font-size: 32rpx;
  545. }
  546. .mcName {
  547. font-size: 40rpx;
  548. font-weight: 550;
  549. }
  550. .topbtm {
  551. width: 100%;
  552. margin-bottom: 5px;
  553. justify-content: space-evenly;
  554. }
  555. .topbtm-name {
  556. padding: 3px 12px;
  557. background-color: #9fda39;
  558. border-radius: 5px;
  559. text-align: center;
  560. font-weight: 500;
  561. color: #497400;
  562. font-size: 14px;
  563. }
  564. .cal {
  565. width: 46rpx;
  566. height: 46rpx;
  567. margin-right: 20rpx;
  568. }
  569. .main {
  570. width: 100%;
  571. /* height: 70vh; */
  572. flex-grow: 1;
  573. justify-content: space-around;
  574. /* justify-content: space-between; */
  575. }
  576. .main-tab {
  577. width: 90%;
  578. margin-top: 20rpx;
  579. }
  580. .tab-view {
  581. width: 100%;
  582. /* height: 69vh; */
  583. flex-grow: 1;
  584. }
  585. .btnBack {
  586. width: 70%;
  587. /* height: 6vh; */
  588. height: 80rpx;
  589. /* margin-bottom: 1vh; */
  590. margin-bottom: 20rpx;
  591. /* font-weight: bold; */
  592. color: white;
  593. font-size: 32rpx;
  594. line-height: 80rpx;
  595. border-radius: 27px;
  596. background-color: #81cd00;
  597. }
  598. </style>