登录优化

main
xuechunyuan 2 years ago
parent f9256d2364
commit 0cbc4a25b5
  1. 17
      App.vue
  2. 13
      pages/pages_zhentou/homePage/homePage.vue
  3. 11
      pages/pages_zhentou/order/confirmOrder.vue

@ -107,7 +107,13 @@
success: (res) => {
if (res.data.code == 200) {
uni.setStorageSync('token', res.data.data.access_token);
} else {
setTimeout(() => {
console.log('重新渲染')
wx.reLaunch({
url: '/pages/pages_zhentou/homePage/homePage'
})
}, 500)
}else{
uni.showToast({
title: res.data.msg,
icon: 'none'
@ -137,9 +143,13 @@
},
success: (res) => {
if (res.data.code == 200) {
this.globalData.openId = res.data.data.openid;
uni.setStorageSync('openId', res.data.data.openid);
if (res.data.data.userInfo) {
uni.setStorageSync('userInfo', res.data.data.userInfo);
uni.setStorageSync('userInfo', JSON.stringify(res.data.data.userInfo));
if(res.data.data.userInfo.phone){
this.doLogin(res.data.data.userInfo.username, res.data.data.userInfo.phone);
}
}
} else {
uni.showToast({
@ -147,6 +157,9 @@
icon: 'none'
})
}
},
fail: (err) => {
console.log('wxlogin',err)
}
});
},

@ -35,6 +35,7 @@
let userInfo = uni.getStorageSync('userInfo');
if (userInfo) {
this.userInfo = JSON.parse(userInfo);
console.log('home',userInfo)
if(this.userInfo.phone) {
this.phone = this.userInfo.phone;
this.hasPhone = true;
@ -81,6 +82,9 @@
},
//
getPhoneNumber(e) {
if(e.detail.errMsg == 'getPhoneNumber:fail user deny'){
return;
}
console.log(e, '获取手机号授权')
uni.request({
url: getApp().globalData.baseUrl + '/app/phone', //
@ -92,7 +96,7 @@
if (res.data.code == 200) {
this.phone = res.data.data;
this.hasPhone = true;
uni.setStorageSync('phone', res.data.data);
// uni.setStorageSync('phone', res.data.data);
this.doSave();
} else {
uni.showToast({
@ -129,7 +133,7 @@
if (res.data.code == 200) {
uni.setStorageSync('userInfo', JSON.stringify(res.data.data));
//
this.doLogin();
this.doLogin(1);
} else {
uni.showToast({
title: res.data.msg,
@ -140,7 +144,7 @@
})
},
//
doLogin() {
doLogin(type) {
uni.showLoading({
title: '登录中',
mask: true
@ -159,6 +163,9 @@
success: (res) => {
if (res.data.code == 200) {
uni.setStorageSync('token', res.data.data.access_token);
if(type == 1) {
this.clickCustom();
}
} else {
uni.showToast({
title: res.data.msg,

@ -167,8 +167,11 @@
goodsNum: this.orderInfo.goodsNum,
consignee: this.addressInfo.consignee,
consigneePhone: this.addressInfo.phone,
address: this.addressInfo.province + this.addressInfo.city + this.addressInfo.area + this.addressInfo
.address
province: this.addressInfo.province,
city: this.addressInfo.city,
district: this.addressInfo.distrit,
address: this.addressInfo.address,
isDefaultAddress: this.addressInfo.isDefault
},
header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
@ -222,7 +225,7 @@
uni.redirectTo({
url: '/pages/pages_zhentou/form/form?orderNo=' + orderInfo.orderNo + '&orderNum=' + this.orderInfo.goodsNum
})
}, 2000)
}, 1000)
} else {
uni.showToast({
title: res.data.msg,
@ -232,7 +235,7 @@
uni.redirectTo({
url: '/pages/pages_zhentou/order/order'
})
}, 2000)
}, 1000)
}
}
})

Loading…
Cancel
Save