订单支付逻辑优化

main
xuechunyuan 2 years ago
parent 91bf2ab85b
commit d09219e41c
  1. 4
      App.vue
  2. 2
      pages/pages_zhentou/myPage/myPage.vue
  3. 158
      pages/pages_zhentou/order/confirmOrder.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/", //
},

@ -9,7 +9,7 @@
</view>
<view class="nickname_warp">
<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 class="cnt-box">

@ -2,15 +2,15 @@
<view class="order_box">
<view class="order_address" @click="goAddress">
<view class="address_info">
<view class="address_top" v-if="address">
<view class="isflag" v-if="address.isDefault == 1">默认</view>
<view class="txt">山东省青岛市市北区</view>
<view class="address_top" v-if="addressInfo">
<view class="isflag" v-if="addressInfo.isDefault == 1">默认</view>
<view class="txt">{{addressInfo.province}} {{addressInfo.city}} {{addressInfo.area}}</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_user" v-if="address">
<text class="user_name">1d</text>
<text class="user_phone">15612345678</text>
<view class="address_user" v-if="addressInfo">
<text class="user_name">{{addressInfo.consignee}}</text>
<text class="user_phone">{{addressInfo.phone}}</text>
</view>
</view>
<image class="arrow" src="../../../static/image/icon-arrow-right.png"></image>
@ -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 @@
<style lang="scss" scoped>
.order_box {
.order_address{
.order_address {
display: flex;
justify-content: space-between;
align-items: center;
@ -314,16 +342,20 @@
margin: 30rpx 30rpx 18rpx;
background-color: #fff;
border-radius: 30rpx;
.arrow{
.arrow {
width: 40rpx;
height: 40rpx;
}
.address_info{
.address_info {
width: 554rpx;
.address_top{
.address_top {
display: flex;
align-items: center;
.isflag{
.isflag {
width: 60rpx;
color: #D73232;
font-size: 20rpx;
@ -336,7 +368,8 @@
border: 1rpx solid #D73232;
margin-right: 12rpx;
}
.txt{
.txt {
line-height: 32rpx;
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
@ -344,7 +377,8 @@
color: #666666;
}
}
.address_des{
.address_des {
line-height: 40rpx;
font-size: 28rpx;
font-family: PingFang SC-Bold, PingFang SC;
@ -353,17 +387,20 @@
word-break: break-all;
margin: 20rpx 0;
}
.address_user{
.address_user {
display: flex;
align-items: center;
line-height: 33rpx;
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
.user_name{
.user_name {
color: #333333;
}
.user_phone{
.user_phone {
color: #999999;
margin-left: 10rpx;
}
@ -381,7 +418,6 @@
background: #FFFFFF;
border-radius: 30rpx;
margin: 0 auto;
margin-top: 30rpx;
padding-bottom: 30rpx;
.top_title {
@ -433,25 +469,29 @@
}
}
.order_num{
.order_num {
display: flex;
justify-content: space-between;
color: #333333;
font-family: PingFang SC-Regular, PingFang SC;
line-height: 38rpx;
padding: 30rpx 30rpx 0;
.num_title{
.num_title {
font-size: 26rpx;
font-weight: 400;
}
.goods_num_btn{
.goods_num_btn {
display: flex;
align-items: center;
.act_img{
.act_img {
width: 38rpx;
height: 38rpx;
}
.goods_num{
.goods_num {
min-width: 38rpx;
font-size: 28rpx;
font-weight: bold;
@ -460,21 +500,23 @@
}
}
}
}
}
//
.goods_sum{
.goods_sum {
position: absolute;
left: 0;
right:0;
bottom:0;
right: 0;
bottom: 0;
display: flex;
justify-content: space-between;
justify-content: space-between;
height: 128rpx;
background-color: #fff;
padding: 21rpx 30rpx;
.sum_title{
.sum_title {
display: flex;
align-items: center;
font-size: 26rpx;
@ -482,15 +524,18 @@
font-weight: bold;
height: 78rpx;
color: #333333;
.price{
.price {
margin-left: 11rpx;
.price_unit{
.price_unit {
font-size: 22rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #D73232;
}
.price{
.price {
font-size: 34rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
@ -499,7 +544,8 @@
}
}
}
.order_btn{
.order_btn {
width: 320rpx;
height: 78rpx;
line-height: 78rpx;

Loading…
Cancel
Save