|
@@ -54,7 +54,7 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad() {
|
|
onLoad() {
|
|
- // this.initLogin()
|
|
|
|
|
|
+ this.initLogin()
|
|
},
|
|
},
|
|
methods:{
|
|
methods:{
|
|
// 获取微信登录的code以及发送请求
|
|
// 获取微信登录的code以及发送请求
|
|
@@ -65,7 +65,7 @@
|
|
if (res.code) { //微信登录成功 已拿到code
|
|
if (res.code) { //微信登录成功 已拿到code
|
|
this.wxCode = res.code //保存获取到的code
|
|
this.wxCode = res.code //保存获取到的code
|
|
console.log(res.code,"WXcode");
|
|
console.log(res.code,"WXcode");
|
|
- uni.request({
|
|
|
|
|
|
+ /*uni.request({
|
|
url: 'https://api.weixin.qq.com/sns/jscode2session',
|
|
url: 'https://api.weixin.qq.com/sns/jscode2session',
|
|
method: 'GET',
|
|
method: 'GET',
|
|
data: {
|
|
data: {
|
|
@@ -82,41 +82,46 @@
|
|
this.session_key = cts.data.session_key //session_key 会话密钥
|
|
this.session_key = cts.data.session_key //session_key 会话密钥
|
|
|
|
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ });*/
|
|
|
|
|
|
} else {
|
|
} else {
|
|
console.log('登录失败!' + res.errMsg)
|
|
console.log('登录失败!' + res.errMsg)
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
getPhoneNumber (e) {
|
|
getPhoneNumber (e) {
|
|
if(e.detail.errMsg=="getPhoneNumber:ok"){
|
|
if(e.detail.errMsg=="getPhoneNumber:ok"){
|
|
- uni.login({
|
|
|
|
|
|
+ /*uni.login({
|
|
success: (res) => {
|
|
success: (res) => {
|
|
// console.log(res)
|
|
// console.log(res)
|
|
if (res.code) { //微信登录成功 已拿到code
|
|
if (res.code) { //微信登录成功 已拿到code
|
|
- this.wxCode = res.code //保存获取到的code
|
|
|
|
|
|
+ this.wxCode = res.code //保存获取到的code */
|
|
|
|
+
|
|
uni.$u.http.post('/api/login/phone',{
|
|
uni.$u.http.post('/api/login/phone',{
|
|
- code:this.code,
|
|
|
|
|
|
+ code:this.wxCode,
|
|
iv:e.detail.iv,
|
|
iv:e.detail.iv,
|
|
enc:e.detail.encryptedData
|
|
enc:e.detail.encryptedData
|
|
}).then(res=>{
|
|
}).then(res=>{
|
|
console.log(res)
|
|
console.log(res)
|
|
- // uni.setStorageSync('token', res.token)
|
|
|
|
- // uni.setStorageSync('code', this.wxCode)
|
|
|
|
- // uni.setStorageSync('phone', this.phone)
|
|
|
|
- // this.$store.commit('setToken', res.token)
|
|
|
|
- // this.$store.commit('loginState', res.token)
|
|
|
|
- // this.$store.commit('getUserInfo',{code:this.wxCode,phone:this.phone})
|
|
|
|
- // uni.showToast({
|
|
|
|
- // title: '登录成功',
|
|
|
|
- // icon:"success",
|
|
|
|
- // duration: 1000
|
|
|
|
- // })
|
|
|
|
- // uni.reLaunch({
|
|
|
|
- // url:"/pages/index/index"
|
|
|
|
- // })
|
|
|
|
|
|
+ uni.setStorageSync('token', res.token)
|
|
|
|
+ //uni.setStorageSync('code', this.wxCode)
|
|
|
|
+ uni.setStorageSync('phone', res.user.phone)
|
|
|
|
+ this.$store.commit('setToken', res.token)
|
|
|
|
+ this.$store.commit('loginState', res.token)
|
|
|
|
+ this.$store.commit('getUserInfo',{
|
|
|
|
+ //code:this.wxCode,
|
|
|
|
+ phone:res.user.phone,
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '登录成功',
|
|
|
|
+ icon:"success",
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ uni.reLaunch({
|
|
|
|
+ url:"/pages/index/index"
|
|
|
|
+ })
|
|
}).catch(err=>{
|
|
}).catch(err=>{
|
|
console.log(err)
|
|
console.log(err)
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -125,11 +130,12 @@
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
+ /*} else {
|
|
console.log('登录失败!' + res.errMsg)
|
|
console.log('登录失败!' + res.errMsg)
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ })*/
|
|
|
|
+
|
|
// console.log('用户点击了接受',e);
|
|
// console.log('用户点击了接受',e);
|
|
// let pc = new WXBizDataCrypt('wxdc8ecff90bf3f4c3', this.session_key); //wxXXXXXXX为你的小程序APPID
|
|
// let pc = new WXBizDataCrypt('wxdc8ecff90bf3f4c3', this.session_key); //wxXXXXXXX为你的小程序APPID
|
|
// let data = pc.decryptData(e.detail.encryptedData, e.detail.iv);
|
|
// let data = pc.decryptData(e.detail.encryptedData, e.detail.iv);
|