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