Quellcode durchsuchen

1.增加没有学校或者班级时候的默认提示
2.修改个人信息接口
3.注册界面接口逻辑修改
4.我的界面获取信息赋值逻辑
5.更新个人信息界面修改
6.监控界面获取信息赋值逻辑
7.故障报修接口
8.修改密码接口

FailedToRead vor 2 Jahren
Ursprung
Commit
c4372e86d6

+ 110 - 20
miniprogram/component/myInfo/myInfo.ts

@@ -25,9 +25,9 @@ Component({
             Array<String>()
         ],
         regionIndex: [0, 0, 0],
-        schoolArray: [['中国']],
+        schoolArray: [['暂无学校']],
         schoolIndex: 0,
-        classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
+        classArray: ['暂无班级'],
         classIndex: 0,
         provinceValue: '',//省份value
         regionValue: '',//地区value
@@ -38,7 +38,9 @@ Component({
         classId: '',
         isShowPassWord: true,
         userName: "",
-        userPwd: ""
+        userPwd: "",
+
+        initFirst: true
     },
 
 
@@ -46,7 +48,9 @@ Component({
         attached: function () {
             // 在组件实例被从页面节点树添加时执行
 
-            this.changeOrganizeInfo()
+            //获取用户信息
+            this.getMyInfo()
+
 
         },
         detached: function () {
@@ -61,28 +65,73 @@ Component({
      */
     methods: {
 
+        getMyInfo: function () {
+
+            if (ConstsData.AppData.myInfoData.id == 0) {
+                //没有用户信息,请求接口
+                httpUtil.wxGet(httpUtil.interfaces.getUserById, null).then((res: any) => {
+                    ConstsData.AppData.myInfoData = res.data.data
+                    //获取地区和学校班级等信息
+                    this.changeOrganizeInfo()
+                }).catch((res) => {
+                    console.log("获取我的信息失败:", res)
+                })
+            } else {
+                //有用户信息,直接设置地区啥的
+
+                this.changeOrganizeInfo()
+            }
+
 
+        },
 
 
         changeOrganizeInfo: function () {
 
+
+            //设置名字
+            this.setData({
+                userName: ConstsData.AppData.myInfoData.name
+            })
             //切换地区
             this.setData({
                 regionOne: [],
                 regionTwo: [],
                 regionThree: []
             })
-            ConstsData.AppData.organizeInfo.data.children.forEach((item: { title: String; }) => {
+            ConstsData.AppData.organizeInfo.data.children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.province) {
+                        //如果是当前的
+                        this.setData({
+                            regionOneIndex: index
+                        })
+                    }
+                }
+
                 this.data.regionOne.push(item.title)
             })
 
-            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item: { title: String; }) => {
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.city) {
+                        this.setData({
+                            regionTwoIndex: index
+                        })
+                    }
+                }
 
                 this.data.regionTwo.push(item.title)
             })
 
-            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item: { title: String; }) => {
-
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.region) {
+                        this.setData({
+                            regionThreeIndex: index
+                        })
+                    }
+                }
                 this.data.regionThree.push(item.title)
             })
 
@@ -92,16 +141,18 @@ Component({
                 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()
+                regionValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children[this.data.regionThreeIndex].value.toString(),
+                initFirst: false
+
             })
 
 
             //切换学校
             this.changeSchool();
 
-            //切换班级
         },
 
+
         //查询学校
         changeSchool: function () {
 
@@ -122,7 +173,13 @@ Component({
                 })
 
                 let newArray: string[] = [];
-                res.data.data.forEach((element: { title: string; }) => {
+                res.data.data.forEach((element, index) => {
+                    if (ConstsData.AppData.myInfoData.schoolId == element.id) {
+                        this.setData({
+                            schoolIndex: index,
+                            schoolId: this.data.schoolData[index].id
+                        })
+                    }
                     newArray.push(element.title)
                 });
                 this.data.schoolArray.push(newArray)
@@ -131,9 +188,18 @@ Component({
                 })
 
 
+                //切换班级
                 this.changeClass()
             }).catch(res => {
                 console.log("查询学校error:", res)
+                this.setData({
+                    schoolArray: [['暂无学校']],
+                    schoolId: '',
+                    classArray: ['暂无班级'],
+                    classId: ''
+
+
+                })
             })
         },
 
@@ -155,8 +221,15 @@ Component({
                     classData: res.data.data,
                     classId: res.data.data[0].id
                 })
