rankList.vue 11 KB

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