signup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. } 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. pageReady: false,
  67. pageName: "signup",
  68. firstEnterKey: 'firstEnter-bm',
  69. rankKey: "rank-bm-style1",
  70. queryObj: {},
  71. queryString: "",
  72. from: "", // 来源页面
  73. token: "",
  74. ecId: 0, // 卡片id
  75. mcId: 0, // 赛事id
  76. mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  77. mcName: "", // 赛事名称
  78. acttime: "", // 活动时间
  79. beginSecond: null, // 活动或赛事开始时间戳,单位秒
  80. endSecond: null, // 活动或赛事结束时间戳,单位秒
  81. coiId: 0, // 已报名单位id
  82. coiName: "", // 已报名单位名称,可为空
  83. teamNum: 0, // 已报名队伍编号,可为0
  84. coiRs: [], // 组织信息集合
  85. orgList: [], // 分组下拉列表数据源
  86. teamList: [], //
  87. interval: null,
  88. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  89. teamType: 0, // 队伍类型 0: 红黄蓝紫 1: 学生/家长
  90. cssTop: "",
  91. cssLogo: "",
  92. introduce: {
  93. title: "",
  94. content: ""
  95. },
  96. popupRuleConfig: {}, // 规则弹窗配置
  97. popupDataList: [],
  98. }
  99. },
  100. computed: {},
  101. onLoad(query) { // 类型非必填,可自动推导
  102. // console.log(query);
  103. this.queryObj = query;
  104. this.queryString = tools.objectToQueryString(this.queryObj);
  105. // console.log(queryString);
  106. this.from = query["from"] ?? "";
  107. this.token = query["token"] ?? token;
  108. this.ecId = query["id"] ?? 0;
  109. this.firstEnterKey += "-" + this.ecId;
  110. console.log("firstEnterKey:", this.firstEnterKey);
  111. this.rankKey += "-" + this.ecId;
  112. console.log("rankKey:", this.rankKey);
  113. tools.removeCssCode();
  114. this.getCardConfigQuery();
  115. this.getCardDetailQuery();
  116. this.getUserCurrentRankNumQuery();
  117. },
  118. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  119. onReady() {
  120. // this.dealFirstEnter();
  121. },
  122. onUnload() {
  123. this.clear();
  124. },
  125. methods: {
  126. dealNotice(rank) {
  127. // console.log('[dealFirstEnter]');
  128. let that = this;
  129. uni.getStorage({
  130. key: that.rankKey,
  131. success: (res) => {
  132. console.log('[getStorage]', that.rankKey, res.data);
  133. const oldRank = res.data;
  134. if (oldRank != rank) {
  135. // that.notice = true;
  136. that.setRankValue(rank);
  137. }
  138. },
  139. fail: (e) => {
  140. console.log('[getStorage] fail', that.rankKey, e);
  141. // that.notice = false;
  142. that.setRankValue(rank);
  143. },
  144. })
  145. },
  146. setRankValue(data) {
  147. let that = this;
  148. uni.setStorage({
  149. key: that.rankKey,
  150. data: data,
  151. success: () => {
  152. console.log('[setStorage] success', that.rankKey, data);
  153. },
  154. fail: (e) => {
  155. console.log('[setStorage] fail', that.rankKey, e);
  156. },
  157. })
  158. },
  159. dealFirstEnter() {
  160. // console.log('[dealFirstEnter]');
  161. let that = this;
  162. uni.getStorage({
  163. key: that.firstEnterKey,
  164. success: (res) => {
  165. console.log('[getStorage]', that.firstEnterKey, res.data);
  166. },
  167. fail: (e) => {
  168. console.log('[getStorage] fail', that.firstEnterKey, e);
  169. that.btnInfo();
  170. that.setFirstEnterValue(true);
  171. },
  172. })
  173. },
  174. setFirstEnterValue(data) {
  175. let that = this;
  176. uni.setStorage({
  177. key: that.firstEnterKey,
  178. data: data,
  179. success: () => {
  180. console.log('[setStorage] success', that.firstEnterKey, data);
  181. },
  182. fail: (e) => {
  183. console.log('[setStorage] fail', that.firstEnterKey, e);
  184. },
  185. })
  186. },
  187. clear() {
  188. if (this.interval != null) {
  189. clearInterval(this.interval);
  190. this.interval = null;
  191. }
  192. },
  193. loadConfig(config) {
  194. // console.log("config", config);
  195. // 加载CSS样式
  196. const css = config.css;
  197. if (css != undefined && css.length > 0) {
  198. tools.loadCssCode(css);
  199. if (css.indexOf(".top{") >= 0) {
  200. this.cssTop = "top";
  201. }
  202. if (css.indexOf(".logo{") >= 0) {
  203. this.cssLogo = "logo";
  204. }
  205. }
  206. if (this.cssTop == "") {
  207. this.cssTop = "top-default";
  208. }
  209. if (this.cssLogo == "") {
  210. this.cssLogo = "logo-default";
  211. }
  212. console.log("[loadConfig] cssTop:", this.cssTop);
  213. console.log("[loadConfig] cssLogo:", this.cssLogo);
  214. // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
  215. if (config.teamType != undefined && config.teamType >= 0) {
  216. this.teamType = config.teamType;
  217. }
  218. // 加载介绍内容
  219. const introduce = config.introduce;
  220. if (introduce != undefined) {
  221. if (introduce.title != undefined) {
  222. this.introduce.title = introduce.title;
  223. }
  224. if (introduce.content != undefined) {
  225. this.introduce.content = introduce.content;
  226. }
  227. }
  228. // 加载规则弹窗配置
  229. const popupRuleConfig = config.popupRuleConfig;
  230. if (popupRuleConfig != undefined) {
  231. this.popupRuleConfig = popupRuleConfig;
  232. }
  233. // console.log("[loadConfig] popupRuleConfig:", this.popupRuleConfig);
  234. // 加载弹窗数据
  235. const popupDataList = config.popupDataList;
  236. // console.log("[loadConfig] popupDataList:", popupDataList);
  237. if (popupDataList != undefined && popupDataList.length > 0) {
  238. for (var i = 0; i < popupDataList.length; i++) {
  239. // console.log("[loadConfig] popupDataList", i, popupDataList[i]);
  240. if (popupDataList[i] == 'default') {
  241. for (var j = 0; j < defaultPopUpDataList.length; j++) {
  242. this.popupDataList.push(defaultPopUpDataList[j]);
  243. }
  244. } else {
  245. this.popupDataList.push(popupDataList[i]);
  246. }
  247. }
  248. } else {
  249. this.popupDataList = defaultPopUpDataList;
  250. console.log("[loadConfig] popupDataList 加载默认列表");
  251. }
  252. // console.log("[loadConfig] popupDataList:", this.popupDataList);
  253. this.pageReady = true;
  254. },
  255. getTeamList(teamNum) {
  256. var teamList = [];
  257. if (teamNum > 0) {
  258. for (let i = 0; i <= teamNum; i++) {
  259. teamList[i] = {};
  260. teamList[i].value = i;
  261. // teamList[i].text = `第 ${i+1} 队`;
  262. teamList[i].text = teamName[this.teamType][i];
  263. }
  264. }
  265. this.teamList = teamList;
  266. },
  267. fmtMcTime(timestamp) {
  268. return tools.fmtMcTime(timestamp);
  269. },
  270. // 获取倒计时
  271. getActtime() {
  272. this.acttime = tools.getActtime(this.beginSecond, 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. const url = '/pages/bm/style1/rankList?' + this.queryString;
  458. tools.appAction(url, "uni.navigateTo");
  459. }
  460. },
  461. fail: (err) => {
  462. console.log("onlineMcSignUp err", err)
  463. uni.showToast({
  464. title: '出错了,报名失败',
  465. icon: 'none',
  466. duration: 3000
  467. });
  468. },
  469. });
  470. },
  471. btnBack() {
  472. // console.log("from:", this.from)
  473. if (this.from != '') {
  474. // window.history.back();
  475. // uni.navigateTo({
  476. // url: '/pages/bm/style1/rankList?' + this.queryString
  477. // });
  478. const url = '/pages/bm/style1/rankList?' + this.queryString;
  479. tools.appAction(url, "uni.navigateTo");
  480. } else {
  481. const url = `action://to_home/`;
  482. tools.appAction(url);
  483. }
  484. },
  485. btnInfo() {
  486. this.$refs.mypopup.popupOpen();
  487. },
  488. orgChange(value, resetTeamNum = true) {
  489. // console.log("[orgChange] value:", value);
  490. if (resetTeamNum) {
  491. this.teamNum = 0;
  492. }
  493. if (value > 0) {
  494. const selectedOption = this.orgList.find(option => option.value === value);
  495. const teamNum = selectedOption.teamNum;
  496. // console.log("[orgChange] teamNum:", teamNum);
  497. this.getTeamList(teamNum);
  498. } else {
  499. this.getTeamList(0);
  500. }
  501. },
  502. btnSignup() {
  503. if (!checkToken(this.token)) {
  504. return;
  505. }
  506. if (!(this.coiId > 0)) {
  507. uni.showToast({
  508. title: '请选择组织名称',
  509. icon: 'none',
  510. duration: 2000
  511. });
  512. return;
  513. }
  514. // if ((this.teamList.length > 0) && !(this.teamNum > 0)) {
  515. // uni.showToast({
  516. // title: '请选择分组',
  517. // icon: 'none',
  518. // duration: 2000
  519. // });
  520. // return;
  521. // }
  522. this.coiName = tools.getSelectedText(this.orgList, this.coiId);
  523. this.teamName = tools.getSelectedText(this.teamList, this.teamNum);
  524. this.$refs.alertDialog.open();
  525. },
  526. dialogConfirm() {
  527. this.onlineMcSignUp();
  528. },
  529. dialogClose() {}
  530. }
  531. }
  532. </script>
  533. <style scoped>
  534. .content {
  535. width: 100vw;
  536. height: 100vh;
  537. }
  538. .top-default {
  539. width: 100%;
  540. /* height: 35vh; */
  541. height: 206px;
  542. padding-top: 36px;
  543. padding-bottom: 30px;
  544. justify-content: space-between;
  545. background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg, #f8a95a 0%, #d25f11 100%);
  546. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#7aedff 0%,#047200 100%); */
  547. /* background-image: url("/static/backgroud/top_colorbar.png"), linear-gradient(180deg,#178bff 0%,#004d9b 100%); */
  548. background-repeat: no-repeat;
  549. background-position: center, 0px 0px;
  550. background-size: auto 176px, cover;
  551. }
  552. .logo-default {
  553. width: 150px;
  554. height: 150px;
  555. margin-top: 10px;
  556. background-image: url('/static/logo/jbs.png');
  557. background-repeat: no-repeat;
  558. background-position-x: center;
  559. background-position-y: center;
  560. background-size: contain;
  561. }
  562. .topbar-color {
  563. color: white;
  564. }
  565. .toptime {
  566. /* width: 90%; */
  567. height: 65rpx;
  568. margin-top: 20rpx;
  569. padding: 0 36rpx;
  570. justify-content: space-evenly;
  571. background-color: white;
  572. border-radius: 40rpx;
  573. }
  574. .acttime {
  575. font-weight: 550;
  576. color: #333333;
  577. font-size: 30rpx;
  578. }
  579. .clock {
  580. width: 30rpx;
  581. height: 30rpx;
  582. margin-right: 20rpx;
  583. }
  584. .main {
  585. width: 76%;
  586. /* height: 500rpx; */
  587. margin-top: 80rpx;
  588. justify-content: space-around;
  589. }
  590. .select {
  591. margin-bottom: 36rpx;
  592. }
  593. .introduce {
  594. margin-top: 10rpx;
  595. margin-bottom: 80rpx;
  596. align-items: flex-start;
  597. justify-content: space-around;
  598. }
  599. .introduce-title {
  600. color: #333333;
  601. font-size: 30rpx;
  602. line-height: 60rpx;
  603. }
  604. .introduce-content {
  605. color: #333333;
  606. font-size: 25rpx;
  607. line-height: 46rpx;
  608. }
  609. .btnSignup {
  610. width: 100%;
  611. height: 100rpx;
  612. margin-bottom: 30rpx;
  613. color: white;
  614. font-weight: bold;
  615. line-height: 100rpx;
  616. border-radius: 55rpx;
  617. }
  618. .btnSignup-enable {
  619. background-color: #2e85ec;
  620. }
  621. .btnSignup-disable {
  622. background-color: #c3c3c3;
  623. }
  624. .dialog-content {
  625. width: 279px;
  626. height: 152px;
  627. background: #f1f1f1;
  628. border-radius: 9px;
  629. justify-content: center;
  630. text-align: center;
  631. font-weight: 550;
  632. color: #333333;
  633. }
  634. .dialog-content-1 {
  635. font-size: 40rpx;
  636. margin-bottom: 30rpx;
  637. }
  638. .dialog-content-2 {
  639. font-size: 32rpx;
  640. margin-bottom: 10rpx;
  641. }
  642. </style>