signup.vue 18 KB

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