signup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. <my-topbar :mcName="mcName" class="topbar-color"
  11. @btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
  12. <view :class="cssLogo"></view>
  13. <view class="toptime uni-row">
  14. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  15. <text class="acttime">{{acttime}}</text>
  16. </view>
  17. <!-- <text class="mcName">{{ecId}} - {{mcId}} - {{token}}</text> -->
  18. </view>
  19. <view class="main uni-column">
  20. <!-- <text>token: {{token}}</text> -->
  21. <!-- <text>queryString: {{queryString}}</text> -->
  22. <uni-data-select class="select" placeholder="请选择组织名称" v-model="coiId" :localdata="orgList"
  23. @change="orgChange"></uni-data-select>
  24. <uni-data-select v-if="teamList.length > 0" class="select" placeholder="请选择分组" v-model="teamNum"
  25. :localdata="teamList"></uni-data-select>
  26. <view class="introduce uni-column">
  27. <text class="introduce-title">{{introduce.title}}</text>
  28. <text class="introduce-content" v-html="introduce.content"></text>
  29. </view>
  30. <button class="btnSignup btnSignup-enable" v-if="mcState<=1" @click="btnSignup">报 名</button>
  31. <button class="btnSignup btnSignup-disable" v-if="mcState==2">活动已结束</button>
  32. </view>
  33. <my-popup ref="mypopup" :dataList="popupDataList" :acttime="acttime"></my-popup>
  34. <uni-popup ref="alertDialog" type="dialog">
  35. <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="您选择的是:" @confirm="dialogConfirm"
  36. @close="dialogClose">
  37. <view class="dialog-content uni-column">
  38. <text class="dialog-content-1">{{mcName}}</text>
  39. <text class="dialog-content-2">{{coiName}}</text>
  40. <text class="dialog-content-2">{{teamName}}</text>
  41. </view>
  42. </uni-popup-dialog>
  43. </uni-popup>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import tools from '../../../common/tools';
  49. import {
  50. teamName,
  51. defaultPopUpDataList
  52. } from '../../../common/define';
  53. import {
  54. token,
  55. apiCardDetailQuery,
  56. apiOnlineMcSignUpDetail,
  57. apiOnlineMcSignUp,
  58. apiCardConfigQuery,
  59. apiUserCurrentRankNumQuery,
  60. checkResCode,
  61. checkToken
  62. } from '../../../common/api';
  63. export default {
  64. data() {
  65. return {
  66. pageName: "signup",
  67. firstEnterKey: 'firstEnter-bm',
  68. rankKey: "rank-bm-style1",
  69. queryObj: {},
  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. onLoad(query) { // 类型非必填,可自动推导
  100. // console.log(query);
  101. this.queryObj = query;
  102. this.queryString = tools.objectToQueryString(this.queryObj);
  103. // console.log(queryString);
  104. this.from = query["from"] ?? "";
  105. this.token = query["token"] ?? token;
  106. this.ecId = query["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. return tools.fmtMcTime(timestamp);
  260. },
  261. // 获取倒计时
  262. getActtime() {
  263. this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
  264. },
  265. getCardConfigQuery() {
  266. uni.request({
  267. url: apiCardConfigQuery,
  268. header: {
  269. "Content-Type": "application/x-www-form-urlencoded",
  270. "token": this.token,
  271. },
  272. method: "POST",
  273. data: {
  274. ecId: this.ecId,
  275. pageName: this.pageName
  276. },
  277. success: (res) => {
  278. // console.log("getCardConfigQuery", res)
  279. const data = res.data.data;
  280. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  281. // console.log("configJson", data.configJson);
  282. /* const config = {
  283. "css": `
  284. .top{
  285. width: 100%;
  286. height: 215px;
  287. padding-top: 30px;
  288. padding-bottom: 30px;
  289. justify-content: space-between;
  290. background-image: url("static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  291. background-repeat: no-repeat;
  292. background-position: center, 0px 0px;
  293. background-size: auto 176px , cover;
  294. }
  295. .logo{
  296. width: 150px;
  297. height: 150px;
  298. margin-top: 10px;
  299. background-image: url('static/logo/xfl.png');
  300. background-repeat: no-repeat;
  301. background-position-x: center;
  302. background-position-y: center;
  303. background-size: contain;
  304. }
  305. `,
  306. "popupDataList": [
  307. {
  308. "type": 1,
  309. "data": {
  310. "title": "山青活动",
  311. "img": "/static/logo/sqsj.png",
  312. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  313. }
  314. },
  315. "default"
  316. ],
  317. "introduce": {
  318. "title" : "介绍:",
  319. "content": "山青世界为广大青少年提供了亲近自然、劳动实践、拓展培训、军事教育、科普体验、自然探索的平台和机会,也为企事业单位青年团队提供会议培训、拓展训练等服务",
  320. },
  321. "teamType": 1
  322. }; */
  323. this.loadConfig(config);
  324. setTimeout(this.dealFirstEnter, 500);
  325. },
  326. fail: (err) => {
  327. console.log("getCardConfigQuery err", err)
  328. },
  329. });
  330. },
  331. // 卡片信息查询
  332. getCardDetailQuery() {
  333. uni.request({
  334. url: apiCardDetailQuery,
  335. header: {
  336. "Content-Type": "application/x-www-form-urlencoded",
  337. "token": this.token
  338. },
  339. method: "POST",
  340. data: {
  341. ecId: this.ecId
  342. },
  343. success: (res) => {
  344. // console.log("getCardDetailQuery", res);
  345. const data = res.data.data;
  346. this.mcType = data.mcType;
  347. this.mcId = data.mcId;
  348. this.mcName = data.mcName;
  349. this.beginSecond = data.beginSecond;
  350. this.endSecond = data.endSecond;
  351. this.coiId = data.coiId;
  352. this.coiName = data.coiName;
  353. this.teamNum = data.teamNum;
  354. this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
  355. this.getActtime();
  356. this.getOnlineMcSignUpDetail();
  357. // this.clear();
  358. // this.interval = setInterval(this.getActtime, 60000);
  359. },
  360. fail: (err) => {
  361. console.log("getCardDetailQuery err", err)
  362. },
  363. });
  364. },
  365. // 卡片用户当前排名查询
  366. getUserCurrentRankNumQuery() {
  367. uni.request({
  368. url: apiUserCurrentRankNumQuery,
  369. header: {
  370. "Content-Type": "application/x-www-form-urlencoded",
  371. "token": this.token,
  372. },
  373. method: "POST",
  374. data: {
  375. ecId: this.ecId
  376. },
  377. success: (res) => {
  378. // console.log("getUserCurrentRankNumQuery", res)
  379. if (res.data.code == 0) {
  380. const data = res.data.data;
  381. const rankNum = data.rankNum;
  382. this.dealNotice(rankNum);
  383. }
  384. },
  385. fail: (err) => {
  386. console.log("getUserCurrentRankNumQuery err", err)
  387. },
  388. });
  389. },
  390. // 线上赛报名页面信息详情
  391. getOnlineMcSignUpDetail() {
  392. uni.request({
  393. url: apiOnlineMcSignUpDetail,
  394. header: {
  395. "Content-Type": "application/x-www-form-urlencoded",
  396. "token": this.token,
  397. },
  398. method: "POST",
  399. data: {
  400. mcId: this.mcId,
  401. },
  402. success: (res) => {
  403. // console.log("getOnlineMcSignUpDetail", res)
  404. this.coiRs = res.data.data.coiRs;
  405. const rsNum = this.coiRs.length;
  406. this.orgList = [];
  407. for (let i = 0; i < rsNum; i++) {
  408. this.orgList[i] = {};
  409. this.orgList[i].value = this.coiRs[i].coiId;
  410. this.orgList[i].text = this.coiRs[i].coiName;
  411. this.orgList[i].teamNum = this.coiRs[i].teamNum;
  412. }
  413. // console.log("orgList", this.orgList);
  414. if (this.coiId > 0) {
  415. this.orgChange(this.coiId, false);
  416. }
  417. },
  418. fail: (err) => {
  419. console.log("getOnlineMcSignUpDetail err", err)
  420. },
  421. });
  422. },
  423. // 线上赛报名(重新分组)
  424. onlineMcSignUp() {
  425. uni.request({
  426. url: apiOnlineMcSignUp,
  427. header: {
  428. "Content-Type": "application/x-www-form-urlencoded",
  429. "token": this.token,
  430. },
  431. method: "POST",
  432. data: {
  433. mcId: this.mcId,
  434. coiId: this.coiId,
  435. selectTeam: this.teamNum
  436. },
  437. success: (res) => {
  438. // console.log("onlineMcSignUp", res)
  439. if (checkResCode(res)) {
  440. uni.showToast({
  441. title: '比赛报名成功!',
  442. icon: 'none',
  443. duration: 3000
  444. });
  445. // uni.navigateTo({
  446. // url: '/pages/bm/style1/rankList?' + this.queryString
  447. // });
  448. const url = '/pages/bm/style1/rankList?' + this.queryString;
  449. tools.appAction(url, "uni.navigateTo");
  450. }
  451. },
  452. fail: (err) => {
  453. console.log("onlineMcSignUp err", err)
  454. uni.showToast({
  455. title: '出错了,报名失败',
  456. icon: 'none',
  457. duration: 3000
  458. });
  459. },
  460. });
  461. },
  462. btnBack() {
  463. // console.log("from:", this.from)
  464. if (this.from != '') {
  465. // window.history.back();
  466. // uni.navigateTo({
  467. // url: '/pages/bm/style1/rankList?' + this.queryString
  468. // });
  469. const url = '/pages/bm/style1/rankList?' + this.queryString;
  470. tools.appAction(url, "uni.navigateTo");
  471. } else {
  472. const url = `action://to_home/`;
  473. tools.appAction(url);
  474. }
  475. },
  476. btnInfo() {
  477. this.$refs.mypopup.popupOpen();
  478. },
  479. orgChange(value, resetTeamNum = true) {
  480. // console.log("[orgChange] value:", value);
  481. if (resetTeamNum) {
  482. this.teamNum = 0;
  483. }
  484. if (value > 0) {
  485. const selectedOption = this.orgList.find(option => option.value === value);
  486. const teamNum = selectedOption.teamNum;
  487. // console.log("[orgChange] teamNum:", teamNum);
  488. this.getTeamList(teamNum);
  489. } else {
  490. this.getTeamList(0);
  491. }
  492. },
  493. btnSignup() {
  494. if (!checkToken(this.token)) {
  495. return;
  496. }
  497. if (!(this.coiId > 0)) {
  498. uni.showToast({
  499. title: '请选择组织名称',
  500. icon: 'none',
  501. duration: 2000
  502. });
  503. return;
  504. }
  505. // if ((this.teamList.length > 0) && !(this.teamNum > 0)) {
  506. // uni.showToast({
  507. // title: '请选择分组',
  508. // icon: 'none',
  509. // duration: 2000
  510. // });
  511. // return;
  512. // }
  513. this.coiName = tools.getSelectedText(this.orgList, this.coiId);
  514. this.teamName = tools.getSelectedText(this.teamList, this.teamNum);
  515. this.$refs.alertDialog.open();
  516. },
  517. dialogConfirm() {
  518. this.onlineMcSignUp();
  519. },
  520. dialogClose() {}
  521. }
  522. }
  523. </script>
  524. <style scoped>
  525. .content {
  526. width: 100vw;
  527. height: 100vh;
  528. }
  529. .top-default {
  530. width: 100%;
  531. /* height: 35vh; */
  532. height: 206px;
  533. padding-top: 36px;
  534. padding-bottom: 30px;
  535. justify-content: space-between;
  536. background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg, #f8a95a 0%, #d25f11 100%);
  537. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#7aedff 0%,#047200 100%); */
  538. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%); */
  539. background-repeat: no-repeat;
  540. background-position: center, 0px 0px;
  541. background-size: auto 176px, cover;
  542. }
  543. .logo-default {
  544. width: 150px;
  545. height: 150px;
  546. margin-top: 10px;
  547. background-image: url('/static/logo/jbs.png');
  548. background-repeat: no-repeat;
  549. background-position-x: center;
  550. background-position-y: center;
  551. background-size: contain;
  552. }
  553. .topbar-color {
  554. color: white;
  555. }
  556. .toptime {
  557. /* width: 90%; */
  558. height: 65rpx;
  559. margin-top: 20rpx;
  560. padding: 0 36rpx;
  561. justify-content: space-evenly;
  562. background-color: white;
  563. border-radius: 40rpx;
  564. }
  565. .acttime {
  566. font-weight: 550;
  567. color: #333333;
  568. font-size: 30rpx;
  569. }
  570. .clock {
  571. width: 30rpx;
  572. height: 30rpx;
  573. margin-right: 20rpx;
  574. }
  575. .main {
  576. width: 76%;
  577. /* height: 500rpx; */
  578. margin-top: 80rpx;
  579. justify-content: space-around;
  580. }
  581. .select {
  582. margin-bottom: 36rpx;
  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: 46rpx;
  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: #2e85ec;
  611. }
  612. .btnSignup-disable {
  613. background-color: #c3c3c3;
  614. }
  615. .dialog-content {
  616. width: 279px;
  617. height: 152px;
  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. margin-bottom: 30rpx;
  628. }
  629. .dialog-content-2 {
  630. font-size: 32rpx;
  631. margin-bottom: 10rpx;
  632. }
  633. </style>