preRegister.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <meta name="format-detection" content="telephone=no">
  9. <meta name="mobile-web-app-capable" content="yes">
  10. <meta name="msapplication-tap-highlight" content="no">
  11. <meta name="fragment" content="!">
  12. <meta name="viewport"
  13. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover">
  14. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  15. <meta http-equiv="Pragma" content="no-cache" />
  16. <meta http-equiv="Expires" content="0" />
  17. <meta http-equiv="Cache" content="no-cache">
  18. <meta name="description" content="">
  19. <link rel="icon" href="../favicon.ico">
  20. <title>乐团预报名</title>
  21. <!-- 引入样式文件 -->
  22. <link rel="stylesheet" href="./js/vant-index.css" />
  23. <link rel="stylesheet" href="./css/preRegister.css">
  24. <script src="./js/flexible.js"></script>
  25. </head>
  26. <body>
  27. <style>
  28. .m-toast {
  29. position: fixed;
  30. top: 50%;
  31. left: 50%;
  32. display: -webkit-box;
  33. display: -webkit-flex;
  34. display: flex;
  35. -webkit-box-orient: vertical;
  36. -webkit-box-direction: normal;
  37. -webkit-flex-direction: column;
  38. flex-direction: column;
  39. -webkit-box-align: center;
  40. -webkit-align-items: center;
  41. align-items: center;
  42. -webkit-box-pack: center;
  43. -webkit-justify-content: center;
  44. justify-content: center;
  45. box-sizing: content-box;
  46. width: 88px;
  47. max-width: 70%;
  48. min-height: 88px;
  49. padding: 16px;
  50. color: #fff;
  51. font-size: 14px;
  52. line-height: 20px;
  53. white-space: pre-wrap;
  54. text-align: center;
  55. word-wrap: break-word;
  56. background-color: rgba(50, 50, 51, 0.88);
  57. border-radius: 4px;
  58. -webkit-transform: translate3d(-50%, -50%, 0);
  59. transform: translate3d(-50%, -50%, 0);
  60. z-index: 2002
  61. }
  62. .m-loading {
  63. position: relative;
  64. color: #fff;
  65. font-size: 0;
  66. vertical-align: middle;
  67. padding: 4px
  68. }
  69. .m-loading__spinner {
  70. position: relative;
  71. display: inline-block;
  72. width: 30px;
  73. max-width: 100%;
  74. height: 30px;
  75. max-height: 100%;
  76. vertical-align: middle;
  77. -webkit-animation: m-rotate .8s linear infinite;
  78. animation: m-rotate .8s linear infinite
  79. }
  80. .m-loading__spinner--circular {
  81. -webkit-animation-duration: 2s;
  82. animation-duration: 2s
  83. }
  84. .m-loading__circular {
  85. display: block;
  86. width: 100%;
  87. height: 100%
  88. }
  89. .m-loading__circular circle {
  90. -webkit-animation: m-circular 1.5s ease-in-out infinite;
  91. animation: m-circular 1.5s ease-in-out infinite;
  92. stroke: currentColor;
  93. stroke-width: 3;
  94. stroke-linecap: round
  95. }
  96. .m-loading__text {
  97. display: inline-block;
  98. margin-left: 8px;
  99. color: #969799;
  100. font-size: 14px;
  101. vertical-align: middle
  102. }
  103. .m-loading--vertical {
  104. display: -webkit-box;
  105. display: -webkit-flex;
  106. display: flex;
  107. -webkit-box-orient: vertical;
  108. -webkit-box-direction: normal;
  109. -webkit-flex-direction: column;
  110. flex-direction: column;
  111. -webkit-box-align: center;
  112. -webkit-align-items: center;
  113. align-items: center
  114. }
  115. .m-loading--vertical .m-loading__text {
  116. margin: 8px 0 0
  117. }
  118. @-webkit-keyframes m-circular {
  119. 0% {
  120. stroke-dasharray: 1, 200;
  121. stroke-dashoffset: 0
  122. }
  123. 50% {
  124. stroke-dasharray: 90, 150;
  125. stroke-dashoffset: -40
  126. }
  127. 100% {
  128. stroke-dasharray: 90, 150;
  129. stroke-dashoffset: -120
  130. }
  131. }
  132. @keyframes m-circular {
  133. 0% {
  134. stroke-dasharray: 1, 200;
  135. stroke-dashoffset: 0
  136. }
  137. 50% {
  138. stroke-dasharray: 90, 150;
  139. stroke-dashoffset: -40
  140. }
  141. 100% {
  142. stroke-dasharray: 90, 150;
  143. stroke-dashoffset: -120
  144. }
  145. }
  146. .m-toast__text {
  147. margin-top: 8px
  148. }
  149. .van-field--error .van-field__control,
  150. .van-field--error .van-field__control::placeholder {
  151. color: #c8c9cc;
  152. -webkit-text-fill-color: currentColor;
  153. }
  154. </style>
  155. <div id="m_loading" class="m-toast m-toast--middle m-toast--loading" style="z-index: 2001;">
  156. <div class="m-loading m-loading--circular m-toast__loading"><span
  157. class="m-loading__spinner m-loading__spinner--circular"><svg viewBox="25 25 50 50" class="m-loading__circular">
  158. <circle cx="50" cy="50" r="20" fill="none"></circle>
  159. </svg></span></div>
  160. <div class="m-toast__text">加载中...</div>
  161. </div>
  162. <div id="app">
  163. <!-- <div class="banner">
  164. <img src="./images/initiation/banner.png" alt="">
  165. </div> -->
  166. <div class="title">
  167. {{ orchestraName }} 首轮报名
  168. </div>
  169. <van-form validate-first scroll-to-error @submit="onSubmit" ref='form' class="form">
  170. <div class="top-tips">科学的教育与关爱,足以改变世界。我们希望,学生的未来会因您和我们的共同努力而更加光辉灿烂!</div>
  171. <van-cell-group inset class="cell-group">
  172. <van-field type="tel" @blur='checkchangePhone' maxlength="11" minlength="11" label="联系电话(直接监护人)"
  173. v-model="stu.phone" name="phone" :rules="[{ pattern, message: '输入监护人手机号码有误' }]" placeholder="请输入监护人手机号码">
  174. </van-field>
  175. <van-field label="学员姓名" :rules="[{ validator, message }]" name="username" v-model="stu.username"
  176. placeholder="请填写学员真实姓名"></van-field>
  177. <van-field label="性别" name="sex" :rules="[{ required: true, message: '请选择性别' }]">
  178. <template #input>
  179. <van-radio-group v-model="stu.sex" checked-color="#9A64FF" direction="horizontal">
  180. <van-tag size="large" type="primary" :color="!(stu.sex === 1) ? '#EAEAEA' : '#64A9FF'"
  181. :text-color="!(stu.sex === 1) ? '#AAA' : '#FFF'" class="radioSection" round>
  182. <van-radio class="radioItem" :name="1"></van-radio>男生
  183. </van-tag>
  184. <van-tag size="large" type="primary" :color="!(stu.sex === 0) ? '#EAEAEA' : '#64A9FF'"
  185. :text-color="!(stu.sex === 0) ? '#AAA' : '#FFF'" class="radioSection" round>
  186. <van-radio class="radioItem" :name="0"></van-radio>女生
  187. </van-tag>
  188. </van-radio-group>
  189. </template>
  190. </van-field>
  191. <van-field label="在读年级" v-model="stu.currentGrade" readonly name="currentGrade"
  192. :rules="[{ required: true, message: '请选择在读年级', trigger: 'onChange' }]" @click="pickerChange"
  193. placeholder="请选择在读年级">
  194. <template #right-icon>
  195. <van-icon name="arrow" :color="checkPhone ? '#aaa' : '#323233'" size="16"></van-icon>
  196. </template>
  197. </van-field>
  198. <van-field label="所在班级" v-model="stu.currentClass" readonly name="currentClass"
  199. :rules="[{ required: true, message: '请选择所在班级', trigger: 'onChange' }]" @click="pickerChange1"
  200. placeholder="请选择所在班级">
  201. <template #right-icon>
  202. <van-icon name="arrow" :color="checkPhone ? '#aaa' : '#323233'" size="16"></van-icon>
  203. </template>
  204. </van-field>
  205. </van-cell-group>
  206. <van-cell-group inset class="cell-group">
  207. <van-field label="选报声部" v-model="stu.registerSubjectId" readonly name="registerSubjectId"
  208. :rules="[{ required: true, message: '请选择选报声部', trigger: 'onChange' }]" @click="pickerChange2"
  209. placeholder="请选择选报声部">
  210. <template #right-icon>
  211. <van-icon name="arrow" :color="checkPhone ? '#aaa' : '#323233'" size="16"></van-icon>
  212. </template>
  213. </van-field>
  214. <van-field label="乐器准备方式" name="instrumentsPrepareMode" :rules="[{ required: true, message: '请选择乐器准备方式' }]">
  215. <template #input>
  216. <van-radio-group v-model="stu.instrumentsPrepareMode" checked-color="#9A64FF" direction="horizontal">
  217. <van-tag size="large" type="primary"
  218. :color="!(stu.instrumentsPrepareMode === 'GROUP_PURCHASE') ? '#EAEAEA' : '#64A9FF'"
  219. :text-color="!(stu.instrumentsPrepareMode === 'GROUP_PURCHASE') ? '#AAA' : '#FFF'" class="radioSection"
  220. round>
  221. <van-radio class="radioItem" name="GROUP_PURCHASE"></van-radio>团购
  222. </van-tag>
  223. <van-tag size="large" type="primary"
  224. :color="!(stu.instrumentsPrepareMode === 'ONESELF') ? '#EAEAEA' : '#64A9FF'"
  225. :text-color="!(stu.instrumentsPrepareMode === 'ONESELF') ? '#AAA' : '#FFF'" class="radioSection" round>
  226. <van-radio class="radioItem" name="ONESELF"></van-radio>自备
  227. </van-tag>
  228. </van-radio-group>
  229. </template>
  230. </van-field>
  231. <van-field label="乐团学习系统准备方式" name="learningSystemPrepareMode"
  232. :rules="[{ required: true, message: '请选择乐团学习系统准备方式' }]">
  233. <template #input>
  234. <van-radio-group v-model="stu.learningSystemPrepareMode" checked-color="#9A64FF" direction="horizontal">
  235. <!-- :color="checkPhone ? '#ccc': '#9A64FF'" -->
  236. <van-tag size="large" type="primary"
  237. :color="!(stu.learningSystemPrepareMode === 'GROUP_PURCHASE') ? '#EAEAEA' : '#64A9FF'"
  238. :text-color="!(stu.learningSystemPrepareMode === 'GROUP_PURCHASE') ? '#AAA' : '#FFF'"
  239. class="radioSection" round>
  240. <van-radio class="radioItem" name="GROUP_PURCHASE"></van-radio>团购
  241. </van-tag>
  242. <van-tag size="large" type="primary"
  243. :color="!(stu.learningSystemPrepareMode === 'ONESELF') ? '#EAEAEA' : '#64A9FF'"
  244. :text-color="!(stu.learningSystemPrepareMode === 'ONESELF') ? '#AAA' : '#FFF'"
  245. :color="checkPhone ? '#ccc': '#9A64FF'" class="radioSection" round>
  246. <van-radio class="radioItem" name="ONESELF"></van-radio>自备
  247. </van-tag>
  248. </van-radio-group>
  249. </template>
  250. </van-field>
  251. </van-cell-group>
  252. <van-button size="large" block round class="btn-submit" color="#9A64FF" :loading="btnLoading"
  253. native-type="submit">提交</van-button>
  254. </van-form>
  255. <van-popup v-model:show="showPicker" position="bottom" round>
  256. <van-picker show-toolbar :columns="currentGrade" @cancel="showPicker = false" @confirm="onConfirm" />
  257. </van-popup>
  258. <van-popup v-model:show="classPicker" position="bottom" round>
  259. <van-picker show-toolbar :columns="classList" @cancel="classPicker = false" @confirm="onConfirmClass" />
  260. </van-popup>
  261. <van-popup v-model:show="subjectPicker" position="bottom" round>
  262. <van-picker show-toolbar :columns="subjectList" @cancel="subjectPicker = false" @confirm="onConfirmSubject" />
  263. </van-popup>
  264. <van-popup v-model:show="submitStatus" round style="width: 100%;background-color: transparent;"
  265. :close-on-click-overlay="false">
  266. <div class="submit-container">
  267. <p class="submit-title">提交成功</p>
  268. <p class="submit-tips">您已完成乐团报名</p>
  269. <div @click="onLinkUrl" class="submit-btn"></div>
  270. </div>
  271. </van-popup>
  272. </div>
  273. <!-- 引入 Vue 和 Vant 的 JS 文件 -->
  274. <script src="./js/vue.global.min.js"></script>
  275. <script src="./js/vant.min.js"></script>
  276. <!-- <script src="https://cdn.jsdelivr.net/npm/umi-request@1.4.0/dist/index.min.js"></script> -->
  277. <script src="./js/axios.js"></script>
  278. <script type="text/javascript" src="./js/utils.js"></script>
  279. <script>
  280. // 乐团交付,乐团停止或关闭,有新的交付团;则不允许报名
  281. var classList = []
  282. for (var i = 1; i <= 40; i++) {
  283. classList.push({ text: i + '班', value: i })
  284. }
  285. var app = Vue.createApp({
  286. data() {
  287. return {
  288. orchestraId: getQueryVariable('orchestraId'),
  289. orchestraName: null,
  290. schoolId: null,
  291. showPicker: false,
  292. classPicker: false,
  293. subjectPicker: false,
  294. submitStatus: false,
  295. pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
  296. nameReg: /^[\u4E00-\u9FA5]+$/,
  297. currentGrade: [
  298. { text: '一年级', value: 1 },
  299. { text: '二年级', value: 2 },
  300. { text: '三年级', value: 3 },
  301. { text: '四年级', value: 4 },
  302. { text: '五年级', value: 5 },
  303. ], // 年级数组列表
  304. classList: classList,
  305. subjectList: [],
  306. columns: [],
  307. pickerType: null, // 下拉类型
  308. stu: {
  309. username: null, // 姓名
  310. sex: 1, // 性别
  311. phone: null, // 电话
  312. currentGrade: '', // 年级
  313. currentGradeNum: null, // 年级编号
  314. currentClass: '', // 班级
  315. currentClassNum: null, // 年级编号
  316. registerSubjectId: '',
  317. registerSubjectNum: null, // 所在声部
  318. instrumentsPrepareMode: null,
  319. learningSystemPrepareMode: null,
  320. },
  321. btnLoading: false,
  322. checkPhone: true
  323. }
  324. },
  325. async mounted() {
  326. if (document.querySelector('#m_loading')) {
  327. document.querySelector('#m_loading').remove()
  328. }
  329. if (!this.orchestraId) {
  330. vant.showToast('信息获取失败,请联系老师')
  331. }
  332. try {
  333. this.setLoading(true)
  334. var schoolDetail = await axios.post('/api-student/open/school/detail', {
  335. orchestraId: this.orchestraId
  336. })
  337. console.log(schoolDetail)
  338. if (schoolDetail.data.code === 200) {
  339. var schoolSystem = schoolDetail.data.data.schoolSystem || 'sixYearSystem'
  340. this.schoolId = schoolDetail.data.data.id
  341. if (schoolSystem === 'sixYearSystem') {
  342. this.currentGrade.push({ text: '六年级', value: 6 })
  343. }
  344. }
  345. var orchestraDetail = await axios.get('/api-student/open/orchestra/detail/' + this.orchestraId)
  346. if (orchestraDetail.data.code === 200) {
  347. this.orchestraName = orchestraDetail.data.data.name || ''
  348. }
  349. var subjects = await axios.post('/api-student/open/orchestraSubjectConfig/pageByOrchestraId', {
  350. orchestraId: this.orchestraId,
  351. page: 1,
  352. rows: 100
  353. })
  354. if (subjects.data.code === 200) {
  355. var rows = subjects.data.data.rows || []
  356. // console.log(rows, 'rows')
  357. rows.forEach(item => {
  358. this.subjectList.push({
  359. text: item.name,
  360. value: item.subjectId
  361. })
  362. })
  363. }
  364. } catch {
  365. vant.showDialog({
  366. message: '信息获取失败,请联系老师',
  367. theme: 'round-button',
  368. confirmButtonColor: '#9A64FF'
  369. })
  370. }
  371. this.setLoading(false)
  372. },
  373. methods: {
  374. onLinkUrl() {
  375. this.submitStatus = false
  376. window.location.href = window.location.origin + '/orchestra-student/#/download'
  377. },
  378. async checkchangePhone(val) {
  379. try {
  380. await this.$refs.form.validate('phone')
  381. this.checkPhone = false
  382. // 查询老数据
  383. let tempValues = {}
  384. this.setLoading(true)
  385. tempValues.orchestraId = this.orchestraId
  386. tempValues.phone = this.stu.phone
  387. // 先从预报名中取数据
  388. var preRegister = await axios.get('/api-student/open/orchestraPreRegister/detailByPhone', {
  389. params: {
  390. ...tempValues
  391. }
  392. })
  393. if (preRegister.data.code === 200 && preRegister.data.data) {
  394. var detail = preRegister.data.data
  395. var grade = this.currentGrade.find(item => item.value == detail.currentGrade)
  396. var cls = this.classList.find(item => item.value == detail.currentClass)
  397. var subjects = this.subjectList.find(item => item.value == detail.registerSubjectId)
  398. this.stu = {
  399. username: detail.username, // 姓名
  400. sex: detail.sex ? 1 : 0, // 性别
  401. phone: detail.phone, // 电话
  402. currentGrade: grade.text, // 年级
  403. currentGradeNum: detail.currentGrade, // 年级编号
  404. currentClass: cls.text, // 班级
  405. currentClassNum: detail.currentClass, // 年级编号
  406. registerSubjectId: subjects.text, //
  407. registerSubjectNum: detail.registerSubjectId, //
  408. instrumentsPrepareMode: detail.instrumentsPrepareMode,
  409. learningSystemPrepareMode: detail.learningSystemPrepareMode,
  410. }
  411. this.setLoading(false)
  412. return
  413. }
  414. // 如果预报名中没有数据,则从启蒙报名中取数据
  415. var userDetail = await axios.get('/api-student/open/orchestraInitiationSurvey/detailByPhone', {
  416. params: {
  417. ...tempValues
  418. }
  419. })
  420. if (userDetail.data.code === 200 && userDetail.data.data) {
  421. var detail = userDetail.data.data
  422. var grade = this.currentGrade.find(item => item.value == detail.currentGrade)
  423. var cls = this.classList.find(item => item.value == detail.currentClass)
  424. this.stu = {
  425. username: detail.username, // 姓名
  426. sex: detail.sex ? 1 : 0, // 性别
  427. phone: detail.phone, // 电话
  428. currentGrade: grade.text, // 年级
  429. currentGradeNum: detail.currentGrade, // 年级编号
  430. currentClass: cls.text, // 班级
  431. currentClassNum: detail.currentClass, // 年级编号
  432. }
  433. }
  434. } catch { }
  435. this.setLoading(false)
  436. },
  437. validator(val) {
  438. // 校验函数返回 true 表示校验通过,false 表示不通过
  439. return this.nameReg.test(val) && (val.length >= 2 && val.length <= 15);
  440. },
  441. message(value) {
  442. if (!value) {
  443. return '请填写学员真实姓名'
  444. } else if (!this.nameReg.test(value)) {
  445. return '学员姓名必须为中文'
  446. } else if (value.length < 2 || value.length > 15) {
  447. return '学员姓名必须为2~15个字'
  448. }
  449. },
  450. async onSubmit() {
  451. this.btnLoading = true
  452. try {
  453. var stu = this.stu
  454. var res = await axios.post('/api-student/open/orchestraPreRegister/save', {
  455. orchestraId: this.orchestraId,
  456. schoolId: this.schoolId,
  457. ...stu,
  458. currentClass: stu.currentClassNum,
  459. currentGrade: stu.currentGradeNum,
  460. registerSubjectId: stu.registerSubjectNum
  461. })
  462. if (res.data.code === 200) {
  463. this.submitStatus = true
  464. } else {
  465. vant.showToast(res.data.message)
  466. }
  467. } catch {
  468. // vant.showToast('保存失败,请重试')
  469. }
  470. this.btnLoading = false
  471. },
  472. setLoading(status) {
  473. if (status) {
  474. vant.showLoadingToast({
  475. duration: 0, // 持续展示 toast
  476. message: '加载中...',
  477. forbidClick: true,
  478. loadingType: 'spinner',
  479. })
  480. } else {
  481. vant.closeToast()
  482. }
  483. },
  484. pickerChange(type) {
  485. if (this.checkPhone) return
  486. this.showPicker = true
  487. },
  488. pickerChange1(type) {
  489. if (this.checkPhone) return
  490. this.classPicker = true
  491. },
  492. pickerChange2(type) {
  493. if (this.checkPhone) return
  494. this.subjectPicker = true
  495. },
  496. onConfirm(options) {
  497. var stu = this.stu
  498. stu.currentGrade = options.selectedOptions[0].text
  499. stu.currentGradeNum = options.selectedOptions[0].value
  500. this.showPicker = false
  501. },
  502. onConfirmClass(options) {
  503. var stu = this.stu
  504. stu.currentClass = options.selectedOptions[0].text
  505. stu.currentClassNum = options.selectedOptions[0].value
  506. this.classPicker = false
  507. },
  508. onConfirmSubject(options) {
  509. var stu = this.stu
  510. stu.registerSubjectId = options.selectedOptions[0].text
  511. stu.registerSubjectNum = options.selectedOptions[0].value
  512. this.subjectPicker = false
  513. }
  514. }
  515. })
  516. app.use(vant)
  517. app.mount('#app')
  518. </script>
  519. </body>
  520. </html>