signup.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <!--
  2. [报名] 样式1 - 报名
  3. http://localhost:5173/card/#/pages/bm/style1/signup
  4. https://oss-mbh5.colormaprun.com/card/#/pages/bm/style1/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">
  11. <image mode="aspectFit" class="topbar-back" @click="btnBack" src="/static/default/back.png"></image>
  12. <text class="mcName">{{mcName}}</text>
  13. <image mode="aspectFit" class="topbar-info" @click="btnInfo" src="/static/default/info.png"></image>
  14. </view>
  15. <view :class="cssLogo"></view>
  16. <view class="toptime uni-row">
  17. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  18. <text class="acttime">{{acttime}}</text>
  19. </view>
  20. <!-- <text class="mcName">{{ecId}} - {{mcId}} - {{token}}</text> -->
  21. </view>
  22. <view class="main uni-column">
  23. <uni-data-select class="select" placeholder="请选择组织名称" v-model="coiId" :localdata="orgList"
  24. @change="orgChange"></uni-data-select>
  25. <uni-data-select v-if="teamList.length > 0" class="select" placeholder="请选择分组" v-model="teamNum"
  26. :localdata="teamList"></uni-data-select>
  27. <view class="introduce uni-column">
  28. <text class="introduce-title">{{introduce.title}}</text>
  29. <text
  30. class="introduce-content">{{introduce.content}}</text>
  31. </view>
  32. <button class="btnSignup btnSignup-enable" v-if="mcState<=1" @click="btnSignup">报 名</button>
  33. <button class="btnSignup btnSignup-disable" v-if="mcState==2">活动已结束</button>
  34. </view>
  35. <my-popup ref="mypopup" :dataList="popupDataList" :acttime="acttime"></my-popup>
  36. <uni-popup ref="alertDialog" type="dialog">
  37. <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="您选择的是:" @confirm="dialogConfirm"
  38. @close="dialogClose">
  39. <view class="dialog-content uni-column">
  40. <text class="dialog-content-1">{{mcName}}</text>
  41. <text class="dialog-content-2">{{coiName}}</text>
  42. <text class="dialog-content-2">{{teamName}}</text>
  43. </view>
  44. </uni-popup-dialog>
  45. </uni-popup>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import tools from '../../../common/tools';
  51. import { teamName, defaultPopUpDataList } from '../../../common/define';
  52. import {
  53. token,
  54. apiCardDetailQuery,
  55. apiOnlineMcSignUpDetail,
  56. apiOnlineMcSignUp,
  57. apiCardConfigQuery,
  58. checkResCode,
  59. checkToken
  60. } from '../../../common/api';
  61. export default {
  62. data() {
  63. return {
  64. pageName: "signup",
  65. // firstEnterKey: 'firstEnter-bm_sqsj_signup',
  66. firstEnterKey: 'firstEnter-bm_sqsj',
  67. queryString: "",
  68. from: "", // 来源页面
  69. token: "",
  70. ecId: 0, // 卡片id
  71. mcId: 0, // 赛事id
  72. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  73. mcName: "", // 赛事名称
  74. acttime: "", // 活动时间
  75. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  76. endSecond: null, // 活动或赛事结束时间戳,单位秒
  77. coiId: 0, // 已报名单位id
  78. coiName: "", // 已报名单位名称,可为空
  79. teamNum: 0, // 已报名队伍编号,可为0
  80. coiRs: [], // 组织信息集合
  81. orgList: [], // 分组下拉列表数据源
  82. teamList: [], //
  83. interval: null,
  84. mcState: 0 ,// 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  85. teamType: 0, // 队伍类型 0: 红黄蓝紫 1: 学生/家长
  86. cssTop: "",
  87. cssLogo: "",
  88. introduce: {
  89. title: "",
  90. content: ""
  91. },
  92. popupDataList: [],
  93. }
  94. },
  95. computed: {
  96. },
  97. onLoad(event) { // 类型非必填,可自动推导
  98. // console.log(event);
  99. this.queryString = tools.objectToQueryString(event);
  100. // console.log(queryString);
  101. this.from = event["from"] ?? "";
  102. this.token = event["token"] ?? token;
  103. this.ecId = event["id"] ?? 0;
  104. tools.removeCssCode();
  105. this.getCardConfigQuery();
  106. this.getCardDetailQuery();
  107. },
  108. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  109. onReady() {
  110. this.dealFirstEnter();
  111. },
  112. onUnload() {
  113. this.clear();
  114. },
  115. methods: {
  116. dealFirstEnter() {
  117. // console.log('[dealFirstEnter]');
  118. let that = this;
  119. uni.getStorage({
  120. key: that.firstEnterKey,
  121. success: (res) => {
  122. console.log('[getStorage]', that.firstEnterKey, res.data);
  123. },
  124. fail: (e) => {
  125. console.log('[getStorage] fail', that.firstEnterKey, e);
  126. that.btnInfo();
  127. that.setFirstEnterValue(true);
  128. },
  129. })
  130. },
  131. setFirstEnterValue(data) {
  132. let that = this;
  133. uni.setStorage({
  134. key: that.firstEnterKey,
  135. data: data,
  136. success: () => {
  137. console.log('[setStorage] success', that.firstEnterKey, data);
  138. },
  139. fail: (e) => {
  140. console.log('[setStorage] fail', that.firstEnterKey, e);
  141. },
  142. })
  143. },
  144. clear() {
  145. if (this.interval != null) {
  146. clearInterval(this.interval);
  147. this.interval = null;
  148. }
  149. },
  150. loadConfig(config) {
  151. // console.log("config", config);
  152. // 加载CSS样式
  153. const css = config.css;
  154. if (css != undefined && css.length > 0) {
  155. tools.loadCssCode(css);
  156. if (css.indexOf(".top{") >= 0) {
  157. this.cssTop = "top";
  158. }
  159. if (css.indexOf(".logo{") >= 0) {
  160. this.cssLogo = "logo";
  161. }
  162. }
  163. if (this.cssTop == "") {
  164. this.cssTop = "top-default";
  165. }
  166. if (this.cssLogo == "") {
  167. this.cssLogo = "logo-default";
  168. }
  169. console.log("[loadConfig] cssTop:", this.cssTop);
  170. console.log("[loadConfig] cssLogo:", this.cssLogo);
  171. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  172. if (config.teamType != undefined && config.teamType >= 0) {
  173. this.teamType = config.teamType;
  174. }
  175. // 加载介绍内容
  176. const introduce = config.introduce;
  177. if (introduce != undefined) {
  178. if (introduce.title != undefined) {
  179. this.introduce.title = introduce.title;
  180. }
  181. if (introduce.content != undefined) {
  182. this.introduce.content = introduce.content;
  183. }
  184. }
  185. // 加载弹窗数据
  186. const popupDataList = config.popupDataList;
  187. // console.log("[loadConfig] popupDataList:", popupDataList);
  188. if (popupDataList != undefined && popupDataList.length > 0) {
  189. for (var i = 0; i < popupDataList.length; i++) {
  190. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  191. if (popupDataList[i] == 'default') {
  192. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  193. this.popupDataList.push(defaultPopUpDataList[j]);
  194. }
  195. } else {
  196. this.popupDataList.push(popupDataList[i]);
  197. }
  198. }
  199. } else {
  200. this.popupDataList = defaultPopUpDataList;
  201. console.log("[loadConfig] popupDataList 加载默认列表");
  202. }
  203. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  204. },
  205. getTeamList(teamNum) {
  206. var teamList = [];
  207. if (teamNum > 0) {
  208. for (let i=0; i<=teamNum; i++) {
  209. teamList[i] = {};
  210. teamList[i].value = i;
  211. // teamList[i].text = `第 ${i+1} 队`;
  212. teamList[i].text = teamName[this.teamType][i];
  213. }
  214. }
  215. this.teamList = teamList;
  216. },
  217. fmtMcTime(timestamp) {
  218. var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  219. // var Y = date.getFullYear() + '-';
  220. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  221. var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
  222. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  223. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  224. // var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  225. const timeStr = M + D + h + m;
  226. // console.log("timeStr", timeStr);
  227. return timeStr;
  228. },
  229. // 获取倒计时
  230. getActtime() {
  231. this.acttime = this.fmtMcTime(this.beginSecond) + " 至 " + this.fmtMcTime(this.endSecond);
  232. },
  233. getCardConfigQuery() {
  234. uni.request({
  235. url: apiCardConfigQuery,
  236. header: {
  237. "Content-Type": "application/x-www-form-urlencoded",
  238. "token": this.token,
  239. },
  240. method: "POST",
  241. data: {
  242. ecId: this.ecId,
  243. pageName: this.pageName
  244. },
  245. success: (res) => {
  246. console.log("getCardConfigQuery", res)
  247. const data = res.data.data;
  248. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  249. // console.log("configJson", data.configJson);
  250. /* const config = {
  251. "css": `
  252. .top{
  253. width: 100%;
  254. height: 215px;
  255. padding-top: 30px;
  256. padding-bottom: 30px;
  257. justify-content: space-between;
  258. background-image: url("static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  259. background-repeat: no-repeat;
  260. background-position: center, 0px 0px;
  261. background-size: auto 176px , cover;
  262. }
  263. .logo{
  264. width: 150px;
  265. height: 150px;
  266. margin-top: 10px;
  267. background-image: url('static/logo/xfl.png');
  268. background-repeat: no-repeat;
  269. background-position-x: center;
  270. background-position-y: center;
  271. background-size: contain;
  272. }
  273. `,
  274. "popupDataList": [
  275. {
  276. "type": 1,
  277. "data": {
  278. "title": "山青活动",
  279. "img": "/static/logo/sqsj.png",
  280. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  281. }
  282. },
  283. "default"
  284. ],
  285. "introduce": {
  286. "title" : "介绍:",
  287. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  288. },
  289. "teamType": 1
  290. }; */
  291. this.loadConfig(config);
  292. },
  293. fail: (err) => {
  294. console.log("getCardConfigQuery err", err)
  295. },
  296. });
  297. },
  298. // 卡片信息查询
  299. getCardDetailQuery() {
  300. uni.request({
  301. url: apiCardDetailQuery,
  302. header: {
  303. "Content-Type": "application/x-www-form-urlencoded",
  304. "token": this.token
  305. },
  306. method: "POST",
  307. data: {
  308. ecId: this.ecId
  309. },
  310. success: (res) => {
  311. console.log("getCardDetailQuery", res);
  312. const data = res.data.data;
  313. this.mcType = data.mcType;
  314. this.mcId = data.mcId;
  315. this.mcName = data.mcName;
  316. this.beginSecond = data.beginSecond;
  317. this.endSecond = data.endSecond;
  318. this.coiId = data.coiId;
  319. this.coiName = data.coiName;
  320. this.teamNum = data.teamNum;
  321. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  322. this.getActtime();
  323. this.getOnlineMcSignUpDetail();
  324. // this.clear();
  325. // this.interval = setInterval(this.getActtime, 60000);
  326. },
  327. fail: (err) => {
  328. console.log("getCardDetailQuery err", err)
  329. },
  330. });
  331. },
  332. // 线上赛报名页面信息详情
  333. getOnlineMcSignUpDetail() {
  334. uni.request({
  335. url: apiOnlineMcSignUpDetail,
  336. header: {
  337. "Content-Type": "application/x-www-form-urlencoded",
  338. "token": this.token,
  339. },
  340. method: "POST",
  341. data: {
  342. mcId: this.mcId,
  343. },
  344. success: (res) => {
  345. console.log("getOnlineMcSignUpDetail", res)
  346. this.coiRs = res.data.data.coiRs;
  347. const rsNum = this.coiRs.length;
  348. this.orgList = [];
  349. for (let i=0; i<rsNum; i++) {
  350. this.orgList[i] = {};
  351. this.orgList[i].value = this.coiRs[i].coiId;
  352. this.orgList[i].text = this.coiRs[i].coiName;
  353. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  354. }
  355. // console.log("orgList", this.orgList);
  356. if (this.coiId > 0) {
  357. this.orgChange(this.coiId, false);
  358. }
  359. },
  360. fail: (err) => {
  361. console.log("getOnlineMcSignUpDetail err", err)
  362. },
  363. });
  364. },
  365. // 线上赛报名(重新分组)
  366. onlineMcSignUp() {
  367. uni.request({
  368. url: apiOnlineMcSignUp,
  369. header: {
  370. "Content-Type": "application/x-www-form-urlencoded",
  371. "token": this.token,
  372. },
  373. method: "POST",
  374. data: {
  375. mcId: this.mcId,
  376. coiId: this.coiId,
  377. selectTeam: this.teamNum
  378. },
  379. success: (res) => {
  380. console.log("onlineMcSignUp", res)
  381. if (checkResCode(res)) {
  382. uni.showToast({
  383. title: '比赛报名成功!',
  384. icon: 'none',
  385. duration: 3000
  386. });
  387. uni.navigateTo({
  388. url: '/pages/bm/style1/rankList?' + this.queryString
  389. });
  390. }
  391. },
  392. fail: (err) => {
  393. console.log("onlineMcSignUp err", err)
  394. uni.showToast({
  395. title: '出错了,报名失败',
  396. icon: 'none',
  397. duration: 3000
  398. });
  399. },
  400. });
  401. },
  402. btnBack() {
  403. // console.log("from:", this.from)
  404. if (this.from != '') {
  405. // window.history.back();
  406. uni.navigateTo({
  407. url: '/pages/bm/style1/rankList?' + this.queryString
  408. });
  409. } else {
  410. window.location.href = `action://to_home/`;
  411. }
  412. },
  413. btnInfo() {
  414. this.$refs.mypopup.popupOpen();
  415. },
  416. orgChange(value, resetTeamNum=true) {
  417. console.log("[orgChange] value:", value);
  418. if (resetTeamNum) {
  419. this.teamNum = 0;
  420. }
  421. if (value > 0) {
  422. const selectedOption = this.orgList.find(option => option.value === value);
  423. const teamNum = selectedOption.teamNum;
  424. // console.log("[orgChange] teamNum:", teamNum);
  425. this.getTeamList(teamNum);
  426. } else {
  427. this.getTeamList(0);
  428. }
  429. },
  430. btnSignup() {
  431. if (!checkToken(this.token)) {
  432. return;
  433. }
  434. if (!(this.coiId > 0)) {
  435. uni.showToast({
  436. title: '请选择组织名称',
  437. icon: 'none',
  438. duration: 2000
  439. });
  440. return;
  441. }
  442. // if ((this.teamList.length > 0) && !(this.teamNum > 0)) {
  443. // uni.showToast({
  444. // title: '请选择分组',
  445. // icon: 'none',
  446. // duration: 2000
  447. // });
  448. // return;
  449. // }
  450. this.coiName = tools.getSelectedText(this.orgList, this.coiId);
  451. this.teamName = tools.getSelectedText(this.teamList, this.teamNum);
  452. this.$refs.alertDialog.open();
  453. },
  454. dialogConfirm() {
  455. this.onlineMcSignUp();
  456. },
  457. dialogClose() {}
  458. }
  459. }
  460. </script>
  461. <style scoped>
  462. .content {
  463. width: 100vw;
  464. height: 100vh;
  465. }
  466. .top-default {
  467. width: 100%;
  468. /* height: 35vh; */
  469. height: 206px;
  470. padding-top: 36px;
  471. padding-bottom: 30px;
  472. justify-content: space-between;
  473. background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#f8a95a 0%,#d25f11 100%);
  474. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#7aedff 0%,#047200 100%); */
  475. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%); */
  476. background-repeat: no-repeat;
  477. background-position: center, 0px 0px;
  478. background-size: auto 176px , cover;
  479. }
  480. .logo-default {
  481. width: 150px;
  482. height: 150px;
  483. margin-top: 10px;
  484. background-image: url('/static/logo/jbs.png');
  485. background-repeat: no-repeat;
  486. background-position-x: center;
  487. background-position-y: center;
  488. background-size: contain;
  489. }
  490. .topbar {
  491. width: 90%;
  492. padding: 0rpx 30rpx;
  493. justify-content: space-between;
  494. }
  495. .topbar-back {
  496. width: 43rpx;
  497. height: 43rpx;
  498. /* opacity: 0; */
  499. }
  500. .topbar-info {
  501. width: 46rpx;
  502. height: 46rpx;
  503. }
  504. .mcName {
  505. color: white;
  506. font-size: 40rpx;
  507. font-weight: 550;
  508. }
  509. .toptime {
  510. height: 65rpx;
  511. margin-top: 20rpx;
  512. padding: 0 50rpx;
  513. justify-content: space-evenly;
  514. background-color: white;
  515. border-radius: 40rpx;
  516. }
  517. .acttime {
  518. font-weight: 550;
  519. color: #333333;
  520. font-size: 30rpx;
  521. }
  522. .clock {
  523. width: 30rpx;
  524. height: 30rpx;
  525. margin-right: 20rpx;
  526. }
  527. .main {
  528. width: 76%;
  529. /* height: 500rpx; */
  530. margin-top: 80rpx;
  531. justify-content: space-around;
  532. }
  533. .select {
  534. margin-bottom: 36rpx;
  535. }
  536. .introduce {
  537. margin-top: 10rpx;
  538. margin-bottom: 80rpx;
  539. align-items: flex-start;
  540. justify-content: space-around;
  541. }
  542. .introduce-title {
  543. color: #333333;
  544. font-size: 30rpx;
  545. line-height: 60rpx;
  546. }
  547. .introduce-content {
  548. color: #333333;
  549. font-size: 25rpx;
  550. line-height: 36rpx;
  551. }
  552. .btnSignup {
  553. width: 100%;
  554. height: 100rpx;
  555. margin-bottom: 30rpx;
  556. color: white;
  557. font-weight: bold;
  558. line-height: 100rpx;
  559. border-radius: 55rpx;
  560. }
  561. .btnSignup-enable {
  562. background-color: #2e85ec;
  563. }
  564. .btnSignup-disable {
  565. background-color: #c3c3c3;
  566. }
  567. .dialog-content {
  568. width: 279px;
  569. height: 152px;
  570. background: #f1f1f1;
  571. border-radius: 9px;
  572. justify-content: center;
  573. text-align: center;
  574. font-weight: 550;
  575. color: #333333;
  576. }
  577. .dialog-content-1 {
  578. font-size: 40rpx;
  579. margin-bottom: 30rpx;
  580. }
  581. .dialog-content-2 {
  582. font-size: 32rpx;
  583. margin-bottom: 10rpx;
  584. }
  585. </style>