Procházet zdrojové kódy

1.注册界面接口逻辑
2.注册界面UI大修改

FailedToRead před 2 roky
rodič
revize
621d4c0c99

+ 2 - 1
miniprogram/app.json

@@ -13,7 +13,8 @@
         "backgroundTextStyle": "light",
         "navigationBarBackgroundColor": "#fff",
         "navigationBarTitleText": "Weixin",
-        "navigationBarTextStyle": "black"
+        "navigationBarTextStyle": "black",
+        "disableScroll": true
     },
     "style": "v2",
     "sitemapLocation": "sitemap.json"

+ 46 - 1
miniprogram/component/myInfo/myInfo.ts

@@ -16,13 +16,21 @@ Component({
         schoolIndex: 0,
         classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
         classIndex: 0,
-        isShowPassWord: true
+        isShowPassWord: true,
+        userName: "",
+        userPwd: ""
     },
 
     /**
      * 组件的方法列表
      */
     methods: {
+        bindRegionChange: function (event: any) {
+        
+            this.setData({
+                region: event.detail.value
+            })
+        },
         bindSchoolPicker: function (event: any) {
             let newArray;
             switch (Number(event.detail.value)) {
@@ -75,6 +83,43 @@ Component({
                 })
             }
 
+        },
+
+        bindUserNameInput: function (event: any) {
+            this.setData({
+                userName: event.detail.value
+            })
+        },
+        bindUserPwdInput: function (event: any) {
+            this.setData({
+                userPwd: event.detail.value
+            })
+        },
+        submitMyInfo: function () {
+            if (!this.data.userName) {
+                wx.showToast({
+                    title: '请输入姓名',
+                    icon: 'none',
+                    duration: 1000
+                })
+                return;
+            }
+            if (!this.data.userPwd) {
+                wx.showToast({
+                    title: '请输入密码',
+                    icon: 'none',
+                    duration: 1000
+                })
+                return;
+            }
+            let params = {
+                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
+            }
+            console.log("params:", params)
         }
     }
 })

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

@@ -4,7 +4,7 @@
         <!--输入姓名-->
         <view class="item_input_bg">
             <text class="item_input_title">姓名:</text>
-            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" />
+            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" bindinput="bindUserNameInput" />
         </view>
         <!--输入姓名 end-->
         <!--选择地区-->
@@ -51,7 +51,7 @@
         <!--设置密码-->
         <view class="item_input_bg">
             <text class="item_input_title">设置密码:</text>
-            <input class="item_input_content" maxlength="11" password="{{isShowPassWord}}" placeholder="请输入密码" />
+            <input class="item_input_content" maxlength="11" password="{{isShowPassWord}}" placeholder="请输入密码" bindinput="bindUserPwdInput" />
             <view class="phonenum_pwd_icon" bindtap="showPwdTab">
                 <image src="../../image/login/account_show_pwd_icon.png" style="width:33rpx;height:22rpx;"></image>
             </view>
@@ -60,7 +60,7 @@
         <!--设置密码 end-->
         <!-- 按钮-->
         <view>
-            <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 267rpx;">
+            <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 267rpx;" bindtap="submitMyInfo">
                 <button class="login_btn" style="width: 100%; margin-left: 0rpx;">确认</button>
             </view>
         </view>

+ 141 - 0
miniprogram/component/teacher/teacherFault/teacherFault.ts

