signup.vue 17 KB

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