rankList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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"></text>
  28. <text class="topbtm-sspm">实时排名</text>
  29. <view class="btnReGroup" v-if="mcState==1" @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. checkResCode
  66. } from '/common/api';
  67. export default {
  68. data() {
  69. return {
  70. pageName: "rankList",
  71. // firstEnterKey: 'firstEnter-bm_sqsj_rankList',
  72. firstEnterKey: 'firstEnter-bm_sqsj',
  73. queryString: "",
  74. token: "",
  75. ecId: 0, // 卡片id
  76. mcId: 0, // 赛事id
  77. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  78. mcName: "", // 赛事名称
  79. acttime: "", // 活动时间
  80. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  81. endSecond: null, // 活动或赛事结束时间戳,单位秒
  82. coiName: "", // 已报名单位名称,可为空
  83. teamNum: 0, // 已报名队伍编号,可为0
  84. mcState: 0 ,// 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  85. countdown: "", // 倒计时
  86. rankList: { // 排名列表
  87. totalRankRs: [],
  88. teamRankRs: [],
  89. inTeamRs: [],
  90. otherRs: []
  91. },
  92. interval: null,
  93. teamType: 0, // 队伍类型
  94. dispArrStr: "", // 要显示的集合范围 (total,team,in,other)
  95. tabItems: [],
  96. tabCurrent: 0,
  97. cssTop: "",
  98. popupDataList: [],
  99. }
  100. },
  101. computed: {},
  102. onLoad(event) { // 类型非必填,可自动推导
  103. // console.log(event);
  104. this.queryString = tools.objectToQueryString(event);
  105. // console.log(queryString);
  106. this.token = event["token"] ?? token;
  107. this.ecId = event["id"] ?? 0;
  108. tools.removeCssCode();
  109. this.getCardConfigQuery();
  110. },
  111. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  112. onReady() {
  113. this.dealFirstEnter();
  114. },
  115. onUnload() {
  116. this.clear();
  117. },
  118. methods: {
  119. dealFirstEnter() {
  120. // console.log('[dealFirstEnter]');
  121. let that = this;
  122. uni.getStorage({
  123. key: that.firstEnterKey,
  124. success: (res) => {
  125. console.log('[getStorage]', that.firstEnterKey, res.data);
  126. },
  127. fail: (e) => {
  128. console.log('[getStorage] fail', that.firstEnterKey, e);
  129. that.btnInfo();
  130. that.setFirstEnterValue(true);
  131. },
  132. })
  133. },
  134. setFirstEnterValue(data) {
  135. let that = this;
  136. uni.setStorage({
  137. key: that.firstEnterKey,
  138. data: data,
  139. success: () => {
  140. console.log('[setStorage] success', that.firstEnterKey, data);
  141. },
  142. fail: (e) => {
  143. console.log('[setStorage] fail', that.firstEnterKey, e);
  144. },
  145. })
  146. },
  147. clear() {
  148. if (this.interval != null) {
  149. clearInterval(this.interval);
  150. this.interval = null;
  151. }
  152. },
  153. loadConfig(config) {
  154. // console.log("config", config);
  155. // 加载CSS样式
  156. const css = config.css;
  157. if (css != undefined && css.length > 0) {
  158. tools.loadCssCode(css);
  159. if (css.indexOf(".top{") >= 0) {
  160. this.cssTop = "top";
  161. }
  162. }
  163. if (this.cssTop == "") {
  164. this.cssTop = "top-default";
  165. }
  166. console.log("[loadConfig] cssTop:", this.cssTop);
  167. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  168. if (config.teamType != undefined && config.teamType >= 0) {
  169. this.teamType = config.teamType;
  170. }
  171. if (this.teamType == 0) {
  172. this.dispArrStr = "total,team,in", // 要显示的集合范围 (total,team,in,other)
  173. this.tabItems = ['总排名', '队伍排名', '队内排名'];
  174. } else if (this.teamType == 1) {
  175. this.dispArrStr = "total,in,other", // 要显示的集合范围 (total,team,in,other)
  176. this.tabItems = ['总排名', '学生排名', '家长排名'];
  177. }
  178. // 加载弹窗数据
  179. const popupDataList = config.popupDataList;
  180. // console.log("[loadConfig] popupDataList:", popupDataList);
  181. if (popupDataList != undefined && popupDataList.length > 0) {
  182. for (var i = 0; i < popupDataList.length; i++) {
  183. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  184. if (popupDataList[i] == 'default') {
  185. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  186. this.popupDataList.push(defaultPopUpDataList[j]);
  187. }
  188. } else {
  189. this.popupDataList.push(popupDataList[i]);
  190. }
  191. }
  192. } else {
  193. this.popupDataList = defaultPopUpDataList;
  194. console.log("[loadConfig] popupDataList 加载默认列表");
  195. }
  196. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  197. },
  198. // 获取倒计时
  199. getCountdown() {
  200. // console.log(this.endSecond)
  201. if (this.endSecond > 0) {
  202. const now = Date.now() / 1000;
  203. const dif = this.endSecond - now;
  204. // const dif = 3600*24 - 60;
  205. if (dif > 0) {
  206. this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
  207. } else {
  208. this.countdown = "活动已结束";
  209. }
  210. // this.countdown = tools.convertSecondsToHMS(dif);
  211. } else {
  212. this.countdown = "距结束 --天--小时";
  213. }
  214. },
  215. fmtMcTime(timestamp) {
  216. var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  217. // var Y = date.getFullYear() + '-';
  218. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  219. var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
  220. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  221. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  222. // var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  223. const timeStr = M + D + h + m;
  224. // console.log("timeStr", timeStr);
  225. return timeStr;
  226. },
  227. // 获取活动时间
  228. getActtime() {
  229. this.acttime = this.fmtMcTime(this.beginSecond) + " 至 " + this.fmtMcTime(this.endSecond);
  230. },
  231. getTeamName(teamType, teamIndex) {
  232. return teamName[teamType][teamIndex];
  233. },
  234. getCardConfigQuery() {
  235. uni.request({
  236. url: apiCardConfigQuery,
  237. header: {
  238. "Content-Type": "application/x-www-form-urlencoded",
  239. "token": this.token,
  240. },
  241. method: "POST",
  242. data: {
  243. ecId: this.ecId,
  244. pageName: this.pageName
  245. },
  246. success: (res) => {
  247. console.log("getCardConfigQuery", res)
  248. const data = res.data.data;
  249. // console.log("configJson", data.configJson);
  250. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  251. // console.log("configJson", data.configJson);
  252. /* const config = {
  253. "css": `
  254. .top{
  255. width: 100%;
  256. height: 26vh;
  257. padding-top: 30px;
  258. justify-content: space-between;
  259. background-image: url('static/backgroud/top_run.png'), url('static/backgroud/top_colorbar.png'), linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  260. background-repeat: no-repeat;
  261. background-position: 45px 25px, center, 0px 0px;
  262. background-size: auto 27vh, auto 22vh , cover;
  263. }
  264. `,
  265. "popupDataList": [
  266. {
  267. "type": 1,
  268. "data": {
  269. "title": "山青活动",
  270. "img": "/static/logo/sqsj.png",
  271. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  272. }
  273. },
  274. "default"
  275. ],
  276. "teamType": 1
  277. }; */
  278. this.loadConfig(config);
  279. this.getCardDetailQuery();
  280. },
  281. fail: (err) => {
  282. console.log("getCardConfigQuery err", err)
  283. },
  284. });
  285. },
  286. // 卡片对应活动或赛事详情查询
  287. getCardDetailQuery() {
  288. uni.request({
  289. url: apiCardDetailQuery,
  290. header: {
  291. "Content-Type": "application/x-www-form-urlencoded",
  292. "token": this.token,
  293. },
  294. method: "POST",
  295. data: {
  296. ecId: this.ecId
  297. },
  298. success: (res) => {
  299. // console.log("getCardDetailQuery", res)
  300. const data = res.data.data;
  301. this.mcType = data.mcType;
  302. this.mcId = data.mcId;
  303. this.mcName = data.mcName;
  304. this.beginSecond = data.beginSecond;
  305. this.endSecond = data.endSecond;
  306. this.coiName = data.coiName;
  307. this.teamNum = data.teamNum;
  308. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  309. this.getCountdown();
  310. this.getActtime();
  311. this.getCardRankDetailQuery();
  312. this.clear();
  313. this.interval = setInterval(this.getCountdown, 60000);
  314. },
  315. fail: (err) => {
  316. console.log("getCardDetailQuery err", err)
  317. },
  318. });
  319. },
  320. // 排名查询
  321. getCardRankDetailQuery() {
  322. uni.request({
  323. url: apiCardRankDetailQuery,
  324. header: {
  325. "Content-Type": "application/x-www-form-urlencoded",
  326. "token": this.token,
  327. },
  328. method: "POST",
  329. data: {
  330. mcIdListStr: this.mcId,
  331. mcType: this.mcType,
  332. dispArrStr: this.dispArrStr
  333. },
  334. success: (res) => {
  335. console.log("getCardRankDetailQuery", res)
  336. const rankdata = res.data.data;
  337. this.rankList.totalRankRs = rankdata.totalRankRs;
  338. this.rankList.teamRankRs = rankdata.teamRankRs;
  339. this.rankList.inTeamRs = rankdata.inTeamRs;
  340. this.rankList.otherRs = rankdata.otherRs;
  341. },
  342. fail: (err) => {
  343. console.log("getCardRankDetailQuery err", err)
  344. },
  345. });
  346. },
  347. btnBack() {
  348. // window.history.back();
  349. window.location.href = `action://to_home/`;
  350. },
  351. btnReGroup() {
  352. uni.navigateTo({
  353. url: '/pages/bm/style1/signup?from=rankList&' + this.queryString
  354. });
  355. },
  356. btnStart() {
  357. window.location.href = `action://to_detail/?id=${this.mcId}&matchType=${this.mcType}`;
  358. },
  359. btnInfo() {
  360. // console.log(this.$refs.mypopup);
  361. this.$refs.mypopup.popupOpen();
  362. },
  363. onClickTabItem(e) {
  364. if (this.tabCurrent != e.currentIndex) {
  365. this.tabCurrent = e.currentIndex;
  366. }
  367. }
  368. }
  369. }
  370. </script>
  371. <style scoped>
  372. .content {
  373. width: 100vw;
  374. height: 100vh;
  375. }
  376. .top-default {
  377. width: 100%;
  378. height: 24.6vh;
  379. padding-top: 36px;
  380. justify-content: space-between;
  381. background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#f8a95a 0%,#d25f11 100%);
  382. /* background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#7aedff 0%,#047200 100%); */
  383. /* background-image: url("/static/backgroud/top_run.png"), url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%); */
  384. background-repeat: no-repeat;
  385. background-position: 45px 25px, center, 0px 0px;
  386. /* background-position-x: center; */
  387. /* background-position-y: center; */
  388. background-size: auto 27vh, auto 22vh , cover;
  389. }
  390. .topbar {
  391. width: 90%;
  392. justify-content: space-between;
  393. }
  394. .topbar-back {
  395. width: 43rpx;
  396. height: 43rpx;
  397. /* opacity: 0; */
  398. }
  399. .topbar-info {
  400. width: 46rpx;
  401. height: 46rpx;
  402. }
  403. .mcName {
  404. color: white;
  405. font-size: 39rpx;
  406. font-weight: bold;
  407. }
  408. .topcontent {
  409. /* height: 1300rpx; */
  410. /* background-color: #2e85ec; */
  411. margin-top: 50rpx;
  412. justify-content: center;
  413. }
  414. .top-countdown {
  415. height: 90rpx;
  416. color: #ffdc51;
  417. font-size: 28rpx;
  418. }
  419. .cal {
  420. width: 46rpx;
  421. height: 46rpx;
  422. margin-right: 20rpx;
  423. }
  424. .toptext {
  425. margin: 0 10rpx;
  426. color: #ffffff;
  427. font-size: 35rpx;
  428. font-weight: 500;
  429. line-height: 60rpx;
  430. }
  431. .btnReGroup {
  432. width: 130rpx;
  433. height: 36rpx;
  434. margin-top: 15rpx;
  435. margin-bottom: 15rpx;
  436. background: #ffcb00;
  437. border-radius: 15px;
  438. color: #000000;
  439. font-size: 24rpx;
  440. text-align: center;
  441. line-height: 36rpx;
  442. }
  443. .topbtm {
  444. width: 100%;
  445. height: 60rpx;
  446. margin-bottom: 10rpx;
  447. justify-content: space-evenly;
  448. }
  449. .topbtm-content {
  450. width: 100%;
  451. justify-content: space-around;
  452. /* justify-content: space-between; */
  453. }
  454. .topbtm-sspm {
  455. width: 120rpx;
  456. color: #ffee00;
  457. font-size: 24rpx;
  458. text-align: center;
  459. }
  460. .main {
  461. width: 100%;
  462. height: 70vh;
  463. justify-content: space-around;
  464. /* justify-content: space-between; */
  465. }
  466. .main-tab {
  467. width: 90%;
  468. margin-top: 20rpx;
  469. }
  470. .tab-view {
  471. width: 100%;
  472. /* height: 69vh; */
  473. }
  474. .btnStart {
  475. width: 70%;
  476. /* height: 6vh; */
  477. height: 80rpx;
  478. /* margin-bottom: 1vh; */
  479. margin-bottom: 20rpx;
  480. /* font-weight: bold; */
  481. color: white;
  482. font-size: 32rpx;
  483. line-height: 80rpx;
  484. border-radius: 27px;
  485. }
  486. .btnStart-enable {
  487. background-color: #ffb40b;
  488. }
  489. .btnStart-disable {
  490. background-color: #c3c3c3;
  491. }
  492. </style>