signup.vue 17 KB

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