支付相关调整

This commit is contained in:
@fawn-nine
2024-09-19 11:35:36 +08:00
parent e421621155
commit 54a69954dd
4 changed files with 116 additions and 39 deletions

View File

@@ -24,7 +24,7 @@
"type" : "uni-app:app-ios" "type" : "uni-app:app-ios"
}, },
{ {
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
}, },
{ {

View File

@@ -50,7 +50,7 @@
: '' : ''
}`" }`"
> >
<view class="image_box" style="margin-right: 10rpx"> <view class="image_box" style="margin-right: 10rpx; ">
<image <image
:src="slotProps.row.productImages" :src="slotProps.row.productImages"
mode="aspectFit" mode="aspectFit"
@@ -58,12 +58,17 @@
></image> ></image>
</view> </view>
<view :class="`goods_info `"> <view :class="`goods_info flex_box just`" style="justify-content: space-between;">
<view class="name">{{ slotProps.row.productName }}</view> <view class="name">{{ slotProps.row.productName }}</view>
<view class="price" style="color: #258feb" <view class="flex_box">
>{{ slotProps.row.activityPrice?slotProps.row.activityPrice:slotProps.row.price }}</view <text style="color: #999; text-decoration: line-through; margin-right: 20rpx;"
></view v-if="slotProps.row.activityPrice > 0 && slotProps.row.activityPrice < slotProps.row.price" >{{slotProps.row.price}}</text>
> <view class="price" style="color: #258feb"
>{{ slotProps.row.activityPrice?slotProps.row.activityPrice:slotProps.row.price }}</view
></view
>
</view>
</view> </view>
<!-- <text v-if="slotProps.row.conditions!='03'">试听</text> --> <!-- <text v-if="slotProps.row.conditions!='03'">试听</text> -->

View File

@@ -877,7 +877,8 @@ export default {
productImages: this.selectGoodsData.productImages, productImages: this.selectGoodsData.productImages,
productId: this.selectGoodsData.productId, productId: this.selectGoodsData.productId,
productName: this.selectGoodsData.productName, productName: this.selectGoodsData.productName,
price: this.selectGoodsData.activityPrice?this.selectGoodsData.activityPrice:this.selectGoodsData.price, activityPrice:this.selectGoodsData.activityPrice,
price: this.selectGoodsData.price,
goodsType: this.selectGoodsData.goodsType, goodsType: this.selectGoodsData.goodsType,
}, },
], ],

View File

