rankList.vue 12 KB

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