rankList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <!--
  2. 锦标赛排名列表
  3. http://localhost:5173/card/#/pages/jbs/rankList
  4. https://oss-mbh5.colormaprun.com/card/#/pages/jbs/rankList
  5. -->
  6. <template>
  7. <view class="body">
  8. <view v-if="pageReady" 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. <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="cssLogo"></view>
  17. <view class="topcontent uni-row">
  18. <text class="countdown">结束倒计时:</text>
  19. <image mode="aspectFit" class="cal" src="/static/default/cal.png"></image>
  20. <text class="countdown">{{countdown}}</text>
  21. </view>
  22. <!-- <text class="mcName">{{ecId}} - {{mcId}} - {{token}}</text> -->
  23. </view>
  24. <view class="main uni-column">
  25. <my-ranklist :rankRs="rankList.totalRankRs"></my-ranklist>
  26. <button class="btnStart btnStart-disable" v-if="mcState==0">活动尚未开始</button>
  27. <button class="btnStart btnStart-enable" v-if="mcState==1" @click="btnStart">开始比赛</button>
  28. <button class="btnStart btnStart-disable" v-if="mcState==2">活动已结束</button>
  29. </view>
  30. <my-popup ref="mypopup" :config="popupRuleConfig" :dataList="popupDataList"></my-popup>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import tools from '../../common/tools';
  36. import {
  37. defaultPopUpDataList
  38. } from '/common/define';
  39. import {
  40. token,
  41. apiCardDetailQuery,
  42. apiCardRankDetailQuery,
  43. apiUserCurrentRankNumQuery,
  44. apiCardConfigQuery,
  45. apiOnlineMcSignUp,
  46. checkResCode
  47. } from '../../common/api';
  48. export default {
  49. data() {
  50. return {
  51. pageReady: false,
  52. pageName: "rankList",
  53. firstEnterKey: 'firstEnter-jbs_rankList',
  54. rankKey: "rank-jbs",
  55. queryObj: {},
  56. queryString: "",
  57. token: "",
  58. ecId: 0, // 卡片id
  59. coiId: 0, // 单位id
  60. mcId: 0, // 赛事id
  61. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  62. mcName: "", // 赛事名称
  63. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  64. endSecond: null, // 活动或赛事结束时间戳,单位秒
  65. ocaId: 0, // 关联id,带入到App活动详情页面
  66. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  67. countdown: "", // 倒计时
  68. rankList: { // 排名列表
  69. totalRankRs: [],
  70. teamRankRs: [],
  71. inTeamRs: [],
  72. },
  73. interval: null,
  74. dispArrStr: "total", // 要显示的集合范围 (total,team,in,other)
  75. cssTop: "",
  76. cssLogo: "",
  77. popupRuleConfig: {}, // 规则弹窗配置
  78. popupDataList: [],
  79. }
  80. },
  81. computed: {},
  82. onLoad(query) { // 类型非必填,可自动推导
  83. // console.log(query);
  84. this.queryObj = query;
  85. this.queryString = tools.objectToQueryString(this.queryObj);
  86. // console.log(queryString);
  87. this.token = query["token"] ?? token;
  88. this.ecId = query["id"] ?? 0;
  89. this.firstEnterKey += "-" + this.ecId;
  90. console.log("firstEnterKey:", this.firstEnterKey);
  91. this.rankKey += "-" + this.ecId;
  92. console.log("rankKey:", this.rankKey);
  93. tools.removeCssCode();
  94. this.getCardConfigQuery();
  95. this.getUserCurrentRankNumQuery();
  96. // this.getCardDetailQuery();
  97. },
  98. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  99. onReady() {
  100. // this.dealFirstEnter();
  101. },
  102. onUnload() {
  103. this.clear();
  104. },
  105. methods: {
  106. dealNotice(rank) {
  107. // console.log('[dealFirstEnter]');
  108. let that = this;
  109. uni.getStorage({
  110. key: that.rankKey,
  111. success: (res) => {
  112. console.log('[getStorage]', that.rankKey, res.data);
  113. const oldRank = res.data;
  114. if (oldRank != rank) {
  115. // that.notice = true;
  116. that.setRankValue(rank);
  117. }
  118. },
  119. fail: (e) => {
  120. console.log('[getStorage] fail', that.rankKey, e);
  121. // that.notice = false;
  122. that.setRankValue(rank);
  123. },
  124. })
  125. },
  126. setRankValue(data) {
  127. let that = this;
  128. uni.setStorage({
  129. key: that.rankKey,
  130. data: data,
  131. success: () => {
  132. console.log('[setStorage] success', that.rankKey, data);
  133. },
  134. fail: (e) => {
  135. console.log('[setStorage] fail', that.rankKey, e);
  136. },
  137. })
  138. },
  139. dealFirstEnter() {
  140. let that = this;
  141. uni.getStorage({
  142. key: that.firstEnterKey,
  143. success: (res) => {
  144. console.log('[getStorage]', that.firstEnterKey, res.data);
  145. },
  146. fail: (e) => {
  147. console.log('[getStorage] fail', that.firstEnterKey, e);
  148. that.btnInfo();
  149. that.setFirstEnterValue(true);
  150. },
  151. })
  152. },
  153. setFirstEnterValue(data) {
  154. let that = this;
  155. uni.setStorage({
  156. key: that.firstEnterKey,
  157. data: data,
  158. success: () => {
  159. console.log('[setStorage] success', that.firstEnterKey, data);
  160. },
  161. fail: (e) => {
  162. console.log('[setStorage] fail', that.firstEnterKey, e);
  163. },
  164. })
  165. },
  166. clear() {
  167. if (this.interval != null) {
  168. clearInterval(this.interval);
  169. this.interval = null;
  170. }
  171. },
  172. loadConfig(config) {
  173. // console.log("config", config);
  174. // 加载CSS样式
  175. const css = config.css;
  176. if (css != undefined && css.length > 0) {
  177. tools.loadCssCode(css);
  178. if (css.indexOf(".top{") >= 0) {
  179. this.cssTop = "top";
  180. }
  181. if (css.indexOf(".logo{") >= 0) {
  182. this.cssLogo = "logo";
  183. }
  184. }
  185. if (this.cssTop == "") {
  186. this.cssTop = "top-default";
  187. }
  188. if (this.cssLogo == "") {
  189. this.cssLogo = "logo-default";
  190. }
  191. console.log("[loadConfig] cssTop:", this.cssTop);
  192. console.log("[loadConfig] cssLogo:", this.cssLogo);
  193. // 加载规则弹窗配置
  194. const popupRuleConfig = config.popupRuleConfig;
  195. if (popupRuleConfig != undefined) {
  196. this.popupRuleConfig = popupRuleConfig;
  197. }
  198. // console.log("[loadConfig] popupRuleConfig:", this.popupRuleConfig);
  199. // 加载弹窗数据
  200. const popupDataList = config.popupDataList;
  201. // console.log("[loadConfig] popupDataList:", popupDataList);
  202. if (popupDataList != undefined && popupDataList.length > 0) {
  203. for (var i = 0; i < popupDataList.length; i++) {
  204. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  205. if (popupDataList[i] == 'default') {
  206. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  207. this.popupDataList.push(defaultPopUpDataList[j]);
  208. }
  209. } else {
  210. this.popupDataList.push(popupDataList[i]);
  211. }
  212. }
  213. } else {
  214. this.popupDataList = defaultPopUpDataList;
  215. console.log("[loadConfig] popupDataList 加载默认列表");
  216. }
  217. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  218. this.pageReady = true;
  219. },
  220. // 获取倒计时
  221. getCountdown() {
  222. if (this.endSecond > 0) {
  223. const now = Date.now() / 1000;
  224. const dif = this.endSecond - now;
  225. // const dif = 3600*24 - 60;
  226. if (dif > 0) {
  227. this.countdown = tools.convertSecondsToDHM(dif);
  228. } else {
  229. this.countdown = "已结束";
  230. }
  231. // this.countdown = tools.convertSecondsToHMS(dif);
  232. } else {
  233. this.countdown = "--天--小时";
  234. }
  235. },
  236. getCardConfigQuery() {
  237. uni.request({
  238. url: apiCardConfigQuery,
  239. header: {
  240. "Content-Type": "application/x-www-form-urlencoded",
  241. "token": this.token,
  242. },
  243. method: "POST",
  244. data: {
  245. ecId: this.ecId,
  246. pageName: this.pageName
  247. },
  248. success: (res) => {
  249. // console.log("getCardConfigQuery", res)
  250. const data = res.data.data;
  251. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  252. // console.log("configJson", data.configJson);
  253. /* const config = {
  254. "css": `
  255. .top{
  256. width: 100%;
  257. height: 26vh;
  258. padding-top: 36px;
  259. justify-content: space-between;
  260. background-image: url('static/backgroud/top_colorbar.png'), linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  261. background-repeat: no-repeat;
  262. background-position: center, 0px 0px;
  263. background-size: auto 22vh , cover;
  264. }
  265. .logo{
  266. width: 150px;
  267. height: 150px;
  268. margin-top: 10px;
  269. background-image: url('static/logo/xfl.png');
  270. background-repeat: no-repeat;
  271. background-position-x: center;
  272. background-position-y: center;
  273. background-size: contain;
  274. }
  275. `,
  276. "popupDataList": [
  277. {
  278. "type": 1,
  279. "data": {
  280. "title": "山青活动",
  281. "img": "/static/logo/sqsj.png",
  282. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  283. }
  284. },
  285. "default"
  286. ]
  287. }; */
  288. this.loadConfig(config);
  289. this.getCardDetailQuery();
  290. setTimeout(this.dealFirstEnter, 500);
  291. },
  292. fail: (err) => {
  293. console.log("getCardConfigQuery err", err)
  294. },
  295. });
  296. },
  297. // 卡片信息查询
  298. getCardDetailQuery() {
  299. uni.request({
  300. url: apiCardDetailQuery,
  301. header: {
  302. "Content-Type": "application/x-www-form-urlencoded",
  303. "token": this.token,
  304. },
  305. method: "POST",
  306. data: {
  307. ecId: this.ecId
  308. },
  309. success: (res) => {
  310. // console.log("getCardDetailQuery", res)
  311. const data = res.data.data;
  312. this.coiId = data.coiId;
  313. this.mcId = data.mcId;
  314. this.mcType = data.mcType;
  315. this.mcName = data.mcName;
  316. this.beginSecond = data.beginSecond;
  317. this.endSecond = data.endSecond;
  318. this.ocaId = data.ocaId;
  319. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  320. this.getCountdown();
  321. this.getCardRankDetailQuery();
  322. this.clear();
  323. this.interval = setInterval(this.getCountdown, 60000);
  324. },
  325. fail: (err) => {
  326. console.log("getCardDetailQuery err", err)
  327. },
  328. });
  329. },
  330. // 排名查询
  331. getCardRankDetailQuery() {
  332. uni.request({
  333. url: apiCardRankDetailQuery,
  334. header: {
  335. "Content-Type": "application/x-www-form-urlencoded",
  336. "token": this.token,
  337. },
  338. method: "POST",
  339. data: {
  340. mcIdListStr: this.mcId,
  341. mcType: this.mcType,
  342. dispArrStr: this.dispArrStr
  343. },
  344. success: (res) => {
  345. // console.log("getCardRankDetailQuery", res)
  346. const rankdata = res.data.data;
  347. this.rankList.totalRankRs = rankdata.totalRankRs;
  348. this.rankList.teamRankRs = rankdata.teamRankRs;
  349. this.rankList.inTeamRs = rankdata.inTeamRs;
  350. },
  351. fail: (err) => {
  352. console.log("getCardRankDetailQuery err", err)
  353. },
  354. });
  355. },
  356. // 卡片用户当前排名查询
  357. getUserCurrentRankNumQuery() {
  358. uni.request({
  359. url: apiUserCurrentRankNumQuery,
  360. header: {
  361. "Content-Type": "application/x-www-form-urlencoded",
  362. "token": this.token,
  363. },
  364. method: "POST",
  365. data: {
  366. ecId: this.ecId
  367. },
  368. success: (res) => {
  369. // console.log("getUserCurrentRankNumQuery", res)
  370. if (res.data.code == 0) {
  371. const data = res.data.data;
  372. const rankNum = data.rankNum;
  373. this.dealNotice(rankNum);
  374. }
  375. },
  376. fail: (err) => {
  377. console.log("getUserCurrentRankNumQuery err", err)
  378. },
  379. });
  380. },
  381. // 线上赛报名(重新分组)
  382. onlineMcSignUp() {
  383. uni.request({
  384. url: apiOnlineMcSignUp,
  385. header: {
  386. "Content-Type": "application/x-www-form-urlencoded",
  387. "token": this.token,
  388. },
  389. method: "POST",
  390. data: {
  391. mcId: this.mcId,
  392. coiId: this.coiId,
  393. selectTeam: 0
  394. },
  395. success: (res) => {
  396. // console.log("onlineMcSignUp", res)
  397. if (checkResCode(res)) {
  398. // uni.showToast({
  399. // title: '比赛报名成功!',
  400. // icon: 'none',
  401. // duration: 3000
  402. // });
  403. const url = `action://to_detail/?id=${this.ocaId}&matchType=${this.mcType}`;
  404. tools.appAction(url);
  405. }
  406. },
  407. fail: (err) => {
  408. console.log("onlineMcSignUp err", err)
  409. uni.showToast({
  410. title: '出错了,比赛报名失败',
  411. icon: 'none',
  412. duration: 3000
  413. });
  414. },
  415. });
  416. },
  417. btnBack() {
  418. // window.history.back();
  419. const url = `action://to_home/`;
  420. tools.appAction(url);
  421. },
  422. btnStart() {
  423. this.onlineMcSignUp();
  424. },
  425. btnInfo() {
  426. this.$refs.mypopup.popupOpen();
  427. },
  428. }
  429. }
  430. </script>
  431. <style scoped>
  432. .content {
  433. width: 100vw;
  434. height: 100vh;
  435. }
  436. .top-default {
  437. width: 100%;
  438. height: 28vh;
  439. /* height: 500rpx; */
  440. padding-top: 36px;
  441. justify-content: flex-start;
  442. background-image: url("/static/backgroud/top_medal.png"), url("/static/backgroud/top_bg1.png");
  443. background-repeat: no-repeat;
  444. background-position-x: center, center;
  445. background-position-y: 15vh, center;
  446. background-size: 55vw auto, cover;
  447. }
  448. .logo-default {
  449. /* width: 150px;
  450. height: 150px;
  451. margin-top: 10px;
  452. background-image: url('/static/logo/jbs.png');
  453. background-repeat: no-repeat;
  454. background-position-x: center;
  455. background-position-y: center;
  456. background-size: contain; */
  457. }
  458. .topbar {
  459. width: 90%;
  460. /* padding: 0rpx 30rpx; */
  461. justify-content: space-between;
  462. }
  463. .topbar-back {
  464. width: 43rpx;
  465. height: 43rpx;
  466. /* opacity: 0; */
  467. }
  468. .topbar-info {
  469. width: 46rpx;
  470. height: 46rpx;
  471. }
  472. .topbar-rule {
  473. color: white;
  474. font-size: 32rpx;
  475. }
  476. .mcName {
  477. color: white;
  478. /* font-size: 32rpx; */
  479. font-size: 39rpx;
  480. font-weight: bold;
  481. }
  482. .topcontent {
  483. min-width: 300rpx;
  484. height: 100rpx;
  485. justify-content: space-evenly;
  486. }
  487. .countdown {
  488. color: white;
  489. font-size: 32rpx;
  490. }
  491. .cal {
  492. width: 30rpx;
  493. margin-right: 20rpx;
  494. }
  495. .main {
  496. width: 100%;
  497. height: 66vh;
  498. justify-content: space-between;
  499. }
  500. .btnStart {
  501. width: 70%;
  502. height: 5vh;
  503. /* height: 80rpx; */
  504. margin-bottom: 1vh;
  505. font-weight: bold;
  506. line-height: 5vh;
  507. background-color: #ffb40b;
  508. }
  509. .btnStart-enable {
  510. background-color: #ffb40b;
  511. }
  512. .btnStart-disable {
  513. background-color: #c3c3c3;
  514. }
  515. </style>
  516. <style lang="scss" scoped>
  517. ::v-deep .list {
  518. height: 58vh;
  519. margin-top: 5px;
  520. }
  521. </style>