@@ -53,15 +53,25 @@
<view class="normal_box"> <view class="normal_box">
<view class="normal_box_top" style="justify-content: space-between"> <view class="normal_box_top" style="justify-content: space-between">
<view class="curriulum_title">{{ v.productName }} </view> <view class="curriulum_title">{{ v.productName }} </view>
<view class="price_box"> <!-- <view class="price_box">
<text class="price" style="margin-right: 0"> <text class="price" style="margin-right: 0">
{{ v.activityPrice && v.activityPrice > 0 ? v.activityPrice : v.price}} {{ v.activityPrice && v.activityPrice > 0 ? v.activityPrice : v.price}}
</text> </text>
</view> </view> -->
</view> </view>
<!-- <view class=""></view> -->
<view style="width: 100%; text-align: right"> <view style="width: 100% !important; text-align: right;" class=" ">
x 1 <!-- <view class="flexbox" style="justify-content: space-between; align-items: center;"> -->
<!-- -->
<text style="color: #999; text-decoration: line-through; margin-right: 20rpx;"
v-if="v.activityPrice > 0 && v.activityPrice < v.price" >原价:{{v.price}}</text>
<text class="" style="margin-right: 26rpx">
{{ v.activityPrice && v.activityPrice > 0 ? v.activityPrice : v.price}}
</text>
<text>x 1</text>
<!-- </view> -->
<!-- <u-number-box v-model="number" style="float: right"> <!-- <u-number-box v-model="number" style="float: right">
<view slot="minus" class="minus"> <view slot="minus" class="minus">
<u-icon name="minus" size="12"></u-icon> <u-icon name="minus" size="12"></u-icon>
@@ -412,6 +422,7 @@
}, },
data() { data() {
return { return {
historyOrderInfo:undefined, //上一个订单的参数
isDefaultCurrency: false, isDefaultCurrency: false,
isShowAddress: false, isShowAddress: false,
jfNumber: 0, jfNumber: 0,
@@ -484,6 +495,7 @@
"margin-left": "30rpx", "margin-left": "30rpx",
}, },
modalInfo: {}, modalInfo: {},
canjump:true, // 是否可以跳转到其他页面
currentCateIndex: 0, currentCateIndex: 0,
show: false, show: false,
playData: {}, playData: {},
@@ -929,6 +941,7 @@
} }
}, },
async goBuyJie() { async goBuyJie() {
console.log('this.buyingFlag',this.buyingFlag);
if (this.buyingFlag) { if (this.buyingFlag) {
uni.showToast({ uni.showToast({
title: '操作太频繁了,休息下吧', title: '操作太频繁了,休息下吧',
@@ -948,6 +961,7 @@
setTimeout(() => { setTimeout(() => {
this.nowClick = true; this.nowClick = true;
}, 5000); }, 5000);
// let youPre = { // let youPre = {
// id: "", // id: "",
// coupons: { // coupons: {
@@ -970,7 +984,8 @@
this.$commonJS.showToast("请选择收货地址"); this.$commonJS.showToast("请选择收货地址");
return false; return false;
} }
} }
let data = { let data = {
buyType: this.options.typeId, //0- 商品页直接下单 1- 购物车结算 buyType: this.options.typeId, //0- 商品页直接下单 1- 购物车结算
userId: this.userInfo.id, //下单人ID userId: this.userInfo.id, //下单人ID
@@ -998,9 +1013,48 @@
appName: "wumen", appName: "wumen",
come: "2", come: "2",
}; };
var productList = [...data.productList]
console.log("data at line 477:", data); var thisproduct = productList.map(item => {
return item.productId+"_"+item.quantity
})
thisproduct = thisproduct.join(',')
console.log("data at line 477:", data);
// console.log('成功信息',product,thisproduct,data.addressId, data.realMoney);
if(this.historyOrderInfo &&
thisproduct == this.historyOrderInfo.product &&
data.addressId == this.historyOrderInfo.addressId &&
this.historyOrderInfo.realMoney == data.realMoney){
that.canjump = false
uni.showModal({
title:'提示',
content:'您短时间内有一笔相同金额的订单,是否确定继续下单?',
cancelText:'点错了',
confirmText:'继续操作',
success: function(res) {
that.canjump = true
if (res.confirm) {
that.buyingFlag = false
console.log('用户点击确定',that.buyingFlag);
that.submitorder(data)
}
else{
that.buyingFlag = false
}
}
})
}else{
that.submitorder(data)
}
},
async submitorder(data){
uni.showLoading({
title:'正在请求订单'
})
// this.buyingFlag = false
console.log('进来请求了吗?');
let that = this
await $http await $http
.request({ .request({
// url: "book/buyOrder/buySave", // url: "book/buyOrder/buySave",
@@ -1013,9 +1067,19 @@
}, },
}) })
.then(async (res) => { .then(async (res) => {
this.buyingFlag = false that.buyingFlag = false
var product = data.productList.map(item => {
return item.productId+"_"+item.quantity
})
product = product.join(',')
that.historyOrderInfo = {
'product':product,
'addressId':data.addressId,
'realMoney':data.realMoney
}
console.log("res at line 598系统下单返回结果:", res); console.log("res at line 598系统下单返回结果:", res);
if (res.code == 0) { if (res.code == 0) {
if (res.orderSn == null) { if (res.orderSn == null) {
uni.showToast({ uni.showToast({
title: "失败,请重新下单", title: "失败,请重新下单",
@@ -1024,12 +1088,12 @@
}); });
} else { } else {
console.log("that.payType at line 607:", that.payType); console.log("that.payType at line 607:", that.payType);
uni.showToast({
title: "下单成功,即将进行支付",
icon:'none'
})
if (that.payType == 2) { if (that.payType == 2) {
// 常规支付 // 常规支付
uni.showToast({
title: "正在支付",
icon: "loading",
});
await setPay({ await setPay({
typePay: "alipay", typePay: "alipay",
subject: "order", subject: "order",
@@ -1043,12 +1107,14 @@
title: "加载中", title: "加载中",
}); });
console.log(res, "支付支付"); console.log(res, "支付支付");
if (res.success) { if (res.success) {
uni.hideLoading()
uni.showToast({ uni.showToast({
title: "支付成功", title: "支付成功",
}); });
setTimeout(() => { setTimeout(() => {
if (that.goToInfo.type == 1) { if(that.canjump){
if (that.goToInfo.type == 1 ) {
uni.switchTab({ uni.switchTab({
url: `${that.goToInfo.url}?type=order`, url: `${that.goToInfo.url}?type=order`,
}); });
@@ -1060,8 +1126,10 @@
url: `${that.goToInfo.url}?backType=order`, url: `${that.goToInfo.url}?backType=order`,
}); });
} }
}
}, 1000); }, 1000);
} else { } else {
uni.hideLoading()
console.log("失败失败失败"); console.log("失败失败失败");
// this.buyingFlag = false // this.buyingFlag = false
// that.$commonJS.showToast('支付是失败') // that.$commonJS.showToast('支付是失败')
@@ -1069,13 +1137,12 @@
console.log("延迟调用 失败提示"); console.log("延迟调用 失败提示");
uni.showToast({ uni.showToast({
title: "支付失败", title: "支付失败",
image: "../../../static/icon/ic_close.png", image: "../../../static/icon/ic_close.png",
}); });
}, 0); }, 0);
// setTimeout(() => { // setTimeout(() => {
// uni.navigateTo({ // uni.navigateTo({
// url: './orderList' // url: './orderList'
// }); // });
@@ -1083,7 +1150,7 @@
} }
} }
); );
} else if (this.payType == 1) { } else if (that.payType == 1) {
// 微信支付 // 微信支付
let data1 = { let data1 = {
orderSn: res.orderSn, orderSn: res.orderSn,
@@ -1093,26 +1160,26 @@
setWXPay(data1, (res) => { setWXPay(data1, (res) => {
if (res.success) { if (res.success) {
// this.buyingFlag = false // this.buyingFlag = false
uni.hideLoading()
uni.showToast({ uni.showToast({
title: "支付成功", title: "支付成功",
}); });
setTimeout(() => { setTimeout(() => {
if(that.canjump){
if (that.goToInfo.type == 1) { if (that.goToInfo.type == 1) {
uni.switchTab({ uni.switchTab({
url: `${that.goToInfo.url}?type=order`, url: `${that.goToInfo.url}?type=order`,
}); });
} else { } else {
// uni.navigateBack({
// delta: 2,
// });
// uni.n
uni.redirectTo({ uni.redirectTo({
url: `${that.goToInfo.url}?backType=order`, url: `${that.goToInfo.url}?backType=order`,
}); });
} }
}
}, 1000); }, 1000);
} else { } else {
// this.buyingFlag = false // this.buyingFlag = false
uni.hideLoading()
console.log(res, "微信支付111111111111111"); console.log(res, "微信支付111111111111111");
if (res.data.errMsg.indexOf("User canceled") != -1) { if (res.data.errMsg.indexOf("User canceled") != -1) {
uni.showToast({ uni.showToast({
@@ -1129,14 +1196,16 @@
} }
} }
}); });
} else if (this.payType == 4) { } else if (that.payType == 4) {
// this.buyingFlag = false that.buyingFlag = false
// 天医币支付 // 天医币支付
uni.hideLoading()
uni.showToast({ uni.showToast({
title: "购买成功", title: "购买成功",
icon: "success", icon: "success",
}); });
setTimeout(() => { setTimeout(() => {
if(that.canjump){
if (that.goToInfo.type == 1) { if (that.goToInfo.type == 1) {
uni.switchTab({ uni.switchTab({
url: `${that.goToInfo.url}?type=order`, url: `${that.goToInfo.url}?type=order`,
@@ -1146,15 +1215,16 @@
url: `${that.goToInfo.url}?backType=order`, url: `${that.goToInfo.url}?backType=order`,
}); });
} }
}
}, 1000); }, 1000);
} }
} }
} }
}).catch(e => { }).catch(e => {
this.buyingFlag = false that.buyingFlag = false
uni.hideLoading()
}); });
}, },
radioChange(index) { radioChange(index) {
if (index == this.selectPayIndex) { if (index == this.selectPayIndex) {
return return
@@ -1867,6 +1937,7 @@
background-color: #fff; background-color: #fff;
.curriulum_title { .curriulum_title {
// width: calc(100% - 80rpx);
width: calc(100% - 80rpx); width: calc(100% - 80rpx);
font-weight: 500; font-weight: 500;
font-size: 30rpx; font-size: 30rpx;