订单支付逻辑优化

main
xuechunyuan 2 years ago
parent 91bf2ab85b
commit d09219e41c
  1. 4
      App.vue
  2. 2
      pages/pages_zhentou/myPage/myPage.vue
  3. 92
      pages/pages_zhentou/order/confirmOrder.vue

@ -60,8 +60,8 @@
globalData: { globalData: {
openId: '', openId: '',
test: '', test: '',
baseUrl: "http://192.168.3.32:80", // baseUrl: "http://192.168.3.32:80",
// baseUrl: "http://192.168.1.106:80", baseUrl: "http://192.168.1.106:80",
// baseUrl: "http://47.104.224.41:80",// // baseUrl: "http://47.104.224.41:80",//
imgPrefix: "http://47.104.224.41:9000/etriphome/appresource/image/", // imgPrefix: "http://47.104.224.41:9000/etriphome/appresource/image/", //
}, },

@ -9,7 +9,7 @@
</view> </view>
<view class="nickname_warp"> <view class="nickname_warp">
<text>昵称</text> <text>昵称</text>
<input blur="formSubmit" v-model="userInfo.username" class="nickname" type="nickname" placeholder="请输入昵称" /> <input @blur="formSubmit" v-model="userInfo.username" class="nickname" type="nickname" placeholder="请输入昵称" />
</view> </view>
</view> </view>
<view class="cnt-box"> <view class="cnt-box">

