signup.vue 17 KB

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