Browse Source

验证服务修改校验

Shan9312 1 month ago
parent
commit
d2e4650aee
2 changed files with 101 additions and 134 deletions
  1. 97 130
      pages/login/login.js
  2. 4 4
      pages/workbench/acceptFill/acceptFill.js

+ 97 - 130
pages/login/login.js

@@ -1,104 +1,81 @@
 var util = require('../../utils/util.js')
-var app = getApp();
+var app = getApp()
 
 Page({
-
   data: {
     isHiden: true,
-//  http://210.16.189.72:8099/authdata/GetDataByNames
-    userurl:'http://210.16.189.72:8099/' ,
-      // 'https://kptyun.cn/',//正式地址
-   // userurl: 'http://192.168.1.57:8084/',//刘欢地址
-   // userurl: 'http://210.16.189.72:8099/',//测试地址
+    userurl: 'https://kptyun.cn/', //正式地址
+    // userurl: 'http://192.168.1.57:8084/', //刘欢地址
+    // userurl: 'http://210.16.189.72:8099/', //测试地址
     username: '',
-     password: '',
-  // username: '00020',
-  //    password: '123456',
-     isChecked:true,
-    
-    openid: ''
-  },
-  onLaunch: function () {
-
+    password: '',
+    // username: '00020',
+    //  password: '123456',
+    isChecked: true,
+    openid: '',
   },
+  onLaunch: function () {},
   onLoad: function (option) {
-    var that = this;
-   
-      var url2 = this.data.userurl + "getData"
-      wx.login({
-        success: function (res) {
-          if (res.code) {
-            //发起网络请求
-            wx.request({
-              url: url2,
-              data: {
-                code:res.code
-              },
-              method: 'GET',
-              header: {
-                "Content-Type": "json"
-              },
-              success: function (res) {
-                  console.log(res)
-                  var openid = res.data.openid;//获取到的openid  
-                  that.setData({
-                      openid: openid,
-                  })
- 
-              },
-              fail: function (error) {
-                console.log(error)
-        
-              }
-            })
-
-           
-          } else {
-            console.log('登录失败!' + res.errMsg)
-          }
+    var that = this
+
+    var url2 = this.data.userurl + 'getData'
+    wx.login({
+      success: function (res) {
+        if (res.code) {
+          //发起网络请求
+          wx.request({
+            url: url2,
+            data: {
+              code: res.code,
+            },
+            method: 'GET',
+            header: {
+              'Content-Type': 'json',
+            },
+            success: function (res) {
+              console.log(res)
+              var openid = res.data.openid //获取到的openid
+              that.setData({
+                openid: openid,
+              })
+            },
+            fail: function (error) {
+              console.log(error)
+            },
+          })
+        } else {
+          console.log('登录失败!' + res.errMsg)
         }
-      });
-
-
-
+      },
+    })
 
- 
     var username = wx.getStorageSync('username')
     var password = wx.getStorageSync('password')
-    if (username !== "" && password !== "") {
+    if (username !== '' && password !== '') {
       this.setData({
         username: username,
-        password: password
+        password: password,
       })
     }
-
-
-    
-
   },
   //记住密码
-  on_checked:function(e){
+  on_checked: function (e) {
     console.log(username, password)
     var check = e.detail.checked
-    var username =  this.data.username
-    var password =  this.data.password
-
+    var username = this.data.username
+    var password = this.data.password
 
-    if(check){
-      console.log("选中")
-      this.setData({isChecked:true})
+    if (check) {
+      console.log('选中')
+      this.setData({ isChecked: true })
       wx.setStorageSync('username', username)
       wx.setStorageSync('password', password)
-      
-
     } else {
-      console.log("没选中")
-      this.setData({isChecked:false})
+      console.log('没选中')
+      this.setData({ isChecked: false })
       wx.setStorageSync('username', '')
       wx.setStorageSync('password', '')
-      
     }
-
   },
 
   formSubmit: function (e) {
@@ -106,94 +83,91 @@ Page({
     var password = e.detail.value.password
     var userurl = this.data.userurl
     var openid = this.data.openid
-    if (username == "" || password == "" ) {
+    if (username == '' || password == '') {
       this.setData({
-        tips: '用户名、密码或地址不能为空'
+        tips: '用户名、密码或地址不能为空',
       })
     } else {
-      var url = userurl + "auth"
+      var url = userurl + 'auth'
       var data = {
         username: username,
         password: password,
-        openid: openid
+        openid: openid,
       }
       this.setData({
         username: username,
-        password: password
+        password: password,
       })
-      console.log("url:",url)
-      util.ajax(url, data, 'POST', this.getUserData   )
+      console.log('url:', url)
+      util.ajax(url, data, 'POST', this.getUserData)
     }
-
-
   },
 
   getUserData: function (e) {
     console.log(e)
-   
-    wx.setStorageSync('usertoken', e.data.token);
-    if (e.msg != "ok") {
+
+    wx.setStorageSync('usertoken', e.data.token)
+    if (e.msg != 'ok') {
       var msg = e.data
       this.setData({
-        tips: msg
+        tips: msg,
       })
     } else {
-
       var g_token = e.data.token
       // var g_infoname = e.data.info.userMsg["登录人名称"]
       var userurl = this.data.userurl
       var username = this.data.username
       var password = this.data.password
 
-      var g_url = this.data.userurl  
+      var g_url = this.data.userurl
       app.globalData.g_url = g_url
       app.globalData.g_token = g_token
       // app.globalData.g_infoname = g_infoname
       wx.setStorageSync('userinfo', {
         userurl: g_url,
         username: this.data.username,
-        password: this.data.password
+        password: this.data.password,
       })
 
-     if(this.data.isChecked){
+      if (this.data.isChecked) {
         wx.setStorageSync('userurl', userurl)
         wx.setStorageSync('username', username)
         wx.setStorageSync('password', password)
-     } else {
+      } else {
         wx.setStorageSync('username', '')
         wx.setStorageSync('password', '')
-     }
+      }
 
-      
-     
       wx.setStorageSync('g_url', g_url)
       wx.setStorageSync('g_token', g_token)
-      
-      var that = this 
-
-      util.getDataByName({ 'name': 'findByUserPastureName', 'parammaps': { 'jwt_username': username } }, function(e){
-         console.log(e)
-         wx.setStorageSync('g_userId',  e.data.list[0].employeId)
-
-         var g_lgName = e.data.list[0].employeName
-         var g_countName = e.data.list[0].username
-         var g_depName = e.data.list[0].dname
-         var g_lgNameId = e.data.list[0].empid
-         var g_createrId = e.data.list[0].employeId
-         var g_userId= e.data.list[0].employeId
-         var g_roleId = e.data.list[0].roleId
-
-         app.globalData.g_countName = g_countName
-         app.globalData.g_depName = g_depName
-         app.globalData.g_lgName = g_lgName
-         app.globalData.g_lgNameId = g_lgNameId
-         app.globalData.g_createrId = g_createrId
-         app.globalData.g_userId = g_userId
-         app.globalData.g_roleId = g_roleId
-
-         that.linkJump()
-      })
-      
+
+      var that = this
+
+      util.getDataByName(
+        { name: 'findByUserPastureName', parammaps: { jwt_username: username } },
+        function (e) {
+          console.log(e)
+          wx.setStorageSync('g_userId', e.data.list[0].employeId)
+
+          var g_lgName = e.data.list[0].employeName
+          var g_countName = e.data.list[0].username
+          var g_depName = e.data.list[0].dname
+          var g_lgNameId = e.data.list[0].empid
+          var g_createrId = e.data.list[0].employeId
+          var g_userId = e.data.list[0].employeId
+          var g_roleId = e.data.list[0].roleId
+
+          app.globalData.g_countName = g_countName
+          app.globalData.g_depName = g_depName
+          app.globalData.g_lgName = g_lgName
+          app.globalData.g_lgNameId = g_lgNameId
+          app.globalData.g_createrId = g_createrId
+          app.globalData.g_userId = g_userId
+          app.globalData.g_roleId = g_roleId
+
+          that.linkJump()
+        },
+      )
     }
   },
 
@@ -203,16 +177,9 @@ Page({
     })
   },
 
- 
-
   getUrl: function (e) {
     this.setData({
-      userurl: e.detail.value
+      userurl: e.detail.value,
     })
   },
-
-
- 
- 
- 
-})
+})

+ 4 - 4
pages/workbench/acceptFill/acceptFill.js

@@ -140,7 +140,7 @@ Page({
   },
 
   validateForm() {
-    const { checkUserName, checkDate, contactId, telephone } = this.data.formObj
+    const { checkUserName, checkDate, contactName, telephone } = this.data.formObj
     const { images } = this.data
     if (!checkUserName) {
       wx.showToast({ title: '请填写服务人员', icon: 'none' })
@@ -154,7 +154,7 @@ Page({
       wx.showToast({ title: '请先选择图片', icon: 'none' })
       return
     }
-    if (!contactId) {
+    if (!contactName) {
       wx.showToast({ title: '请输入客户对接人', icon: 'none' })
       return false
     }
@@ -254,9 +254,9 @@ Page({
   },
 
   formSubmit(e) {
+    console.log(this.data.formObj, 'this.data.formObj')
     if (!this.validateForm()) return
     this.data.formObj.orderId = this.data.orderId
-    console.log(this.data.formObj, 'this.data.formObj')
     this.uploadForm()
   },
   // 验收表单上传
@@ -365,8 +365,8 @@ Page({
   },
 
   getPickerList2: function (res) {
-    console.log('接待人下拉数据======>', res.data.list)
     var custormList = res.data.list
+    console.log('接待人下拉数据======>', custormList)
     this.setData({
       receiverShow: true,
       allDisabled: false,