signup.vue 18 KB

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