signup.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <!--
  2. [报名] 样式2 - 报名
  3. http://localhost:5173/card/#/pages/bm/style2/signup
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style2/signup
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content uni-column">
  9. <view class="uni-column" :class="cssTop">
  10. <my-topbar :mcName="mcName" :class="cssTopbarColor"
  11. @btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
  12. </view>
  13. <view class="main uni-column">
  14. <view class="timebar uni-row">
  15. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  16. <text class="acttime">{{acttime}}</text>
  17. </view>
  18. <input class="uni-input" maxlength="12" placeholder="请填写昵称或姓名" v-model="nickName" />
  19. <view class="introduce uni-column">
  20. <text class="introduce-title">{{introduce.title}}</text>
  21. <text class="introduce-content" v-html="introduce.content"></text>
  22. </view>
  23. <button class="btnSignup btnSignup-enable" v-if="mcState<=1" @click="btnSignup">报 名</button>
  24. <button class="btnSignup btnSignup-disable" v-if="mcState==2">活动已结束</button>
  25. </view>
  26. <my-popup ref="mypopup" :config="popupRuleConfig" :dataList="popupDataList" :acttime="acttime"></my-popup>
  27. <uni-popup ref="alertDialog" type="dialog">
  28. <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="您填写的姓名:" @confirm="dialogConfirm"
  29. @close="dialogClose">
  30. <view class="dialog-content uni-column">
  31. <text class="dialog-content-1">{{nickName}}</text>
  32. </view>
  33. </uni-popup-dialog>
  34. </uni-popup>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import tools from '../../../common/tools';
  40. import {
  41. defaultPopUpDataList
  42. } from '../../../common/define';
  43. import {
  44. token,
  45. apiCardDetailQuery,
  46. apiOnlineMcSignUpDetail,
  47. apiOnlineMcSignUp,
  48. apiCardConfigQuery,
  49. apiMatchRsDetailQuery,
  50. checkResCode,
  51. checkToken
  52. } from '../../../common/api';
  53. export default {
  54. data() {
  55. return {
  56. pageName: "signup",
  57. firstEnterKey: 'firstEnter-bm-style2',
  58. rankKey: "rank-bm-style2",
  59. queryObj: {},
  60. queryString: "",
  61. from: "", // 来源页面
  62. token: "",
  63. ecId: 0, // 卡片id
  64. mcId: 0, // 赛事id
  65. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  66. mcName: "", // 赛事名称
  67. acttime: "", // 活动时间
  68. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  69. endSecond: null, // 活动或赛事结束时间戳,单位秒
  70. coiId: 0, // 已报名单位id
  71. coiName: "", // 已报名单位名称,可为空
  72. teamNum: 0, // 已报名队伍编号,可为0
  73. nickName: "", // 昵称
  74. // coiRs: [], // 组织信息集合
  75. // orgList: [], // 分组下拉列表数据源
  76. // teamList: [], //
  77. interval: null,
  78. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  79. // teamType: 0, // 队伍类型 0: 红黄蓝紫 1: 学生/家长
  80. cssTop: "",
  81. cssTopbarColor: "",
  82. cssLogo: "",
  83. introduce: {
  84. title: "",
  85. content: ""
  86. },
  87. popupRuleConfig: {}, // 规则弹窗配置
  88. popupDataList: [],
  89. }
  90. },
  91. computed: {},
  92. onLoad(query) { // 类型非必填,可自动推导
  93. // console.log(query);
  94. this.queryObj = query;
  95. this.queryString = tools.objectToQueryString(this.queryObj);
  96. // console.log(queryString);
  97. this.from = query["from"] ?? "";
  98. this.token = query["token"] ?? token;
  99. this.ecId = query["id"] ?? 0;
  100. this.firstEnterKey += "-" + this.ecId;
  101. console.log("firstEnterKey:", this.firstEnterKey);
  102. this.rankKey += "-" + this.ecId;
  103. console.log("rankKey:", this.rankKey);
  104. tools.removeCssCode();
  105. this.getCardConfigQuery();
  106. this.getCardDetailQuery();
  107. this.matchRsDetailQuery();
  108. },
  109. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  110. onReady() {
  111. // this.dealFirstEnter();
  112. },
  113. onUnload() {
  114. this.clear();
  115. },
  116. methods: {
  117. dealNotice(rank) {
  118. // console.log('[dealNotice]');
  119. let that = this;
  120. uni.getStorage({
  121. key: that.rankKey,
  122. success: (res) => {
  123. console.log('[getStorage]', that.rankKey, res.data);
  124. const oldRank = res.data;
  125. if (oldRank != rank) {
  126. // that.notice = true;
  127. that.setRankValue(rank);
  128. }
  129. },
  130. fail: (e) => {
  131. console.log('[getStorage] fail', that.rankKey, e);
  132. // that.notice = false;
  133. that.setRankValue(rank);
  134. },
  135. })
  136. },
  137. setRankValue(data) {
  138. let that = this;
  139. uni.setStorage({
  140. key: that.rankKey,
  141. data: data,
  142. success: () => {
  143. console.log('[setStorage] success', that.rankKey, data);
  144. },
  145. fail: (e) => {
  146. console.log('[setStorage] fail', that.rankKey, e);
  147. },
  148. })
  149. },
  150. dealFirstEnter() {
  151. // console.log('[dealFirstEnter]');
  152. let that = this;
  153. uni.getStorage({
  154. key: that.firstEnterKey,
  155. success: (res) => {
  156. console.log('[getStorage]', that.firstEnterKey, res.data);
  157. },
  158. fail: (e) => {
  159. console.log('[getStorage] fail', that.firstEnterKey, e);
  160. that.btnInfo();
  161. that.setFirstEnterValue(true);
  162. },
  163. })
  164. },
  165. setFirstEnterValue(data) {
  166. let that = this;
  167. uni.setStorage({
  168. key: that.firstEnterKey,
  169. data: data,
  170. success: () => {
  171. console.log('[setStorage] success', that.firstEnterKey, data);
  172. },
  173. fail: (e) => {
  174. console.log('[setStorage] fail', that.firstEnterKey, e);
  175. },
  176. })
  177. },
  178. clear() {
  179. if (this.interval != null) {
  180. clearInterval(this.interval);
  181. this.interval = null;
  182. }
  183. },
  184. loadConfig(config) {
  185. // console.log("config", config);
  186. // 加载CSS样式
  187. const css = config.css;
  188. if (css != undefined && css.length > 0) {
  189. tools.loadCssCode(css);
  190. if (css.indexOf(".top{") >= 0) {
  191. this.cssTop = "top";
  192. }
  193. if (css.indexOf(".topbar-color{") >= 0) {
  194. this.cssTopbarColor = "topbar-color";
  195. }
  196. }
  197. if (this.cssTop == "") {
  198. this.cssTop = "top-default";
  199. }
  200. if (this.cssTopbarColor == "") {
  201. this.cssTopbarColor = "topbar-color-default";
  202. }
  203. console.log("[loadConfig] cssTop:", this.cssTop);
  204. console.log("[loadConfig] cssTopbarColor:", this.cssTopbarColor);
  205. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  206. /* if (config.teamType != undefined && config.teamType >= 0) {
  207. this.teamType = config.teamType;
  208. } */
  209. // 加载介绍内容
  210. const introduce = config.introduce;
  211. if (introduce != undefined) {
  212. if (introduce.title != undefined) {
  213. this.introduce.title = introduce.title;
  214. }
  215. if (introduce.content != undefined) {
  216. this.introduce.content = introduce.content;
  217. }
  218. }
  219. // 加载规则弹窗配置
  220. const popupRuleConfig = config.popupRuleConfig;
  221. if (popupRuleConfig != undefined) {
  222. this.popupRuleConfig = popupRuleConfig;
  223. }
  224. // console.log("[loadConfig] popupRuleConfig:", this.popupRuleConfig);
  225. // 加载弹窗数据
  226. const popupDataList = config.popupDataList;
  227. // console.log("[loadConfig] popupDataList:", popupDataList);
  228. if (popupDataList != undefined && popupDataList.length > 0) {
  229. for (var i = 0; i < popupDataList.length; i++) {
  230. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  231. if (popupDataList[i] == 'default') {
  232. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  233. this.popupDataList.push(defaultPopUpDataList[j]);
  234. }
  235. } else {
  236. this.popupDataList.push(popupDataList[i]);
  237. }
  238. }
  239. } else {
  240. this.popupDataList = defaultPopUpDataList;
  241. console.log("[loadConfig] popupDataList 加载默认列表");
  242. }
  243. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  244. },
  245. fmtMcTime(timestamp) {
  246. return tools.fmtMcTime(timestamp);
  247. },
  248. // 获取倒计时
  249. getActtime() {
  250. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  251. },
  252. getCardConfigQuery() {
  253. uni.request({
  254. url: apiCardConfigQuery,
  255. header: {
  256. "Content-Type": "application/x-www-form-urlencoded",
  257. "token": this.token,
  258. },
  259. method: "POST",
  260. data: {
  261. ecId: this.ecId,
  262. pageName: this.pageName
  263. },
  264. success: (res) => {
  265. // console.log("getCardConfigQuery", res)
  266. const data = res.data.data;
  267. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  268. // console.log("configJson", data.configJson);
  269. /* const config = {
  270. "css": `
  271. .top{
  272. width: 100%;
  273. height: 230px;
  274. padding-top: 36px;
  275. justify-content: space-between;
  276. background-image: url("static/backgroud/top_bg_aoti.png");
  277. background-repeat: no-repeat;
  278. background-position: center;
  279. background-size: cover;
  280. }
  281. .topbar-color{
  282. color: #5b9100;
  283. }
  284. .swiper-item-button {
  285. background-color: #81cd00 !important;
  286. }
  287. `,
  288. "popupDataList": [{
  289. "type": 1,
  290. "data": {
  291. "title": "小飞龙定向赛",
  292. "img": "/static/common/aoti.png",
  293. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  294. }
  295. },
  296. "default"
  297. ],
  298. "introduce": {
  299. "title": "介绍:",
  300. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  301. }
  302. }; */
  303. this.loadConfig(config);
  304. setTimeout(this.dealFirstEnter, 500);
  305. },
  306. fail: (err) => {
  307. console.log("getCardConfigQuery err", err)
  308. },
  309. });
  310. },
  311. // 卡片信息查询
  312. getCardDetailQuery() {
  313. uni.request({
  314. url: apiCardDetailQuery,
  315. header: {
  316. "Content-Type": "application/x-www-form-urlencoded",
  317. "token": this.token
  318. },
  319. method: "POST",
  320. data: {
  321. ecId: this.ecId
  322. },
  323. success: (res) => {
  324. // console.log("getCardDetailQuery", res);
  325. const data = res.data.data;
  326. this.mcType = data.mcType;
  327. this.mcId = data.mcId;
  328. this.mcName = data.mcName;
  329. this.beginSecond = data.beginSecond;
  330. this.endSecond = data.endSecond;
  331. this.coiId = data.coiId;
  332. this.coiName = data.coiName;
  333. this.teamNum = data.teamNum;
  334. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  335. this.getActtime();
  336. // this.getOnlineMcSignUpDetail();
  337. this.clear();
  338. this.interval = setInterval(this.getActtime, 60000);
  339. },
  340. fail: (err) => {
  341. console.log("getCardDetailQuery err", err)
  342. },
  343. });
  344. },
  345. // 卡片对应线上赛多个活动查询
  346. matchRsDetailQuery() {
  347. uni.request({
  348. url: apiMatchRsDetailQuery,
  349. header: {
  350. "Content-Type": "application/x-www-form-urlencoded",
  351. "token": this.token,
  352. },
  353. method: "POST",
  354. data: {
  355. ecId: this.ecId
  356. },
  357. success: (res) => {
  358. // console.log("matchRsDetailQuery", res);
  359. if (res.data.code == 0) {
  360. const data = res.data.data;
  361. const rank = JSON.stringify(data);
  362. this.dealNotice(rank);
  363. }
  364. },
  365. fail: (err) => {
  366. console.log("matchRsDetailQuery err", err)
  367. },
  368. });
  369. },
  370. // 卡片用户当前排名查询
  371. // getUserCurrentRankNumQuery() {
  372. // uni.request({
  373. // url: apiUserCurrentRankNumQuery,
  374. // header: {
  375. // "Content-Type": "application/x-www-form-urlencoded",
  376. // "token": this.token,
  377. // },
  378. // method: "POST",
  379. // data: {
  380. // ecId: this.ecId
  381. // },
  382. // success: (res) => {
  383. // // console.log("getUserCurrentRankNumQuery", res)
  384. // if (res.data.code == 0) {
  385. // const data = res.data.data;
  386. // const rankNum = data.rankNum;
  387. // this.dealNotice(rankNum);
  388. // }
  389. // },
  390. // fail: (err) => {
  391. // console.log("getUserCurrentRankNumQuery err", err)
  392. // },
  393. // });
  394. // },
  395. // 线上赛报名页面信息详情
  396. /* getOnlineMcSignUpDetail() {
  397. uni.request({
  398. url: apiOnlineMcSignUpDetail,
  399. header: {
  400. "Content-Type": "application/x-www-form-urlencoded",
  401. "token": this.token,
  402. },
  403. method: "POST",
  404. data: {
  405. mcId: this.mcId,
  406. },
  407. success: (res) => {
  408. // console.log("getOnlineMcSignUpDetail", res)
  409. this.coiRs = res.data.data.coiRs;
  410. const rsNum = this.coiRs.length;
  411. this.orgList = [];
  412. for (let i = 0; i < rsNum; i++) {
  413. this.orgList[i] = {};
  414. this.orgList[i].value = this.coiRs[i].coiId;
  415. this.orgList[i].text = this.coiRs[i].coiName;
  416. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  417. }
  418. // console.log("orgList", this.orgList);
  419. if (this.coiId > 0) {
  420. this.orgChange(this.coiId, false);
  421. }
  422. },
  423. fail: (err) => {
  424. console.log("getOnlineMcSignUpDetail err", err)
  425. },
  426. });
  427. }, */
  428. // 线上赛报名
  429. onlineMcSignUp() {
  430. uni.request({
  431. url: apiOnlineMcSignUp,
  432. header: {
  433. "Content-Type": "application/x-www-form-urlencoded",
  434. "token": this.token,
  435. },
  436. method: "POST",
  437. data: {
  438. mcId: this.mcId,
  439. coiId: this.coiId,
  440. selectTeam: this.teamNum,
  441. nickName: this.nickName
  442. },
  443. success: (res) => {
  444. // console.log("onlineMcSignUp", res);
  445. if (checkResCode(res)) {
  446. uni.showToast({
  447. title: '比赛报名成功!',
  448. icon: 'none',
  449. duration: 3000
  450. });
  451. // uni.navigateTo({
  452. // // url: '/pages/bm/style2/rankOverview?' + this.queryString
  453. // url: '/pages/bm/style2/rankList?' + this.queryString
  454. // });
  455. const url = '/pages/bm/style2/rankList?' + this.queryString;
  456. tools.appAction(url, "uni.navigateTo");
  457. }
  458. },
  459. fail: (err) => {
  460. console.log("onlineMcSignUp err", err);
  461. uni.showToast({
  462. title: '出错了,报名失败',
  463. icon: 'none',
  464. duration: 3000
  465. });
  466. },
  467. });
  468. },
  469. btnBack() {
  470. // console.log("from:", this.from)
  471. if (this.from != '') {
  472. // window.history.back();
  473. // uni.navigateTo({
  474. // url: '/pages/bm/style2/rankList?' + this.queryString
  475. // });
  476. const url = '/pages/bm/style2/rankList?' + this.queryString;
  477. tools.appAction(url, "uni.navigateTo");
  478. } else {
  479. const url = `action://to_home/`;
  480. tools.appAction(url);
  481. }
  482. },
  483. btnInfo() {
  484. this.$refs.mypopup.popupOpen();
  485. },
  486. btnSignup() {
  487. if (!checkToken(this.token)) {
  488. return;
  489. }
  490. if (!(this.nickName.trim().length > 0)) {
  491. uni.showToast({
  492. title: '请填写姓名',
  493. icon: 'none',
  494. duration: 2000
  495. });
  496. return;
  497. }
  498. this.nickName = this.nickName.trim();
  499. this.$refs.alertDialog.open();
  500. },
  501. dialogConfirm() {
  502. this.onlineMcSignUp();
  503. },
  504. dialogClose() {}
  505. }
  506. }
  507. </script>
  508. <style scoped>
  509. .content {
  510. width: 100vw;
  511. height: 100vh;
  512. }
  513. .top-default {
  514. width: 100%;
  515. height: 230px;
  516. padding-top: 36px;
  517. justify-content: space-between;
  518. background-image: url("/static/backgroud/top_bg_aoti.png");
  519. background-repeat: no-repeat;
  520. background-position: center;
  521. background-size: cover;
  522. }
  523. .topbar-color-default {
  524. color: #5b9100;
  525. }
  526. .main {
  527. width: 76%;
  528. min-height: 800rpx;
  529. /* margin-top: 20rpx; */
  530. justify-content: space-around;
  531. }
  532. .timebar {
  533. width: 90%;
  534. height: 32px;
  535. margin-top: 10px;
  536. margin-bottom: 10px;
  537. padding: 0 15px;
  538. justify-content: center;
  539. background: #ffffff;
  540. border: 0.5px solid;
  541. border-color: #e7e7e7;
  542. border-radius: 20px;
  543. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  544. }
  545. .acttime {
  546. font-weight: 550;
  547. color: #333333;
  548. font-size: 15px;
  549. }
  550. .clock {
  551. width: 15px;
  552. height: 15px;
  553. margin-right: 10px;
  554. }
  555. .uni-input {
  556. width: 90%;
  557. height: 85rpx;
  558. padding: 0 30rpx;
  559. background: #f1f1f1;
  560. border-radius: 9px;
  561. }
  562. .input-placeholder {
  563. color: #333333;
  564. font-size: 16px;
  565. }
  566. .introduce {
  567. width: 100%;
  568. margin-top: 10rpx;
  569. margin-bottom: 80rpx;
  570. align-items: flex-start;
  571. justify-content: space-around;
  572. }
  573. .introduce-title {
  574. color: #333333;
  575. font-size: 30rpx;
  576. line-height: 60rpx;
  577. }
  578. .introduce-content {
  579. color: #333333;
  580. font-size: 25rpx;
  581. line-height: 46rpx;
  582. }
  583. .btnSignup {
  584. width: 100%;
  585. height: 100rpx;
  586. margin-bottom: 30rpx;
  587. color: white;
  588. font-weight: bold;
  589. line-height: 100rpx;
  590. border-radius: 55rpx;
  591. }
  592. .btnSignup-enable {
  593. background-color: #81cd00;
  594. }
  595. .btnSignup-disable {
  596. background-color: #c3c3c3;
  597. }
  598. .dialog-content {
  599. width: 279px;
  600. height: 110px;
  601. background: #f1f1f1;
  602. border-radius: 9px;
  603. justify-content: center;
  604. text-align: center;
  605. font-weight: 550;
  606. color: #333333;
  607. }
  608. .dialog-content-1 {
  609. font-size: 40rpx;
  610. }
  611. </style>