@@ -11,6 +11,19 @@ Component({
      * 组件的初始数据
      */
     data: {
+        //判断当前页面显示哪个view
+        pageState: 0,
+        pageStateText: ['故障报修', '报修记录'],
+        //故障报修界面所用数据
+        fault: ['紧急', '不紧急'],
+        faultIndex: 0,
+        region: ['北京市', '北京市', '海淀区'],
+        schoolArray: ['中国', '美国', '巴西', '日本'],
+        schoolIndex: 0,
+        classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
+        classIndex: 0,
+        deviceId: '',
+        faultText: ""
 
     },
 
@@ -19,5 +32,133 @@ Component({
      */
     methods: {
 
+        //选择是故障报修界面还是报修记录界面
+        bindPageChange: function (event: any) {
+            console.log("event.detail.value:", event.detail.value)
+            this.setData({
+                pageState: event.detail.value
+            })
+        },
+
+
+        //选择是否紧急
+        bindFaultChange: function (event: any) {
+            this.setData({
+                faultIndex: event.detail.value
+            })
+        },
+
+        //选择地区回调
+        bindRegionChange: function (event: any) {
+            this.setData({
+                region: event.detail.value
+            })
+        },
+        //选择学校回调
+        bindSchoolPicker: function (event: any) {
+            let newArray;
+            switch (Number(event.detail.value)) {
+                case 0:
+                    newArray = ["一", "二", "三"];
+                    this.setData({
+                        classArray: newArray,
+                        classIndex: 0
+                    })
+                    break;
+                case 1:
+                    newArray = ["4", "5", "6"];
+                    this.setData({
+                        classArray: newArray,
+                        classIndex: 0
+                    })
+                    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
+                    })
+                    break;
+            }
+            this.setData({
+                schoolIndex: event.detail.value
+            })
+        },
+        //选择班级回调
+        bindClssPicker: function (event: any) {
+            this.setData({
+                classIndex: event.detail.value
+            })
+        },
+
+
+        //获取设备ID的输入
+        bindDeviceInput(event: any) {
+            this.setData({
+                deviceId: event.detail.value
+            })
+        },
+
+        //获取故障描述输入
+        bindFaultText: function (event: any) {
+            this.setData({
+                faultText: event.detail.value
+            })
+        },
+
+        //提交故障
+        submitFault: function (event: any) {
+            if (!this.data.deviceId) {
+                wx.showToast({
+                    title: '请输入设备ID',
+                    icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
+                    duration: 1000
+                })
+                return;
+            }
+            if (!this.data.faultText) {
+                wx.showToast({
+                    title: '请输入故障描述',
+                    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,
+                fault: this.data.fault[this.data.faultIndex],
+                faultText: this.data.faultText
+
+            }
+            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)
+        }
+
     }
 })

+ 94 - 4
miniprogram/component/teacher/teacherFault/teacherFault.wxml

@@ -1,14 +1,104 @@
 <view class="page">
     <view class="toptitle">
-        <text class="toptitle_left">报修记录</text>
+        <text wx:if="{{pageState==1}}" class="toptitle_left">报修记录</text>
+        <text wx:else class="toptitle_left"></text>
         <view class="toptitle_right">
-            <text class="toptitle_right_text">报修记录</text>
+            <picker bindchange="bindPageChange" value="{{pageState}}" range="{{pageStateText}}" >
+                <text class="toptitle_right_text">{{pageStateText[pageState]}}</text>
+            </picker>
+
             <image src="../../../image/teacher/dorpdown_white_icon.png" class="toptitle_right_icon"></image>
         </view>
     </view>
-    <scroll-view scroll-y="true" class="scrollview">
-        <view wx:for="{{30}}" class="scroll_item_bg">
+
+
+    <view wx:if="{{pageState==0}}">
+        <view class="center_picker_layout" style="margin-top: 24rpx;">
+            <!--是否紧急-->
+            <view class="item_input_bg" style=" margin-top: 0rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
+                <text class="item_input_title">故障级别:</text>
+                <picker bindchange="bindFaultChange" value="{{faultIndex}}" range="{{fault}}" class="item_picker_bg">
+                    <view class="item_picker_content">
+                        {{fault[faultIndex]}}
+                    </view>
+                </picker>
+                <view class="item_picker_icon_layout">
+                    <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
+                </view>
+            </view>
+            <!--是否紧急end-->
+            <!--选择地区-->
+            <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">
+                    <view class="item_picker_content">
+                        <p> {{region[0]}} </p>
+                        <p> {{region[1]}} </p>
+                        <p> {{region[2]}} </p>
+                    </view>
+                </picker>
+                <view class="item_picker_icon_layout">
+                    <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
+                </view>
+            </view>
+            <!--选择地区 end-->
+            <!--选择学校-->
+            <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">
+                    <view class="item_picker_content">
+                        {{schoolArray[schoolIndex]}}
+                    </view>
+                </picker>
+                <view class="item_picker_icon_layout">
+                    <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
+                </view>
+            </view>
+            <!--选择学校end-->
+            <!--选择班级-->
+            <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_icon_layout">
+                    <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
+                </view>
+            </view>
+            <!--选择班级end-->
+            <view class="item_input_bg" style="margin-top: 1rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
+                <text class="item_input_title">设备ID:</text>
+                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" />
+            </view>
+        </view>
+        <view class="fault_info_layout">
+            <textarea bindinput="bindFaultText" class="fault_info_textarea" placeholder="故障描述:请描述故障情况请描述故障情况,\n请描述故障情况请描述故障情况"></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>
+                </view>
+            </scroll-view>
+        </view>
+
+
+        <view class="submitFault_layout">
+            <button class="submitFault" bindtap="submitFault">提交</button>
+        </view>
+
+
+    </view>
+
+
+    <!-- 报修记录-->
+    <scroll-view wx:if="{{pageState==1}}" scroll-y="true" class="scrollview">
+        <view wx:for="{{30}}" class="scroll_item_bg" wx:key="index">
             <fauleItem faultStatus="{{index%3}}"></fauleItem>
         </view>
     </scroll-view>
+    <!-- 报修记录-->
+
+
+
 </view>

+ 60 - 1
miniprogram/component/teacher/teacherFault/teacherFault.wxss

@@ -1,4 +1,7 @@
 /* component/teacher/teacherFault/teacherFault.wxss */
+@import "../../../pages/register/register.wxss";
+@import "../../../pages/login/login.wxss";
+
 .page {
     display: flex;
     flex-direction: column;
@@ -53,10 +56,66 @@
     flex: 1;
     height: 0;
     width: 100%;
-    margin-bottom: 112rpx;
+    margin-bottom: 152rpx;
 }
 
 .scroll_item_bg {
     display: flex;
     justify-content: center;
+}
+
+
+/* 故障报修样式 */
+
+
+.fault_info_textarea {
+    font-size: 30rpx;
+    width: 580rpx;
+    word-wrap: break-word;
+    white-space: pre-line;
+    height: 84rpx;
+    margin-top: 52rpx;
+    background-color: #f1f1f1;
+}
+
+.fault_info_scroll {
+    width: 580rpx;
+    display: flex;
+    flex-direction: row;
+    white-space: nowrap;
+    margin-top: 25rpx;
+}
+
+.fault_info_layout {
+    display: flex;
+    justify-content: center;
+    flex-direction: column;
+    align-items: center;
+}
+
+.fault_info_scroll_item {
+    width: 167rpx;
+    height: 93rpx;
+    background-color: saddlebrown;
+    margin-left: 10rpx;
+    margin-right: 10rpx;
+}
+
+.submitFault_layout {
+    width: 100;
+    display: flex;
+    margin-top: 150rpx;
+    justify-content: center;
+    align-items: center;
+}
+
+.submitFault {
+    width: 327rpx;
+    height: 73rpx;
+    font-size: 30rpx;
+    font-weight: 600;
+    text-align: center;
+    background-color: #7DB0FF;
+    color: #FFFFFF;
+    border-radius: 7rpx;
 }

+ 2 - 2
miniprogram/component/teacher/teacherFile/teacherFile.wxml

@@ -2,7 +2,7 @@
     <view>
         <!--搜索框-->
         <view class="search_layout">
-            <image class="search_layout_icon"></image>
+            <image class="search_layout_icon" src="../../../image/teacher/search_icon.png"></image>
             <input class="search_layout_input" placeholder="输入关键词搜索" />
         </view>
         <!--搜索框-->
@@ -12,7 +12,7 @@
     </view>
 
     <scroll-view scroll-y="true" class="scrollview">
-        <view wx:for="{{20}}" style="display: flex; justify-content: center;">
+        <view wx:for="{{20}}" class="scroll_item_bg" wx:key="index">
             <fileItem></fileItem>
         </view>
 

+ 4 - 1
miniprogram/component/teacher/teacherFile/teacherFile.wxss

@@ -21,7 +21,6 @@
 .search_layout_icon {
     width: 46rpx;
     height: 46rpx;
-    background-color: red;
     margin-left: 20rpx;
 }
 
@@ -51,4 +50,8 @@
     height: 0;
     width: 100%;
     margin-bottom: 112rpx;
+}
+.scroll_item_bg {
+    display: flex;
+    justify-content: center;
 }

