123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import Api from "../../model/api";
- import {getDataSet, getEventParam, isMobile, toast, isIdCard} from "../../utils/utils";
- import Config from "../../model/config";
- import {logicStatus, studentTypes} from "../../model/enum";
- Page({
- data: {
- formData: {
- name: "",
- phone: "",
- verify: '',
- idCard: "",
- perType: 3,
- code: "",
- },
- errMsg: "",
- studentTypeData: [],
- parentIds: '', //清空行政区划选择
- },
- async onLoad(options) {
- const res = await Api.getPulishDict(Config.DICT.STUDENT_TYPE);
- const studentTypeData = res.data;
- this.setData({studentTypeData})
- },
- changeInfo(e) {
- // let eventParam = getEventParam(e);
- // this.setData({
- // ...eventParam
- // })
- let eventParam = getEventParam(e);
- //额外处理一下联动
- if (eventParam['formData.perType'] && eventParam['formData.perType'] != this.data.formData.perType) {
- this.setData({
- // 'formData.jobId': -1,
- 'formData.code': '',
- parentIds:'',
- })
- }
- this.setData({
- ...eventParam
- })
- },
- onChange(e) {
- const field = getDataSet(e, "field");
- this.setData({
- [field]: getEventParam(e)
- })
- },
- async submit() {
- if (!this.data.formData.name.trim()) {
- toast('请输入姓名')
- return;
- }
- if (!isMobile(this.data.formData.phone)) {
- toast('请输入正确的手机号')
- return;
- }
- if (!this.data.formData.verify) {
- toast('请输入验证码')
- return;
- }
- // if (!this.data.formData.idCard) {
- // toast('请输入身份证号')
- // return;
- // }
- if (!isIdCard(this.data.formData.idCard)) {
- toast('身份证号格式不正确')
- return;
- }
- // if (this.data.formData.perType == -1) {
- // toast('请选择学员类别')
- // return;
- // }
- // let isCommunityWorker = this.data.formData.perType == studentTypes.COMMUNITY_WORKER;
- // console.log('isCommunityWorker -> ', isCommunityWorker);
- if (!this.data.formData.code || !this.data.formData.code.trim()) {
- // wx.showModal({
- // title: "单位所在的行政区域提示",
- // content: "吉林省社区工作者必须选择到社区一级,非吉林省社区工作者必须选择到市一级!",
- // showCancel:false
- // })
- // let unitChooseTipContent = isCommunityWorker? '吉林省社区工作者必须选择到社区一级,非吉林省社区工作者必须选择到市一级!' : '请选择单位所在的行政区域!';
- // wx.showModal({
- // title: "单位所在的行政区域提示",
- // content: unitChooseTipContent,
- // showCancel: false
- // });
- let unitChooseTipContent = '请选择单位所在的行政区域!';
- wx.showModal({
- title: "单位所在的行政区域提示",
- content: unitChooseTipContent,
- showCancel: false
- });
- return;
- }
- let submitForm = {...this.data.formData, perType: 10};
- // await Api.register(this.data.formData, true);
- await Api.register(submitForm, true);
- toast("注册成功")
- wx.navigateBack();
- },
- })
|