rankList.vue 17 KB

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