-                res.data.data.forEach((element: { title: string; }) => {
-
+                console.log("classData:", this.data.classData)
+                res.data.data.forEach((element: { id: number; title: string; }, index: number) => {
+                    if (element.id == ConstsData.AppData.myInfoData.classId) {
+                        this.setData({
+                            classIndex: index,
+                            classId: res.data.data[index].id
+                        })
+                        console.log("this.data.classIndex:", this.data.classIndex)
+                    }
                     this.data.classArray.push(element.title)
                 });
                 this.setData({
@@ -167,10 +240,13 @@ Component({
 
             }).catch(res => {
                 console.log("查询班级error:", res)
+                this.setData({
+                    classArray: ['暂无班级'],
+                    classId: ''
+                })
             })
         },
 
-
         bindMultiPickerColumnChange: function (event: any) {
 
             //
@@ -206,6 +282,7 @@ Component({
         },
         bindSchoolPicker: function (event: any) {
 
+            console.log(" event.detail.value:", event.detail.value)
             this.setData({
                 schoolIndex: event.detail.value,
                 schoolId: this.data.schoolData[event.detail.value].id
@@ -216,7 +293,8 @@ Component({
         },
         bindClssPicker: function (event: any) {
             this.setData({
-                classIndex: event.detail.value
+                classIndex: event.detail.value,
+                classId: this.data.classData[event.detail.value].id
             })
         },
 
@@ -262,13 +340,25 @@ Component({
                 return;
             }
             let params = {
+                id: httpUtil.httpData.userId,
+                city: this.data.cityValue,
+                classId: this.data.classId,
                 name: this.data.userName,
-                address: this.data.region[0] + "--" + this.data.region[1] + "--" + this.data.region[2],
-                school: this.data.schoolArray[this.data.schoolIndex],
-                class: this.data.classArray[this.data.classIndex],
-                password: this.data.userPwd
+                password: this.data.userPwd,
+                province: this.data.provinceValue,//省份
+                region: this.data.regionValue,//地区
+                schoolId: this.data.schoolId,
             }
-            console.log("params:", params)
+            httpUtil.wxPut(httpUtil.interfaces.updateUserInfo, params).then((res: any) => {
+                console.log("更新个人信息成功:", res)
+                ConstsData.AppData.myInfoData = res.data.data
+                wx.showToast({
+                    title: '更新成功',
+                    icon: 'none'
+                })
+            }).catch((res) => {
+                console.log("更新个人信息失败:", res)
+            })
         }
     }
 })

+ 3 - 3
miniprogram/component/myInfo/myInfo.wxml

@@ -4,13 +4,13 @@
         <!--输入姓名-->
         <view class="item_input_bg">
             <text class="item_input_title">姓名:</text>
-            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" bindinput="bindUserNameInput" />
+            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" bindinput="bindUserNameInput" value="{{userName}}" />
         </view>
         <!--输入姓名 end-->
         <!--选择地区-->
         <view class="item_input_bg">
             <text class="item_input_title">地区:</text>
-            <picker mode="multiSelector" bindchange="bindRegionChange" bindcolumnchange="bindMultiPickerColumnChange" range="{{region}}" class="item_picker_bg">
+            <picker mode="multiSelector" bindchange="bindRegionChange" bindcolumnchange="bindMultiPickerColumnChange" range="{{region}}" class="item_picker_bg" value="{{regionIndex}}">
                 <view class="item_picker_content">
                     <p> {{region[0][regionIndex[0]]}} </p>
                     <p> {{region[1][regionIndex[1]]}} </p>
@@ -25,7 +25,7 @@
         <!--选择学校-->
         <view class="item_input_bg">
             <text class="item_input_title">学校:</text>
-            <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" class="item_picker_bg">
+            <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" value="{{[schoolIndex,0]}}" class="item_picker_bg">
                 <view class="item_picker_content">
                     {{schoolArray[0][schoolIndex]}}
                 </view>

+ 265 - 53
miniprogram/component/teacher/teacherFault/teacherFault.ts

@@ -1,4 +1,6 @@
 // component/teacher/teacherFault/teacherFault.ts
+import { ConstsData } from "../../../utils/const"
+import { httpUtil } from "../../../utils/restful";
 Component({
     /**
      * 组件的属性列表
@@ -15,18 +17,51 @@ Component({
         pageState: 0,
         pageStateText: ['故障报修', '报修记录'],
         //故障报修界面所用数据
-        fault: ['紧急', '不紧急'],
+        fault: ['普通', '待查', '紧急'],
         faultIndex: 0,
-        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班'],
+        classArray: ['暂无班级'],
         classIndex: 0,
+        provinceValue: '',//省份value
+        regionValue: '',//地区value
+        cityValue: '',
+        schoolData: [{ 'id': '' }],
+        schoolId: '',
+        classData: [{ 'id': '' }],
+        classId: '',
+        initFirst: true,
         deviceId: '',
-        faultText: ""
+        describe: ""
 
     },
 
+    lifetimes: {
+        attached: function () {
+            // 在组件实例被从页面节点树添加时执行
+
+            this.changeOrganizeInfo();
+
+        },
+        detached: function () {
+            // 在组件实例被从页面节点树移除时执行
+
+        },
+    },
+
+
     /**
      * 组件的方法列表
      */
@@ -48,53 +83,215 @@ Component({
             })
         },
 
-        //选择地区回调
-        bindRegionChange: function (event: any) {
+
+        changeOrganizeInfo: function () {
+
+
+            //设置名字
+            this.setData({
+                userName: ConstsData.AppData.myInfoData.name
+            })
+            //切换地区
+            this.setData({
+                regionOne: [],
+                regionTwo: [],
+                regionThree: []
+            })
+            ConstsData.AppData.organizeInfo.data.children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.province) {
+                        //如果是当前的
+                        this.setData({
+                            regionOneIndex: index
+                        })
+                    }
+                }
+
+                this.data.regionOne.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.city) {
+                        this.setData({
+                            regionTwoIndex: index
+                        })
+                    }
+                }
+
+                this.data.regionTwo.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.region) {
+                        this.setData({
+                            regionThreeIndex: index
+                        })
+                    }
+                }
+                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(),
+                initFirst: false
+
             })
+
+
+            //切换学校
+            this.changeSchool();
+
         },
