rankList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <!--
  2. [报名] 样式1 - 排名列表
  3. http://localhost:5173/card/#/pages/bm/style1/rankList
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style1/rankList
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content">
  9. <view class="uni-column" :class="cssTop">
  10. <view class="topbar uni-row">
  11. <image mode="aspectFit" class="topbar-back" @click="btnBack" src="/static/default/back.png"></image>
  12. <text class="mcName">{{mcName}}</text>
  13. <image mode="aspectFit" class="topbar-info" @click="btnInfo" src="/static/default/info.png"></image>
  14. </view>
  15. <view class="topcontent uni-column">
  16. <view>
  17. <text class="toptext">{{coiName}}</text>
  18. <text class="toptext" v-if="teamNum > 0">{{getTeamName(teamType, teamNum)}}</text>
  19. </view>
  20. <view class="top-countdown uni-row">
  21. <image mode="aspectFit" class="cal" src="/static/default/cal.png"></image>
  22. <text>{{countdown}}</text>
  23. </view>
  24. </view>
  25. <view class="topbtm uni-column">
  26. <view class="topbtm-content uni-row">
  27. <text class="topbtm-sspm" v-if="mcState==1 && allowMcSignUp"></text>
  28. <text class="topbtm-sspm">实时排名</text>
  29. <view class="btnReGroup" v-if="mcState==1 && allowMcSignUp" @click="btnReGroup">重新分组</view>
  30. </view>
  31. </view>
  32. <!-- <text class="mcName">{{ecId}} - {{mcId}} - {{token}}</text> -->
  33. </view>
  34. <view class="main uni-column">
  35. <uni-segmented-control class="main-tab" :current="tabCurrent" :values="tabItems"
  36. @clickItem="onClickTabItem" styleType="button" activeColor="#2e85ec"></uni-segmented-control>
  37. <view class="tab-view uni-column">
  38. <!-- 总排名 -->
  39. <my-ranklist v-show="tabCurrent === 0" :rankRs="rankList.totalRankRs"></my-ranklist>
  40. <!-- 队伍排名 -->
  41. <my-ranklist v-show="tabCurrent === 1" v-if="teamType==0" :rankRs="rankList.teamRankRs" :teamType="this.teamType"></my-ranklist>
  42. <!-- 队内排名 -->
  43. <my-ranklist v-show="tabCurrent === 2" v-if="teamType==0" :rankRs="rankList.inTeamRs"></my-ranklist>
  44. <!-- 学生排名 -->
  45. <my-ranklist v-show="tabCurrent === 1" v-if="teamType==1" :rankRs="teamNum==1 ? rankList.inTeamRs : rankList.otherRs[1]"></my-ranklist>
  46. <!-- 家长排名 -->
  47. <my-ranklist v-show="tabCurrent === 2" v-if="teamType==1" :rankRs="teamNum==2 ? rankList.inTeamRs : rankList.otherRs[2]"></my-ranklist>
  48. </view>
  49. <button class="btnStart btnStart-disable" v-if="mcState==0">活动尚未开始</button>
  50. <button class="btnStart btnStart-enable" v-if="mcState==1" @click="btnStart">开始比赛</button>
  51. <button class="btnStart btnStart-disable" v-if="mcState==2">活动已结束</button>
  52. </view>
  53. <my-popup ref="mypopup" :dataList="popupDataList" :acttime="acttime"></my-popup>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import tools from '/common/tools';
  59. import { teamName, defaultPopUpDataList } from '/common/define';
  60. import {
  61. token,
  62. apiCardDetailQuery,
  63. apiCardRankDetailQuery,
  64. apiCardConfigQuery,
  65. apiUserCurrentRankNumQuery,
  66. apiIsAllowMcSignUp,
  67. checkResCode
  68. } from '/common/api';
  69. export default {
  70. data() {
  71. return {
  72. pageName: "rankList",
  73. firstEnterKey: 'firstEnter-bm',
  74. rankKey: "rank-bm-style1",
  75. queryString: "",
  76. token: "",
  77. ecId: 0, // 卡片id
  78. mcId: 0, // 赛事id
  79. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  80. mcName: "", // 赛事名称
  81. acttime: "", // 活动时间
  82. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  83. endSecond: null, // 活动或赛事结束时间戳,单位秒
  84. coiName: "", // 已报名单位名称,可为空
  85. teamNum: 0, // 已报名队伍编号,可为0
  86. mcState: 0 , // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  87. allowMcSignUp: false, // 是否允许重新分组
  88. countdown: "", // 倒计时
  89. rankList: { // 排名列表
  90. totalRankRs: [],
  91. teamRankRs: [],
  92. inTeamRs: [],
  93. otherRs: []
  94. },
  95. interval: null,
  96. teamType: 0, // 队伍类型
  97. dispArrStr: "", // 要显示的集合范围 (total,team,in,other)
  98. tabItems: [],
  99. tabCurrent: 0,
  100. cssTop: "",
  101. popupDataList: [],
  102. }
  103. },
  104. computed: {},
  105. onLoad(event) { // 类型非必填,可自动推导
  106. // console.log(event);
  107. this.queryString = tools.objectToQueryString(event);
  108. // console.log(queryString);
  109. this.token = event["token"] ?? token;
  110. this.ecId = event["id"] ?? 0;
  111. this.firstEnterKey += "-" + this.ecId;
  112. console.log("firstEnterKey:", this.firstEnterKey);
  113. this.rankKey += "-" + this.ecId;
  114. console.log("rankKey:", this.rankKey);
  115. tools.removeCssCode();
  116. this.getCardConfigQuery();
  117. this.getUserCurrentRankNumQuery();
  118. this.isAllowMcSignUp();
  119. },
  120. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  121. onReady() {
  122. // this.dealFirstEnter();
  123. },
  124. onUnload() {
  125. this.clear();
  126. },
  127. methods: {
  128. dealNotice(rank) {
  129. // console.log('[dealFirstEnter]');
  130. let that = this;
  131. uni.getStorage({
  132. key: that.rankKey,
  133. success: (res) => {
  134. console.log('[getStorage]', that.rankKey, res.data);
  135. const oldRank = res.data;
  136. if (oldRank != rank) {
  137. // that.notice = true;
  138. that.setRankValue(rank);
  139. }
  140. },
  141. fail: (e) => {
  142. console.log('[getStorage] fail', that.rankKey, e);
  143. // that.notice = false;
  144. that.setRankValue(rank);
  145. },
  146. })
  147. },
  148. setRankValue(data) {
  149. let that = this;
  150. uni.setStorage({
  151. key: that.rankKey,
  152. data: data,
  153. success: () => {
  154. console.log('[setStorage] success', that.rankKey, data);
  155. },
  156. fail: (e) => {
  157. console.log('[setStorage] fail', that.rankKey, e);
  158. },
  159. })
  160. },
  161. dealFirstEnter() {
  162. // console.log('[dealFirstEnter]');
  163. let that = this;
  164. uni.getStorage({
  165. key: that.firstEnterKey,
  166. success: (res) => {
  167. console.log('[getStorage]', that.firstEnterKey, res.data);
  168. },
  169. fail: (e) => {
  170. console.log('[getStorage] fail', that.firstEnterKey, e);
  171. that.btnInfo();
  172. that.setFirstEnterValue(true);
  173. },
  174. })
  175. },
  176. setFirstEnterValue(data) {
  177. let that = this;
  178. uni.setStorage({
  179. key: that.firstEnterKey,
  180. data: data,
  181. success: () => {
  182. console.log('[setStorage] success', that.firstEnterKey, data);
  183. },
  184. fail: (e) => {
  185. console.log('[setStorage] fail', that.firstEnterKey, e);
  186. },
  187. })
  188. },
  189. clear() {
  190. if (this.interval != null) {
  191. clearInterval(this.interval);
  192. this.interval = null;
  193. }
  194. },
  195. loadConfig(config) {
  196. // console.log("config", config);
  197. // 加载CSS样式
  198. const css = config.css;
  199. if (css != undefined && css.length > 0) {
  200. tools.loadCssCode(css);
  201. if (css.indexOf(".top{") >= 0) {
  202. this.cssTop = "top";
  203. }
  204. }
  205. if (this.cssTop == "") {
  206. this.cssTop = "top-default";
  207. }
  208. console.log("[loadConfig] cssTop:", this.cssTop);
  209. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  210. if (config.teamType != undefined && config.teamType >= 0) {
  211. this.teamType = config.teamType;
  212. }
  213. if (this.teamType == 0) {
  214. this.dispArrStr = "total,team,in", // 要显示的集合范围 (total,team,in,other)
  215. this.tabItems = ['总排名', '队伍排名', '队内排名'];
  216. } else if (this.teamType == 1) {
  217. this.dispArrStr = "total,in,other", // 要显示的集合范围 (total,team,in,other)
  218. this.tabItems = ['总排名', '学生排名', '家长排名'];
  219. }
  220. // 加载弹窗数据
  221. const popupDataList = config.popupDataList;
  222. // console.log("[loadConfig] popupDataList:", popupDataList);
  223. if (popupDataList != undefined && popupDataList.length > 0) {
  224. for (var i = 0; i < popupDataList.length; i++) {
  225. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  226. if (popupDataList[i] == 'default') {
  227. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  228. this.popupDataList.push(defaultPopUpDataList[j]);
  229. }
  230. } else {
  231. this.popupDataList.push(popupDataList[i]);
  232. }
  233. }
  234. } else {
  235. this.popupDataList = defaultPopUpDataList;
  236. console.log("[loadConfig] popupDataList 加载默认列表");
  237. }
  238. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  239. },
  240. // 获取倒计时
  241. getCountdown() {
  242. // console.log(this.endSecond)
  243. if (this.endSecond > 0) {
  244. const now = Date.now() / 1000;
  245. const dif = this.endSecond - now;
  246. // const dif = 3600*24 - 60;
  247. if (dif > 0) {
  248. this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
  249. } else {
  250. this.countdown = "活动已结束";
  251. }
  252. // this.countdown = tools.convertSecondsToHMS(dif);
  253. } else {
  254. this.countdown = "距结束 --天--小时";
  255. }
  256. },
  257. fmtMcTime(timestamp) {
  258. var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  259. // var Y = date.getFullYear() + '-';
  260. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  261. var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
  262. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  263. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  264. // var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  265. const timeStr = M + D + h + m;
  266. // console.log("timeStr", timeStr);
  267. return timeStr;
  268. },
  269. // 获取活动时间
  270. getActtime() {
  271. this.acttime = this.fmtMcTime(this.beginSecond) + " 至 " + this.fmtMcTime(this.endSecond);
  272. },
  273. getTeamName(teamType, teamIndex) {
  274. return teamName[teamType][teamIndex];
  275. },
  276. getCardConfigQuery() {
  277. uni.request({
  278. url: apiCardConfigQuery,
  279. header: {
  280. "Content-Type": "application/x-www-form-urlencoded",
  281. "token": this.token,
  282. },
  283. method: "POST",
  284. data: {
  285. ecId: this.ecId,
  286. pageName: this.pageName
  287. },
  288. success: (res) => {
  289. // console.log("getCardConfigQuery", res)
  290. const data = res.data.data;
  291. // console.log("configJson", data.configJson);
  292. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  293. // console.log("configJson", data.configJson);
  294. /* const config = {
  295. "css": `
  296. .top{
  297. width: 100%;
  298. height: 26vh;
  299. padding-top: 30px;
  300. justify-content: space-between;
  301. background-image: url('static/backgroud/top_run.png'), url('static/backgroud/top_colorbar.png'), linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  302. background-repeat: no-repeat;
  303. background-position: 45px 25px, center, 0px 0px;
  304. background-size: auto 27vh, auto 22vh , cover;
  305. }
  306. `,
  307. "popupDataList": [
  308. {
  309. "type": 1,
  310. "data": {
  311. "title": "山青活动",
  312. "img": "/static/logo/sqsj.png",
  313. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  314. }
  315. },
  316. "default"
  317. ],
  318. "teamType": 1
  319. }; */
  320. this.loadConfig(config);
  321. this.getCardDetailQuery();
  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. getCardRankDetailQuery() {
  365. uni.request({
  366. url: apiCardRankDetailQuery,
  367. header: {
  368. "Content-Type": "application/x-www-form-urlencoded",
  369. "token": this.token,
  370. },
  371. method: "POST",
  372. data: {
  373. mcIdListStr: this.mcId,
  374. mcType: this.mcType,
  375. dispArrStr: this.dispArrStr
  376. },
  377. success: (res) => {
  378. // console.log("getCardRankDetailQuery", res)
  379. const rankdata = res.data.data;
  380. this.rankList.totalRankRs = rankdata.totalRankRs;
  381. this.rankList.teamRankRs = rankdata.teamRankRs;
  382. this.rankList.inTeamRs = rankdata.inTeamRs;
  383. this.rankList.otherRs = rankdata.otherRs;
  384. },
  385. fail: (err) => {
  386. console.log("getCardRankDetailQuery err", err)
  387. },
  388. });
  389. },
  390. // 卡片用户当前排名查询
  391. getUserCurrentRankNumQuery() {
  392. uni.request({
  393. url: apiUserCurrentRankNumQuery,
  394. header: {
  395. "Content-Type": "application/x-www-form-urlencoded",
  396. "token": this.token,
  397. },
  398. method: "POST",
  399. data: {
  400. ecId: this.ecId
  401. },
  402. success: (res) => {
  403. // console.log("getUserCurrentRankNumQuery", res)
  404. if (res.data.code == 0) {
  405. const data = res.data.data;
  406. const rankNum = data.rankNum;
  407. this.dealNotice(rankNum);
  408. }
  409. },
  410. fail: (err) => {
  411. console.log("getUserCurrentRankNumQuery err", err)
  412. },
  413. });
  414. },
  415. // 是否允许重新分组(报名)
  416. isAllowMcSignUp() {
  417. uni.request({
  418. url: apiIsAllowMcSignUp,
  419. header: {
  420. "Content-Type": "application/x-www-form-urlencoded",
  421. "token": this.token,
  422. },
  423. method: "POST",
  424. data: {
  425. ecId: this.ecId
  426. },
  427. success: (res) => {
  428. // console.log("isAllowMcSignUp", res)
  429. if (res.data.code == 0) {
  430. const data = res.data.data;
  431. this.allowMcSignUp = data.allowSignUp;
  432. }
  433. },
  434. fail: (err) => {
  435. console.log("isAllowMcSignUp err", err)
  436. },
  437. });
  438. },
  439. btnBack() {
  440. // window.history.back();
  441. window.location.href = `action://to_home/`;
  442. },
  443. btnReGroup() {
  444. uni.navigateTo({
  445. url: '/pages/bm/style1/signup?from=rankList&' + this.queryString
  446. });
  447. },
  448. btnStart() {
  449. window.location.href = `action://to_detail/?id=${this.mcId}&matchType=${this.mcType}`;
  450. },
  451. btnInfo() {
  452. // console.log(this.$refs.mypopup);
  453. this.$refs.mypopup.popupOpen();
  454. },
  455. onClickTabItem(e) {
  456. if (this.tabCurrent != e.currentIndex) {
  457. this.tabCurrent = e.currentIndex;
  458. }
  459. }
  460. }
  461. }
  462. </script>
  463. <style scoped>
  464. .content {
  465. width: 100vw;
  466. height: 100vh;
  467. }
  468. .top-default {
  469. width: 100%;
  470. height: 24.6vh;
  471. padding-top: 36px;
  472. justify-content: space-between;
  473. background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#f8a95a 0%,#d25f11 100%);
  474. /* background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#7aedff 0%,#047200 100%); */
  475. /* background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%); */
  476. background-repeat: no-repeat;
  477. background-position: 45px 25px, center, 0px 0px;
  478. /* background-position-x: center; */
  479. /* background-position-y: center; */
  480. background-size: auto 27vh, auto 22vh , cover;
  481. }
  482. .topbar {
  483. width: 90%;
  484. justify-content: space-between;
  485. }
  486. .topbar-back {
  487. width: 43rpx;
  488. height: 43rpx;
  489. /* opacity: 0; */
  490. }
  491. .topbar-info {
  492. width: 46rpx;
  493. height: 46rpx;
  494. }
  495. .mcName {
  496. color: white;
  497. font-size: 39rpx;
  498. font-weight: bold;
  499. }
  500. .topcontent {
  501. /* height: 1300rpx; */
  502. /* background-color: #2e85ec; */
  503. margin-top: 50rpx;
  504. justify-content: center;
  505. }
  506. .top-countdown {
  507. height: 90rpx;
  508. color: #ffdc51;
  509. font-size: 28rpx;
  510. }
  511. .cal {
  512. width: 46rpx;
  513. height: 46rpx;
  514. margin-right: 20rpx;
  515. }
  516. .toptext {
  517. margin: 0 10rpx;
  518. color: #ffffff;
  519. font-size: 35rpx;
  520. font-weight: 500;
  521. line-height: 60rpx;
  522. }
  523. .btnReGroup {
  524. width: 130rpx;
  525. height: 36rpx;
  526. margin-top: 15rpx;
  527. margin-bottom: 15rpx;
  528. background: #ffcb00;
  529. border-radius: 15px;
  530. color: #000000;
  531. font-size: 24rpx;
  532. text-align: center;
  533. line-height: 36rpx;
  534. }
  535. .topbtm {
  536. width: 100%;
  537. height: 60rpx;
  538. margin-bottom: 10rpx;
  539. justify-content: space-evenly;
  540. }
  541. .topbtm-content {
  542. width: 100%;
  543. justify-content: space-around;
  544. /* justify-content: space-between; */
  545. }
  546. .topbtm-sspm {
  547. width: 120rpx;
  548. color: #ffee00;
  549. font-size: 24rpx;
  550. text-align: center;
  551. }
  552. .main {
  553. width: 100%;
  554. height: 70vh;
  555. justify-content: space-around;
  556. /* justify-content: space-between; */
  557. }
  558. .main-tab {
  559. width: 90%;
  560. margin-top: 20rpx;
  561. }
  562. .tab-view {
  563. width: 100%;
  564. /* height: 69vh; */
  565. }
  566. .btnStart {
  567. width: 70%;
  568. /* height: 6vh; */
  569. height: 80rpx;
  570. /* margin-bottom: 1vh; */
  571. margin-bottom: 20rpx;
  572. /* font-weight: bold; */
  573. color: white;
  574. font-size: 32rpx;
  575. line-height: 80rpx;
  576. border-radius: 27px;
  577. }
  578. .btnStart-enable {
  579. background-color: #ffb40b;
  580. }
  581. .btnStart-disable {
  582. background-color: #c3c3c3;
  583. }
  584. </style>