购物车,订单,霸王餐

This commit is contained in:
wwz
2025-03-20 18:33:21 +08:00
parent 9da31e2faa
commit 5b8100aa64
16 changed files with 1382 additions and 1224 deletions

View File

@@ -36,39 +36,18 @@
<!-- x详情 -->
<orderInfoAfter ref="orderInfoAfterRef" :rechargeFreeChecked="rechargeFreeChecked" :freeCheck="freeCheck"
:listinfo="listinfo" :orderVIP="orderVIP" :ordershopUserInfo='ordershopUserInfo' @istype="istype"
@clickPointsamount='clickPointsamount' @learcoupons="learcoupons">
@clickPointsamount='clickPointsamount' @learcoupons="learcoupons" :changeFreeenable='changeFreeenable'>
</orderInfoAfter>
<!-- 充值免单 -->
<!-- <block v-if="listinfo.useType == 'dine-in-after'">
<rechargeFree
:rechargeFreeChecked="rechargeFreeChecked"
v-if="listinfo.freeDingConfig&&listinfo.freeDingConfig.enable == 1&&(listinfo.status == 'unpaid' || listinfo.status == 'paying')"
ref="rechargeFree"
:freeDisabled="freeDisabled"
:payAmount="listinfo.payAmount"
:freeDingConfig="listinfo.freeDingConfig" :shopUserInfo="orderVIP" @changeFree="changeFree"></rechargeFree>
</block>
<block v-else>
<rechargeFree
:rechargeFreeChecked="rechargeFreeChecked"
v-if="listinfo.freeDingConfig&&listinfo.freeDingConfig.enable == 1&&(!listinfo.couponInfoList&&listinfo.pointsDiscountAmount<=0)&&(listinfo.status == 'unpaid' || listinfo.status == 'paying')"
ref="rechargeFree"
:freeDisabled="freeDisabled"
:payAmount="listinfo.payAmount"
:freeDingConfig="listinfo.freeDingConfig" :shopUserInfo="orderVIP" @changeFree="changeFree"></rechargeFree>
</block> -->
<!-- 霸王餐 -->
<rechargeFree :freeDineConfig="orderVIP.freeDineConfig" :payAmount="listinfo.totalPrices"
v-if="listinfo.status == 'unpaid' && orderVIP.freeDineConfig.enable" @changeFree="changeFree">
</rechargeFree>
<!-- 支付方式 -->
<paymentMethodes ref="paymentMethodref" :orderVIP="orderVIP" @groupChange="groupChange"
v-if="listinfo.status == 'unpaid'">
:changeFreeenable='changeFreeenable' v-if="listinfo.status == 'unpaid'">
</paymentMethodes>
<!-- <paymentMethodes ref="paymentMethodes" :rechargeFreeChecked="rechargeFreeChecked"
v-if="orderVIP&&listinfo.status == 'unpaid' || listinfo.status == 'paying'" :freeCheck="freeCheck"
:payAmount="listinfo.payAmount" :orderVIP="orderVIP" @groupChange="groupChange"></paymentMethodes> -->
<view class="fixedview">
<view class="flex-between" v-if="listinfo.status == 'unpaid'">
<view class="fixedview_one flex-start">
@@ -77,8 +56,13 @@
<text>¥</text>{{listinfo.totalCost}}
</view>
</view>
<view class="fixedview_tow" @tap="$u.debounce(goToPay,1000)">
{{paymentmethod.paymentBtnText}}
<view class="flex-colum-end">
<view class="fixedview_tow" @tap="$u.debounce(istoricalorders,1000)">
{{paymentmethod.paymentBtnText}}
</view>
<!-- <view class="fixedview_tows" @tap="$u.debounce(APIputuserorderclick,1000)">
取消订单
</view> -->
</view>
</view>
</view>
@@ -97,11 +81,12 @@
} from 'vue';
import {
APIgetOrderById
APIgetOrderById,
APIputuserorder,
APIhistoryOrder
} from '@/common/api/order/index.js'
import {
APIusershopInfodetail,
APIshopUserInfo
} from '@/common/api/member.js'
@@ -131,7 +116,7 @@
import payPassword from '@/components/payPassword.vue'
import orderInfoAfter from './components/orderInfoAfter.vue'
// import orderInfoBefore from '../components/orderInfoBefore.vue'
// import rechargeFree from '../components/rechargeFree.vue'
import rechargeFree from './components/rechargeFree.vue'
import paymentMethodes from '@/components/paymentMethod.vue'; //支付方式
import {
onBackPress
@@ -186,13 +171,13 @@
})
if (res) {
Object.assign(listinfo, res);
if (listinfo.status == 'unpaid') {
try {
let res = await APIhistoryOrder({
orderId: orderId.value
})
} catch (error) {}
}
// if (listinfo.status == 'unpaid') {
// try {
// let res = await APIhistoryOrder({
// orderId: orderId.value
// })
// } catch (error) {}
// }
// 历史订单
if (listinfo.detailMap) {
let combinedArray = [];
@@ -245,6 +230,13 @@
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100;
// 霸王餐
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
.freeDineConfig
.rechargeTimes)).toFixed(2)
}
// 积分
if (listinfo.totalCost && listinfo.status == 'unpaid') {
uni.$u.debounce(memberPointscalcUsablePoints, 500)
@@ -256,6 +248,34 @@
}
});
// 霸王餐
const changeFreeenable = ref(false)
const changeFree = (e) => {
console.log(e)
if (e) {
uniqueIds.value = [] // 筛选出商品卷的id
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
listinfo.Productroll = 0 // 商品卷总价价格
uniqueIds.value = [] // 筛选出商品卷的id
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
// 支付方式切换
// #ifdef MP-WEIXIN
paymentMethodref.value.groupChanges(2)
// paymentmethod.radiovalue = 2;
// paymentmethod.paymentBtnText = "微信支付";
// paymentmethod.payType = 'wechatPay';
// #endif
// #ifdef MP-ALIPAY
paymentMethodref.value.groupChanges(3)
// paymentmethod.radiovalue = 3;
// paymentmethod.paymentBtnText = "支付宝支付";
// paymentmethod.payType = 'wechatPay';
// #endif
}
changeFreeenable.value = e
}
const saveImage = (url) => {
uni.saveImage({
url: url,
@@ -268,6 +288,9 @@
});
}
//
const paymentMethodref = ref(null)
// 支付方式切换
const paymentmethod = reactive({
radiovalue: 2,
@@ -330,8 +353,52 @@
}
}
// 删除订单
const APIputuserorderclick = async () => {
await APIputuserorder(listinfo.id)
uni.navigateBack()
}
const istoricalorders = async () => {
console.log(paymentmethod.payType, '1212')
// 先调用历史订单
let APIhistoryOrderres = await APIhistoryOrder({
tableCode: listinfo.tableCode
})
// 判断是否有历史订单
if (APIhistoryOrderres.detailMap) {
let combinedArray = [];
for (const key in APIhistoryOrderres.detailMap) {
if (APIhistoryOrderres.detailMap.hasOwnProperty(key)) {
let subArray = APIhistoryOrderres.detailMap[key];
combinedArray = [...combinedArray, ...subArray]
}
}
// 判断支付之前是是否还有新加订单
if (listinfo.combinedArray.length === combinedArray.length) {
goToPay()
} else {
uni.showToast({
title: '你的订单已更新!',
icon: 'none'
})
orderorderInfo()
}
} else {
uni.showToast({
title: '你的小伙伴已提交订单~',
icon: 'none'
})
setTimeout(() => {
orderorderInfo()
}, 1000)
}
}
// * 去支付
const goToPay = async () => {
// 霸王餐
// 余额支付
if (paymentmethod.payType == 'accountPay') {
if (orderVIP.value.isVip == 0) {
@@ -369,34 +436,48 @@
}
return false
}
let checkOrderPay = {
orderId: orderId.value,
vipPrice: orderVIP.value.isVip == 1 && ordershopUserInfo.value.isMemberPrice == 1 ? 1 :
0, //是否使用会员价0否1是
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数
originAmount: listinfo.originAmount, //订单金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
discountAmount: 0, //手动优惠金额 写死0
productCouponDiscountAmount: listinfo.Productroll, //商品优惠券抵扣金额
fullCouponDiscountAmount: listinfo.coupondiscountAmount, //满减优惠券抵扣金额
couponList: uniqueIds.value, //用户使用的卡券
orderAmount: listinfo.totalCost, // 最中订单金额
roundAmount: 0, //抹零金额 减免多少钱
pointsDiscountAmount: listinfo.pointsDiscountAmount, //积分抵扣金额(tb_points_basic_setting表)
pointsNum: 0, //(扣除各类折扣 enable_deduction后使用)
remark: '', //用户备注
}
try {
await storeMemberpay.actionsltPayOrder({
checkOrderPay,
payType: paymentmethod.payType,
buyerRemark: '',
returnUrl: ''
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
await storeMemberpay.actionspayltPayVip({
shopId: orderVIP.value.shopId,
shopUserId: orderVIP.value.id,
orderId: orderId.value,
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
amount: listinfo.totalCost, // 最终订单金额
returnUrl: '', //跳转地址
buyerRemark: ''
})
} catch (error) {
//TODO handle the exception
return false;
} else {
let checkOrderPay = {
orderId: orderId.value,
vipPrice: orderVIP.value.isVip == 1 && ordershopUserInfo.value.isMemberPrice == 1 ? 1 :
0, //是否使用会员价0否1是
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数
originAmount: listinfo.originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
discountAmount: 0, //手动优惠金额 写死0
productCouponDiscountAmount: listinfo.Productroll, //商品优惠券抵扣金额
fullCouponDiscountAmount: listinfo.coupondiscountAmount, //满减优惠券抵扣金额
couponList: uniqueIds.value, //用户使用的卡券
orderAmount: listinfo.totalCost, // 最终订单金额
roundAmount: 0, //抹零金额 减免多少钱
pointsDiscountAmount: listinfo.pointsDiscountAmount, //积分抵扣金额(tb_points_basic_setting表)
pointsNum: 0, //(扣除各类折扣 enable_deduction后使用)
remark: '', //用户备注
}
try {
await storeMemberpay.actionsltPayOrder({
checkOrderPay,
payType: paymentmethod.payType,
buyerRemark: '',
returnUrl: ''
})
} catch (error) {
//TODO handle the exception
}
}
orderorderInfo()
}
@@ -906,6 +987,7 @@
left: 0;
width: 100%;
// height: 80rpx;
.flex-between {
width: 100%;
padding: 36rpx 54rpx 102rpx 54rpx;
@@ -932,14 +1014,26 @@
}
}
.fixedview_tow {
background: #E3AD7F;
border-radius: 36rpx;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
padding: 14rpx 44rpx;
.flex-colum-end {
.fixedview_tow {
background: #E3AD7F;
border-radius: 36rpx;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
padding: 14rpx 44rpx;
}
.fixedview_tows {
background: #c3c3c3;
border-radius: 36rpx;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
padding: 14rpx 44rpx;
}
}
}
}
</style>