Prechádzať zdrojové kódy

整合学生端和教师端

wangjinbiao 6 rokov pred
rodič
commit
9b687f1b7e

+ 71 - 1
dorm-manager-wx/pages/student/application/application.js

@@ -18,9 +18,27 @@ Page({
   },
   swiper:function(e){
     let that=this
+    // if(that.data.current==1){
+    //   if (!this.data.name || !this.data.idcard || !this.data.phone || !this.data.text) {
+    //     if (!(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(that.data.idcard)) && !(/^1[3456789]\d{9}$/.test(that.data.phone))) {
+    //       that.setData({
+    //         isYesno: true,
+    //         current: e.detail.current
+    //       })
+    //       return false
+    //     }
+    //   }else{
+    //     that.setData({
+    //       isYesno: false,
+    //       current: e.detail.current
+    //     })
+    //     return false
+    //   }
+    // }
     that.setData({
-      current:e.detail.current
+      current: e.detail.current
     })
+    
   },
   code:function(){
     let that=this
@@ -124,25 +142,47 @@ Page({
       }
     })
   },
+  ifYesno(){
+    let that=this
+    if (that.data.name || that.data.idcard || that.data.phone || that.data.text) {
+      if ((/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/.test(that.data.name))&&(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(that.data.idcard)) && (/^1[3456789]\d{9}$/.test(that.data.phone))) {
+        that.setData({
+          isYesno: true
+        })
+      }else{
+        that.setData({
+          isYesno: false
+        })
+      }
+    }else{
+      that.setData({
+        isYesno: false
+      })
+    }
+  },
   name:function(e){
     this.setData({
       name:e.detail.value
     })
+    this.ifYesno()
   },
   idcard: function (e) {
     this.setData({
       idcard: e.detail.value
     })
+    this.ifYesno()
   },
   phone: function (e) {
     this.setData({
       phone: e.detail.value
     })
+    this.ifYesno()
   },
   text: function (e) {
     this.setData({
       text: e.detail.value
     })
+    this.ifYesno()
   },
   previewImage:function(){
     wx.previewImage({
@@ -157,12 +197,42 @@ Page({
     })
   },
   next:function(){
+    if(!this.data.photo){
+      wx.showToast({
+        title: '请先上传头像照',
+        icon:'none'
+      })
+      return false
+    }else if(this.data.current==1){
+      if (!this.data.name && !this.data.idcard && !this.data.phone && !this.data.text) {
+        wx.showToast({
+          title: '资料请填写完整',
+          icon: 'none'
+        })
+        return false
+      }
+      if (!(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(this.data.idcard))){
+        wx.showToast({
+          title: '身份证输入不合法',
+          icon:'none'
+        })
+        return false
+      }
+      if (!(/^1[3456789]\d{9}$/.test(this.data.phone))){
+        wx.showToast({
+          title: '手机号输入不合法',
+          icon: 'none'
+        })
+        return false
+      }
+    }
     this.data.current++
     this.setData({
       current: this.data.current,
       swipercurrent: this.data.current
     })
   },
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 6 - 6
dorm-manager-wx/pages/student/application/application.wxml

@@ -27,12 +27,12 @@
         <image wx:if='{{photo}}' bindtap="photo" mode="aspectFill" class='photo-show' src='{{photo}}'></image>
       </view>
     </swiper-item>
-    <swiper-item>
+    <swiper-item wx:if='{{photo}}'>
       <view class="form">
         <view class="input">
           <view class="input-name"><text>访</text><text>客</text><text>姓名</text></view>
           <view>:</view>
-          <input bindinput="name" name='name'></input>
+          <input bindblur="name" name='name'></input>
         </view>
         <view class="input">
           <view class="input-name"><text>身</text><text>份</text><text>类</text><text>型</text></view>
@@ -49,12 +49,12 @@
         <view class="input">
           <view class="input-name"><text>身</text><text>份</text><text>证</text><text>号</text></view>
           <view>:</view>
-          <input bindinput="idcard" maxlength="18" type="number" name='idcard'></input>
+          <input bindblur="idcard" maxlength="18" type="number" name='idcard'></input>
         </view>
         <view class="input">
           <view class="input-name"><text>手</text><text>机</text><text>号</text><text>码</text></view>
           <view>:</view>
-          <input bindinput="phone" maxlength="11" type="number" name='phone'></input>
+          <input bindblur="phone" maxlength="11" type="number" name='phone'></input>
         </view>
         <!-- <view class="input">
           <view class="input-name"><text>验</text><text>证</text><text>码</text></view>
@@ -65,11 +65,11 @@
         <view class="textarea">
           <view class="input-name"><text>通</text><text>行</text><text>原</text><text>因</text></view>
           <view>:</view>
-          <textarea bindinput="text" name='text'></textarea>
+          <textarea bindblur="text" name='text'></textarea>
         </view>
       </view>
     </swiper-item>
-    <swiper-item>
+    <swiper-item wx:if='{{photo&&isYesno}}'>
       <view class="result">
         <view style="padding-top:40rpx;text-align:center">
           <view wx:if='{{!photo}}' class="photo-images" style="margin:auto;">

+ 54 - 9
dorm-manager-wx/pages/student/facephoto/facephoto.js

@@ -40,20 +40,47 @@ Page({
   },
   submit:function(){
     let that=this
+    wx.showLoading({
+      title: '正在上传',
+    })
+    if (!that.data.ditufile&&!that.data.fengmianfile){
+      if (!that.data.dtFilePaths) {
+        wx.showToast({
+          title: '请上传底库照',
+          icon: 'none'
+        })
+        return false
+      } else if (!that.data.fmFilePaths){
+        wx.showToast({
+          title: '请上传封面照',
+          icon: 'none'
+        })
+        return false
+      }
+    } else if (!that.data.dtFilePaths && !that.data.fmFilePaths){
+      wx.showToast({
+        title: '请先上传新的照片',
+        icon: 'none'
+      })
+      return false
+    }
+    that.data.pathscount=0
+    if (that.data.dtFilePaths){
+      that.data.pathscount++
+    } else if (that.data.fmFilePaths){
+      that.data.pathscount++
+    }
     if(that.data.dtFilePaths){
       that.upload(that.data.dtFilePaths,'false')
     }
     if(that.data.fmFilePaths){
-      that.upload(that.data.fmFilePaths,true)
+      that.upload(that.data.fmFilePaths,'true')
     }
   },
   upload: function (file, isShowPhoto){
     let that=this
-    wx.showLoading({
-      title: '正在上传',
-    })
     wx.uploadFile({
-      url: api.updateUserHeadImage.if,
+      url: api.updateUserHeadImage,
       filePath: file[0],
       header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
       name: 'file',
@@ -65,9 +92,17 @@ Page({
       success(res) {
         wx.hideLoading()
         if (JSON.parse(res.data).youtuMessage.error_code==0){
-          wx.redirectTo({
-            url: '/pages/success/index',
-          })
+          if (that.data.pathscount==1){
+            wx.redirectTo({
+              url: '/pages/success/index',
+            })
+          }else{
+            if (isShowPhoto=='true'){
+              wx.redirectTo({
+                url: '/pages/success/index',
+              })
+            }
+          }
         }
       }
     })
@@ -76,7 +111,17 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    let that=this
+    wx.request({
+      url: api.getYouTuImage,
+      data:{loginId:wx.getStorageSync('loginId')},
+      success(res){
+        that.setData({
+          ditufile: res.data.img?api.total.split('.if')[0] + res.data.img:'',
+          fengmianfile: res.data.showImg? api.total.split('.if')[0] + res.data.showImg:''
+        })
+      }
+    })
   },
 
   /**

+ 7 - 2
dorm-manager-wx/pages/user/index.js

@@ -125,8 +125,13 @@ Page({
           success(res) {
             wx.hideLoading()
             console.log(res)
-            if (JSON.parse(res.data.data).status == true) {
-              wx.getStorageSync('userInfo').avatarUrl = api.total + JSON.parse(res.data.data).headImage
+            if (JSON.parse(res.data).status == true) {
+              let user = wx.getStorageSync('userInfo')
+              user.avatarUrl = api.total.split('.if')[0] + JSON.parse(res.data).headImage
+              wx.setStorageSync('userInfo', user)
+              that.setData({
+                photo: user.avatarUrl
+              })
               wx.showToast({
                 title: '修改成功',
                 icon:'none'

+ 2 - 1
dorm-manager-wx/utils/api.js

@@ -94,6 +94,7 @@ const index = 2,
     getUserInfo: 'userinfo/getUserInfo.if', //查询用户信息
     updateUserHeadImage: 'userinfo/updateUserHeadImage.if',//上传用户和底库图片
     updateimage: 'userinfo/updateImage.if',//修改用户头像
+    getYouTuImage: 'userinfo/getYouTuImage.if',//获取学生人脸自助上传图片
 
     //宿管系统--教师端
     getDeptInfo: 'deptInfo/getDeptInfolevel.if', //获取学院信息
@@ -112,7 +113,7 @@ const index = 2,
   [oneportal, root] = [
     ["http://192.168.100.234:8080/oneportal/", "https://zhll.dgtis.com/wx/"],
     ["http://192.168.100.254:9082/wx/", "https://zhll.dgtis.com/wx/"],
-    ["https://dorm.dgtis.com/oneportal/", "http://192.168.100.248:9082/wx/"]
+    ["https://dorm.dgtis.com/oneportal/", "https://dorm.dgtis.com/wx/"]
   ][index]
 Object.keys(api).forEach(x => {
   let v = api[x]