signup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <!--
  2. [报名] 样式3 - 报名
  3. http://localhost:5173/card/#/pages/bm/style3/signup
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style3/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="30" 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" :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-style3',
  58. rankKey: "rank-bm-style3",
  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. popupDataList: [],
  88. }
  89. },
  90. computed: {},
  91. onLoad(query) { // 类型非必填,可自动推导
  92. // console.log(query);
  93. this.queryObj = query;
  94. this.queryString = tools.objectToQueryString(this.queryObj);
  95. // console.log(queryString);
  96. this.from = query["from"] ?? "";
  97. this.token = query["token"] ?? token;
  98. this.ecId = query["id"] ?? 0;
  99. this.firstEnterKey += "-" + this.ecId;
  100. console.log("firstEnterKey:", this.firstEnterKey);
  101. this.rankKey += "-" + this.ecId;
  102. console.log("rankKey:", this.rankKey);
  103. tools.removeCssCode();
  104. this.getCardConfigQuery();
  105. this.getCardDetailQuery();
  106. this.matchRsDetailQuery();
  107. },
  108. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  109. onReady() {
  110. // this.dealFirstEnter();
  111. },
  112. onUnload() {
  113. this.clear();
  114. },
  115. methods: {
  116. dealNotice(rank) {
  117. // console.log('[dealNotice]');
  118. let that = this;
  119. uni.getStorage({
  120. key: that.rankKey,
  121. success: (res) => {
  122. console.log('[getStorage]', that.rankKey, res.data);
  123. const oldRank = res.data;
  124. if (oldRank != rank) {
  125. // that.notice = true;
  126. that.setRankValue(rank);
  127. }
  128. },
  129. fail: (e) => {
  130. console.log('[getStorage] fail', that.rankKey, e);
  131. // that.notice = false;
  132. that.setRankValue(rank);
  133. },
  134. })
  135. },
  136. setRankValue(data) {
  137. let that = this;
  138. uni.setStorage({
  139. key: that.rankKey,
  140. data: data,
  141. success: () => {
  142. console.log('[setStorage] success', that.rankKey, data);
  143. },
  144. fail: (e) => {
  145. console.log('[setStorage] fail', that.rankKey, e);
  146. },
  147. })
  148. },
  149. dealFirstEnter() {
  150. // console.log('[dealFirstEnter]');
  151. let that = this;
  152. uni.getStorage({
  153. key: that.firstEnterKey,
  154. success: (res) => {
  155. console.log('[getStorage]', that.firstEnterKey, res.data);
  156. },
  157. fail: (e) => {
  158. console.log('[getStorage] fail', that.firstEnterKey, e);
  159. that.btnInfo();
  160. that.setFirstEnterValue(true);
  161. },
  162. })
  163. },
  164. setFirstEnterValue(data) {
  165. let that = this;
  166. uni.setStorage({
  167. key: that.firstEnterKey,
  168. data: data,
  169. success: () => {
  170. console.log('[setStorage] success', that.firstEnterKey, data);
  171. },
  172. fail: (e) => {
  173. console.log('[setStorage] fail', that.firstEnterKey, e);
  174. },
  175. })
  176. },
  177. clear() {
  178. if (this.interval != null) {
  179. clearInterval(this.interval);
  180. this.interval = null;
  181. }
  182. },
  183. loadConfig(config) {
  184. // console.log("config", config);
  185. // 加载CSS样式
  186. const css = config.css;
  187. if (css != undefined && css.length > 0) {
  188. tools.loadCssCode(css);
  189. if (css.indexOf(".top{") >= 0) {
  190. this.cssTop = "top";
  191. }
  192. if (css.indexOf(".topbar-color{") >= 0) {
  193. this.cssTopbarColor = "topbar-color";
  194. }
  195. }
  196. if (this.cssTop == "") {
  197. this.cssTop = "top-default";
  198. }
  199. if (this.cssTopbarColor == "") {
  200. this.cssTopbarColor = "topbar-color-default";
  201. }
  202. console.log("[loadConfig] cssTop:", this.cssTop);
  203. console.log("[loadConfig] cssTopbarColor:", this.cssTopbarColor);
  204. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  205. /* if (config.teamType != undefined && config.teamType >= 0) {
  206. this.teamType = config.teamType;
  207. } */
  208. // 加载介绍内容
  209. const introduce = config.introduce;
  210. if (introduce != undefined) {
  211. if (introduce.title != undefined) {
  212. this.introduce.title = introduce.title;
  213. }
  214. if (introduce.content != undefined) {
  215. this.introduce.content = introduce.content;
  216. }
  217. }
  218. // 加载弹窗数据
  219. const popupDataList = config.popupDataList;
  220. // console.log("[loadConfig] popupDataList:", popupDataList);
  221. if (popupDataList != undefined && popupDataList.length > 0) {
  222. for (var i = 0; i < popupDataList.length; i++) {
  223. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  224. if (popupDataList[i] == 'default') {
  225. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  226. this.popupDataList.push(defaultPopUpDataList[j]);
  227. }
  228. } else {
  229. this.popupDataList.push(popupDataList[i]);
  230. }
  231. }
  232. } else {
  233. this.popupDataList = defaultPopUpDataList;
  234. console.log("[loadConfig] popupDataList 加载默认列表");
  235. }
  236. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  237. },
  238. fmtMcTime(timestamp) {
  239. return tools.fmtMcTime(timestamp);
  240. },
  241. // 获取倒计时
  242. getActtime() {
  243. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  244. },
  245. getCardConfigQuery() {
  246. uni.request({
  247. url: apiCardConfigQuery,
  248. header: {
  249. "Content-Type": "application/x-www-form-urlencoded",
  250. "token": this.token,
  251. },
  252. method: "POST",
  253. data: {
  254. ecId: this.ecId,
  255. pageName: this.pageName
  256. },
  257. success: (res) => {
  258. // console.log("getCardConfigQuery", res)
  259. const data = res.data.data;
  260. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  261. // console.log("configJson", data.configJson);
  262. /* const config = {
  263. "css": `
  264. .top{
  265. width: 100%;
  266. height: 170px;
  267. padding-top: 36px;
  268. justify-content: space-between;
  269. background-image: url('static/backgroud/top_bg_guoqing.png');
  270. background-repeat: no-repeat;
  271. background-position-y: 20%;
  272. background-size: cover;
  273. }
  274. .topbar-color{
  275. color: #ffffff;
  276. }
  277. .btnSignup-enable {
  278. background-color: #ff0000 !important;
  279. }
  280. .swiper-item-button {
  281. background-color: #ff0000 !important;
  282. }
  283. .uni-swiper-dot-active {
  284. background: #ff0000 !important;
  285. }
  286. `,
  287. "popupDataList": [
  288. {
  289. "type": 2,
  290. "data": {
  291. "title": "基本图例",
  292. "img": "/static/common/jbtl.png"
  293. }
  294. }, {
  295. "type": 2,
  296. "data": {
  297. "title": "基本标识",
  298. "img": "/static/common/jbbs2.png"
  299. }
  300. },
  301. {
  302. "type": 7,
  303. "data": {
  304. "title": "活动规则",
  305. "content": "<li>赛期内随时参赛、不限完赛次数、起点任选、实时排名 <li>起点-各途经点-结束点完整打卡为1次有效完赛 <li>赛事如有疑问,请咨询微信客服",
  306. "imageList": [
  307. {
  308. "src": "/static/common/qrcode_wxkf.png",
  309. "width": "100px",
  310. "height": "100px"
  311. }
  312. ]
  313. }
  314. },
  315. {
  316. "type": 7,
  317. "data": {
  318. "title": "活动奖励",
  319. "content": "<li>途经点打卡1次,获1个百味豆<br><li>每次正确答题,再获1个百味豆<br><li>20个百味豆兑换1个鸡蛋<br><li>上不封顶!随时兑换!<br><text style='font-size:12px;color:#999999;'>(限本次活动百味豆,兑换以“蛋叔券”为准)</text><br><li>健身又能“薅羊毛”~",
  320. "imageList": [
  321. {
  322. "src": "/static/common/jidanquan.png",
  323. "width": "80px",
  324. "height": "80px"
  325. }
  326. ]
  327. }
  328. }
  329. ],
  330. "introduce": {
  331. "title": "介绍:",
  332. "content": "<li>领秀城社区欢乐定向赛来袭 \r\n <li>领秀城 A、B、C、D、E、F 区及商业街、贵和购物广场等8个起点任选。\r\n <li>跑的多,得蛋多,神秘蛋叔赞助!\r\n <li>还等什么?火速报名吧!\r\n <li>定向赛场上,每一个人都是主角~"
  333. }
  334. }; */
  335. this.loadConfig(config);
  336. setTimeout(this.dealFirstEnter, 500);
  337. },
  338. fail: (err) => {
  339. console.log("getCardConfigQuery err", err)
  340. },
  341. });
  342. },
  343. // 卡片信息查询
  344. getCardDetailQuery() {
  345. uni.request({
  346. url: apiCardDetailQuery,
  347. header: {
  348. "Content-Type": "application/x-www-form-urlencoded",
  349. "token": this.token
  350. },
  351. method: "POST",
  352. data: {
  353. ecId: this.ecId
  354. },
  355. success: (res) => {
  356. // console.log("getCardDetailQuery", res);
  357. const data = res.data.data;
  358. this.mcType = data.mcType;
  359. this.mcId = data.mcId;
  360. this.mcName = data.mcName;
  361. this.beginSecond = data.beginSecond;
  362. this.endSecond = data.endSecond;
  363. this.coiId = data.coiId;
  364. this.coiName = data.coiName;
  365. this.teamNum = data.teamNum;
  366. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  367. this.getActtime();
  368. // this.getOnlineMcSignUpDetail();
  369. this.clear();
  370. this.interval = setInterval(this.getActtime, 60000);
  371. },
  372. fail: (err) => {
  373. console.log("getCardDetailQuery err", err)
  374. },
  375. });
  376. },
  377. // 卡片对应线上赛多个活动查询
  378. matchRsDetailQuery() {
  379. uni.request({
  380. url: apiMatchRsDetailQuery,
  381. header: {
  382. "Content-Type": "application/x-www-form-urlencoded",
  383. "token": this.token,
  384. },
  385. method: "POST",
  386. data: {
  387. ecId: this.ecId
  388. },
  389. success: (res) => {
  390. // console.log("matchRsDetailQuery", res);
  391. if (res.data.code == 0) {
  392. const data = res.data.data;
  393. const rank = JSON.stringify(data);
  394. this.dealNotice(rank);
  395. }
  396. },
  397. fail: (err) => {
  398. console.log("matchRsDetailQuery err", err)
  399. },
  400. });
  401. },
  402. // 卡片用户当前排名查询
  403. // getUserCurrentRankNumQuery() {
  404. // uni.request({
  405. // url: apiUserCurrentRankNumQuery,
  406. // header: {
  407. // "Content-Type": "application/x-www-form-urlencoded",
  408. // "token": this.token,
  409. // },
  410. // method: "POST",
  411. // data: {
  412. // ecId: this.ecId
  413. // },
  414. // success: (res) => {
  415. // // console.log("getUserCurrentRankNumQuery", res)
  416. // if (res.data.code == 0) {
  417. // const data = res.data.data;
  418. // const rankNum = data.rankNum;
  419. // this.dealNotice(rankNum);
  420. // }
  421. // },
  422. // fail: (err) => {
  423. // console.log("getUserCurrentRankNumQuery err", err)
  424. // },
  425. // });
  426. // },
  427. // 线上赛报名页面信息详情
  428. /* getOnlineMcSignUpDetail() {
  429. uni.request({
  430. url: apiOnlineMcSignUpDetail,
  431. header: {
  432. "Content-Type": "application/x-www-form-urlencoded",
  433. "token": this.token,
  434. },
  435. method: "POST",
  436. data: {
  437. mcId: this.mcId,
  438. },
  439. success: (res) => {
  440. // console.log("getOnlineMcSignUpDetail", res)
  441. this.coiRs = res.data.data.coiRs;
  442. const rsNum = this.coiRs.length;
  443. this.orgList = [];
  444. for (let i = 0; i < rsNum; i++) {
  445. this.orgList[i] = {};
  446. this.orgList[i].value = this.coiRs[i].coiId;
  447. this.orgList[i].text = this.coiRs[i].coiName;
  448. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  449. }
  450. // console.log("orgList", this.orgList);
  451. if (this.coiId > 0) {
  452. this.orgChange(this.coiId, false);
  453. }
  454. },
  455. fail: (err) => {
  456. console.log("getOnlineMcSignUpDetail err", err)
  457. },
  458. });
  459. }, */
  460. // 线上赛报名
  461. onlineMcSignUp() {
  462. uni.request({
  463. url: apiOnlineMcSignUp,
  464. header: {
  465. "Content-Type": "application/x-www-form-urlencoded",
  466. "token": this.token,
  467. },
  468. method: "POST",
  469. data: {
  470. mcId: this.mcId,
  471. coiId: this.coiId,
  472. selectTeam: this.teamNum,
  473. nickName: this.nickName
  474. },
  475. success: (res) => {
  476. // console.log("onlineMcSignUp", res);
  477. if (checkResCode(res)) {
  478. uni.showToast({
  479. title: '比赛报名成功!',
  480. icon: 'none',
  481. duration: 3000
  482. });
  483. // uni.navigateTo({
  484. // // url: '/pages/bm/style3/rankOverview?' + this.queryString
  485. // url: '/pages/bm/style3/rankList?' + this.queryString
  486. // });
  487. const url = '/pages/bm/style3/rankList?' + this.queryString;
  488. tools.appAction(url, "uni.navigateTo");
  489. }
  490. },
  491. fail: (err) => {
  492. console.log("onlineMcSignUp err", err);
  493. uni.showToast({
  494. title: '出错了,报名失败',
  495. icon: 'none',
  496. duration: 3000
  497. });
  498. },
  499. });
  500. },
  501. btnBack() {
  502. // console.log("from:", this.from)
  503. if (this.from != '') {
  504. // window.history.back();
  505. // uni.navigateTo({
  506. // url: '/pages/bm/style3/rankList?' + this.queryString
  507. // });
  508. const url = '/pages/bm/style3/rankList?' + this.queryString;
  509. tools.appAction(url, "uni.navigateTo");
  510. } else {
  511. const url = `action://to_home/`;
  512. tools.appAction(url);
  513. }
  514. },
  515. btnInfo() {
  516. this.$refs.mypopup.popupOpen();
  517. },
  518. btnSignup() {
  519. if (!checkToken(this.token)) {
  520. return;
  521. }
  522. if (!(this.nickName.trim().length > 0)) {
  523. uni.showToast({
  524. title: '请填写姓名',
  525. icon: 'none',
  526. duration: 2000
  527. });
  528. return;
  529. }
  530. this.nickName = this.nickName.trim();
  531. this.$refs.alertDialog.open();
  532. },
  533. dialogConfirm() {
  534. this.onlineMcSignUp();
  535. },
  536. dialogClose() {}
  537. }
  538. }
  539. </script>
  540. <style scoped>
  541. .content {
  542. width: 100vw;
  543. height: 100vh;
  544. }
  545. .top-default {
  546. width: 100%;
  547. height: 170px;
  548. padding-top: 36px;
  549. justify-content: space-between;
  550. background-image: url("/static/backgroud/top_bg_egg3.png");
  551. background-repeat: no-repeat;
  552. background-position: center;
  553. background-size: cover;
  554. }
  555. .topbar-color-default {
  556. color: #333333;
  557. }
  558. .main {
  559. width: 76%;
  560. min-height: 800rpx;
  561. /* margin-top: 20rpx; */
  562. justify-content: space-around;
  563. }
  564. .timebar {
  565. width: 90%;
  566. height: 65rpx;
  567. margin-top: 20rpx;
  568. padding: 0 30rpx;
  569. justify-content: space-evenly;
  570. background: #ffffff;
  571. border: 0.5px solid;
  572. border-color: #e7e7e7;
  573. border-radius: 20px;
  574. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  575. }
  576. .acttime {
  577. font-weight: 550;
  578. color: #333333;
  579. font-size: 30rpx;
  580. }
  581. .clock {
  582. width: 30rpx;
  583. height: 30rpx;
  584. margin-right: 20rpx;
  585. }
  586. .uni-input {
  587. width: 90%;
  588. height: 85rpx;
  589. /* margin-top: 30rpx; */
  590. padding: 0 30rpx;
  591. background: #f1f1f1;
  592. border-radius: 9px;
  593. }
  594. .input-placeholder {
  595. color: #333333;
  596. font-size: 16px;
  597. }
  598. .introduce {
  599. width: 100%;
  600. margin-top: 10rpx;
  601. margin-bottom: 30rpx;
  602. align-items: flex-start;
  603. justify-content: space-around;
  604. }
  605. .introduce-title {
  606. color: #333333;
  607. font-size: 30rpx;
  608. line-height: 60rpx;
  609. font-family: Source Han Sans CN;
  610. }
  611. .introduce-content {
  612. color: #333333;
  613. font-size: 25rpx;
  614. line-height: 46rpx;
  615. font-family: Source Han Sans CN;
  616. }
  617. .btnSignup {
  618. width: 100%;
  619. height: 100rpx;
  620. margin-bottom: 30rpx;
  621. color: white;
  622. font-weight: bold;
  623. line-height: 100rpx;
  624. border-radius: 55rpx;
  625. }
  626. .btnSignup-enable {
  627. background-color: #81cd00;
  628. }
  629. .btnSignup-disable {
  630. background-color: #c3c3c3;
  631. }
  632. .dialog-content {
  633. width: 279px;
  634. height: 110px;
  635. background: #f1f1f1;
  636. border-radius: 9px;
  637. justify-content: center;
  638. text-align: center;
  639. font-weight: 550;
  640. color: #333333;
  641. }
  642. .dialog-content-1 {
  643. font-size: 40rpx;
  644. }
  645. </style>