signup.vue 17 KB

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