From d09219e41ceb223cd3d61fb4278b8967f3af4afe Mon Sep 17 00:00:00 2001 From: xuechunyuan <17853500702@163.com> Date: Wed, 23 Aug 2023 18:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 4 +- pages/pages_zhentou/myPage/myPage.vue | 2 +- pages/pages_zhentou/order/confirmOrder.vue | 158 +++++++++++++-------- 3 files changed, 105 insertions(+), 59 deletions(-) diff --git a/App.vue b/App.vue index f111356..bafa876 100644 --- a/App.vue +++ b/App.vue @@ -60,8 +60,8 @@ globalData: { openId: '', test: '', - baseUrl: "http://192.168.3.32:80", - // baseUrl: "http://192.168.1.106:80", + // baseUrl: "http://192.168.3.32:80", + baseUrl: "http://192.168.1.106:80", // baseUrl: "http://47.104.224.41:80",//测试环境 imgPrefix: "http://47.104.224.41:9000/etriphome/appresource/image/", //图片资源 }, diff --git a/pages/pages_zhentou/myPage/myPage.vue b/pages/pages_zhentou/myPage/myPage.vue index 6169b30..9de82b4 100644 --- a/pages/pages_zhentou/myPage/myPage.vue +++ b/pages/pages_zhentou/myPage/myPage.vue @@ -9,7 +9,7 @@ 昵称 - + diff --git a/pages/pages_zhentou/order/confirmOrder.vue b/pages/pages_zhentou/order/confirmOrder.vue index a13e8f4..bcb182e 100644 --- a/pages/pages_zhentou/order/confirmOrder.vue +++ b/pages/pages_zhentou/order/confirmOrder.vue @@ -2,15 +2,15 @@ - - 默认 - 山东省青岛市市北区 + + 默认 + {{addressInfo.province}} {{addressInfo.city}} {{addressInfo.area}} - 大港街道大港三路8号铁路住宅小区6号楼6单元666室 + {{addressInfo.address}} 请填写收货地址 - - 1d - 15612345678 + + {{addressInfo.consignee}} + {{addressInfo.phone}} @@ -66,7 +66,7 @@ return { imgPrefix: getApp().globalData.imgPrefix, phone: '', - address: null, + addressInfo: null, goodsInfo: { goodsName: '', price: 699 @@ -80,18 +80,22 @@ }, onLoad() { let userInfo = uni.getStorageSync('userInfo'); - if(userInfo) { + if (userInfo) { this.userInfo = JSON.parse(userInfo); this.phone = this.userInfo.phone; this.queryAddress(); } this.queryGoodsInfo(); }, + onShow() { + let address = uni.getStorageSync('address'); + if(address) { + this.addressInfo = JSON.parse(address); + uni.removeStorageSync('address'); + console.log(this.addressInfo) + } + }, methods: { - //切换收货地址 - changeAddress(address) { - this.address = address; - }, //设置收货地址 goAddress() { uni.navigateTo({ @@ -132,9 +136,9 @@ }, success: (res) => { if (res.data.code == 200) { - this.address = JSON.stringify(res.data.data) == '{}' ? null : res.data.data; + this.addressInfo = JSON.stringify(res.data.data) == '{}' ? null : res.data.data; } else if (res.data.code == 401) { - this.doLogin(); + this.doLogin(1); } else { uni.showToast({ title: res.data.msg, @@ -146,7 +150,7 @@ }, //提交订单 submitOrder() { - if(!this.address) { + if (!this.addressInfo) { uni.showToast({ title: '请填写收货地址', icon: 'none' @@ -160,7 +164,11 @@ buyerId: this.userInfo.id, buyerName: this.userInfo.username, buyerPhone: this.phone, - goodsNum: this.orderInfo.goodsNum + 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 }, header: { 'Blade-Auth': 'bearer ' + uni.getStorageSync('token') @@ -176,7 +184,7 @@ content: res.data.msg, success: (res2) => { if (res2.confirm) { - uni.navigateTo({ + uni.redirectTo({ url: '/pages/pages_zhentou/order/order' }) } else if (res.cancel) { @@ -194,30 +202,37 @@ }) }, //支付成功回调 - doPaySuccess(orderNo) { + doPaySuccess(orderInfo) { uni.request({ - url:getApp().globalData.baseUrl + '/blade-desk/order/paySuccessCallback', - method:'POST', + url: getApp().globalData.baseUrl + '/blade-desk/order/paySuccessCallback', + method: 'POST', data: { - id: orderNo + id: orderInfo.id }, - header:{ + header: { 'Blade-Auth': 'bearer ' + uni.getStorageSync('token') }, success: (res) => { - if(res.data.code == 200){ + if (res.data.code == 200) { uni.showToast({ title: '订单支付成功', icon: 'none' }) - uni.redirectTo({ - url: '/pages/pages_zhentou/order/order' - }) - }else{ + setTimeout(() => { + uni.redirectTo({ + url: '/pages/pages_zhentou/form/form?id=' + orderInfo.id + '&num=' + this.orderInfo.goodsNum + }) + }, 2000) + } else { uni.showToast({ title: res.data.msg, icon: 'none' }) + setTimeout(() => { + uni.redirectTo({ + url: '/pages/pages_zhentou/order/order' + }) + }, 2000) } } }) @@ -251,10 +266,20 @@ paySign: res.data.data.paySign, success: (res1) => { console.log(res1) - this.doPaySuccess(orderInfo.id) + if(res1.errMsg == 'requestPayment:ok'){ + this.doPaySuccess(orderInfo); + } + else{ + uni.redirectTo({ + url: '/pages/pages_zhentou/order/order' + }) + } }, fail: (res2) => { console.log(res2) + uni.redirectTo({ + url: '/pages/pages_zhentou/order/order' + }) } }) } else { @@ -270,7 +295,7 @@ }) }, //登录 - doLogin() { + doLogin(type) { uni.showLoading({ title: '登录中', mask: true @@ -288,6 +313,9 @@ success: (res) => { if (res.data.code == 200) { uni.setStorageSync('token', res.data.data.access_token); + if (type == 1 && !this.addressInfo) { + this.queryAddress(); //重新查询默认地址 + } } else { uni.showToast({ title: res.data.msg, @@ -306,7 +334,7 @@