+ 92 - 1
miniprogram/component/teacher/teacherMonitor/monitor.ts

@@ -10,6 +10,14 @@ Page({
         schoolIndex: 0,
         classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
         classIndex: 0,
+        deviceId: '',
+        //0=未上课 1=正在上课
+        pageState: 0,
+
+        //开始上课用到的数据
+
+        //0是正常,1是error
+        videostatus: 0
     },
 
     /**
@@ -27,12 +35,13 @@ Page({
     },
 
 
+    //选择地区回调
     bindRegionChange: function (event: any) {
-        console.log('picker发送选择改变,携带值为', event.detail.value)
         this.setData({
             region: event.detail.value
         })
     },
+    //选择学校回调
     bindSchoolPicker: function (event: any) {
         let newArray;
         switch (Number(event.detail.value)) {
@@ -69,9 +78,91 @@ Page({
             schoolIndex: event.detail.value
         })
     },
+    //选择班级回调
     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({
+                    scanCodeMsg: res.result
+                });
+                wx.showToast({
+                    title: '扫码成功',
+                    icon: 'success',
+                    duration: 1000
+                })
+            },
+            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('点击取消回调')
+                }
+            }
+        })
+
+
+    }
 })

+ 39 - 5
miniprogram/component/teacher/teacherMonitor/monitor.wxml

@@ -1,7 +1,7 @@
 <!--pages/teacher/monitor/monitor.wxml-->
-<view class="container" style="background-color: #F4F4F4;">
+<view wx:if="{{pageState==0}}" class="container" style="background-color: #F4F4F4;">
     <view class="qrcode_layout">
-        <view class="qrcode_layout_bg">
+        <view class="qrcode_layout_bg" bindtap="scanCode">
             <image src="../../../image/teacher/qrcode.png" style="width:60rpx;height:60rpx"></image>
             <text>扫一扫</text>
         </view>
@@ -52,11 +52,45 @@
             <!--选择班级end-->
             <view class="item_input_bg" style="margin-top: 1rpx;">
                 <text class="item_input_title">设备ID:</text>
-                <input class="item_input_content" placeholder="请输入设备ID" />
+                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" />
             </view>
         </view>
-        <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 190rpx;">
+        <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 190rpx;" bindtap="startMonitor">
             <button class="login_btn" style="width: 100%; margin-left: 0rpx;font-size: 36rpx;font-weight: 400;">开始上课</button>
         </view>
     </view>
-</view>
+</view>
+
+
+<!--开始上课之后-->
+<view wx:if="{{pageState==1}}" class="container" style="background-color: #F4F4F4;">
+    <view style="margin-top: 33rpx;">
+        <text class="title">设备监控</text>
+    </view>
+    <!--播放视频的视频框-->
+    <view style="width: 100%;height: 422rpx; background-color: blue;margin-top: 40rpx;;display: flex;">
+        <live-player style="width: 100%; height: 100%; "></live-player>
+        <view style="width: 100%;height: 422rpx; position: absolute;">
+            <view class="light_green {{videostatus==1?'light_red':''}}"></view>
+        </view>
+    </view>
+    <!--播放视频的视频框-->
+
+    <!-- 快照-->
+    <view style="margin-top:48rpx;font-size:25rpx;font-weight: 500;">
+        <text style="margin-left:10rpx">快照</text>
+        <scroll-view scroll-x class="image_scroll">
+            <view wx:for="{{20}}" wx:key="index" style="display:inline-block;">
+                <image class="image"></image>
+                <view class="image_index">{{index}}</view>
+            </view>
+        </scroll-view>
+    </view>
+    <!-- 快照-->
+    <!-- 下课按钮-->
+    <view>
+        <image bindtap="classOver" class="class_over" src="../../../image/teacher/class_over.png"></image>
+    </view>
+    <!-- 下课按钮-->
+</view>
+<!--开始上课之后-->

+ 75 - 0
miniprogram/component/teacher/teacherMonitor/monitor.wxss

@@ -39,4 +39,79 @@
     height: 324rpx;
     border-radius: 20rpx;
     margin-top: 27rpx;
+}
+
+
+
+
+/* 上课的wxss */
+
+
+.title {
+    margin-left: 11rpx;
+    font-size: 32rpx;
+    font-weight: 500;
+}
+
+.light_green {
+    width: 16rpx;
+    height: 16rpx;
+    background: radial-gradient(#85ff98, #4ce65d);
+    border-radius: 50%;
+    box-shadow: 0px 1px 10px 4px #6bff93;
+    position: absolute;
+    left: 13rpx;
+    top: 13rpx;
+}
+
+.light_red {
+    width: 16rpx;
+    height: 16rpx;
+    background: radial-gradient(#ff8585, #e65e4c);
+    border-radius: 50%;
+    box-shadow: 0px 1px 10px 4px #ff8585;
+    position: absolute;
+    left: 13rpx;
+    top: 13rpx;
+}
+
+
+.image {
+    height: 115rpx;
+    width: 203rpx;
+    background-color: burlywood;
+    margin-left: 10rpx;
+    margin-right: 10rpx;
+    align-items: center;
+    justify-content: center;
+}
+
+.image_index {
+    width: 190rpx;
+    position: absolute;
+    top: 0rpx;
+    margin-left: 10rpx;
+    text-align: right;
+    color: #5F5F5F;
+    font-size: 28rpx;
+    font-weight: 400;
+
+}
+
+.image_scroll {
+    width: 100%;
+    height: 115rpx;
+    display: flex;
+    flex-direction: row;
+    white-space: nowrap;
+    justify-content: center;
+    margin-top: 8rpx;
+}
+
+.class_over {
+    width: 133rpx;
+    height: 133rpx;
+    position: absolute;
+    right: 0rpx;
+    bottom: 150rpx;
 }

binární
miniprogram/image/teacher/class_over.png


+ 1 - 1
miniprogram/pages/index/index.json

@@ -1,6 +1,6 @@
 {
   "usingComponents": {
-  
+
   },
 
   "navigationBarTitleText": ""

+ 8 - 6
miniprogram/pages/index/index.ts

@@ -1,6 +1,7 @@
 // pages/index/index.ts
 import { httpUtil } from "../../utils/restful";
-import { loginType } from '../../utils/loginType'
+import { loginType } from '../../utils/loginType';
+import { ConstsData } from "../../utils/const"
 
 Page({
 
@@ -15,11 +16,12 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad() {
-        // httpUtil.wxGet(httpUtil.interfaces.getUserById, null).then((res) => {
-        //     console.log("res:", res)
-        // }).catch((res) => {
-        //     console.log(res)
-        // })
+        httpUtil.wxGet(httpUtil.interfaces.getOrganizeAll, null).then((res: any) => {
+            ConstsData.AppData.organizeInfo = res.data
+
+        }).catch((res) => {
+            console.log(res)
+        })
     },
     clickItem: function (event: any) {
         console.log(event.target.id)

+ 117 - 6
miniprogram/pages/login/login.ts

@@ -1,16 +1,20 @@
 // index.ts
 
 import { loginType } from "../../utils/loginType"
+import { httpUtil } from "../../utils/restful";
 
-// 获取应用实例
-const app = getApp<IAppOption>()
 
 Page({
   data: {
     login_check_tab: 0,
     loginType: 0,
     showAccPwd: true,
-    showUpdatePassWordLayout: false
+    showUpdatePassWordLayout: false,
+    //短信验证码登录参数
+    inputPhoneNum: '',
+    inputVCodeNum: '',
+    inputPhonePwdLoginNum: '',
+    inputPwdText: ''
   },
 
   onLoad(opention: any) {
@@ -28,7 +32,10 @@ Page({
     console.log("短信验证码登录")
     console.log(event)
     this.setData({
-      login_check_tab: 0
+      login_check_tab: 0,
+      inputPhoneNum: '',
+      inputPhonePwdLoginNum: ''
+
     })
 
   },
@@ -38,7 +45,9 @@ Page({
     console.log("账号密码登录")
     console.log(event)
     this.setData({
-      login_check_tab: 1
+      login_check_tab: 1,
+      inputPhoneNum: '',
+      inputPhonePwdLoginNum: ''
     })
   },
 
@@ -84,7 +93,98 @@ Page({
       url: '../register/register',
     })
   },
+
+
+
+  //判断是短信登录还是账号密码登录进行相应登录
   toTabIndex: function () {
+
+    switch (Number(this.data.login_check_tab)) {
+      case 0:
+        //短信验证码登录
+        this.phoneVCodeLogin();
+        break;
+      case 1:
+        //账号密码登录
+
+        this.pwdPhoneLogin();
+        break;
+    }
+
+    // this.toNextPage();
+  },
+
+
+
+  //短信验证码登录
+  phoneVCodeLogin: function () {
+    console.log("this.data.inputPhoneNum:" + this.data.inputPhoneNum)
+    if (!this.data.inputPhoneNum) {
+      this.showToast('请输入手机号')
+      return;
+    }
+    if (!this.data.inputVCodeNum) {
+      this.showToast('请输入验证码')
+    }
+    let phone = this.data.inputPhoneNum;
+    let vcode = this.data.inputVCodeNum;
+
+  },
+
+
+  //账号密码登录
+  pwdPhoneLogin: function () {
+
+    if (!this.data.inputPhonePwdLoginNum) {
+      this.showToast('请输入手机号')
+      return;
+    }
+    if (!this.data.inputPwdText) {
+      this.showToast('请输入密码')
+    }
+
+    let params = {
+      password: this.data.inputPwdText,
+      userName: this.data.inputPhonePwdLoginNum
+    }
+    httpUtil.wxPost(httpUtil.interfaces.pwdPhoneLogin, params).then((res) => {
+      console.log("res:", res)
+    }).catch((res) => {
+      console.log(res)
+    })
+  },
+
+
+  bindPhoneInput: function (event: any) {
+    this.setData({
+      inputPhoneNum: event.detail.value
+    })
+
+  },
+
+  bindPwdLoginPhoneInput: function (event: any) {
+    this.setData({
+      inputPhonePwdLoginNum: event.detail.value
+    })
+
+  },
+
+  bindVCodeInput: function (event: any) {
+    this.setData({
+      inputVCodeNum: event.detail.value
+    })
+  },
+
+  bindPwdInput: function (event: any) {
+    this.setData({
+      inputPwdText: event.detail.value
+    })
+  },
+
+
+  //登录成功后跳转界面
+  toNextPage: function () {
+
     let toUrl = '';
     switch (Number(this.data.loginType)) {
       case loginType.Teacher:
@@ -107,6 +207,17 @@ Page({
     wx.navigateTo({
       url: toUrl,
     })
-  }
+  },
+
+  showToast: function (message: string) {
+    wx.showToast({
+      title: message,
+      icon: 'none'
+    })
+  },
+
+
+
+
 
 })

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

@@ -28,13 +28,13 @@
     <!--输入手机号的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="输入您的手机号" />
+      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPhoneInput" />
     </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="输入验证码" />
+      <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>
     </view>
     <!--输入验证码的iput end-->
@@ -46,13 +46,13 @@
     <!--输入手机号的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="输入您的手机号" />
+      <input class="phonenum_login_layout_input" maxlength="11" type="number" placeholder="输入您的手机号" bindinput="bindPwdLoginPhoneInput" />
     </view>
     <!--输入手机号的iput end-->
     <!-- 密码的input-->
     <view class="phonenum_login_layout_input_bg" style="margin-top: 48rpx;">
       <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="bindPwdInput" />
       <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>

+ 250 - 27
miniprogram/pages/register/register.ts

@@ -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'
+        })
+    },
+
+
 
 })

+ 13 - 12
miniprogram/pages/register/register.wxml

@@ -4,17 +4,18 @@
         <!--输入姓名-->
         <view class="item_input_bg">
             <text class="item_input_title">姓名:</text>
-            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" />
+            <input class="item_input_content" maxlength="11" placeholder="请输入姓名" bindinput="bindUserNameInput" />
         </view>
         <!--输入姓名 end-->
         <!--选择地区-->
         <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 +26,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">
@@ -53,20 +54,20 @@
             <!--输入手机号-->
             <view class="item_input_bg">
                 <text class="item_input_title">手机号:</text>
-                <input class="item_input_content" maxlength="11" placeholder="请输入手机号" />
+                <input class="item_input_content" maxlength="11" placeholder="请输入手机号" bindinput="bindUserPhoneInput" />
             </view>
             <!--输入手机号 end-->
             <!--获取验证码-->
             <view class="item_input_bg">
                 <text class="item_input_title">验证码:</text>
-                <input class="item_input_content" maxlength="11" placeholder="请输入验证码" />
-                <text class="phonenum_getvcode">获取验证码</text>
+                <input class="item_input_content" maxlength="11" placeholder="请输入验证码" bindinput="bindVerificationCodeInput" />
+                <text class="phonenum_getvcode" bindtap="getVerificationCode">获取验证码</text>
             </view>
             <!--获取验证码 end-->
             <!--设置密码-->
             <view class="item_input_bg">
                 <text class="item_input_title">设置密码:</text>
-                <input class="item_input_content" maxlength="11" password="{{isShowPassWord}}" placeholder="请输入密码" />
+                <input class="item_input_content" maxlength="11" password="{{isShowPassWord}}" placeholder="请输入密码" bindinput="bindPwdInput" />
                 <view class="phonenum_pwd_icon" bindtap="showPwdTab">
                     <image src="../../image/login/account_show_pwd_icon.png" style="width:33rpx;height:22rpx;"></image>
                 </view>
@@ -77,7 +78,7 @@
         <!-- 按钮-->
         <view>
             <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 267rpx;">
-                <button class="login_btn" style="width: 100%; margin-left: 0rpx;">确认</button>
+                <button class="login_btn" style="width: 100%; margin-left: 0rpx;" bindtap="doRegister">确认</button>
                 <text style="margin-top: 21rpx;" bindtap="exitPage">取消</text>
             </view>
         </view>

+ 40 - 0
miniprogram/utils/const.ts

@@ -0,0 +1,40 @@
+const AppData = {
+    organizeInfo: {
+        "success": "",
+        "code": 0,
+        "message": null,
+        "data": {
+            "title": "",
+            "value": 0,
+            "children": [
+                {
+                    "title": "",
+                    "value": 0,
+                    "children": [
+                        {
+                            "title": "",
+                            "value": 0,
+                            "children": [
+                                {
+                                    "title": "",
+                                    "value": 0,
+                                    "children": null,
+                                    "disabled": false
+                                }
+                            ],
+                            "disabled": false
+                        }
+                    ],
+                    "disabled": false
+                }
+            ],
+            "disabled": false
+        }
+    },
+    
+
+
+}
+export const ConstsData = {
+    AppData,
+}

+ 24 - 3
miniprogram/utils/restful.ts

@@ -5,14 +5,33 @@ const TOKEN_BEOVERDUE = 40001;
 const TOKEN = wx.getStorageSync('accessToken') == null ? '' : wx.getStorageSync('accessToken');
 
 //测试环境
-// const HOST = 'http://192.168.1.106:9901';
+const HOST = 'https://wordpad-api-test.efunbox.cn';
 
 //正式环境
-const HOST = 'http://wordpad-api-test.efunbox.cn';
+// const HOST = 'https://wordpad-api-test.efunbox.cn';
+
+
+const httpData = {
+    userId: 'test'
+}
+
 
 //API接口
 const interfaces = {
     //这里边放入请求的接口
+
+    //获取全国地址
+    getOrganizeAll:'/organize/all',
+
+    //获取学校信息和班级信息(根据type判断)
+    getSchoolOrClass:'/school',
+
+    //手机号登录注册
+    phoneRegister: '/tch/user/register',
+
+    //账号密码登录
+    pwdPhoneLogin: '/tch/user/login',
+
     //根据userId获取用户信息
     getUserById: '/tch/user/getUserById'
 }
@@ -21,6 +40,7 @@ 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({
@@ -30,7 +50,7 @@ function fun(url: String, type: any, data: any, otherType: any) {
             header: {
                 'content-type': otherType ? APPLICATION_JSON_UTF8_FORM : APPLICATION_JSON_UTF8_VALUE,
                 'access-token': wx.getStorageSync('accessToken') == null ? '' : wx.getStorageSync('accessToken'),
-                'userId': TOKEN
+                'userId': httpData.userId
             },
             success: function (res: any) {
                 wx.stopPullDownRefresh();
@@ -53,6 +73,7 @@ function fun(url: String, type: any, data: any, otherType: any) {
     return promise
 }
 export const httpUtil = {
+    httpData,
     interfaces,
     wxGet: function (url: String, data: any) {
         return fun(url, 'GET', data, null)