signup.vue 17 KB

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