|
@@ -22,7 +22,8 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
path: '/pages/index/index',
|
|
path: '/pages/index/index',
|
|
- lanuch: true
|
|
|
|
|
|
+ lanuch: true,
|
|
|
|
+ code: ''
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
@@ -30,7 +31,8 @@
|
|
},
|
|
},
|
|
mounted() {},
|
|
mounted() {},
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
- console.log(option)
|
|
|
|
|
|
+ // 为解决首次登录异常问题 进入页面先调微信登录获取code
|
|
|
|
+ this.wxLogin()
|
|
const {
|
|
const {
|
|
path,
|
|
path,
|
|
lanuch
|
|
lanuch
|
|
@@ -39,7 +41,7 @@
|
|
if (path) {
|
|
if (path) {
|
|
this.path = decodeURIComponent(path);
|
|
this.path = decodeURIComponent(path);
|
|
}
|
|
}
|
|
- console.log(this.path,this.lanuch,'111111111')
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
getPhoneNumber(e) {
|
|
getPhoneNumber(e) {
|
|
@@ -48,41 +50,40 @@
|
|
mask: true,
|
|
mask: true,
|
|
title: '加载中'
|
|
title: '加载中'
|
|
});
|
|
});
|
|
|
|
+ if (!this.code) {
|
|
|
|
+ this.wxLogin()
|
|
|
|
+ }
|
|
console.log(e.target.encryptedData,'eeeeeee')
|
|
console.log(e.target.encryptedData,'eeeeeee')
|
|
if (e.target.errMsg === 'getPhoneNumber:ok') {
|
|
if (e.target.errMsg === 'getPhoneNumber:ok') {
|
|
- uni.login({
|
|
|
|
- provider: 'weixin',
|
|
|
|
- success(res) {
|
|
|
|
- login({
|
|
|
|
- code: res.code,
|
|
|
|
- encryptedData: e.target.encryptedData,
|
|
|
|
- iv: e.target.iv
|
|
|
|
- }).then(res => {
|
|
|
|
- uni.hideLoading();
|
|
|
|
- console.log(res, 'login data')
|
|
|
|
- if (res.status == '200') {
|
|
|
|
- console.log(res.data, 'login data')
|
|
|
|
- getApp().globalData.token = res.data
|
|
|
|
- _this.$u.vuex('vuex_token',res.data)
|
|
|
|
- if (_this.path === '/pages/index/index' || _this.lanuch) {
|
|
|
|
- uni.reLaunch({
|
|
|
|
- url: _this.path
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: _this.path
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: res.message,
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 2500
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ login({
|
|
|
|
+ code: _this.code,
|
|
|
|
+ encryptedData: e.target.encryptedData,
|
|
|
|
+ iv: e.target.iv
|
|
|
|
+ }).then(res => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ _this.code = ''
|
|
|
|
+ console.log(res, 'login data')
|
|
|
|
+ if (res.status == '200') {
|
|
|
|
+ getApp().globalData.token = res.data
|
|
|
|
+ _this.$u.vuex('vuex_token',res.data)
|
|
|
|
+ if (_this.path === '/pages/index/index' || _this.lanuch) {
|
|
|
|
+ uni.reLaunch({
|
|
|
|
+ url: _this.path
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: _this.path
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.message,
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2500
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: '授权失败',
|
|
title: '授权失败',
|
|
@@ -91,6 +92,17 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 调微信登录 获取code
|
|
|
|
+ wxLogin () {
|
|
|
|
+ let _this = this
|
|
|
|
+ uni.login({
|
|
|
|
+ provider: 'weixin',
|
|
|
|
+ success(res) {
|
|
|
|
+ _this.code = res.code
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ console.log(this.code,'1111111111')
|
|
|
|
+ },
|
|
gotoHome () {
|
|
gotoHome () {
|
|
wx.reLaunch({
|
|
wx.reLaunch({
|
|
url: '/pages/index/index'
|
|
url: '/pages/index/index'
|