register.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div class="register">
  3. <header>报名</header>
  4. <div class="banner">
  5. <img src="../assets/register_banner.png" alt="">
  6. </div>
  7. <div class="reg-title">
  8. <i class="icon card_icon"></i> 请填写学生信息 <span>(必填)</span>
  9. </div>
  10. <van-cell-group>
  11. <van-field required label="姓名" placeholder="请输入姓名" v-model="stu.name"></van-field>
  12. <van-cell required title="性别" v-model="stu.sex" @click="onChange('sex')" is-link value="请选择"></van-cell>
  13. <van-cell required title="生日" v-model="stu.birthday" @click="birthdayStatus = true" is-link value="请选择"></van-cell>
  14. <van-field required disabled label="乐团" placeholder="" v-model="stu.band"></van-field>
  15. <!-- <van-cell title="学校" v-model="stu.school" @click="onChange('school')" is-link value="请选择"></van-cell> -->
  16. <van-cell required title="年级" v-model="stu.class" @click="onChange('class')" is-link value="请选择"></van-cell>
  17. <van-field required label="班级" placeholder="请输入班级" v-model="stu.grade"></van-field>
  18. </van-cell-group>
  19. <div class="reg-title">
  20. <i class="icon card_icon"></i> 请填写专业信息 <span>(必填)</span>
  21. </div>
  22. <van-cell-group>
  23. <van-cell required title="声部" v-model="stu.major" @click="onChange('major')" is-link value="请选择"></van-cell>
  24. <van-cell required title="是否服从调配" v-model="stu.adjust" @click="onChange('adjust')" is-link value="请选择"></van-cell>
  25. </van-cell-group>
  26. <div class="reg-title">
  27. <i class="icon card_icon"></i> 请填写家长信息 <span>(必填,至少1名联系人)</span>
  28. </div>
  29. <van-cell-group>
  30. <van-field required label="家长" placeholder="请输入家长姓名" v-model="stu.patriarch"></van-field>
  31. <van-field required disabled label="手机" placeholder="请输入手机号" v-model="stu.phone"></van-field>
  32. <van-field label="单位" placeholder="请输入单位名称" v-model="stu.company"></van-field>
  33. <van-field
  34. v-model="stu.remark"
  35. label="备注"
  36. type="textarea"
  37. placeholder="请输入备注"
  38. rows="2"
  39. autosize
  40. />
  41. </van-cell-group>
  42. <div class="btn-group">
  43. <van-button class="btn-submit" @click="onSubmit" size="large">提交</van-button>
  44. </div>
  45. <van-action-sheet :class="[selectName=='class'?'height3':'']"
  46. v-model= "sheetStatus"
  47. :actions= "sheetActions"
  48. @select= "onSelect"
  49. @cancel= "sheetStatus = false"
  50. />
  51. <van-popup v-model="birthdayStatus" position="bottom">
  52. <van-datetime-picker
  53. v-model="currentDate"
  54. type="date"
  55. :min-date="minDate"
  56. :formatter="formatter"
  57. @confirm= "onConfirmDate"
  58. @cancel= "birthdayStatus = false"
  59. />
  60. </van-popup>
  61. </div>
  62. </template>
  63. <script>
  64. import { Field, CellGroup, Cell, ActionSheet, Button, DatetimePicker, Popup, Toast, Dialog } from 'vant'
  65. import cityName from '../assets/front_ciry'
  66. import qs from 'qs'
  67. export default {
  68. name: 'register',
  69. components: { Field, CellGroup, Cell, ActionSheet, Button, DatetimePicker, Popup, Toast, Dialog },
  70. data() {
  71. return {
  72. currentDate: new Date(), // 当前时间
  73. minDate: new Date(1980, 1, 1), // 最小日期时间
  74. sheetStatus: false, // 选项卡状态
  75. birthdayStatus: false, // 日期选择状态
  76. stu: {
  77. name: '', // 姓名
  78. sex: '请选择', // 性别
  79. birthday: '请选择', // 生日
  80. city: '请选择', // 城市
  81. band: '',// 乐团
  82. // school: '', // 学校
  83. class: '请选择', // 年级
  84. grade: '', // 班级
  85. major: '请选择', // 专业
  86. adjust: '是', // 是否服从调配
  87. patriarch: '', // 家长
  88. phone: '', // 电话
  89. company: '', // 单位
  90. remark: '', // 备注
  91. },
  92. stuIndex: {
  93. sexNo: null, // 性别编号
  94. majorNo: null, // 专业编号
  95. subNo: null, // 科目编号
  96. adjustNo: 1, // 是否服从调配编号
  97. },
  98. selectName: '', // 选择是哪个字段
  99. sheetActions: [], // 上拉列表数据展示
  100. dataList: { // 上拉列表数据列表
  101. sex: [{ name: '男', index: 0 }, {name: '女', index: 1}],
  102. // school: [
  103. // { name: '小学' },
  104. // { name: '初中' },
  105. // { name: '高中' },
  106. // ],
  107. class: [
  108. { name: '一年级' },
  109. { name: '二年级' },
  110. { name: '三年级' },
  111. { name: '四年级' },
  112. { name: '五年级' },
  113. { name: '六年级' },
  114. { name: '初一/七年级' },
  115. { name: '初二/八年级' },
  116. { name: '初三/九年级' },
  117. { name: '高一' },
  118. { name: '高二' },
  119. { name: '高三' },
  120. ],
  121. adjust: [{ name: '是', index: 1 }, {name: '否', index: 0}],
  122. }
  123. }
  124. },
  125. mounted() {
  126. let params = this.$route.query
  127. this.stu.phone = params.phone
  128. this.stu.city = cityName(params.cityId)
  129. this.stu.band = params.schoolName
  130. let arr = []
  131. axios.post('/user/getCourses', qs.stringify({clazzId: params.classId})).then((res) => {
  132. (res.data.data).forEach(element => {
  133. let tempSubName = element.subName.split('.').reverse()[0]
  134. arr.push({
  135. name: tempSubName,
  136. index: element.id,
  137. subNo: element.subId
  138. })
  139. })
  140. this.dataList.major = arr
  141. })
  142. },
  143. methods: {
  144. // 选中子选项时赋值
  145. onSelect(item) {
  146. this.stu[this.selectName] = item.name
  147. this.sheetStatus = false
  148. // 根据不同的类型取到对应的编号
  149. if(this.selectName == 'sex') {
  150. this.stuIndex.sexNo = item.index
  151. } else if(this.selectName == 'adjust') {
  152. this.stuIndex.adjustNo = item.index
  153. } else if(this.selectName == 'major') {
  154. this.stuIndex.majorNo = item.index
  155. this.stuIndex.subNo = item.subNo
  156. }
  157. },
  158. onChange(name) {
  159. this.sheetStatus = true
  160. this.sheetActions = this.dataList[name]
  161. this.selectName = name
  162. },
  163. formatter(type, value) { // 格式化时间
  164. if (type === 'year') {
  165. return `${value}年`;
  166. } else if (type === 'month') {
  167. return `${value}月`
  168. } else if (type === 'day') {
  169. return `${value}日`
  170. }
  171. return value
  172. },
  173. onConfirmDate() {
  174. // 生日赋值
  175. this.birthdayStatus = false
  176. this.stu.birthday = this.dateFormat(this.currentDate)
  177. },
  178. dateFormat(date) {
  179. let cur = new Date(date)
  180. return `${cur.getFullYear()}-${cur.getMonth() + 1}-${cur.getDate()}`
  181. },
  182. onSubmit() {
  183. // 确定注册
  184. let checkResult = this.onCheckForm()
  185. if(checkResult) {
  186. Toast(checkResult)
  187. return false
  188. }
  189. let s = this.stu
  190. let params = this.$route.query
  191. axios.post('/user/userApply', qs.stringify({
  192. name: s.name,
  193. sex: this.stuIndex.sexNo,
  194. birthday: s.birthday,
  195. city: s.city,
  196. classId: params.classId,
  197. courseId: this.stuIndex.majorNo,
  198. subId: this.stuIndex.subNo,
  199. branchId: params.branchId,
  200. schoolId: params.schoolId,
  201. grade: s.class,
  202. gClass: s.grade,
  203. isAdjust: this.stuIndex.adjustNo,
  204. patriarchPhone: s.phone,
  205. patriarchName: s.patriarch,
  206. patriarchUnit: s.company,
  207. remark: s.remark
  208. })).then((res) => {
  209. let result = res.data
  210. if(result.code == 200) {
  211. Dialog.alert({
  212. title: '提示',
  213. message: '恭喜您,已报名成功',
  214. confirmButtonColor: '#269a93'
  215. }).then(() => {
  216. // 判断是否开启缴费
  217. if(params.status == 2) {
  218. this.$router.push({
  219. path: 'home',
  220. query: {
  221. branchId: params.branchId,
  222. stuId: result.data,
  223. classId: params.classId,
  224. cityId: params.cityId,
  225. schoolId: params.schoolId
  226. }
  227. })
  228. } else {
  229. // 跳转到登录页面
  230. this.$router.push({ path: 'login', query: {
  231. schoolId: params.schoolId, // 学校编号
  232. cityId: params.cityId // 城市编号
  233. }})
  234. }
  235. })
  236. } else {
  237. Toast(result.msg)
  238. }
  239. })
  240. },
  241. onCheckForm() {
  242. let student = this.stu
  243. let errorTextArr = {
  244. name: '请输入姓名',
  245. sex: '请选择性别', // 性别
  246. birthday: '请选择生日', // 生日
  247. // school: '请选择学校', // 学校
  248. class: '请选择年级', // 年级
  249. grade: '请输入班级', // 班级
  250. major: '请选择声部', // 专业
  251. adjust: '请选择是否服从调配', // 是否服从调配
  252. patriarch: '请输入家长姓名', // 家长
  253. phone: '请输入电话', // 电话
  254. // company: '请输入单位名称'
  255. }
  256. for(let key in student) {
  257. if(student[key] == '' || student[key] == '请选择') {
  258. return errorTextArr[key]
  259. }
  260. }
  261. return ''
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="less" scoped>
  267. .register {
  268. margin-bottom: .3rem;
  269. }
  270. .height3 {
  271. height: 3rem;
  272. }
  273. header {
  274. height: .40rem;
  275. line-height: .40rem;
  276. color: #000;
  277. font-size: .17rem;
  278. background: #fff;
  279. box-shadow: 0px 1px 8px 0px rgba(0,0,0,0.07);
  280. text-align: center;
  281. margin-bottom: .06rem;
  282. }
  283. .banner {
  284. font-size: 0;
  285. img{
  286. width: 100%;
  287. }
  288. }
  289. .reg-title {
  290. padding: 0 .12rem;
  291. position: relative;
  292. height: .4rem;
  293. display: flex;
  294. align-items: center;
  295. color: #666;
  296. font-size: .14rem;
  297. span {
  298. color: #9B9B9B;
  299. }
  300. .card_icon {
  301. display: inline-block;
  302. width: .23rem;
  303. height: .2rem;
  304. margin-right: .1rem;
  305. background: url('../assets/Shape.png') no-repeat center;
  306. background-size: contain;
  307. }
  308. }
  309. .btn-group {
  310. margin: .3rem .3rem 0;
  311. .btn-submit {
  312. background: #14928A;
  313. border-radius: 1rem;
  314. color: #fff;
  315. font-size: .18rem;
  316. }
  317. }
  318. .van-cell {
  319. font-size: .16rem;
  320. padding: .13rem .11rem;
  321. }
  322. /deep/.van-field--disabled .van-field__control {
  323. color: #444 !important;
  324. }
  325. /deep/.van-field__label, /deep/.van-cell__title {
  326. padding-left: .08rem;
  327. }
  328. // .van-field--disabled {
  329. .van-field__controll {
  330. color: #323233;
  331. }
  332. // }
  333. </style>