Kaynağa Gözat

1.修改监控界面的下拉弹窗逻辑
2.修改我的页面的下拉弹窗逻辑
3.增加登录方法

FailedToRead 2 yıl önce
ebeveyn
işleme
fe050cb327

+ 174 - 25
miniprogram/component/myInfo/myInfo.ts

@@ -1,4 +1,6 @@
 // component/myInfo/myInfo.ts
+import { ConstsData } from "../../utils/const"
+import { httpUtil } from "../../utils/restful";
 Component({
     /**
      * 组件的属性列表
@@ -11,67 +13,214 @@ Component({
      * 组件的初始数据
      */
     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,
+        provinceValue: '',//省份value
+        regionValue: '',//地区value
+        cityValue: '',
+        schoolData: [{ 'id': '' }],
+        schoolId: '',
+        classData: [{ 'id': '' }],
+        classId: '',
         isShowPassWord: true,
         userName: "",
         userPwd: ""
     },
 
+
+    lifetimes: {
+        attached: function () {
+            // 在组件实例被从页面节点树添加时执行
+
+            this.changeOrganizeInfo()
+
+        },
+        detached: function () {
+            // 在组件实例被从页面节点树移除时执行
+
+        },
+    },
+
+
     /**
      * 组件的方法列表
      */
     methods: {
-        bindRegionChange: function (event: any) {
-        
+
+
+
+
+        changeOrganizeInfo: function () {
+
+            //切换地区
+            this.setData({
+                regionOne: [],
+                regionTwo: [],
+                regionThree: []
+            })
+            ConstsData.AppData.organizeInfo.data.children.forEach((item: { title: String; }) => {
+                this.data.regionOne.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item: { title: String; }) => {
+
+                this.data.regionTwo.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item: { title: String; }) => {
+
+                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()
             })
+
+
+            //切换学校
+            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: { title: string; }) => {
+                    newArray.push(element.title)
+                });
+                this.data.schoolArray.push(newArray)
+                this.setData({
+                    schoolArray: this.data.schoolArray
+                })
+
+
+                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; }) => {
+
+                    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) {
+
             this.setData({
-                schoolIndex: event.detail.value
+                regionIndex: event.detail.value
             })
+
+        },
+        bindSchoolPicker: function (event: any) {
+
+            this.setData({
+                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({

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

@@ -10,11 +10,11 @@
         <!--选择地区-->
         <view class="item_input_bg">
             <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">
                 <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">
@@ -25,9 +25,9 @@
         <!--选择学校-->
         <view class="item_input_bg">
             <text class="item_input_title">学校:</text>
-            <picker bindchange="bindSchoolPicker" value="{{schoolIndex}}" range="{{schoolArray}}" class="item_picker_bg">
+            <picker mode="multiSelector" bindcolumnchange="bindSchoolPicker" range="{{schoolArray}}" class="item_picker_bg">
                 <view class="item_picker_content">
-                    {{schoolArray[schoolIndex]}}
+                    {{schoolArray[0][schoolIndex]}}
                 </view>
             </picker>
             <view class="item_picker_icon_layout">

+ 248 - 117
miniprogram/component/teacher/teacherMonitor/monitor.ts

@@ -1,15 +1,35 @@
 // pages/teacher/monitor/monitor.ts
-Page({
+import { ConstsData } from "../../../utils/const"
+import { httpUtil } from "../../../utils/restful";
+Component({
 
     /**
      * 页面的初始数据
      */
     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,
+        provinceValue: '',//省份value
+        regionValue: '',//地区value
+        cityValue: '',
+        schoolData: [{ 'id': '' }],
+        schoolId: '',
+        classData: [{ 'id': '' }],
+        classId: '',
         deviceId: '',
         //0=未上课 1=正在上课
         pageState: 0,
@@ -20,149 +40,260 @@ Page({
         videostatus: 0
     },
 
-    /**
-     * 生命周期函数--监听页面加载
-     */
-    onLoad() {
+    lifetimes: {
+        attached: function () {
+            // 在组件实例被从页面节点树添加时执行
 
-    },
+            this.changeOrganizeInfo()
 
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {
+        },
+        detached: function () {
+            // 在组件实例被从页面节点树移除时执行
 
+        },
     },
 
 
-    //选择地区回调
-    bindRegionChange: function (event: any) {
-        this.setData({
-            region: event.detail.value
-        })
-    },
-    //选择学校回调
-    bindSchoolPicker: function (event: any) {
-        let newArray;
-        switch (Number(event.detail.value)) {
-            case 0:
-                newArray = ["一", "二", "三"];
+    methods: {
+
+        changeOrganizeInfo: function () {
+
+            //切换地区
+            this.setData({
+                regionOne: [],
+                regionTwo: [],
+                regionThree: []
+            })
+            ConstsData.AppData.organizeInfo.data.children.forEach((item: { title: String; }) => {
+                this.data.regionOne.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children.forEach((item: { title: String; }) => {
+
+                this.data.regionTwo.push(item.title)
+            })
+
+            ConstsData.AppData.organizeInfo.data.children[this.data.regionOneIndex].children[this.data.regionTwoIndex].children.forEach((item: { title: String; }) => {
+
+                this.data.regionThree.push(item.title)
+            })
+
+
+            this.setData({
+                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()
+            })
+
+
+            //切换学校
+            this.changeSchool();
+
+            //切换班级
+        },
+
+        //查询学校
+        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({
-                    classArray: newArray,
-                    classIndex: 0
+                    schoolArray: [],
+                    schoolIndex: 0,
+                    schoolData: res.data.data,
+                    schoolId: res.data.data[0].id
                 })
-                break;
-            case 1:
-                newArray = ["4", "5", "6"];
+
+                let newArray: string[] = [];
+                res.data.data.forEach((element: { title: string; }) => {
+                    newArray.push(element.title)
+                });
+                this.data.schoolArray.push(newArray)
                 this.setData({
-                    classArray: newArray,
-                    classIndex: 0
+                    schoolArray: this.data.schoolArray
                 })
-                break;
-            case 2:
-                newArray = ["as", "ad", "af"];
+
+
+                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: newArray,
+                    classArray: [],
                     classIndex: 0
                 })
-                break;
-            case 3:
-                newArray = ["b1", "b2", "b3"];
                 this.setData({
-                    classArray: newArray,
-                    classIndex: 0
+                    classData: res.data.data,
+                    classId: res.data.data[0].id
                 })
-                break;
-        }
-        this.setData({
-            schoolIndex: event.detail.value
-        })
-    },
-    //选择班级回调
-    bindClssPicker: function (event: any) {
-        this.setData({
-            classIndex: event.detail.value
-        })
-    },
+                res.data.data.forEach((element: { title: string; }) => {
 
-    //扫码界面(未处理回调)
-    scanCode: function () {
-        var that = this;
-        wx.scanCode({ //扫描API
-            success(res) { //扫描成功
-                console.log(res) //输出回调信息
-                that.setData({
-                    scanCodeMsg: res.result
+                    this.data.classArray.push(element.title)
                 });
-                wx.showToast({
-                    title: '扫码成功',
-                    icon: 'success',
-                    duration: 1000
-                })
-            },
-            fail: (res: any) => {//接口调用失败的回调函数
-                wx.showToast({
-                    title: '扫码失败',
-                    icon: 'success',
-                    duration: 1000
+                this.setData({
+                    classArray: this.data.classArray,
+
                 })
-            },
-        })
-    },
 
-    //获取设备ID的输入
-    bindDeviceInput(event: any) {
-        this.setData({
-            deviceId: event.detail.value
-        })
-    },
 
+            }).catch(res => {
+                console.log("查询班级error:", res)
+            })
+        },
+
+
+        bindMultiPickerColumnChange: function (event: any) {
+
+            //
+            switch (Number(event.detail.column)) {
+                case 0:
+                    //代表第一列
+                    this.setData({
+                        regionOneIndex: event.detail.value,
+                    })
+                    break;
+                case 1:
+                    //代表第二列
+                    this.setData({
+                        regionTwoIndex: event.detail.value,
+                    })
+                    break;
+                case 2:
+                    //代表第三列
+                    this.setData({
+                        regionThreeIndex: event.detail.value
+                    })
+                    break;
+            }
+            this.changeOrganizeInfo();
+        },
+
+        bindRegionChange: function (event: any) {
 
-    //上课
-    startMonitor: function () {
-        if (!this.data.deviceId) {
-            wx.showToast({
-                title: '请输入设备ID',
-                icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
-                duration: 1000
+            this.setData({
+                regionIndex: event.detail.value
             })
-            return;
-        }
-        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],
-            deviceId: this.data.deviceId
-        }
-        console.log("params:", params)
-        //开始上课
-        this.setData({
-            pageState: 1
-        })
-    },
 
+        },
+        bindSchoolPicker: function (event: any) {
 
+            this.setData({
+                schoolIndex: event.detail.value,
+                schoolId: this.data.schoolData[event.detail.value].id
+            })
 
-    //上课之后的方法
-    //下课
-    classOver: function () {
-        //下课
-        let that = this;
-        wx.showModal({
-            title: '',
-            content: '确定下课么',
-            success: function (res) {
-                if (res.confirm) {
-                    console.log('点击确认回调')
+            this.changeClass();
+
+        },
+        bindClssPicker: function (event: any) {
+            this.setData({
+                classIndex: event.detail.value
+            })
+        },
+
+
+
+        //扫码界面(未处理回调)
+        scanCode: function () {
+            var that = this;
+            wx.scanCode({ //扫描API
+                success(res) { //扫描成功
+                    console.log(res) //输出回调信息
                     that.setData({
-                        pageState: 0
+                        scanCodeMsg: res.result
+                    });
+                    wx.showToast({
+                        title: '扫码成功',
+                        icon: 'success',
+                        duration: 1000
                     })
-                } else {
-                    console.log('点击取消回调')
-                }
+                },
+                fail: (res: any) => {//接口调用失败的回调函数
+                    wx.showToast({
+                        title: '扫码失败',
+                        icon: 'success',
+                        duration: 1000
+                    })
+                },
+            })
+        },
+
+        //获取设备ID的输入
+        bindDeviceInput(event: any) {
+            this.setData({
+                deviceId: event.detail.value
+            })
+        },
+
+
+        //上课
+        startMonitor: function () {
+            if (!this.data.deviceId) {
+                wx.showToast({
+                    title: '请输入设备ID',
+                    icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
+                    duration: 1000
+                })
+                return;
             }
-        })
+            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],
+                deviceId: this.data.deviceId
+            }
+            console.log("params:", params)
+            //开始上课
+            this.setData({
+                pageState: 1
+            })
+        },
+
+
+
+        //上课之后的方法
+        //下课
+        classOver: function () {
+            //下课
+            let that = this;
+            wx.showModal({
+                title: '',
+                content: '确定下课么',
+                success: function (res) {
+                    if (res.confirm) {
+                        console.log('点击确认回调')
+                        that.setData({
+                            pageState: 0
+                        })
+                    } else {
+                        console.log('点击取消回调')
+                    }
+                }
+            })
 
 
+        }
     }
+
 })

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

@@ -12,11 +12,11 @@
             <!--选择地区-->
             <view class="item_input_bg" style=" margin-top: 0rpx;   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">
                     <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">
@@ -27,9 +27,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}}" class="item_picker_bg">
                     <view class="item_picker_content">
-                        {{schoolArray[schoolIndex]}}
+                        {{schoolArray[0][schoolIndex]}}
                     </view>
                 </picker>
                 <view class="item_picker_icon_layout">

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

@@ -147,8 +147,15 @@ Page({
       password: this.data.inputPwdText,
       userName: this.data.inputPhonePwdLoginNum
     }
-    httpUtil.wxPost(httpUtil.interfaces.pwdPhoneLogin, params).then((res) => {
-      console.log("res:", res)
+    httpUtil.wxPost(httpUtil.interfaces.pwdPhoneLogin, params).then((res: any) => {
+      console.log("res:", res.data)
+      if (res.data.success) {
+        console.log("res.data.data:", res.data.data.id)
+        httpUtil.httpData.userId = res.data.data.id
+        this.toNextPage()
+      } else {
+        this.showToast(res.data.message)
+      }
     }).catch((res) => {
       console.log(res)
     })

+ 10 - 11
miniprogram/pages/register/register.ts

@@ -75,7 +75,7 @@ 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()
         })
-        console.log("provinceValue", this.data.provinceValue)
+     
 
         //切换学校
         this.changeSchool();
@@ -85,7 +85,7 @@ Page({
 
     //查询学校
     changeSchool: function () {
-        console.log("查询学校")
+
         //查询学校
         let params = {
             city: this.data.cityValue,
@@ -94,7 +94,7 @@ Page({
             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,
@@ -110,7 +110,7 @@ Page({
             this.setData({
                 schoolArray: this.data.schoolArray
             })
-            console.log("schoolId:", this.data.schoolId)
+   
 
             this.changeClass()
         }).catch(res => {
@@ -137,7 +137,7 @@ Page({
                 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({
@@ -179,15 +179,14 @@ Page({
     },
 
     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,
             schoolId: this.data.schoolData[event.detail.value].id
@@ -225,7 +224,7 @@ Page({
 
     //获取输入的姓名
     bindUserNameInput: function (event: any) {
-        console.log("event.detail.value:",)
+       
         this.setData({
             userName: event.detail.value
         })
@@ -285,9 +284,9 @@ Page({
             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',