rankList.vue 14 KB

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