@ -2,15 +2,15 @@
<view class="order_box"> <view class="order_box">
<view class="order_address" @click="goAddress"> <view class="order_address" @click="goAddress">
<view class="address_info"> <view class="address_info">
<view class="address_top" v-if="address"> <view class="address_top" v-if="addressInfo">
<view class="isflag" v-if="address.isDefault == 1">默认</view> <view class="isflag" v-if="addressInfo.isDefault == 1">默认</view>
<view class="txt">山东省青岛市市北区</view> <view class="txt">{{addressInfo.province}} {{addressInfo.city}} {{addressInfo.area}}</view>
</view> </view>
<view class="address_des" v-if="address">大港街道大港三路8号铁路住宅小区6号楼6单元666室</view> <view class="address_des" v-if="addressInfo">{{addressInfo.address}}</view>
<view class="address_des" style="color: #666;font-weight: normal;" v-else>请填写收货地址</view> <view class="address_des" style="color: #666;font-weight: normal;" v-else>请填写收货地址</view>
<view class="address_user" v-if="address"> <view class="address_user" v-if="addressInfo">
<text class="user_name">1d</text> <text class="user_name">{{addressInfo.consignee}}</text>
<text class="user_phone">15612345678</text> <text class="user_phone">{{addressInfo.phone}}</text>
</view> </view>
</view> </view>
<image class="arrow" src="../../../static/image/icon-arrow-right.png"></image> <image class="arrow" src="../../../static/image/icon-arrow-right.png"></image>
@ -66,7 +66,7 @@
return { return {
imgPrefix: getApp().globalData.imgPrefix, imgPrefix: getApp().globalData.imgPrefix,
phone: '', phone: '',
address: null, addressInfo: null,
goodsInfo: { goodsInfo: {
goodsName: '', goodsName: '',
price: 699 price: 699
@ -87,11 +87,15 @@
} }
this.queryGoodsInfo(); this.queryGoodsInfo();
}, },
methods: { onShow() {
// let address = uni.getStorageSync('address');
changeAddress(address) { if(address) {
this.address = address; this.addressInfo = JSON.parse(address);
uni.removeStorageSync('address');
console.log(this.addressInfo)
}
}, },
methods: {
// //
goAddress() { goAddress() {
uni.navigateTo({ uni.navigateTo({
@ -132,9 +136,9 @@
}, },
success: (res) => { success: (res) => {
if (res.data.code == 200) { 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) { } else if (res.data.code == 401) {
this.doLogin(); this.doLogin(1);
} else { } else {
uni.showToast({ uni.showToast({
title: res.data.msg, title: res.data.msg,
@ -146,7 +150,7 @@
}, },
// //
submitOrder() { submitOrder() {
if(!this.address) { if (!this.addressInfo) {
uni.showToast({ uni.showToast({
title: '请填写收货地址', title: '请填写收货地址',
icon: 'none' icon: 'none'
@ -160,7 +164,11 @@
buyerId: this.userInfo.id, buyerId: this.userInfo.id,
buyerName: this.userInfo.username, buyerName: this.userInfo.username,
buyerPhone: this.phone, 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: { header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') 'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
@ -176,7 +184,7 @@
content: res.data.msg, content: res.data.msg,
success: (res2) => { success: (res2) => {
if (res2.confirm) { if (res2.confirm) {
uni.navigateTo({ uni.redirectTo({
url: '/pages/pages_zhentou/order/order' url: '/pages/pages_zhentou/order/order'
}) })
} else if (res.cancel) { } else if (res.cancel) {
@ -194,12 +202,12 @@
}) })
}, },
// //
doPaySuccess(orderNo) { doPaySuccess(orderInfo) {
uni.request({ uni.request({
url: getApp().globalData.baseUrl + '/blade-desk/order/paySuccessCallback', url: getApp().globalData.baseUrl + '/blade-desk/order/paySuccessCallback',
method: 'POST', method: 'POST',
data: { data: {
id: orderNo id: orderInfo.id
}, },
header: { header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') 'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
@ -210,14 +218,21 @@
title: '订单支付成功', title: '订单支付成功',
icon: 'none' icon: 'none'
}) })
setTimeout(() => {
uni.redirectTo({ uni.redirectTo({
url: '/pages/pages_zhentou/order/order' url: '/pages/pages_zhentou/form/form?id=' + orderInfo.id + '&num=' + this.orderInfo.goodsNum
}) })
}, 2000)
} else { } else {
uni.showToast({ uni.showToast({
title: res.data.msg, title: res.data.msg,
icon: 'none' icon: 'none'
}) })
setTimeout(() => {
uni.redirectTo({
url: '/pages/pages_zhentou/order/order'
})
}, 2000)
} }
} }
}) })
@ -251,10 +266,20 @@
paySign: res.data.data.paySign, paySign: res.data.data.paySign,
success: (res1) => { success: (res1) => {
console.log(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) => { fail: (res2) => {
console.log(res2) console.log(res2)
uni.redirectTo({
url: '/pages/pages_zhentou/order/order'
})
} }
}) })
} else { } else {
@ -270,7 +295,7 @@
}) })
}, },
// //
doLogin() { doLogin(type) {
uni.showLoading({ uni.showLoading({
title: '登录中', title: '登录中',
mask: true mask: true
@ -288,6 +313,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.addressInfo) {
this.queryAddress(); //
}
} else { } else {
uni.showToast({ uni.showToast({
title: res.data.msg, title: res.data.msg,
@ -314,15 +342,19 @@
margin: 30rpx 30rpx 18rpx; margin: 30rpx 30rpx 18rpx;
background-color: #fff; background-color: #fff;
border-radius: 30rpx; border-radius: 30rpx;
.arrow { .arrow {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
} }
.address_info { .address_info {
width: 554rpx; width: 554rpx;
.address_top { .address_top {
display: flex; display: flex;
align-items: center; align-items: center;
.isflag { .isflag {
width: 60rpx; width: 60rpx;
color: #D73232; color: #D73232;
@ -336,6 +368,7 @@
border: 1rpx solid #D73232; border: 1rpx solid #D73232;
margin-right: 12rpx; margin-right: 12rpx;
} }
.txt { .txt {
line-height: 32rpx; line-height: 32rpx;
font-size: 24rpx; font-size: 24rpx;
@ -344,6 +377,7 @@
color: #666666; color: #666666;
} }
} }
.address_des { .address_des {
line-height: 40rpx; line-height: 40rpx;
font-size: 28rpx; font-size: 28rpx;
@ -353,6 +387,7 @@
word-break: break-all; word-break: break-all;
margin: 20rpx 0; margin: 20rpx 0;
} }
.address_user { .address_user {
display: flex; display: flex;
align-items: center; align-items: center;
@ -360,9 +395,11 @@
font-size: 24rpx; font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC; font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
.user_name { .user_name {
color: #333333; color: #333333;
} }
.user_phone { .user_phone {
color: #999999; color: #999999;
margin-left: 10rpx; margin-left: 10rpx;
@ -381,7 +418,6 @@
background: #FFFFFF; background: #FFFFFF;
border-radius: 30rpx; border-radius: 30rpx;
margin: 0 auto; margin: 0 auto;
margin-top: 30rpx;
padding-bottom: 30rpx; padding-bottom: 30rpx;
.top_title { .top_title {
@ -440,17 +476,21 @@
font-family: PingFang SC-Regular, PingFang SC; font-family: PingFang SC-Regular, PingFang SC;
line-height: 38rpx; line-height: 38rpx;
padding: 30rpx 30rpx 0; padding: 30rpx 30rpx 0;
.num_title { .num_title {
font-size: 26rpx; font-size: 26rpx;
font-weight: 400; font-weight: 400;
} }
.goods_num_btn { .goods_num_btn {
display: flex; display: flex;
align-items: center; align-items: center;
.act_img { .act_img {
width: 38rpx; width: 38rpx;
height: 38rpx; height: 38rpx;
} }
.goods_num { .goods_num {
min-width: 38rpx; min-width: 38rpx;
font-size: 28rpx; font-size: 28rpx;
@ -463,6 +503,7 @@
} }
} }
// //
.goods_sum { .goods_sum {
position: absolute; position: absolute;
@ -474,6 +515,7 @@
height: 128rpx; height: 128rpx;
background-color: #fff; background-color: #fff;
padding: 21rpx 30rpx; padding: 21rpx 30rpx;
.sum_title { .sum_title {
display: flex; display: flex;
align-items: center; align-items: center;
@ -482,14 +524,17 @@
font-weight: bold; font-weight: bold;
height: 78rpx; height: 78rpx;
color: #333333; color: #333333;
.price { .price {
margin-left: 11rpx; margin-left: 11rpx;
.price_unit { .price_unit {
font-size: 22rpx; font-size: 22rpx;
font-family: PingFang SC-Bold, PingFang SC; font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold; font-weight: bold;
color: #D73232; color: #D73232;
} }
.price { .price {
font-size: 34rpx; font-size: 34rpx;
font-family: PingFang SC-Bold, PingFang SC; font-family: PingFang SC-Bold, PingFang SC;
@ -499,6 +544,7 @@
} }
} }
} }
.order_btn { .order_btn {
width: 320rpx; width: 320rpx;
height: 78rpx; height: 78rpx;

Loading…
Cancel
Save