-        //选择学校回调
-        bindSchoolPicker: function (event: any) {
-            let newArray;
-            switch (Number(event.detail.value)) {
+
+
+        //查询学校
+        changeSchool: function () {
+
+            //查询学校
+            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) => {
+
+                this.setData({
+                    schoolArray: [],
+                    schoolIndex: 0,
+                    schoolData: res.data.data,
+                    schoolId: res.data.data[0].id
+                })
+
+                let newArray: string[] = [];
+                res.data.data.forEach((element, index) => {
+                    if (ConstsData.AppData.myInfoData.schoolId == element.id) {
+                        this.setData({
+                            schoolIndex: index,
+                            schoolId: this.data.schoolData[index].id
+                        })
+                    }
+                    newArray.push(element.title)
+                });
+                this.data.schoolArray.push(newArray)
+                this.setData({
+                    schoolArray: this.data.schoolArray
+                })
+
+
+                //切换班级
+                this.changeClass()
+            }).catch(res => {
+                console.log("查询学校error:", res)
+                this.setData({
+                    schoolArray: [['暂无学校']],
+                    schoolId: '',
+                    classArray: ['暂无班级'],
+                    classId: ''
+
+
+                })
+            })
+        },
+
+        //查询班级
+        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
+                })
+                console.log("classData:", this.data.classData)
+                res.data.data.forEach((element: { id: number; title: string; }, index: number) => {
+                    if (element.id == ConstsData.AppData.myInfoData.classId) {
+                        this.setData({
+                            classIndex: index,
+                            classId: res.data.data[index].id
+                        })
+                        console.log("this.data.classIndex:", this.data.classIndex)
+                    }
+                    this.data.classArray.push(element.title)
+                });
+                this.setData({
+                    classArray: this.data.classArray,
+
+                })
+
+
+            }).catch(res => {
+                console.log("查询班级error:", res)
+                this.setData({
+                    classArray: ['暂无班级'],
+                    classId: ''
+                })
+            })
+        },
+
+        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) {
+
+            this.setData({
+                regionIndex: event.detail.value
+            })
+
+        },
+        bindSchoolPicker: function (event: any) {
+
             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
+                classIndex: event.detail.value,
+                classId: this.data.classData[event.detail.value].id
             })
         },
 
