signup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <!--
  2. [模板] 样式2 - 报名
  3. http://localhost:5173/card/#/pages/tpl/style2/signup
  4. https://oss-mbh5.colormaprun.com/card/#/pages/tpl/style2/signup
  5. -->
  6. <template>
  7. <view class="body">
  8. <view v-if="pageReady" class="content uni-column">
  9. <view class="uni-column page-top">
  10. <my-topbar :mcName="mcName" class="topbar-color" @btnBackClick="btnBack"
  11. @btnInfoClick="btnInfo"></my-topbar>
  12. <view class="topcontent uni-column uni-jcsa">
  13. <view class="logo"></view>
  14. <text v-if="configParam.subTitle.length > 0" class="top-acttime">{{configParam.subTitle}}</text>
  15. <text v-else class="top-acttime">{{fmtMcTime2(beginSecond, endSecond)}}</text>
  16. </view>
  17. </view>
  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. <view class="main uni-column uni-jct">
  23. <input class="uni-input" maxlength="12" :placeholder="'请填写'+configParam.labelName" placeholder-style="font-size: 14px;" v-model="nickName" @click="nickNameClick" />
  24. <!-- <e-select v-model="coiId" :options="coiRs" :props="eSelectionProps" clearable
  25. maxHeight="40vh" :placeholder="'请选择'+configParam.labelOrg+'(可输入关键字)'" @getText="getESelectText"
  26. @change="eSelectChange"></e-select> -->
  27. <view class="introduce uni-column">
  28. <text class="introduce-title">{{introduce.title}}</text>
  29. <text class="introduce-content" v-html="introduce.content"></text>
  30. </view>
  31. <view v-if="activityRules.content.length > 0" class="activityRules uni-column">
  32. <text class="activityRules-title">{{activityRules.title}}</text>
  33. <text class="activityRules-content" v-html="activityRules.content"></text>
  34. </view>
  35. <button class="btnSignup bgcolor-main" v-if="mcState<=1" @click="btnSignup">报 名</button>
  36. <button class="btnSignup btnSignup-disable" v-if="mcState==2">活动已结束</button>
  37. </view>
  38. <my-popup ref="mypopup" :config="cardConfigData.popupRuleConfig" :dataList="cardConfigData.popupRuleList" :acttime="acttime"></my-popup>
  39. <!-- <uni-popup ref="alertDialog" type="dialog">
  40. <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="您填写的姓名:" @confirm="dialogConfirm"
  41. @close="dialogClose">
  42. <view class="dialog-content uni-column">
  43. <text class="dialog-content-1">{{nickName}}</text>
  44. </view>
  45. </uni-popup-dialog>
  46. </uni-popup> -->
  47. <uni-popup ref="alertDialog" type="dialog">
  48. <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="你的报名信息:" @confirm="dialogConfirm"
  49. @close="dialogClose">
  50. <view class="dialog-content uni-column">
  51. <text class="dialog-content-1">{{mcName}}</text>
  52. <view class="uni-column uni-ais">
  53. <text class="dialog-content-2">{{configParam.labelName}}: {{nickName}}</text>
  54. <!-- <text class="dialog-content-2">{{configParam.labelOrg}}: {{coiName}}</text> -->
  55. <!-- <text class="dialog-content-2">{{teamName}}</text> -->
  56. </view>
  57. </view>
  58. </uni-popup-dialog>
  59. </uni-popup>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import tools from '../../../common/tools';
  65. import cardfunc from '../../../common/cardfunc';
  66. import { localCardConfig } from "./cardconfig/test.js";
  67. import {
  68. token,
  69. apiCardDetailQuery,
  70. apiOnlineMcSignUpDetail,
  71. apiOnlineMcSignUp,
  72. apiMatchRsDetailQuery,
  73. checkResCode,
  74. checkToken
  75. } from '../../../common/api';
  76. export default {
  77. data() {
  78. return {
  79. cardConfigData: cardfunc.cardConfigData,
  80. pageReady: false,
  81. pageName: "signup",
  82. firstEnterKey: 'firstEnter-tpl-style2',
  83. rankKey: "rank-tpl-style2",
  84. queryObj: {},
  85. queryString: "",
  86. from: "", // 来源页面
  87. token: "",
  88. ecId: 0, // 卡片id
  89. mcId: 0, // 赛事id
  90. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  91. mcName: "", // 赛事名称
  92. acttime: "", // 活动时间
  93. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  94. endSecond: null, // 活动或赛事结束时间戳,单位秒
  95. coiId: 0, // 已报名单位id
  96. coiName: "", // 已报名单位名称,可为空
  97. teamNum: 0, // 已报名队伍编号,可为0
  98. nickName: "", // 昵称
  99. coiRs: [], // 组织信息集合
  100. // orgList: [], // 分组下拉列表数据源
  101. // teamList: [], //
  102. interval: null,
  103. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  104. // teamType: 0, // 队伍类型 0: 红黄蓝紫 1: 学生/家长
  105. introduce: {
  106. title: "",
  107. content: ""
  108. },
  109. activityRules: {
  110. title: "",
  111. content: ""
  112. },
  113. configParam: {
  114. labelName: "昵称",
  115. labelOrg: "组织",
  116. subTitle: ""
  117. },
  118. eSelectionProps: {
  119. text: 'coiName',
  120. value: 'coiId',
  121. // disabled: 'noallowed'
  122. },
  123. }
  124. },
  125. computed: {},
  126. onLoad(query) { // 类型非必填,可自动推导
  127. // console.log(query);
  128. this.queryObj = query;
  129. this.queryString = tools.objectToQueryString(this.queryObj);
  130. // console.log(queryString);
  131. this.from = query["from"] ?? "";
  132. this.token = query["token"] ?? token;
  133. this.ecId = query["id"] ?? 0;
  134. this.firstEnterKey += "-" + this.ecId;
  135. console.log("firstEnterKey:", this.firstEnterKey);
  136. this.rankKey += "-" + this.ecId;
  137. console.log("rankKey:", this.rankKey);
  138. cardfunc.init(this, this.token, this.ecId);
  139. cardfunc.getCardConfig(this.cardConfigQueryCallback, localCardConfig);
  140. this.getCardDetailQuery();
  141. this.matchRsDetailQuery();
  142. },
  143. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  144. onReady() {
  145. // this.dealFirstEnter();
  146. },
  147. onUnload() {
  148. this.clear();
  149. },
  150. methods: {
  151. dealNotice(rank) {
  152. // console.log('[dealNotice]');
  153. let that = this;
  154. uni.getStorage({
  155. key: that.rankKey,
  156. success: (res) => {
  157. // console.log('[getStorage]', that.rankKey, res.data);
  158. const oldRank = res.data;
  159. if (oldRank != rank) {
  160. // that.notice = true;
  161. that.setRankValue(rank);
  162. }
  163. },
  164. fail: (e) => {
  165. console.log('[getStorage] fail', that.rankKey, e);
  166. // that.notice = false;
  167. that.setRankValue(rank);
  168. },
  169. })
  170. },
  171. setRankValue(data) {
  172. let that = this;
  173. uni.setStorage({
  174. key: that.rankKey,
  175. data: data,
  176. success: () => {
  177. console.log('[setStorage] success', that.rankKey, data);
  178. },
  179. fail: (e) => {
  180. console.log('[setStorage] fail', that.rankKey, e);
  181. },
  182. })
  183. },
  184. dealFirstEnter() {
  185. // console.log('[dealFirstEnter]');
  186. let that = this;
  187. uni.getStorage({
  188. key: that.firstEnterKey,
  189. success: (res) => {
  190. console.log('[getStorage]', that.firstEnterKey, res.data);
  191. },
  192. fail: (e) => {
  193. console.log('[getStorage] fail', that.firstEnterKey, e);
  194. that.btnInfo();
  195. that.setFirstEnterValue(true);
  196. },
  197. })
  198. },
  199. setFirstEnterValue(data) {
  200. let that = this;
  201. uni.setStorage({
  202. key: that.firstEnterKey,
  203. data: data,
  204. success: () => {
  205. console.log('[setStorage] success', that.firstEnterKey, data);
  206. },
  207. fail: (e) => {
  208. console.log('[setStorage] fail', that.firstEnterKey, e);
  209. },
  210. })
  211. },
  212. clear() {
  213. if (this.interval != null) {
  214. clearInterval(this.interval);
  215. this.interval = null;
  216. }
  217. },
  218. cardConfigQueryCallback(cardconfig) {
  219. this.loadConfig(cardconfig);
  220. setTimeout(this.dealFirstEnter, 500);
  221. },
  222. loadConfig(cardconfig) {
  223. cardconfig = cardfunc.parseCardConfig(cardconfig);
  224. // console.log("[loadCardConfig] cardconfig:", cardconfig);
  225. // 加载卡片通用配置
  226. if (cardconfig.common != undefined) {
  227. cardfunc.loadCardCommonConfig(cardconfig.common);
  228. }
  229. // -------- 加载当前页面的配置 --------
  230. const config = cardfunc.parseCardConfig(cardconfig[this.pageName]);
  231. // console.log("[loadConfig] config_page:", config); if (config == undefined || config == null) {
  232. this.pageReady = true; return; }
  233. // 加载CSS样式
  234. const css = config.css;
  235. if (css != undefined && css.length > 0) {
  236. tools.loadCssCode(css);
  237. }
  238. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  239. /* if (config.teamType != undefined && config.teamType >= 0) {
  240. this.teamType = config.teamType;
  241. } */
  242. // 加载介绍内容
  243. const introduce = config.introduce;
  244. if (introduce != undefined) {
  245. if (introduce.title != undefined) {
  246. this.introduce.title = introduce.title;
  247. }
  248. if (introduce.content != undefined) {
  249. this.introduce.content = introduce.content;
  250. }
  251. }
  252. // 加载活动规则
  253. const activityRules = config.activityRules;
  254. if (activityRules != undefined) {
  255. if (activityRules.title != undefined) {
  256. this.activityRules.title = activityRules.title;
  257. }
  258. if (activityRules.content != undefined) {
  259. this.activityRules.content = activityRules.content;
  260. }
  261. }
  262. // 加载页面参数
  263. const param = config.param;
  264. if (param != undefined) {
  265. if (param.labelName != undefined && param.labelName.length > 0) {
  266. this.configParam.labelName = param.labelName;
  267. }
  268. if (param.labelOrg != undefined && param.labelOrg.length > 0) {
  269. this.configParam.labelOrg = param.labelOrg;
  270. }
  271. if (param.subTitle != undefined && param.subTitle.length > 0) {
  272. this.configParam.subTitle = param.subTitle;
  273. }
  274. }
  275. // console.log("[loadConfig] param:", this.configParam);
  276. this.pageReady = true;
  277. },
  278. fmtMcTime(timestamp) {
  279. return tools.fmtMcTime(timestamp);
  280. },
  281. // 获取倒计时
  282. getActtime() {
  283. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  284. },
  285. fmtMcTime2(timestamp1, timestamp2) {
  286. return tools.fmtMcTime2(timestamp1, timestamp2);
  287. },
  288. // 卡片信息查询
  289. getCardDetailQuery() {
  290. uni.request({
  291. url: apiCardDetailQuery,
  292. header: {
  293. "Content-Type": "application/x-www-form-urlencoded",
  294. "token": this.token
  295. },
  296. method: "POST",
  297. data: {
  298. ecId: this.ecId
  299. },
  300. success: (res) => {
  301. // console.log("getCardDetailQuery", res);
  302. const data = res.data.data;
  303. this.mcType = data.mcType;
  304. this.mcId = data.mcId;
  305. this.mcName = data.mcName;
  306. this.beginSecond = data.beginSecond;
  307. this.endSecond = data.endSecond;
  308. this.coiId = data.coiId;
  309. this.coiName = data.coiName;
  310. this.teamNum = data.teamNum;
  311. this.nickName = data.nickName;
  312. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  313. this.getActtime();
  314. this.getOnlineMcSignUpDetail();
  315. this.clear();
  316. this.interval = setInterval(this.getActtime, 60000);
  317. },
  318. fail: (err) => {
  319. console.log("getCardDetailQuery err", err)
  320. },
  321. });
  322. },
  323. // 卡片对应线上赛多个活动查询
  324. matchRsDetailQuery() {
  325. uni.request({
  326. url: apiMatchRsDetailQuery,
  327. header: {
  328. "Content-Type": "application/x-www-form-urlencoded",
  329. "token": this.token,
  330. },
  331. method: "POST",
  332. data: {
  333. ecId: this.ecId
  334. },
  335. success: (res) => {
  336. // console.log("matchRsDetailQuery", res);
  337. if (res.data.code == 0) {
  338. const data = res.data.data;
  339. const rank = JSON.stringify(data);
  340. this.dealNotice(rank);
  341. }
  342. },
  343. fail: (err) => {
  344. console.log("matchRsDetailQuery err", err)
  345. },
  346. });
  347. },
  348. // 线上赛报名页面信息详情
  349. getOnlineMcSignUpDetail() {
  350. uni.request({
  351. url: apiOnlineMcSignUpDetail,
  352. header: {
  353. "Content-Type": "application/x-www-form-urlencoded",
  354. "token": this.token,
  355. },
  356. method: "POST",
  357. data: {
  358. mcId: this.mcId,
  359. },
  360. success: (res) => {
  361. // console.log("getOnlineMcSignUpDetail", res);
  362. this.coiRs = res.data.data.coiRs;
  363. if (this.nickName == undefined || this.nickName == '') {
  364. this.nickName = res.data.data.name;
  365. }
  366. /* const rsNum = this.coiRs.length;
  367. this.orgList = [];
  368. for (let i = 0; i < rsNum; i++) {
  369. this.orgList[i] = {};
  370. this.orgList[i].value = this.coiRs[i].coiId;
  371. this.orgList[i].text = this.coiRs[i].coiName;
  372. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  373. }
  374. // console.log("orgList", this.orgList);
  375. if (this.coiId > 0) {
  376. this.orgChange(this.coiId, false);
  377. } */
  378. },
  379. fail: (err) => {
  380. console.log("getOnlineMcSignUpDetail err", err)
  381. },
  382. });
  383. },
  384. // 线上赛报名
  385. onlineMcSignUp() {
  386. uni.request({
  387. url: apiOnlineMcSignUp,
  388. header: {
  389. "Content-Type": "application/x-www-form-urlencoded",
  390. "token": this.token,
  391. },
  392. method: "POST",
  393. data: {
  394. mcId: this.mcId,
  395. coiId: this.coiId,
  396. selectTeam: this.teamNum,
  397. nickName: this.nickName
  398. },
  399. success: (res) => {
  400. // console.log("onlineMcSignUp", res);
  401. if (checkResCode(res)) {
  402. uni.showToast({
  403. title: '比赛报名成功!',
  404. icon: 'none',
  405. duration: 3000
  406. });
  407. const url = '/pages/tpl/style2/rankList?' + this.queryString;
  408. tools.appAction(url, "uni.navigateTo");
  409. }
  410. },
  411. fail: (err) => {
  412. console.log("onlineMcSignUp err", err);
  413. uni.showToast({
  414. title: '出错了,报名失败',
  415. icon: 'none',
  416. duration: 3000
  417. });
  418. },
  419. });
  420. },
  421. btnBack() {
  422. // console.log("from:", this.from)
  423. if (this.from != '') {
  424. // window.history.back();
  425. const url = '/pages/tpl/style2/' + this.from + '?' + this.queryString;
  426. tools.appAction(url, "uni.navigateTo");
  427. } else {
  428. const url = `action://to_home/`;
  429. tools.appAction(url);
  430. }
  431. },
  432. btnInfo() {
  433. this.$refs.mypopup.popupOpen();
  434. },
  435. nickNameClick() {
  436. checkToken(this.token);
  437. },
  438. btnSignup() {
  439. if (!checkToken(this.token)) {
  440. return;
  441. }
  442. if (!(this.nickName.trim().length > 0)) {
  443. uni.showToast({
  444. title: `请填写${this.configParam.labelName}`,
  445. icon: 'none',
  446. duration: 2000
  447. });
  448. return;
  449. }
  450. /* if (!(this.coiId > 0)) {
  451. uni.showToast({
  452. title: `请选择${this.configParam.labelOrg}`,
  453. icon: 'none',
  454. duration: 2000
  455. });
  456. return;
  457. } */
  458. this.nickName = this.nickName.trim();
  459. // this.coiName = tools.getSelectedText(this.orgList, this.coiId);
  460. // this.teamName = tools.getSelectedText(this.teamList, this.teamNum);
  461. this.$refs.alertDialog.open();
  462. },
  463. dialogConfirm() {
  464. this.onlineMcSignUp();
  465. },
  466. dialogClose() {},
  467. // 获取输入框中值
  468. getESelectText(data) {
  469. // console.log("getESelectText:", data);
  470. this.coiName = data;
  471. },
  472. // 获取选择选项值
  473. eSelectChange(data) {
  474. // console.log("eSelectChange:", data);
  475. },
  476. }
  477. }
  478. </script>
  479. <style scoped>
  480. .content {
  481. width: 100vw;
  482. min-height: 100vh;
  483. }
  484. .page-top {
  485. width: 100%;
  486. height: 220px;
  487. padding-top: 36px;
  488. justify-content: space-between;
  489. background-image: url('static/backgroud/top_bg_sddx.png');
  490. background-repeat: no-repeat;
  491. background-position: center;
  492. background-size: cover;
  493. }
  494. .topbar-color-default {
  495. color: #333333;
  496. }
  497. .topcontent {
  498. height: 90%;
  499. margin-bottom: 30px;
  500. }
  501. .logo {
  502. width: 80px;
  503. height: 80px;
  504. margin-top: 10px;
  505. /* background-image: url('/static/logo/sddx.png'); */
  506. background-repeat: no-repeat;
  507. background-position-x: center;
  508. background-position-y: center;
  509. background-size: contain;
  510. }
  511. .top-acttime {
  512. display: none;
  513. text-shadow: 3px 3px 0px #640008;
  514. font-family: YouSheBiaoTiHei;
  515. /* font-family: Arial, Helvetica, sans-serif; */
  516. font-weight: bold;
  517. color: #ffee0b;
  518. font-size: 26px;
  519. }
  520. .mcName {
  521. font-size: 40rpx;
  522. font-weight: 550;
  523. }
  524. .main {
  525. width: 76%;
  526. flex-grow: 1;
  527. }
  528. .timebar {
  529. min-width: 68%;
  530. height: 32px;
  531. margin-top: -17px;
  532. padding: 0 15px;
  533. justify-content: center;
  534. background: #ffffff;
  535. border: 0.5px solid;
  536. border-color: #e7e7e7;
  537. border-radius: 20px;
  538. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  539. }
  540. .acttime {
  541. font-weight: 550;
  542. color: #333333;
  543. font-size: 14px;
  544. text-wrap: nowrap;
  545. }
  546. .clock {
  547. width: 15px;
  548. height: 15px;
  549. margin-right: 10px;
  550. }
  551. .uni-input {
  552. width: 90%;
  553. height: 34px;
  554. margin-top: 15px;
  555. margin-bottom: 15px;
  556. padding: 0 13px;
  557. /* background: #f1f1f1; */
  558. border: 1px solid #dcdfe6;
  559. border-radius: 4px;
  560. font-size: 14px;
  561. }
  562. .input-placeholder {
  563. color: #333333;
  564. font-size: 16px;
  565. }
  566. .introduce {
  567. width: 100%;
  568. margin-top: 12px;
  569. margin-bottom: 10px;
  570. align-items: flex-start;
  571. justify-content: space-around;
  572. }
  573. .introduce-title {
  574. color: #333333;
  575. font-size: 15px;
  576. line-height: 30px;
  577. font-family: Source Han Sans CN;
  578. }
  579. .introduce-content {
  580. color: #333333;
  581. font-size: 14px;
  582. line-height: 23px;
  583. font-family: Source Han Sans CN;
  584. }
  585. .activityRules {
  586. width: 100%;
  587. margin-top: 5px;
  588. margin-bottom: 10px;
  589. padding: 10px 15px;
  590. align-items: flex-start;
  591. justify-content: space-around;
  592. border-radius: 9px;
  593. background: #EBEBEB;
  594. }
  595. .activityRules-title {
  596. color: #333333;
  597. font-size: 14px;
  598. line-height: 25px;
  599. font-weight: 500;
  600. font-family: Source Han Sans CN;
  601. }
  602. .activityRules-content {
  603. color: #333333;
  604. font-size: 13px;
  605. line-height: 23px;
  606. font-family: Source Han Sans CN;
  607. }
  608. .btnSignup {
  609. width: 100%;
  610. height: 100rpx;
  611. margin-top: 30rpx;
  612. margin-bottom: 30rpx;
  613. color: white;
  614. font-weight: bold;
  615. line-height: 100rpx;
  616. border-radius: 55rpx;
  617. }
  618. .bgcolor-main {
  619. background-color: #81cd00;
  620. }
  621. .btnSignup-disable {
  622. background-color: #c3c3c3;
  623. }
  624. .dialog-content {
  625. width: 280px;
  626. height: 110px;
  627. padding: 0 20px;
  628. background: #f1f1f1;
  629. border-radius: 9px;
  630. justify-content: center;
  631. text-align: center;
  632. font-weight: 550;
  633. color: #333333;
  634. }
  635. .dialog-content-1 {
  636. font-size: 34rpx;
  637. margin-bottom: 30rpx;
  638. }
  639. .dialog-content-2 {
  640. font-size: 28rpx;
  641. margin-bottom: 10rpx;
  642. text-align: left;
  643. }
  644. </style>