diff --git a/App.vue b/App.vue index 184d70e..28028b6 100644 --- a/App.vue +++ b/App.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) } }); }, diff --git a/pages/pages_zhentou/homePage/homePage.vue b/pages/pages_zhentou/homePage/homePage.vue index 0daef41..198c858 100644 --- a/pages/pages_zhentou/homePage/homePage.vue +++ b/pages/pages_zhentou/homePage/homePage.vue @@ -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, diff --git a/pages/pages_zhentou/order/confirmOrder.vue b/pages/pages_zhentou/order/confirmOrder.vue index 1d278b5..7812fd5 100644 --- a/pages/pages_zhentou/order/confirmOrder.vue +++ b/pages/pages_zhentou/order/confirmOrder.vue @@ -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) } } })