signup.vue 16 KB

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