|
@@ -1,16 +1,40 @@
|
|
|
// pages/register/register.ts
|
|
|
+import { ConstsData } from "../../utils/const"
|
|
|
+import { httpUtil } from "../../utils/restful";
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- region: ['北京市', '北京市', '海淀区'],
|
|
|
- schoolArray: ['中国', '美国', '巴西', '日本'],
|
|
|
+ regionOne: Array<String>(),
|
|
|
+ regionTwo: Array<String>(),
|
|
|
+ regionThree: Array<String>(),
|
|
|
+ regionOneIndex: 0,
|
|
|
+ regionTwoIndex: 0,
|
|
|
+ regionThreeIndex: 0,
|
|
|
+ region: [
|
|
|
+ Array<String>(),
|
|
|
+ Array<String>(),
|
|
|
+ Array<String>()
|
|
|
+ ],
|
|
|
+ regionIndex: [0, 0, 0],
|
|
|
+ schoolArray: [['中国']],
|
|
|
schoolIndex: 0,
|
|
|
classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
|
|
|
classIndex: 0,
|
|
|
- isShowPassWord: true
|
|
|
+ isShowPassWord: true,
|
|
|
+ userName: '',
|
|
|
+ userPhone: "",
|
|
|
+ verificationCode: '',
|
|
|
+ userPwd: '',
|
|
|
+ provinceValue: '',//省份value
|
|
|
+ regionValue: '',//地区value
|
|
|
+ cityValue: '',
|
|
|
+ schoolData: [{ 'id': '' }],
|
|
|
+ schoolId: '',
|
|
|
+ classData: [{ 'id': '' }],
|
|
|
+ classId: ''
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -18,54 +42,169 @@ Page({
|
|
|
*/
|
|
|
onLoad() {
|
|
|
|
|
|
+ this.changeOrganizeInfo();
|
|
|
},
|
|
|
- bindRegionChange: function (event: any) {
|
|
|
- console.log('picker发送选择改变,携带值为', event.detail.value)
|
|
|
+
|
|
|
+ changeOrganizeInfo: function () {
|
|
|
+
|
|
|
+ //切换地区
|
|
|
+ this.setData({
|
|
|
+ regionOne: [],
|
|
|
+ regionTwo: [],
|
|
|
+ regionThree: []
|
|
|
+ })
|
|
|
+ ConstsData.AppData.organizeInfo.data.children.forEach((item) => {
|
|
|
+ this.data.regionOne.push(item.title)
|
|
|
+ })
|
|
|
+
|
|
|
+ ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item) => {
|
|
|
+
|
|
|
+ this.data.regionTwo.push(item.title)
|
|
|
+ })
|
|
|
+
|
|
|
+ ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item) => {
|
|
|
+
|
|
|
+ this.data.regionThree.push(item.title)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
this.setData({
|
|
|
- region: event.detail.value
|
|
|
+ region: [this.data.regionOne, this.data.regionTwo, this.data.regionThree],
|
|
|
+ regionIndex: [this.data.regionOneIndex, this.data.regionTwoIndex, this.data.regionThreeIndex],
|
|
|
+ provinceValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].value.toString(),
|
|
|
+ cityValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].value.toString(),
|
|
|
+ regionValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children[this.data.regionThreeIndex].value.toString()
|
|
|
})
|
|
|
+ console.log("provinceValue", this.data.provinceValue)
|
|
|
+
|
|
|
+ //切换学校
|
|
|
+ this.changeSchool();
|
|
|
+
|
|
|
+ //切换班级
|
|
|
},
|
|
|
- bindSchoolPicker: function (event: any) {
|
|
|
- let newArray;
|
|
|
- switch (Number(event.detail.value)) {
|
|
|
+
|
|
|
+ //查询学校
|
|
|
+ changeSchool: function () {
|
|
|
+ console.log("查询学校")
|
|
|
+ //查询学校
|
|
|
+ let params = {
|
|
|
+ city: this.data.cityValue,
|
|
|
+ province: this.data.provinceValue,
|
|
|
+ region: this.data.regionValue,
|
|
|
+ type: 1,
|
|
|
+ }
|
|
|
+ httpUtil.wxGet(httpUtil.interfaces.getSchoolOrClass, params).then((res: any) => {
|
|
|
+ console.log(" res.data.data:", res.data.data[0].id)
|
|
|
+ this.setData({
|
|
|
+ schoolArray: [],
|
|
|
+ schoolIndex: 0,
|
|
|
+ schoolData: res.data.data,
|
|
|
+ schoolId: res.data.data[0].id
|
|
|
+ })
|
|
|
+
|
|
|
+ let newArray: string[] = [];
|
|
|
+ res.data.data.forEach((element: { title: string; }) => {
|
|
|
+ newArray.push(element.title)
|
|
|
+ });
|
|
|
+ this.data.schoolArray.push(newArray)
|
|
|
+ this.setData({
|
|
|
+ schoolArray: this.data.schoolArray
|
|
|
+ })
|
|
|
+ console.log("schoolId:", this.data.schoolId)
|
|
|
+
|
|
|
+ this.changeClass()
|
|
|
+ }).catch(res => {
|
|
|
+ console.log("查询学校error:", res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //查询班级
|
|
|
+ changeClass: function () {
|
|
|
+ let params = {
|
|
|
+ "city": this.data.cityValue,
|
|
|
+ "father": this.data.schoolId,//学校ID
|
|
|
+ "province": this.data.provinceValue,
|
|
|
+ "region": this.data.regionValue,
|
|
|
+ "type": 2,
|
|
|
+ }
|
|
|
+ httpUtil.wxGet(httpUtil.interfaces.getSchoolOrClass, params).then((res: any) => {
|
|
|
+ this.setData({
|
|
|
+ classArray: [],
|
|
|
+ classIndex: 0
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ classData: res.data.data,
|
|
|
+ classId: res.data.data[0].id
|
|
|
+ })
|
|
|
+ res.data.data.forEach((element: { title: string; }) => {
|
|
|
+ console.log("element:", element.title)
|
|
|
+ this.data.classArray.push(element.title)
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ classArray: this.data.classArray,
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ }).catch(res => {
|
|
|
+ console.log("查询班级error:", res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ bindMultiPickerColumnChange: function (event: any) {
|
|
|
+
|
|
|
+ //
|
|
|
+ switch (Number(event.detail.column)) {
|
|
|
case 0:
|
|
|
- newArray = ["一", "二", "三"];
|
|
|
+ //代表第一列
|
|
|
this.setData({
|
|
|
- classArray: newArray,
|
|
|
- classIndex: 0
|
|
|
+ regionOneIndex: event.detail.value,
|
|
|
})
|
|
|
break;
|
|
|
case 1:
|
|
|
- newArray = ["4", "5", "6"];
|
|
|
+ //代表第二列
|
|
|
this.setData({
|
|
|
- classArray: newArray,
|
|
|
- classIndex: 0
|
|
|
+ regionTwoIndex: event.detail.value,
|
|
|
})
|
|
|
break;
|
|
|
case 2:
|
|
|
- newArray = ["as", "ad", "af"];
|
|
|
- this.setData({
|
|
|
- classArray: newArray,
|
|
|
- classIndex: 0
|
|
|
- })
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- newArray = ["b1", "b2", "b3"];
|
|
|
+ //代表第三列
|
|
|
this.setData({
|
|
|
- classArray: newArray,
|
|
|
- classIndex: 0
|
|
|
+ regionThreeIndex: event.detail.value
|
|
|
})
|
|
|
break;
|
|
|
}
|
|
|
+ this.changeOrganizeInfo();
|
|
|
+ },
|
|
|
+
|
|
|
+ bindRegionChange: function (event: any) {
|
|
|
+ console.log('picker发送选择改变,携带值为', event.detail.value)
|
|
|
+ this.setData({
|
|
|
+ regionIndex: event.detail.value
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ bindSchoolPicker: function (event: any) {
|
|
|
+ console.log("event:", event.detail.value)
|
|
|
+ console.log("schoolData:", this.data.schoolData[event.detail.value].id)
|
|
|
this.setData({
|
|
|
- schoolIndex: event.detail.value
|
|
|
+ schoolIndex: event.detail.value,
|
|
|
+ schoolId: this.data.schoolData[event.detail.value].id
|
|
|
})
|
|
|
+
|
|
|
+ this.changeClass();
|
|
|
+
|
|
|
},
|
|
|
bindClssPicker: function (event: any) {
|
|
|
this.setData({
|
|
|
classIndex: event.detail.value
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
showPwdTab: function () {
|
|
|
if (this.data.isShowPassWord) {
|
|
|
this.setData({
|
|
@@ -80,6 +219,90 @@ Page({
|
|
|
},
|
|
|
exitPage: function () {
|
|
|
wx.navigateBack()
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取输入的姓名
|
|
|
+ bindUserNameInput: function (event: any) {
|
|
|
+ console.log("event.detail.value:",)
|
|
|
+ this.setData({
|
|
|
+ userName: event.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取输入的手机号
|
|
|
+ bindUserPhoneInput: function (event: any) {
|
|
|
+ this.setData({
|
|
|
+ userPhone: event.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取输入的验证码
|
|
|
+ bindVerificationCodeInput: function (event: any) {
|
|
|
+ this.setData({
|
|
|
+ verificationCode: event.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取输入的密码
|
|
|
+ bindPwdInput: function (event: any) {
|
|
|
+ this.setData({
|
|
|
+ userPwd: event.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取验证码
|
|
|
+ getVerificationCode: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ doRegister: function () {
|
|
|
+ //注册
|
|
|
+ if (!this.data.userName) {
|
|
|
+ this.showToast("请输入姓名:")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.data.userPhone) {
|
|
|
+ this.showToast("请输入手机号")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.data.userPwd) {
|
|
|
+ this.showToast("请输入密码")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.data.verificationCode) {
|
|
|
+ this.showToast("请输入验证码")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let params = {
|
|
|
+ city: this.data.cityValue,
|
|
|
+ classId: this.data.classId,
|
|
|
+ mobile: this.data.userPhone,
|
|
|
+ name: this.data.userName,
|
|
|
+ password: this.data.userPwd,
|
|
|
+ province: this.data.provinceValue,//省份
|
|
|
+ region: this.data.regionValue,//地区
|
|
|
+ schoolId: this.data.schoolId,
|
|
|
+ userName: this.data.userPhone,//账号
|
|
|
+ verifyCode: this.data.verificationCode//
|
|
|
+ }
|
|
|
+ console.log("params:", params)
|
|
|
+ httpUtil.wxPost(httpUtil.interfaces.phoneRegister, params).then((res: any) => {
|
|
|
+ console.log("注册成功:", res.data)
|
|
|
+ httpUtil.httpData.userId = res.data.data.id;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../teacher/index/index',
|
|
|
+ })
|
|
|
+ }).catch((res) => {
|
|
|
+ console.log("注册失败:", res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showToast: function (message: string) {
|
|
|
+ wx.showToast({
|
|
|
+ title: message,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
|
|
|
})
|