collectInformation.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="collect-information">
  3. <step-register />
  4. <!-- 地区负责人信息 (づ ̄3 ̄)づ╭~ -->
  5. <view class="area-principal-information">
  6. <view class="information-title"> 地区负责人信息(承办人) </view>
  7. <view class="information-form">
  8. <view class="information-form-item">
  9. <view class="information-form-label">承办地区</view>
  10. <view class="information-form-filed">
  11. <view class="filed-input-view" @click="selectArea">
  12. <text
  13. :class="[
  14. form.district.startsWith('请')
  15. ? `placeholder-class`
  16. : 'select-after-text text-Ellipsis',
  17. ]"
  18. style="width: 438rpx"
  19. >
  20. {{ form.district }}
  21. </text>
  22. <van-icon name="arrow-down" />
  23. </view>
  24. </view>
  25. </view>
  26. <view class="information-form-item">
  27. <view class="information-form-label">详细地址 </view>
  28. <view class="information-form-filed">
  29. <input
  30. class="filed-input"
  31. placeholder="选填"
  32. placeholder-class="placeholder-class"
  33. :value="form.detailAddress"
  34. @input="(e) => changeForm(e, 'detailAddress')"
  35. />
  36. <image
  37. class="close-icon"
  38. :src="staticImg.closeIcon"
  39. v-if="form.detailAddress"
  40. @click="clearFormItem('detailAddress')"
  41. />
  42. </view>
  43. </view>
  44. <view class="information-form-item">
  45. <view class="information-form-label">承办单位</view>
  46. <view class="information-form-filed">
  47. <input
  48. class="filed-input"
  49. placeholder="请输入承办单位"
  50. placeholder-class="placeholder-class"
  51. :value="form.unit"
  52. @input="(e) => changeForm(e, 'unit')"
  53. />
  54. <image
  55. class="close-icon"
  56. :src="staticImg.closeIcon"
  57. v-if="form.unit"
  58. @click="clearFormItem('unit')"
  59. />
  60. </view>
  61. </view>
  62. <view class="information-form-item">
  63. <view class="information-form-label">承办人</view>
  64. <view class="information-form-filed">
  65. <input
  66. class="filed-input"
  67. placeholder="请输入承办人姓名"
  68. placeholder-class="placeholder-class"
  69. :value="form.unitPrincipal"
  70. @input="(e) => changeForm(e, 'unitPrincipal')"
  71. />
  72. <image
  73. class="close-icon"
  74. :src="staticImg.closeIcon"
  75. v-if="form.unitPrincipal"
  76. @click="clearFormItem('unitPrincipal')"
  77. />
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- 参赛园所信息 -->
  83. <view class="school-information" @click="handleGoSchoolInfo">
  84. <view class="information-title"> 参赛园所信息 </view>
  85. <view v-if="form.schoolList.length === 0" class="school-add-area">
  86. <view class="school-add-button">
  87. <image class="plus-icon" :src="staticImg.plusIcon" />
  88. <text>添加参赛园所</text>
  89. <image class="plus-arrow" :src="staticImg.arrow" />
  90. </view>
  91. </view>
  92. <view v-else class="school-have-area">
  93. <view class="school-add-button">
  94. <image class="plus-icon" :src="staticImg.plusIcon" />
  95. <text>参赛园所({{ form.schoolList.length }})</text>
  96. <image class="plus-arrow" :src="staticImg.arrow" />
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 预定物料包数量 -->
  101. <view class="pre-material-package">
  102. <view class="information-title pre-material-package-title">
  103. 预定物料包数量 <view class="tip">(50套起订) </view>
  104. </view>
  105. <view class="material-package-information">
  106. <view
  107. class="material-package-item"
  108. v-for="material in form.materialList"
  109. :key="material.materialName"
  110. >
  111. <view class="material-package-item-label">
  112. <van-checkbox
  113. :value="material.isShow"
  114. shape="square"
  115. @change="onChange(material.materialName)"
  116. >
  117. <view class="material-package-item-label-left">
  118. <view class="label-prefix">赛事标准物料包</view
  119. ><view class="clazz">({{ material.materialName }})</view>
  120. </view>
  121. </van-checkbox>
  122. </view>
  123. <view v-if="material.isShow" class="material-count">
  124. <input
  125. class="material-input"
  126. type="number"
  127. :min="50"
  128. :value="material.number"
  129. @change="changeMaterialNumber(material, $event.target.value)"
  130. />
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. <step-tabbar
  136. :totalSchool="totalSchool"
  137. :totalPeople="totalPeople"
  138. :submitIsShow="submitIsShow"
  139. @handleSubmit="submitAgentRegister"
  140. />
  141. <!-- 地区选择 -->
  142. <van-action-sheet
  143. class="area-picker"
  144. :show="showAreaPicker"
  145. @click-overlay="showAreaPicker = false"
  146. >
  147. <van-area
  148. :area-list="areaList"
  149. :value="code"
  150. @confirm="confirmArea"
  151. @cancel="cancelArea"
  152. />
  153. </van-action-sheet>
  154. <!-- 提交成功弹窗 -->
  155. <van-overlay :show="show" @click="handleReturnHome">
  156. <view class="wrapper" @click.stop>
  157. <view class="block">
  158. <image
  159. :src="staticImg.closeBtn"
  160. class="closeBtn"
  161. @click="handleReturnHome"
  162. />
  163. <image :src="staticImg.submitSucess" class="submitSucess" />
  164. <view class="promptText">参与信息提交完成!</view>
  165. <view class="returnHome" @click="handleReturnHome">返回首页</view>
  166. </view>
  167. </view>
  168. </van-overlay>
  169. </view>
  170. </template>
  171. <script>
  172. import {
  173. submitAgentRegister,
  174. getAgentRegisterLastInfo,
  175. } from "@/api/competition.js";
  176. import StepRegister from "./component/step-register.vue";
  177. import StepTabbar from "./component/step-tabbar.vue";
  178. import { areaList } from "@vant/area-data";
  179. import Tip from "@/utils/tip.js";
  180. const staticImg = {
  181. closeIcon: require("@/static/competitionRegister/common/close-icon.png"),
  182. plusIcon: require("@/static/competitionRegister/common/plus-icon.png"),
  183. submitSucess: require("@/static/competitionRegister/common/submitSucess.png"),
  184. closeBtn: require("@/static/competitionRegister/common/closeBtn.png"),
  185. arrow: require("@/static/competitionRegister/common/arrow.png"),
  186. };
  187. export default {
  188. name: "collect-information",
  189. components: {
  190. StepRegister,
  191. StepTabbar,
  192. },
  193. data() {
  194. return {
  195. show: false, // 提交成功弹窗
  196. showAreaPicker: false,
  197. staticImg,
  198. areaList: Object.freeze(areaList),
  199. form: {
  200. competitionChildId: "",
  201. district: "请选择所在地区",
  202. detailAddress: "",
  203. unit: "",
  204. unitPrincipal: "",
  205. materialList: [
  206. { id: 1, materialName: "小班", number: 0, isShow: true },
  207. { id: 2, materialName: "中班", number: 0, isShow: true },
  208. { id: 3, materialName: "大班", number: 0, isShow: true },
  209. ],
  210. schoolList: [],
  211. },
  212. };
  213. },
  214. computed: {
  215. submitIsShow() {
  216. let state = false;
  217. if (
  218. this.form.district !== "请选择所在地区" &&
  219. this.form.unit !== "" &&
  220. this.form.unitPrincipal !== "" &&
  221. this.form.schoolList.length !== 0
  222. ) {
  223. state = true;
  224. }
  225. return state;
  226. },
  227. totalSchool() {
  228. return this.form.schoolList.length || 0;
  229. },
  230. totalPeople() {
  231. let count = 0;
  232. this.form.schoolList.forEach((item) => {
  233. count += item.totalPerson * 1;
  234. });
  235. return count;
  236. },
  237. },
  238. onLoad(options) {
  239. if (options && options.competitionId) {
  240. this.form.competitionChildId = options.competitionId;
  241. }
  242. },
  243. async onReady() {
  244. await this.getAgentRegisterLastInfo();
  245. },
  246. onShow() {
  247. uni.getStorage({
  248. key: "formData",
  249. success: (res) => {
  250. console.log("success", res.data);
  251. this.form = res.data;
  252. },
  253. fail: (res) => {
  254. console.log(res, "fail");
  255. },
  256. });
  257. },
  258. methods: {
  259. // 查询上一次报名基本信息
  260. async getAgentRegisterLastInfo() {
  261. const { data, msg, status } = await getAgentRegisterLastInfo();
  262. if (status === 200 && data) {
  263. // console.log(data, "getAgentRegisterLastInfo");
  264. const obj = {
  265. district: data.district,
  266. unit: data.unit,
  267. unitPrincipal: data.unitPrincipal,
  268. detailAddress: data.detailAddress,
  269. };
  270. Object.assign(this.form, obj);
  271. // console.log(this.form, "form");
  272. }
  273. },
  274. changeMaterialNumber(key, value) {
  275. key.number = value;
  276. this.$forceUpdate();
  277. },
  278. // 去添加园所
  279. handleGoSchoolInfo() {
  280. uni.setStorage({
  281. key: "formData",
  282. data: this.form,
  283. success: () => {
  284. console.log("form保存成功");
  285. },
  286. });
  287. uni.redirectTo({
  288. url: `/pages/competitionRegister/addSchool`,
  289. });
  290. },
  291. // 预料包数量小于50时,强制改成50 @blur="handleInputBlur(material, $event.target.value)"
  292. // handleInputBlur(material, value) {
  293. // if (value * 1 < 50) {
  294. // // this.$set(this.form.materialList[material.id - 1], "number", 50);
  295. // this.form.materialList[material.id - 1].number = 50;
  296. // this.form.materialList[material.id - 1].isShow = false;
  297. // this.$nextTick(() => {
  298. // this.form.materialList[material.id - 1].isShow = true;
  299. // });
  300. // }
  301. // },
  302. // 返回首页
  303. handleReturnHome() {
  304. uni.reLaunch({
  305. url: "/pages/user/index",
  306. });
  307. this.show = false;
  308. },
  309. onChange(val) {
  310. this.form.materialList.forEach((item) => {
  311. if (item.materialName === val) item.isShow = !item.isShow;
  312. });
  313. },
  314. beforeSubmit() {
  315. let total = 0;
  316. this.form.materialList.map((item) => {
  317. if (item.isShow) total += item.number * 1;
  318. });
  319. if (total < 50) {
  320. Tip.error("预定物料包数量总和不得低于50套");
  321. return false;
  322. } else {
  323. return true;
  324. }
  325. },
  326. // 提交海选报名
  327. async submitAgentRegister() {
  328. if (!this.beforeSubmit()) return;
  329. const materialList = this.form.materialList.filter((item) => {
  330. if (item.isShow) {
  331. return item;
  332. }
  333. });
  334. const params = {
  335. ...this.form,
  336. materialList,
  337. };
  338. const { data, msg, status } = await submitAgentRegister(params);
  339. if (status === 200) {
  340. this.show = true;
  341. uni.removeStorage({
  342. key: "formData",
  343. success: function(res) {
  344. console.log("已经移除内存中的schoolList");
  345. },
  346. });
  347. } else {
  348. Tip.error(msg);
  349. }
  350. },
  351. // 清空表单项
  352. clearFormItem(key) {
  353. this.form[key] = "";
  354. },
  355. // 改变表单项
  356. changeForm(e, key) {
  357. console.log(e, key);
  358. const value = e.detail.value;
  359. this.form[key] = value;
  360. },
  361. // 取消地区
  362. cancelArea() {
  363. this.showAreaPicker = false;
  364. },
  365. // 确认地区
  366. confirmArea(e) {
  367. const { values } = e.detail;
  368. this.form.district = values.map((item) => item.name).join(",");
  369. this.showAreaPicker = false;
  370. },
  371. // 选择地区
  372. selectArea() {
  373. this.showAreaPicker = !this.showAreaPicker;
  374. },
  375. },
  376. };
  377. </script>
  378. <style lang="less" scoped>
  379. @import "@/utils/utils.less";
  380. .collect-information {
  381. padding-bottom: 200rpx;
  382. .area-principal-information {
  383. padding: 0 32rpx;
  384. box-sizing: border-box;
  385. margin-top: 50rpx;
  386. .information-form {
  387. .information-form-item {
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. margin-bottom: 28rpx;
  392. .information-form-label {
  393. font-size: 30rpx;
  394. font-family: PingFangSC-Medium, PingFang SC;
  395. font-weight: 500;
  396. color: #666666;
  397. }
  398. .information-form-filed {
  399. width: 530rpx;
  400. height: 88rpx;
  401. background: #ffffff;
  402. box-shadow: 0rpx 0rpx 44rpx 0rpx rgba(226, 226, 226, 0.58);
  403. border-radius: 20rpx;
  404. padding-left: 32rpx;
  405. padding-right: 32rpx;
  406. box-sizing: border-box;
  407. display: flex;
  408. justify-content: space-between;
  409. align-items: center;
  410. .filed-input-view {
  411. height: 88rpx;
  412. box-sizing: border-box;
  413. display: flex;
  414. align-items: center;
  415. justify-content: space-between;
  416. padding-right: 28rpx;
  417. box-sizing: border-box;
  418. }
  419. .filed-input {
  420. width: 408rpx;
  421. height: 88rpx;
  422. }
  423. .close-icon {
  424. width: 26rpx;
  425. height: 28rpx;
  426. display: block;
  427. }
  428. .placeholder-class {
  429. font-size: 30rpx;
  430. font-family: PingFangSC-Regular, PingFang SC;
  431. font-weight: 400;
  432. color: #d1d1d1;
  433. }
  434. .select-after-text {
  435. font-size: 30rpx;
  436. font-family: PingFangSC-Medium, PingFang SC;
  437. font-weight: 500;
  438. color: #333333;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. .school-information {
  445. padding: 0 32rpx;
  446. box-sizing: border-box;
  447. margin-top: 60rpx;
  448. .school-add-area {
  449. .school-add-button {
  450. width: 686rpx;
  451. height: 108rpx;
  452. border-radius: 20rpx;
  453. border: 4rpx dashed rgba(0, 91, 255, 0.3);
  454. display: flex;
  455. justify-content: center;
  456. align-items: center;
  457. .plus-icon {
  458. width: 42rpx;
  459. height: 40rpx;
  460. object-fit: cover;
  461. }
  462. .plus-arrow {
  463. width: 18rpx;
  464. height: 28rpx;
  465. object-fit: cover;
  466. }
  467. text {
  468. margin-left: 20rpx;
  469. margin-right: 10rpx;
  470. height: 34rpx;
  471. line-height: 34rpx;
  472. font-size: 34rpx;
  473. font-family: PingFangSC-Regular, PingFang SC;
  474. font-weight: 400;
  475. color: #4679ff;
  476. }
  477. }
  478. }
  479. .school-have-area {
  480. .school-add-button {
  481. width: 686rpx;
  482. height: 108rpx;
  483. border-radius: 20rpx;
  484. background: #ffffff;
  485. box-shadow: 0px 0px 22px 0px rgba(226, 226, 226, 0.58);
  486. display: flex;
  487. justify-content: center;
  488. align-items: center;
  489. .plus-icon {
  490. width: 42rpx;
  491. height: 40rpx;
  492. object-fit: cover;
  493. }
  494. .plus-arrow {
  495. width: 18rpx;
  496. height: 28rpx;
  497. object-fit: cover;
  498. }
  499. text {
  500. margin-left: 22rpx;
  501. height: 34rpx;
  502. line-height: 34rpx;
  503. font-size: 34rpx;
  504. font-family: PingFangSC-Regular, PingFang SC;
  505. font-weight: 400;
  506. color: #4679ff;
  507. }
  508. }
  509. }
  510. }
  511. .pre-material-package {
  512. margin-top: 60rpx;
  513. padding: 0 32rpx;
  514. box-sizing: border-box;
  515. .pre-material-package-title {
  516. width: 100%;
  517. height: 56rpx;
  518. display: flex;
  519. align-items: center;
  520. .tip {
  521. font-size: 30rpx;
  522. font-family: PingFangSC-Regular, PingFang SC;
  523. font-weight: 400;
  524. color: #fe6573;
  525. }
  526. }
  527. .material-package-information {
  528. width: 686rpx;
  529. height: 300rpx;
  530. background: #ffffff;
  531. box-shadow: 0rpx 0rpx 44rpx 0rpx rgba(226, 226, 226, 0.58);
  532. border-radius: 20rpx;
  533. padding: 34rpx 30rpx;
  534. box-sizing: border-box;
  535. .material-package-item {
  536. display: flex;
  537. justify-content: space-between;
  538. align-items: center;
  539. margin-bottom: 20rpx;
  540. height: 64rpx;
  541. .material-package-item-label {
  542. display: flex;
  543. .material-package-item-label-left {
  544. display: flex;
  545. font-size: 28rpx;
  546. font-family: PingFangSC-Medium, PingFang SC;
  547. font-weight: 500;
  548. color: #666666;
  549. .label-prefix {
  550. color: #666;
  551. margin-right: 10rpx;
  552. }
  553. .clazz {
  554. color: #5f87f0;
  555. }
  556. }
  557. }
  558. .material-count {
  559. display: flex;
  560. align-items: center;
  561. .material-input {
  562. width: 120rpx;
  563. height: 64rpx;
  564. border-radius: 10rpx;
  565. border: 2rpx solid #e3e3e3;
  566. margin-right: 14rpx;
  567. text-align: center;
  568. }
  569. }
  570. }
  571. }
  572. }
  573. .information-title {
  574. font-size: 44rpx;
  575. font-family: PingFangSC-Semibold, PingFang SC;
  576. font-weight: 600;
  577. color: #333333;
  578. margin-bottom: 40rpx;
  579. }
  580. .area-picker {
  581. width: 100vw;
  582. }
  583. }
  584. .wrapper {
  585. display: flex;
  586. align-items: center;
  587. justify-content: center;
  588. height: 100vh;
  589. }
  590. .block {
  591. display: flex;
  592. flex-direction: column;
  593. justify-content: center;
  594. align-items: center;
  595. position: relative;
  596. margin-top: -100rpx;
  597. width: 686rpx;
  598. height: 576rpx;
  599. background: #ffffff;
  600. border-radius: 20rpx;
  601. .closeBtn {
  602. position: absolute;
  603. top: 40rpx;
  604. right: 40rpx;
  605. width: 24rpx;
  606. height: 24rpx;
  607. object-fit: cover;
  608. }
  609. .submitSucess {
  610. width: 334rpx;
  611. height: 336rpx;
  612. object-fit: cover;
  613. }
  614. .promptText {
  615. width: 234rpx;
  616. height: 36rpx;
  617. font-size: 26rpx;
  618. font-family: PingFangSC-Regular, PingFang SC;
  619. font-weight: 400;
  620. color: #333333;
  621. line-height: 36rpx;
  622. }
  623. .returnHome {
  624. margin-top: 32rpx;
  625. width: 278rpx;
  626. height: 90rpx;
  627. line-height: 90rpx;
  628. font-size: 32rpx;
  629. font-family: PingFangSC-Medium, PingFang SC;
  630. font-weight: 500;
  631. color: #ffffff;
  632. background: linear-gradient(130deg, #466efc 0%, #84bdfc 100%);
  633. border-radius: 84rpx;
  634. text-align: center;
  635. }
  636. }
  637. </style>