signup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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="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-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. 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: 230px;
  267. padding-top: 36px;
  268. justify-content: space-between;
  269. background-image: url("static/backgroud/top_bg_aoti.png");
  270. background-repeat: no-repeat;
  271. background-position: center;
  272. background-size: cover;
  273. }
  274. .topbar-color{
  275. color: #5b9100;
  276. }
  277. .swiper-item-button {
  278. background-color: #81cd00 !important;
  279. }
  280. `,
  281. "popupDataList": [{
  282. "type": 1,
  283. "data": {
  284. "title": "小飞龙定向赛",
  285. "img": "/static/common/aoti.png",
  286. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  287. }
  288. },
  289. "default"
  290. ],
  291. "introduce": {
  292. "title": "介绍:",
  293. "content": "济南奥体中心“一场三馆”包括体育场、体育馆、网球馆和游泳馆,呈现出“东荷西柳”的总体布局。 体育场以济南的“市树”柳树为母题,将垂柳柔美飘逸的形态固化为建筑语言。"
  294. }
  295. }; */
  296. this.loadConfig(config);
  297. setTimeout(this.dealFirstEnter, 500);
  298. },
  299. fail: (err) => {
  300. console.log("getCardConfigQuery err", err)
  301. },
  302. });
  303. },
  304. // 卡片信息查询
  305. getCardDetailQuery() {
  306. uni.request({
  307. url: apiCardDetailQuery,
  308. header: {
  309. "Content-Type": "application/x-www-form-urlencoded",
  310. "token": this.token
  311. },
  312. method: "POST",
  313. data: {
  314. ecId: this.ecId
  315. },
  316. success: (res) => {
  317. // console.log("getCardDetailQuery", res);
  318. const data = res.data.data;
  319. this.mcType = data.mcType;
  320. this.mcId = data.mcId;
  321. this.mcName = data.mcName;
  322. this.beginSecond = data.beginSecond;
  323. this.endSecond = data.endSecond;
  324. this.coiId = data.coiId;
  325. this.coiName = data.coiName;
  326. this.teamNum = data.teamNum;
  327. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  328. this.getActtime();
  329. // this.getOnlineMcSignUpDetail();
  330. this.clear();
  331. this.interval = setInterval(this.getActtime, 60000);
  332. },
  333. fail: (err) => {
  334. console.log("getCardDetailQuery err", err)
  335. },
  336. });
  337. },
  338. // 卡片对应线上赛多个活动查询
  339. matchRsDetailQuery() {
  340. uni.request({
  341. url: apiMatchRsDetailQuery,
  342. header: {
  343. "Content-Type": "application/x-www-form-urlencoded",
  344. "token": this.token,
  345. },
  346. method: "POST",
  347. data: {
  348. ecId: this.ecId
  349. },
  350. success: (res) => {
  351. // console.log("matchRsDetailQuery", res);
  352. if (res.data.code == 0) {
  353. const data = res.data.data;
  354. const rank = JSON.stringify(data);
  355. this.dealNotice(rank);
  356. }
  357. },
  358. fail: (err) => {
  359. console.log("matchRsDetailQuery err", err)
  360. },
  361. });
  362. },
  363. // 卡片用户当前排名查询
  364. // getUserCurrentRankNumQuery() {
  365. // uni.request({
  366. // url: apiUserCurrentRankNumQuery,
  367. // header: {
  368. // "Content-Type": "application/x-www-form-urlencoded",
  369. // "token": this.token,
  370. // },
  371. // method: "POST",
  372. // data: {
  373. // ecId: this.ecId
  374. // },
  375. // success: (res) => {
  376. // // console.log("getUserCurrentRankNumQuery", res)
  377. // if (res.data.code == 0) {
  378. // const data = res.data.data;
  379. // const rankNum = data.rankNum;
  380. // this.dealNotice(rankNum);
  381. // }
  382. // },
  383. // fail: (err) => {
  384. // console.log("getUserCurrentRankNumQuery err", err)
  385. // },
  386. // });
  387. // },
  388. // 线上赛报名页面信息详情
  389. /* getOnlineMcSignUpDetail() {
  390. uni.request({
  391. url: apiOnlineMcSignUpDetail,
  392. header: {
  393. "Content-Type": "application/x-www-form-urlencoded",
  394. "token": this.token,
  395. },
  396. method: "POST",
  397. data: {
  398. mcId: this.mcId,
  399. },
  400. success: (res) => {
  401. // console.log("getOnlineMcSignUpDetail", res)
  402. this.coiRs = res.data.data.coiRs;
  403. const rsNum = this.coiRs.length;
  404. this.orgList = [];
  405. for (let i = 0; i < rsNum; i++) {
  406. this.orgList[i] = {};
  407. this.orgList[i].value = this.coiRs[i].coiId;
  408. this.orgList[i].text = this.coiRs[i].coiName;
  409. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  410. }
  411. // console.log("orgList", this.orgList);
  412. if (this.coiId > 0) {
  413. this.orgChange(this.coiId, false);
  414. }
  415. },
  416. fail: (err) => {
  417. console.log("getOnlineMcSignUpDetail err", err)
  418. },
  419. });
  420. }, */
  421. // 线上赛报名
  422. onlineMcSignUp() {
  423. uni.request({
  424. url: apiOnlineMcSignUp,
  425. header: {
  426. "Content-Type": "application/x-www-form-urlencoded",
  427. "token": this.token,
  428. },
  429. method: "POST",
  430. data: {
  431. mcId: this.mcId,
  432. coiId: this.coiId,
  433. selectTeam: this.teamNum,
  434. nickName: this.nickName
  435. },
  436. success: (res) => {
  437. // console.log("onlineMcSignUp", res);
  438. if (checkResCode(res)) {
  439. uni.showToast({
  440. title: '比赛报名成功!',
  441. icon: 'none',
  442. duration: 3000
  443. });
  444. // uni.navigateTo({
  445. // // url: '/pages/bm/style2/rankOverview?' + this.queryString
  446. // url: '/pages/bm/style2/rankList?' + this.queryString
  447. // });
  448. const url = '/pages/bm/style2/rankList?' + this.queryString;
  449. tools.appAction(url, "uni.navigateTo");
  450. }
  451. },
  452. fail: (err) => {
  453. console.log("onlineMcSignUp err", err);
  454. uni.showToast({
  455. title: '出错了,报名失败',
  456. icon: 'none',
  457. duration: 3000
  458. });
  459. },
  460. });
  461. },
  462. btnBack() {
  463. // console.log("from:", this.from)
  464. if (this.from != '') {
  465. // window.history.back();
  466. // uni.navigateTo({
  467. // url: '/pages/bm/style2/rankList?' + this.queryString
  468. // });
  469. const url = '/pages/bm/style2/rankList?' + this.queryString;
  470. tools.appAction(url, "uni.navigateTo");
  471. } else {
  472. const url = `action://to_home/`;
  473. tools.appAction(url);
  474. }
  475. },
  476. btnInfo() {
  477. this.$refs.mypopup.popupOpen();
  478. },
  479. btnSignup() {
  480. if (!checkToken(this.token)) {
  481. return;
  482. }
  483. if (!(this.nickName.trim().length > 0)) {
  484. uni.showToast({
  485. title: '请填写姓名',
  486. icon: 'none',
  487. duration: 2000
  488. });
  489. return;
  490. }
  491. this.nickName = this.nickName.trim();
  492. this.$refs.alertDialog.open();
  493. },
  494. dialogConfirm() {
  495. this.onlineMcSignUp();
  496. },
  497. dialogClose() {}
  498. }
  499. }
  500. </script>
  501. <style scoped>
  502. .content {
  503. width: 100vw;
  504. height: 100vh;
  505. }
  506. .top-default {
  507. width: 100%;
  508. height: 230px;
  509. padding-top: 36px;
  510. justify-content: space-between;
  511. background-image: url("/static/backgroud/top_bg_aoti.png");
  512. background-repeat: no-repeat;
  513. background-position: center;
  514. background-size: cover;
  515. }
  516. .topbar-color-default {
  517. color: #5b9100;
  518. }
  519. .main {
  520. width: 76%;
  521. min-height: 800rpx;
  522. /* margin-top: 20rpx; */
  523. justify-content: space-around;
  524. }
  525. .timebar {
  526. width: 90%;
  527. height: 65rpx;
  528. margin-top: 20rpx;
  529. padding: 0 30rpx;
  530. justify-content: space-evenly;
  531. background: #ffffff;
  532. border: 0.5px solid;
  533. border-color: #e7e7e7;
  534. border-radius: 20px;
  535. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  536. }
  537. .acttime {
  538. font-weight: 550;
  539. color: #333333;
  540. font-size: 30rpx;
  541. }
  542. .clock {
  543. width: 30rpx;
  544. height: 30rpx;
  545. margin-right: 20rpx;
  546. }
  547. .uni-input {
  548. width: 90%;
  549. height: 85rpx;
  550. padding: 0 30rpx;
  551. background: #f1f1f1;
  552. border-radius: 9px;
  553. }
  554. .input-placeholder {
  555. color: #333333;
  556. font-size: 16px;
  557. }
  558. .introduce {
  559. width: 100%;
  560. margin-top: 10rpx;
  561. margin-bottom: 80rpx;
  562. align-items: flex-start;
  563. justify-content: space-around;
  564. }
  565. .introduce-title {
  566. color: #333333;
  567. font-size: 30rpx;
  568. line-height: 60rpx;
  569. }
  570. .introduce-content {
  571. color: #333333;
  572. font-size: 25rpx;
  573. line-height: 46rpx;
  574. }
  575. .btnSignup {
  576. width: 100%;
  577. height: 100rpx;
  578. margin-bottom: 30rpx;
  579. color: white;
  580. font-weight: bold;
  581. line-height: 100rpx;
  582. border-radius: 55rpx;
  583. }
  584. .btnSignup-enable {
  585. background-color: #81cd00;
  586. }
  587. .btnSignup-disable {
  588. background-color: #c3c3c3;
  589. }
  590. .dialog-content {
  591. width: 279px;
  592. height: 110px;
  593. background: #f1f1f1;
  594. border-radius: 9px;
  595. justify-content: center;
  596. text-align: center;
  597. font-weight: 550;
  598. color: #333333;
  599. }
  600. .dialog-content-1 {
  601. font-size: 40rpx;
  602. }
  603. </style>