signup.vue 18 KB

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