signup.vue 18 KB

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