rankList.vue 14 KB

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