@@ -109,7 +306,7 @@ Component({
         //获取故障描述输入
         bindFaultText: function (event: any) {
             this.setData({
-                faultText: event.detail.value
+                describe: event.detail.value
             })
         },
 
@@ -123,7 +320,7 @@ Component({
                 })
                 return;
             }
-            if (!this.data.faultText) {
+            if (!this.data.describe) {
                 wx.showToast({
                     title: '请输入故障描述',
                     icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
@@ -133,31 +330,46 @@ Component({
             }
 
             let params = {
-                address: this.data.region[0] + "--" + this.data.region[1] + "--" + this.data.region[2],
-                school: this.data.schoolArray[this.data.schoolIndex],
-                class: this.data.classArray[this.data.classIndex],
+
+                city: this.data.cityValue,
+                classId: this.data.classId,
+                province: this.data.provinceValue,//省份
+                region: this.data.regionValue,//地区
+                schoolId: this.data.schoolId,
                 deviceId: this.data.deviceId,
-                fault: this.data.fault[this.data.faultIndex],
-                faultText: this.data.faultText
+                faultLevel: this.data.faultIndex,
+                describe: this.data.describe,
+                userId: httpUtil.httpData.userId
 
             }
-            let that = this;
-            wx.showModal({
-                title: '',
-                content: '报修成功',
-                success: function (res) {
-                    if (res.confirm) {
-                        console.log('点击确认回调')
-                        that.setData({
-                            pageState: 1
-                        })
-                    } else {
-                        console.log('点击取消回调')
-                    }
-                }
+            console.log("params:", params)
+            httpUtil.wxPost(httpUtil.interfaces.postDeviceFault, params).then((res: any) => {
+                console.log("设备报修成功:", res)
+                if (res.data.success) {
+                    let that = this;
+                    wx.showModal({
+                        title: '',
+                        content: '报修成功',
+                        success: function (res) {
+                            if (res.confirm) {
+                                console.log('点击确认回调')
+                                that.setData({
+                                    pageState: 1
+                                })
+                            } else {
+                                console.log('点击取消回调')
+                            }
+                        }
+                    })
+                } else { }
+
+            }).catch((res) => {
+                console.log("设备报修失败:", res)
             })
 
-            console.log("params:", params)
+
+
+
         }
 
     }

+ 8 - 8
miniprogram/component/teacher/teacherFault/teacherFault.wxml

@@ -3,7 +3,7 @@
         <text wx:if="{{pageState==1}}" class="toptitle_left">报修记录</text>
         <text wx:else class="toptitle_left"></text>
         <view class="toptitle_right">
-            <picker bindchange="bindPageChange" value="{{pageState}}" range="{{pageStateText}}" >
+            <picker bindchange="bindPageChange" value="{{pageState}}" range="{{pageStateText}}">
                 <text class="toptitle_right_text">{{pageStateText[pageState]}}</text>
             </picker>
 
@@ -30,11 +30,11 @@
             <!--选择地区-->
             <view class="item_input_bg" style=" margin-top: 2rpx;   box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">地区:</text>
-                <picker mode="region" bindchange="bindRegionChange" value="{{region}}" class="item_picker_bg">
+                <picker mode="multiSelector" bindchange="bindRegionChange" bindcolumnchange="bindMultiPickerColumnChange" range="{{region}}" class="item_picker_bg" value="{{regionIndex}}">
                     <view class="item_picker_content">
-                        <p> {{region[0]}} </p>
-                        <p> {{region[1]}} </p>
-                        <p> {{region[2]}} </p>
+                        <p> {{region[0][regionIndex[0]]}} </p>
+                        <p> {{region[1][regionIndex[1]]}} </p>
+                        <p> {{region[2][regionIndex[2]]}} </p>
                     </view>
                 </picker>
                 <view class="item_picker_icon_layout">
@@ -45,9 +45,9 @@
             <!--选择学校-->
             <view class="item_input_bg" style=" margin-top: 2rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">学校:</text>
-                <picker bindchange="bindSchoolPicker" value="{{schoolIndex}}" range="{{schoolArray}}" class="item_picker_bg">
+                <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" value="{{[schoolIndex,0]}}" class="item_picker_bg">
                     <view class="item_picker_content">
-                        {{schoolArray[schoolIndex]}}
+                        {{schoolArray[0][schoolIndex]}}
                     </view>
                 </picker>
                 <view class="item_picker_icon_layout">
@@ -74,7 +74,7 @@
             </view>
         </view>
         <view class="fault_info_layout">
-            <textarea bindinput="bindFaultText" class="fault_info_textarea" placeholder="故障描述:请描述故障情况请描述故障情况,\n请描述故障情况请描述故障情况"></textarea>
+            <textarea bindinput="bindFaultText" class="fault_info_textarea" placeholder="故障描述:请描述故障情况请描述故障情况,\n请描述故障情况请描述故障情况" value="{{describe}}"></textarea>
             <scroll-view scroll-x class="fault_info_scroll">
                 <view wx:for="{{6}}" wx:key="index" style="display:inline-block;">
                     <image class="fault_info_scroll_item"></image>

+ 107 - 18
miniprogram/component/teacher/teacherMonitor/monitor.ts

@@ -19,9 +19,9 @@ Component({
             Array<String>()
         ],
         regionIndex: [0, 0, 0],
-        schoolArray: [['中国']],
+        schoolArray: [['暂无学校']],
         schoolIndex: 0,
-        classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
+        classArray: ['暂无班级'],
         classIndex: 0,
         provinceValue: '',//省份value
         regionValue: '',//地区value
@@ -30,7 +30,8 @@ Component({
         schoolId: '',
         classData: [{ 'id': '' }],
         classId: '',
-        deviceId: '',
+        initFirst: true,
+        deviceId: '6f7aea71-3ed6-3919-ad36-8b94f768b8c1',
         //0=未上课 1=正在上课
         pageState: 0,
 
@@ -38,13 +39,14 @@ Component({
 
         //0是正常,1是error
         videostatus: 0
+
     },
 
     lifetimes: {
         attached: function () {
             // 在组件实例被从页面节点树添加时执行
 
-            this.changeOrganizeInfo()
+            this.getMyInfo();
 
         },
         detached: function () {
@@ -56,25 +58,73 @@ Component({
 
     methods: {
 
+        getMyInfo: function () {
+
+            if (ConstsData.AppData.myInfoData.id == 0) {
+                //没有用户信息,请求接口
+                httpUtil.wxGet(httpUtil.interfaces.getUserById, null).then((res: any) => {
+                    ConstsData.AppData.myInfoData = res.data.data
+                    //获取地区和学校班级等信息
+                    this.changeOrganizeInfo()
+                }).catch((res) => {
+                    console.log("获取我的信息失败:", res)
+                })
+            } else {
+                //有用户信息,直接设置地区啥的
+
+                this.changeOrganizeInfo()
+            }
+
+
+        },
+
+
         changeOrganizeInfo: function () {
 
+
+            //设置名字
+            this.setData({
+                userName: ConstsData.AppData.myInfoData.name
+            })
             //切换地区
             this.setData({
                 regionOne: [],
                 regionTwo: [],
                 regionThree: []
             })
-            ConstsData.AppData.organizeInfo.data.children.forEach((item: { title: String; }) => {
+            ConstsData.AppData.organizeInfo.data.children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.province) {
+                        //如果是当前的
+                        this.setData({
+                            regionOneIndex: index
+                        })
+                    }
+                }
+
                 this.data.regionOne.push(item.title)
             })
 
-            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item: { title: String; }) => {
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.city) {
+                        this.setData({
+                            regionTwoIndex: index
+                        })
+                    }
+                }
 
                 this.data.regionTwo.push(item.title)
             })
 
-            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item: { title: String; }) => {
-
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item, index) => {
+                if (this.data.initFirst) {
+                    if (item.value == ConstsData.AppData.myInfoData.region) {
+                        this.setData({
+                            regionThreeIndex: index
+                        })
+                    }
+                }
                 this.data.regionThree.push(item.title)
             })
 
@@ -84,16 +134,18 @@ Component({
                 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()
+                regionValue: ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children[this.data.regionThreeIndex].value.toString(),
+                initFirst: false
+
             })
 
 
             //切换学校
             this.changeSchool();
 
-            //切换班级
         },
 
+
         //查询学校
         changeSchool: function () {
 
@@ -114,7 +166,13 @@ Component({
                 })
 
                 let newArray: string[] = [];
-                res.data.data.forEach((element: { title: string; }) => {
+                res.data.data.forEach((element, index) => {
+                    if (ConstsData.AppData.myInfoData.schoolId == element.id) {
+                        this.setData({
+                            schoolIndex: index,
+                            schoolId: this.data.schoolData[index].id
+                        })
+                    }
                     newArray.push(element.title)
                 });
                 this.data.schoolArray.push(newArray)
@@ -123,9 +181,18 @@ Component({
                 })
 
 
+                //切换班级
                 this.changeClass()
             }).catch(res => {
                 console.log("查询学校error:", res)
+                this.setData({
+                    schoolArray: [['暂无学校']],
+                    schoolId: '',
+                    classArray: ['暂无班级'],
+                    classId: ''
+
+
+                })
             })
         },
 
@@ -147,8 +214,15 @@ Component({
                     classData: res.data.data,
                     classId: res.data.data[0].id
                 })
-                res.data.data.forEach((element: { title: string; }) => {
-
+                console.log("classData:", this.data.classData)
+                res.data.data.forEach((element: { id: number; title: string; }, index: number) => {
+                    if (element.id == ConstsData.AppData.myInfoData.classId) {
+                        this.setData({
+                            classIndex: index,
+                            classId: res.data.data[index].id
+                        })
+                        console.log("this.data.classIndex:", this.data.classIndex)
+                    }
                     this.data.classArray.push(element.title)
                 });
                 this.setData({
@@ -159,10 +233,13 @@ Component({
 
             }).catch(res => {
                 console.log("查询班级error:", res)
+                this.setData({
+                    classArray: ['暂无班级'],
+                    classId: ''
+                })
             })
         },
 
-
         bindMultiPickerColumnChange: function (event: any) {
 
             //
@@ -208,7 +285,8 @@ Component({
         },
         bindClssPicker: function (event: any) {
             this.setData({
-                classIndex: event.detail.value
+                classIndex: event.detail.value,
+                classId: this.data.classData[event.detail.value].id
             })
         },
 
@@ -264,10 +342,21 @@ Component({
                 deviceId: this.data.deviceId
             }
             console.log("params:", params)
-            //开始上课
-            this.setData({
-                pageState: 1
+
+            httpUtil.wxGet(httpUtil.interfaces.getDeviceById + this.data.deviceId, null).then((res: any) => {
+                console.log("根据ID获取设备信息成功:", res)
+                if (res.data.success) {
+                    //开始上课
+                    this.setData({
+                        pageState: 1
+                    })
+                }
+            }).catch((res) => {
+                console.log("根据ID获取设备信息失败:", res)
             })
+
+
+
         },
 
 

+ 7 - 7
miniprogram/component/teacher/teacherMonitor/monitor.wxml

@@ -12,7 +12,7 @@
             <!--选择地区-->
             <view class="item_input_bg" style=" margin-top: 0rpx;   box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">地区:</text>
-                <picker mode="multiSelector" bindchange="bindRegionChange" bindcolumnchange="bindMultiPickerColumnChange" range="{{region}}" class="item_picker_bg">
+                <picker mode="multiSelector" bindchange="bindRegionChange" bindcolumnchange="bindMultiPickerColumnChange" range="{{region}}" class="item_picker_bg" value="{{regionIndex}}">
                     <view class="item_picker_content">
                         <p> {{region[0][regionIndex[0]]}} </p>
                         <p> {{region[1][regionIndex[1]]}} </p>
@@ -27,7 +27,7 @@
             <!--选择学校-->
             <view class="item_input_bg" style=" margin-top: 2rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">学校:</text>
-                <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" class="item_picker_bg">
+                <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" value="{{[schoolIndex,0]}}" class="item_picker_bg">
                     <view class="item_picker_content">
                         {{schoolArray[0][schoolIndex]}}
                     </view>
@@ -41,10 +41,10 @@
             <view class="item_input_bg" style=" margin-top: 2rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">班级:</text>
                 <picker bindchange="bindClssPicker" value="{{classIndex}}" range="{{classArray}}" class="item_picker_bg">
-                    <view class="item_picker_content">
-                        {{classArray[classIndex]}}
-                    </view>
-                </picker>
+                <view class="item_picker_content">
+                    {{classArray[classIndex]}}
+                </view>
+            </picker>
                 <view class="item_picker_icon_layout">
                     <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
                 </view>
@@ -52,7 +52,7 @@
             <!--选择班级end-->
             <view class="item_input_bg" style="margin-top: 1rpx;">
                 <text class="item_input_title">设备ID:</text>
-                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" />
+                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" value="{{deviceId}}"  />
             </view>
         </view>
         <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 190rpx;" bindtap="startMonitor">

+ 106 - 5
miniprogram/component/updatePassword/updatePassword.ts

@@ -1,4 +1,5 @@
 // component/updatePassword/updatePassword.ts
+import { httpUtil } from "../../utils/restful";
 Component({
     /**
      * 组件的属性列表
@@ -15,7 +16,13 @@ Component({
         height: 713,
         initScale: 0,
         showAccPwd: true,
-        scaleAnim: 0
+        scaleAnim: 0,
+        inputPhoneNum: '',
+        inputVCode: '',
+        inputPwd: '',
+        hasGetVCode: false,
+        getVCodeText: "获取验证码",
+        getvcodeInter: -5
     },
     lifetimes: {
         attached: function () {
@@ -29,7 +36,7 @@ Component({
                 } else {
                     clearInterval(this.data.scaleAnim)
                 }
-                console.log("123123123")
+
             }, 15);
 
         },
@@ -59,15 +66,109 @@ Component({
                 })
             }
 
-       
+
         },
 
-        hideSelf: function (event: any) {
+        hideSelf: function () {
             //调用父组件方法移除自身
             this.triggerEvent('showUpdatePwdLayout');
-        }
+        },
+
+
+        bindPwdLoginPhoneInput: function (event: any) {
+            this.setData({
+                inputPhoneNum: event.detail.value
+            })
+
+        },
+
+        bindVCodeInput: function (event: any) {
+            this.setData({
+                inputVCode: event.detail.value
+            })
+
+        },
+
+        bindPassWordInput: function (event: any) {
+            this.setData({
+                inputPwd: event.detail.value
+            })
+
+        },
+        // 获取验证码
+        clickGetVCode: function (event: any) {
+            if (this.data.hasGetVCode) {
+                this.showToast("请勿频繁点击")
+                return;
+            }
+            if (!this.data.inputPhoneNum) {
+                this.showToast("请输入手机号")
+                return;
+            }
 
+            let that = this;
+            let time = 60;
 
+            this.data.getvcodeInter = setInterval(function () {
+                if (time <= 1) {
+                    clearInterval(that.data.getvcodeInter)
+                    that.setData({
+                        hasGetVCode: false,
+                        getVCodeText: '获取验证码',
+                        getvcodeInter: -5
+                    })
+
+                    return;
+                }
+                time--;
+                that.setData({
+                    getVCodeText: time.toString(),
+                    hasGetVCode: true
+                })
+            }, 1000)
+            let params = {
+                mobileNo: this.data.inputPhoneNum
+            }
+            httpUtil.wxGet(httpUtil.interfaces.getVerifyCode, params).then((res) => {
+                console.log("获取验证码成功:", res)
+            }).catch((res) => {
+                console.log("获取验证码失败:", res)
+            })
+        },
+
+
+        submitInfo: function () {
+            if (!this.data.inputPhoneNum) {
+                this.showToast("请输入手机号")
+                return;
+            }
+            if (!this.data.inputVCode) {
+                this.showToast("请输入验证码")
+                return;
+            }
+
+            let params = {
+                mobile: this.data.inputPhoneNum,
+                password: this.data.inputPwd,
+                verifyCode: this.data.inputVCode
+            }
+            let that = this;
+            httpUtil.wxPost(httpUtil.interfaces.updatePassWord, params).then((res) => {
+                console.log("修改密码成功:", res)
+                that.hideSelf()
+            }).catch((res) => {
+                console.log("修改密码失败:", res)
+                that.showToast(res.data.message)
+            })
+
+        },
+
+        showToast: function (message: string) {
+            wx.showToast({
+                title: message,
+                icon: 'none'
+            })
+        }
     }
 
 

+ 5 - 5
miniprogram/component/updatePassword/updatePassword.wxml

@@ -8,26 +8,26 @@
             <!--输入手机号的iput-->
             <view class="phonenum_login_layout_input_bg" style="height: 77rpx;">
                 <image class="phonenum_login_layout_input_icon" src="../../image/login/phone_num_icon.png"></image>
-                <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" />
+                <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" value="{{inputPhoneNum}}" bindinput="bindPwdLoginPhoneInput" />
             </view>
             <!--输入手机号的iput end-->
             <!--输入验证码的iput-->
             <view class="phonenum_login_layout_input_bg" style="margin-top: 41rpx; height: 77rpx;">
                 <image class="phonenum_login_layout_input_icon" src="../../image/login/phone_vcode_icon.png"></image>
-                <input class="phonenum_login_layout_input" maxlength="6" type="number" placeholder="输入验证码" />
-                <text style="color: #6275FE; font-size: 30rpx; margin-right: 19rpx;" bindtap="clickGetVCode">获取验证码</text>
+                <input class="phonenum_login_layout_input" maxlength="6" type="number" placeholder="输入验证码" bindinput="bindVCodeInput" />
+                <text class="phonenum_loing_layout_getvcode" bindtap="clickGetVCode">{{getVCodeText}}</text>
             </view>
             <!--输入验证码的iput end-->
             <!-- 密码的input-->
             <view class="phonenum_login_layout_input_bg" style="margin-top: 41rpx; height: 77rpx;">
                 <image class="phonenum_login_layout_input_icon" src="../../image/login/account_pwd_icon.png"></image>
-                <input class="phonenum_login_layout_input" password="{{showAccPwd}}" maxlength="11" placeholder="输入密码" />
+                <input class="phonenum_login_layout_input" password="{{showAccPwd}}" maxlength="11" placeholder="输入密码" bindinput="bindPassWordInput" />
                 <view class="account_show_pwd_icon_layout" bindtap="showAccountPwd">
                     <image class="account_show_pwd_icon" style="margin-right: 22rpx;" src="../../image/login/account_show_pwd_icon.png"></image>
                 </view>
             </view>
 
-            <button class="login_btn" style="width: 618.06rpx; height: 83rpx; margin-top: 58rpx;">登 录</button>
+            <button class="login_btn" style="width: 618.06rpx; height: 83rpx; margin-top: 58rpx;font-weight: 500;" bindtap="submitInfo">确 认</button>
             <text style="margin-top: 21rpx;font-size: 30rpx;" bindtap="hideSelf">取消</text>
             <!-- 密码的input end-->
 

+ 71 - 9
miniprogram/pages/login/login.ts

@@ -1,5 +1,6 @@
 // index.ts
 
+import { ConstsData } from "../../utils/const";
 import { loginType } from "../../utils/loginType"
 import { httpUtil } from "../../utils/restful";
 
@@ -14,7 +15,10 @@ Page({
     inputPhoneNum: '',
     inputVCodeNum: '',
     inputPhonePwdLoginNum: '',
-    inputPwdText: ''
+    inputPwdText: '',
+    hasGetVCode: false,
+    getVCodeText: "获取验证码",
+    getvcodeInter: -5
   },
 
   onLoad(opention: any) {
@@ -33,8 +37,8 @@ Page({
     console.log(event)
     this.setData({
       login_check_tab: 0,
-      inputPhoneNum: '',
-      inputPhonePwdLoginNum: ''
+      // inputPhoneNum: '',
+      // inputPhonePwdLoginNum: ''
 
     })
 
@@ -46,14 +50,51 @@ Page({
     console.log(event)
     this.setData({
       login_check_tab: 1,
-      inputPhoneNum: '',
-      inputPhonePwdLoginNum: ''
+      // inputPhoneNum: '',
+      // inputPhonePwdLoginNum: ''
     })
   },
 
   // 获取验证码
   clickGetVCode: function (event: any) {
     console.log("账号密码登录")
+    if (this.data.hasGetVCode) {
+      this.showToast("请勿频繁点击")
+      return;
+    }
+    if (!this.data.inputPhoneNum) {
+      this.showToast("请输入手机号")
+      return;
+    }
+
+    let that = this;
+    let time = 60;
+
+    this.data.getvcodeInter = setInterval(function () {
+      if (time <= 1) {
+        clearInterval(that.data.getvcodeInter)
+        that.setData({
+          hasGetVCode: false,
+          getVCodeText: '获取验证码',
+          getvcodeInter: -5
+        })
+
+        return;
+      }
+      time--;
+      that.setData({
+        getVCodeText: time.toString(),
+        hasGetVCode: true
+      })
+    }, 1000)
+    let params = {
+      mobileNo: this.data.inputPhoneNum
+    }
+    httpUtil.wxGet(httpUtil.interfaces.getVerifyCode, params).then((res) => {
+      console.log("获取验证码成功:", res)
+    }).catch((res) => {
+      console.log("获取验证码失败:", res)
+    })
   },
 
 
@@ -118,7 +159,6 @@ Page({
 
   //短信验证码登录
   phoneVCodeLogin: function () {
-    console.log("this.data.inputPhoneNum:" + this.data.inputPhoneNum)
     if (!this.data.inputPhoneNum) {
       this.showToast('请输入手机号')
       return;
@@ -126,9 +166,26 @@ Page({
     if (!this.data.inputVCodeNum) {
       this.showToast('请输入验证码')
     }
-    let phone = this.data.inputPhoneNum;
-    let vcode = this.data.inputVCodeNum;
 
+    let params = {
+      mobile: this.data.inputPhoneNum,
+      verifyCode: this.data.inputVCodeNum
+    }
+
+    httpUtil.wxPost(httpUtil.interfaces.phoneRegister, params).then((res: any) => {
+
+      if (res.data.success) {
+        console.log("登录成功:", res)
+        httpUtil.httpData.userId = res.data.data.id;
+        ConstsData.AppData.myInfoData = res.data.data
+        this.toNextPage();
+      } else {
+        console.log("登录失败:", res)
+        this.showToast(res.data.message)
+      }
+    }).catch((res) => {
+      console.log("登录失败:", res)
+    })
   },
 
 
@@ -152,6 +209,7 @@ Page({
       if (res.data.success) {
         console.log("res.data.data:", res.data.data.id)
         httpUtil.httpData.userId = res.data.data.id
+        ConstsData.AppData.myInfoData = res.data.data
         this.toNextPage()
       } else {
         this.showToast(res.data.message)
@@ -223,7 +281,11 @@ Page({
     })
   },
 
-
+  onUnload() {
+    if (this.data.getvcodeInter != -5) {
+      clearInterval(this.data.getvcodeInter)
+    }
+  }
 
 
 

+ 3 - 3
miniprogram/pages/login/login.wxml

@@ -28,14 +28,14 @@
     <!--输入手机号的iput-->
     <view class="phonenum_login_layout_input_bg">
       <image class="phonenum_login_layout_input_icon" src="../../image/login/phone_num_icon.png"></image>
-      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPhoneInput" />
+      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPhoneInput" value="{{inputPhoneNum}}" />
     </view>
     <!--输入手机号的iput end-->
     <!--输入验证码的iput-->
     <view class="phonenum_login_layout_input_bg" style="margin-top: 48rpx;">
       <image class="phonenum_login_layout_input_icon" src="../../image/login/phone_vcode_icon.png"></image>
       <input class="phonenum_login_layout_input" maxlength="6" type="number" placeholder="输入验证码" bindinput="bindVCodeInput" />
-      <text style="color: #6275FE; font-size: 30rpx; margin-right: 19rpx;" bindtap="clickGetVCode">获取验证码</text>
+      <text class="phonenum_loing_layout_getvcode" bindtap="clickGetVCode">{{getVCodeText}}</text>
     </view>
     <!--输入验证码的iput end-->
 
@@ -46,7 +46,7 @@
     <!--输入手机号的iput-->
     <view class="phonenum_login_layout_input_bg">
       <image class="phonenum_login_layout_input_icon" src="../../image/login/phone_num_icon.png"></image>
-      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPwdLoginPhoneInput" />
+      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPwdLoginPhoneInput" value="{{inputPhonePwdLoginNum}}" />
     </view>
     <!--输入手机号的iput end-->
     <!-- 密码的input-->

+ 8 - 0
miniprogram/pages/login/login.wxss

@@ -81,6 +81,13 @@
   font-size: 30rpx;
 }
 
+.phonenum_loing_layout_getvcode {
+  color: #6275FE;
+  font-size: 30rpx;
+  margin-right: 19rpx;
+  width: 150rpx;
+  text-align: center;
+}
 
 .account_show_pwd_icon_layout {
   height: 100%;
@@ -113,6 +120,7 @@
   width: 100%;
   height: 89rpx;
   color: white;
+  font-weight: 500;
 }
 
 .updatepwd_layout {

+ 77 - 16
miniprogram/pages/register/register.ts

@@ -19,9 +19,9 @@ Page({
             Array<String>()
         ],
         regionIndex: [0, 0, 0],
-        schoolArray: [['中国']],
+        schoolArray: [['暂无学校']],
         schoolIndex: 0,
-        classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
+        classArray: ['暂无班级'],
         classIndex: 0,
         isShowPassWord: true,
         userName: '',
@@ -34,7 +34,10 @@ Page({
         schoolData: [{ 'id': '' }],
         schoolId: '',
         classData: [{ 'id': '' }],
-        classId: ''
+        classId: '',
+        hasGetVCode: false,
+        getVCodeText: "获取验证码",
+        getvcodeInter: -5,
     },
 
     /**
@@ -75,12 +78,11 @@ Page({
             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()
         })
-     
+
 
         //切换学校
         this.changeSchool();
 
-        //切换班级
     },
 
     //查询学校
@@ -94,7 +96,7 @@ Page({
             type: 1,
         }
         httpUtil.wxGet(httpUtil.interfaces.getSchoolOrClass, params).then((res: any) => {
-        
+
             this.setData({
                 schoolArray: [],
                 schoolIndex: 0,
@@ -110,11 +112,19 @@ Page({
             this.setData({
                 schoolArray: this.data.schoolArray
             })
-   
 
+            //切换班级
             this.changeClass()
         }).catch(res => {
             console.log("查询学校error:", res)
+            this.setData({
+                schoolArray: [['暂无学校']],
+                schoolId: '',
+                classArray: ['暂无班级'],
+                classId: ''
+
+
+            })
         })
     },
 
@@ -137,7 +147,7 @@ Page({
                 classId: res.data.data[0].id
             })
             res.data.data.forEach((element: { title: string; }) => {
-            
+
                 this.data.classArray.push(element.title)
             });
             this.setData({
@@ -148,6 +158,10 @@ Page({
 
         }).catch(res => {
             console.log("查询班级error:", res)
+            this.setData({
+                classArray: ['暂无班级'],
+                classId: ''
+            })
         })
     },
 
@@ -179,14 +193,14 @@ Page({
     },
 
     bindRegionChange: function (event: any) {
-     
+
         this.setData({
             regionIndex: event.detail.value
         })
 
     },
     bindSchoolPicker: function (event: any) {
- 
+
         this.setData({
             schoolIndex: event.detail.value,
             schoolId: this.data.schoolData[event.detail.value].id
@@ -197,13 +211,16 @@ Page({
     },
     bindClssPicker: function (event: any) {
         this.setData({
-            classIndex: event.detail.value
+            classIndex: event.detail.value,
+            classId: this.data.classData[event.detail.value].id
+
         })
+        console.log("班级ID:", this.data.classId)
     },
 
 
 
-    
+
     showPwdTab: function () {
         if (this.data.isShowPassWord) {
             this.setData({
@@ -224,7 +241,7 @@ Page({
 
     //获取输入的姓名
     bindUserNameInput: function (event: any) {
-       
+
         this.setData({
             userName: event.detail.value
         })
@@ -250,8 +267,45 @@ Page({
     },
 
     //获取验证码
-    getVerificationCode: function () {
+    getVerificationCode: function (event: any) {
+
+        if (this.data.hasGetVCode) {
+            this.showToast("请勿频繁点击")
+            return;
+        }
+        if (!this.data.userPhone) {
+            this.showToast("请输入手机号")
+            return;
+        }
+        let that = this;
+        let time = 60;
+
+        this.data.getvcodeInter = setInterval(function () {
+            if (time <= 1) {
+                clearInterval(that.data.getvcodeInter)
+                that.setData({
+                    hasGetVCode: false,
+                    getVCodeText: '获取验证码',
+                    getvcodeInter: -5
+
+                })
 
+                return;
+            }
+            time--;
+            that.setData({
+                getVCodeText: time.toString(),
+                hasGetVCode: true
+            })
+        }, 1000)
+        let params = {
+            mobileNo: this.data.userPhone
+        }
+        httpUtil.wxGet(httpUtil.interfaces.getVerifyCode, params).then((res) => {
+            console.log("获取验证码成功:", res)
+        }).catch((res) => {
+            console.log("获取验证码失败:", res)
+        })
     },
 
     doRegister: function () {
@@ -284,10 +338,12 @@ Page({
             userName: this.data.userPhone,//账号
             verifyCode: this.data.verificationCode//
         }
-   
+
         httpUtil.wxPost(httpUtil.interfaces.phoneRegister, params).then((res: any) => {
- 
+
             httpUtil.httpData.userId = res.data.data.id;
+            ConstsData.AppData.myInfoData = res.data.data;
+            console.log(" res.data.data:", res.data.data)
             wx.navigateTo({
                 url: '../teacher/index/index',
             })
@@ -302,6 +358,11 @@ Page({
         })
     },
 
+    onUnload() {
+        if (this.data.getvcodeInter != -5) {
+            clearInterval(this.data.getvcodeInter)
+        }
+    }
 
 
 })

+ 1 - 1
miniprogram/pages/register/register.wxml

@@ -61,7 +61,7 @@
             <view class="item_input_bg">
                 <text class="item_input_title">验证码:</text>
                 <input class="item_input_content" maxlength="11" placeholder="请输入验证码" bindinput="bindVerificationCodeInput" />
-                <text class="phonenum_getvcode" bindtap="getVerificationCode">获取验证码</text>
+                <text class="phonenum_getvcode" bindtap="getVerificationCode">{{getVCodeText}}</text>
             </view>
             <!--获取验证码 end-->
             <!--设置密码-->

+ 2 - 0
miniprogram/pages/register/register.wxss

@@ -72,7 +72,9 @@
 }
 
 .phonenum_getvcode {
+    width:120rpx;
     color: #FFAA12;
+    text-align: center;
     font-size: 25rpx;
     margin-right: 26rpx;
 }

+ 22 - 0
miniprogram/utils/const.ts

@@ -31,6 +31,28 @@ const AppData = {
             "disabled": false
         }
     },
+    myInfoData: {
+        code: 0,
+        data: null,
+        area: null,
+        areaUserId: null,
+        city: 0,
+        classId: 0,
+        className: null,
+        id: 0,
+        mobile: '',
+        name: "",
+        password: '',
+        province: 0,
+        provinceCity: '',
+        region: 0,
+        role: null,
+        schoolId: 0,
+        schoolName: null,
+        status: 0,
+        type: 3,
+        userName: ""
+    },
     
 
 

+ 22 - 4
miniprogram/utils/restful.ts

@@ -21,26 +21,44 @@ const interfaces = {
     //这里边放入请求的接口
 
     //获取全国地址
-    getOrganizeAll:'/organize/all',
+    getOrganizeAll: '/organize/all',
 
     //获取学校信息和班级信息(根据type判断)
-    getSchoolOrClass:'/school',
+    getSchoolOrClass: '/school',
 
     //手机号登录注册
     phoneRegister: '/tch/user/register',
 
+    //获取手机验证码
+    getVerifyCode: '/tch/user/verifyCode',
+
     //账号密码登录
     pwdPhoneLogin: '/tch/user/login',
 
+    //修改密码
+    updatePassWord: '/tch/user/updatePassword',
+
+    //更新个人信息
+    updateUserInfo: '/tch/user',
+
     //根据userId获取用户信息
-    getUserById: '/tch/user/getUserById'
+    getUserById: '/tch/user/getUserById',
+
+    //根据deviceId获取设备信息(后面拼接deviceId)
+    getDeviceById: '/tch/device/',
+
+    //提交设备报修
+    postDeviceFault: '/tch/fault'
+
+
+
 }
 
 function fun(url: String, type: any, data: any, otherType: any) {
     if (!TOKEN) {
         //这里可以做一个请求的拦截 看有没有携带token
         console.log("Token:", TOKEN)
-        
+
     }
     let promise = new Promise((resolve, reject) => {
         wx.request({