signup.vue 18 KB

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