|
@@ -7,55 +7,55 @@ Page({
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- userName:"",
|
|
|
|
- password:"",
|
|
|
|
- wxCode:"",
|
|
|
|
- openid:"",
|
|
|
|
|
|
+ userName: "",
|
|
|
|
+ password: "",
|
|
|
|
+ wxCode: "",
|
|
|
|
+ openid: "",
|
|
},
|
|
},
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
|
- */
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
|
+ */
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
- app.isLoginSuccess=false;
|
|
|
|
- let that=this;
|
|
|
|
|
|
+ app.isLoginSuccess = false;
|
|
|
|
+ let that = this;
|
|
wx.login({
|
|
wx.login({
|
|
success(res) {
|
|
success(res) {
|
|
that.data.wxCode = res.code
|
|
that.data.wxCode = res.code
|
|
-
|
|
|
|
|
|
+
|
|
that.getOpenIdBywxCode()
|
|
that.getOpenIdBywxCode()
|
|
},
|
|
},
|
|
fail(res) {
|
|
fail(res) {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- bindViewlogin(){
|
|
|
|
- if(this.data.userName==null||this.data.userName==''){
|
|
|
|
|
|
+ bindViewlogin() {
|
|
|
|
+ if (this.data.userName == null || this.data.userName == '') {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '请输入用户名',
|
|
title: '请输入用户名',
|
|
- icon:'none',
|
|
|
|
- duration:2000
|
|
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if(this.data.password==null||this.data.password==''){
|
|
|
|
|
|
+ if (this.data.password == null || this.data.password == '') {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '请输入密码',
|
|
title: '请输入密码',
|
|
- icon:'none',
|
|
|
|
- duration:2000
|
|
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- let that=this;
|
|
|
|
-
|
|
|
|
|
|
+ let that = this;
|
|
|
|
+
|
|
var data = {
|
|
var data = {
|
|
- userName:this.data.userName,
|
|
|
|
- password:this.data.password,
|
|
|
|
- openid:this.data.openid,
|
|
|
|
|
|
+ userName: this.data.userName,
|
|
|
|
+ password: this.data.password,
|
|
|
|
+ openid: this.data.openid,
|
|
}
|
|
}
|
|
http.post_token("/system/minapp/AppLoginController/bindWxUser", data, that.bindSuccess)
|
|
http.post_token("/system/minapp/AppLoginController/bindWxUser", data, that.bindSuccess)
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
bindSuccess(res) {
|
|
bindSuccess(res) {
|
|
let that = this
|
|
let that = this
|
|
if (res.code != 200) {
|
|
if (res.code != 200) {
|
|
@@ -66,16 +66,15 @@ Page({
|
|
// that.setData({
|
|
// that.setData({
|
|
// isShowAccoutDialog : true
|
|
// isShowAccoutDialog : true
|
|
// })
|
|
// })
|
|
-
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
// that.data.openid = res.openid
|
|
// that.data.openid = res.openid
|
|
- app.globalToken = res.data.access_token
|
|
|
|
- ("登陆成功的令牌:",app.globalToken)
|
|
|
|
- wx.setStorageSync('userName', that.data.userName)
|
|
|
|
- wx.setStorageSync('password', that.data.password)
|
|
|
|
- app.isLoginSuccess=true;
|
|
|
|
|
|
+ app.globalToken = res.data.access_token,
|
|
|
|
+ wx.setStorageSync('userName', that.data.userName),
|
|
|
|
+ wx.setStorageSync('password', that.data.password),
|
|
|
|
+ app.isLoginSuccess = true
|
|
this.setData({
|
|
this.setData({
|
|
- isBindSuccess : true
|
|
|
|
|
|
+ isBindSuccess: true,
|
|
})
|
|
})
|
|
wx.reLaunch({
|
|
wx.reLaunch({
|
|
url: '../index/index',
|
|
url: '../index/index',
|
|
@@ -83,30 +82,30 @@ Page({
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
- bindViewUserName(e){
|
|
|
|
- this.data.userName = e.detail.value;
|
|
|
|
|
|
+ bindViewUserName(e) {
|
|
|
|
+ this.data.userName = e.detail.value
|
|
},
|
|
},
|
|
-
|
|
|
|
- bindViewPassword(e){
|
|
|
|
|
|
+
|
|
|
|
+ bindViewPassword(e) {
|
|
this.data.password = e.detail.value
|
|
this.data.password = e.detail.value
|
|
},
|
|
},
|
|
|
|
|
|
- getOpenIdBywxCode(){
|
|
|
|
- let that=this
|
|
|
|
|
|
+ getOpenIdBywxCode() {
|
|
|
|
+ let that = this
|
|
var data = {
|
|
var data = {
|
|
wxCode: that.data.wxCode,
|
|
wxCode: that.data.wxCode,
|
|
- }
|
|
|
|
|
|
+ }
|
|
http.post_token("/system/minapp/AppLoginController/getSessionKeyOropenid", data, this.openIdSuccess)
|
|
http.post_token("/system/minapp/AppLoginController/getSessionKeyOropenid", data, this.openIdSuccess)
|
|
},
|
|
},
|
|
- openIdSuccess(res){
|
|
|
|
|
|
+ openIdSuccess(res) {
|
|
let that = this
|
|
let that = this
|
|
- if (res!=null&&res.openid!=null) {
|
|
|
|
|
|
+ if (res != null && res.openid != null) {
|
|
that.data.openid = res.openid
|
|
that.data.openid = res.openid
|
|
-
|
|
|
|
|
|
+
|
|
// wx.setStorageSync('openid', res.openid)
|
|
// wx.setStorageSync('openid', res.openid)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
@@ -119,7 +118,7 @@ Page({
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
onShow() {
|
|
onShow() {
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|