登录优化

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

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

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

Loading…
Cancel
Save