订单删除

This commit is contained in:
wwz 2025-03-31 14:08:34 +08:00
parent 10a47abe13
commit e352acbdd0
7 changed files with 521 additions and 66 deletions

View File

@ -44,4 +44,22 @@ export const APIgetOrderById = (data) => {
method: 'get',
data: data
})
}
//删除所有待支付订单
export const APIcancelOrder = (data) => {
return request({
url: url + '/user/order/cancelOrder',
method: 'post',
data: data
})
}
//删除某一个待支付订单
export const APIrmPlaceOrder = (data) => {
return request({
url: url + '/user/order/rmPlaceOrder',
method: 'post',
data: data
})
}

View File

@ -1,12 +1,12 @@
// const debug = process.env.NODE_ENV == 'development' ? true : false;
const debug = false
const debug = true
// #ifdef H5
const proxyApi = "/api"
// #endif
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
const proxyApi = 'http://192.168.1.31' // 调试地址
const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址
const proxyApiwws = 'ws://192.168.1.31:2348' // 调试地址
// // 本地
// const proxyApi = 'http://192.168.1.31' // 固定的测试

View File

@ -33,7 +33,7 @@
<!-- #endif -->
</view>
<!-- x详情 -->
<!-- 详情 -->
<orderInfoAfter ref="orderInfoAfterRef" :rechargeFreeChecked="rechargeFreeChecked" :freeCheck="freeCheck"
:listinfo="listinfo" :orderVIP="orderVIP" :ordershopUserInfo='ordershopUserInfo' @istype="istype"
@clickPointsamount='clickPointsamount' @learcoupons="learcoupons" :changeFreeenable='changeFreeenable'>
@ -60,13 +60,13 @@
<view class="fixedview_tow" @tap="$u.debounce(istoricalorders,1000)">
{{paymentmethod.paymentBtnText}}
</view>
<!-- <view class="fixedview_tows" @tap="$u.debounce(APIputuserorderclick,1000)">
<view class="fixedview_tows" @tap="$u.debounce(APIputuserorderclick,1000)">
取消订单
</view> -->
</view>
</view>
</view>
</view>
<view style="width: 100%;height: 200rpx;"> </view>
<view style="width: 100%;height: 290rpx;"> </view>
<payPassword ref="payPasswordref" :isShow="ispws" @inputComplete="accountPayevent" @close="ispws = false" />
</view>
</template>
@ -224,9 +224,9 @@
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100;
//
// console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo
// .Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums) //
//
console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo
.Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums) //
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
@ -354,7 +354,11 @@
//
const APIputuserorderclick = async () => {
await APIputuserorder(listinfo.id)
uni.navigateBack()
uni.showToast({
title: '删除成功',
icon: 'none'
})
uni.pro.switchTab('order/index')
}
const istoricalorders = async () => {
@ -426,6 +430,12 @@
}
}
})
// } else if (orderVIP.value.amount == 0) {
// uni.showToast({
// title: '',
// icon: 'none'
// })
// } else {
} else {
ispws.value = true
}
@ -543,6 +553,7 @@
orderVIP.value = uni.cache.get('orderVIP')
ordershopUserInfo.value = orderVIP.value.shopInfo
paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP'))
orderorderInfo()
}
} catch (error) {
//TODO handle the exception
@ -1029,6 +1040,7 @@
}
.fixedview_tows {
margin-top: 10rpx;
background: #c3c3c3;
border-radius: 36rpx;
font-weight: 400;

View File

@ -183,7 +183,6 @@
//
const totalPrices = computed(() => {
let combinedArray = [];
for (const key in props.orderinfo.detailMap) {
if (props.orderinfo.detailMap.hasOwnProperty(key)) {

View File

@ -12,6 +12,9 @@
</view>
<scroll-view scroll-y class="scroll-view">
<view class="list-wrap">
<view class="ShoppingCart">
购物车
</view>
<view class="shop-item" v-for="(item,index) in cartList" :key="item.id">
<view class="shop-item-content">
<view class="cover" v-if="item.productId!=-999">
@ -69,11 +72,57 @@
</view>
</view>
</view>
<!-- <view class="shop-item-remark" v-if="item.productId!=-999">
<view class="label">备注</view>
<up--input placeholder="商品备注(选填)" border="none" v-model="item.note"
@blur="productBlur(item)"></up--input>
</view> -->
</view>
<!-- 历史订单 -->
<view class="card" v-if="orderinfo.detailMap">
<!-- 订单头部 -->
<view class="cardcalorders">
<!-- ··· 历史订单 ··· -->
历史订单
<view class="absolute flex-start">
<up-icon name="trash" color="#999"></up-icon>
<text style="color:' #999;'" @click="clickcancelOrder('all')">清空历史订单</text>
</view>
</view>
<view class="card_item" v-for="(value, key) in orderinfo.detailMap" :key="key">
<view class="head">
<view class="head_left">
<text class="placeNum">{{key}}次下单</text>
<view class="placeTime flex-start">
<up-icon name="trash" color="#999"></up-icon>
<text class="t" @click="clickcancelOrder('',key)">清空</text>
</view>
</view>
</view>
<!-- 订单详情 -->
<view class="shop-info">
<view class="item" v-for="item in value" :key="item.id">
<view class="cover">
<up-image width="80" radius="10" height="80" :src="item.productImg"
v-if="item.productId!=-999"></up-image>
<up-image width="80" radius="10" height="80"
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png'"
mode="heightFix" v-else></up-image>
</view>
<view class="info">
<text class="productName">{{item.productName}}</text>
<text class="productSkuName"
v-if="item.productSkuName">{{item.productSkuName}}</text>
</view>
<view class="price">
<view class="priceAmount">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.price):item.price}}
</view>
<view class="num">x{{item.num}}</view>
</view>
</view>
</view>
<view class="semicircle_icon" v-if="index > 0">
<view class="semicircle_left_icon"></view>
<view class="semicircle_right_icon"></view>
</view>
</view>
</view>
</view>
</scroll-view>
@ -95,7 +144,7 @@
} from '@/stores/user.js';
//
const emits = defineEmits(['customevent', 'close']);
const emits = defineEmits(['customevent', 'close', 'clickcancelOrder']);
const props = defineProps({
cartList: {
@ -108,6 +157,13 @@
showCart: {
type: Boolean
},
orderinfo: {
type: Object,
default: {
detailMap: {}
}
},
});
const shopInfo = uni.cache.get('shopInfo')
@ -171,6 +227,13 @@
};
})
const clickcancelOrder = (i, key) => {
emits('clickcancelOrder', {
i,
key
})
}
const calculateValue = (cartNumber, i, step = 1) => {
if (i == '+') {
const result = parseFloat(cartNumber) + parseFloat(step);
@ -247,6 +310,13 @@
padding: 28rpx 0 0 28rpx;
}
.ShoppingCart {
margin: 10rpx 0 20rpx 0;
font-size: 30rpx;
text-align: center;
color: #969494;
}
.shop-item {
display: flex;
flex-direction: column;
@ -428,5 +498,365 @@
}
}
.card {
// background-color: #fff;
border-radius: 20upx;
margin-bottom: 28upx;
position: relative;
.cardcalorders {
position: relative;
margin: 40rpx 0 20rpx;
font-size: 35rpx;
text-align: left;
font-weight: bold;
color: #000000;
.absolute {
position: absolute;
right: 28rpx;
top: 2rpx;
font-size: 24rpx;
}
}
.card_item {
display: flex;
flex-direction: column;
position: relative;
padding-right: 20rpx;
.head {
display: flex;
justify-content: space-between;
// padding: 32rpx 0;
.head_left {
width: 100%;
display: flex;
justify-content: space-between;
padding: 20rpx 0;
.placeNum {
font-weight: bold;
font-size: 32rpx;
color: #333333;
}
.placeTime {
font-weight: 400;
font-size: 32rpx;
color: #999;
.t {
margin-left: 4rpx;
font-size: 24rpx;
}
}
}
}
.shop-info {
border-bottom: 2rpx dashed #e5e5e5;
.item {
margin: 30rpx 0;
display: flex;
.info {
flex: 1;
display: flex;
flex-direction: column;
padding-left: 16upx;
.productName {
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-top: 20rpx;
}
.productSkuName {
font-weight: 400;
font-size: 24rpx;
color: #999999;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
}
.n {
font-size: 24upx;
color: #999;
}
}
.price {
display: flex;
flex-direction: column;
align-items: flex-end;
padding: 0 28rpx;
.priceAmount {
font-weight: 500;
font-size: 28rpx;
color: #333333;
margin-top: 26rpx;
}
.num {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-top: 22rpx;
}
}
}
}
.status {
align-self: flex-end;
width: 92rpx;
height: 40rpx;
line-height: 40rpx;
text-align: center;
background: #999999;
border-radius: 10rpx 10rpx 10rpx 10rpx;
font-weight: 400;
font-size: 22rpx;
color: #FFFFFF;
margin-top: 32rpx;
}
.totalAmount {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: flex-end;
padding: 32rpx 0;
border-bottom: 2rpx dashed #e5e5e5;
.label {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.price {
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
}
.semicircle_icon {
width: 100%;
position: absolute;
top: -22.5rpx;
left: 0;
display: flex;
justify-content: space-between;
.semicircle_left_icon {
width: 45rpx;
height: 45rpx;
margin-left: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset -20rpx 0rpx 22rpx -20rpx rgba(87, 86, 86, 0.35);
}
.semicircle_right_icon {
width: 45rpx;
height: 45rpx;
margin-right: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset 13rpx 0rpx 16rpx -9rpx rgba(87, 86, 86, 0.35);
}
}
}
.cell-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 34rpx 0 34rpx;
.label {
font-weight: bold;
font-size: 32rpx;
color: #333333;
padding-bottom: 32rpx;
}
.val {
display: flex;
align-items: flex-end;
padding-bottom: 32rpx;
border-bottom: 2rpx dashed #e5e5e5;
view:nth-child(1) {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-right: 42rpx;
}
view:nth-child(2) {
display: flex;
align-items: flex-end;
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
}
.val.column {
display: flex;
flex-direction: column;
.productCoupon {
display: flex;
align-items: flex-end;
margin: 0 0 10rpx 0;
.name {
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0;
}
.num {
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0 30rpx;
line-height: 20rpx;
}
.amount {
font-weight: bold;
font-size: 26rpx;
color: #333;
}
}
}
}
.favorable {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30rpx;
box-sizing: border-box;
padding-bottom: 26rpx;
padding-top: 26rpx;
border-bottom: 2rpx solid #E5E5E5;
.favorable_left {
display: flex;
align-items: center;
.icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
.name {
font-size: 28rpx;
font-weight: 400rpx;
color: #333;
}
}
.favorable_right {
display: flex;
align-items: center;
.favorable_right_text {
font-size: 24rpx;
color: #999;
font-weight: 400rpx;
}
}
.favorable_right {
.column {
display: flex;
flex-direction: column;
align-items: flex-end;
.favorable_right_text {
margin-bottom: 10rpx;
text:nth-child(1) {
font-size: 26rpx;
color: #999;
}
text:nth-child(2) {
font-size: 26rpx;
color: #999;
margin: 0 30rpx;
}
text:nth-child(3) {
font-size: 26rpx;
color: #333;
}
}
}
}
.favorable_right.column {
align-items: flex-start;
}
}
.favorable.column {
align-items: flex-start;
}
.cell-item.column {
align-items: flex-start;
}
.total-wrap {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: flex-end;
padding: 0 34rpx;
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-top: 64rpx;
.price {
font-weight: bold;
font-size: 36rpx;
}
}
.order_footer {
display: flex;
flex-direction: column;
padding: 34rpx;
position: relative;
}
}
}
</style>

View File

@ -244,7 +244,8 @@
<shopindex ref="showShopInfoRef"></shopindex>
<!-- 购物车 -->
<shoppingCartes :cartLists_count="cartLists_count" v-if="matchedProducts.length>0" :cartList="matchedProducts"
:showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart">
:showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart"
:orderinfo="orderinfo" @clickcancelOrder='clickcancelOrder'>
</shoppingCartes>
<!-- 显示购物车栏 -->
@ -254,7 +255,7 @@
<view class="iconBox">
<image class="icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/shopIcon.png"
mode="aspectFill" @click="showCart = !showCart">
mode="aspectFill" @click="Historicalorders(true)">
</image>
<text class="u-badge"> {{cartLists_count<99?cartLists_count:'99+'}} </text>
</view>
@ -427,7 +428,9 @@
} from "@/common/api/product/product.js";
import {
APIhistoryOrder
APIhistoryOrder,
APIcancelOrder,
APIrmPlaceOrder
} from "@/common/api/order/index.js";
// websocket
@ -1096,7 +1099,6 @@
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
return false
}
//
if (processedMessageIds.has(Message.msg_id)) {
return;
@ -1105,11 +1107,10 @@
//
if (Message.operate_type == "init") {
console.log(Message)
cartList.value = Message.data
setTimeout(() => {
uni.hideLoading();
isLoading.value = false;
}, 500)
uni.hideLoading();
isLoading.value = false;
}
//
@ -1251,24 +1252,50 @@
});
//
const clickcancelOrder = async (i, key) => {
if (i == 'all') {
await APIcancelOrder({
shopId: uni.cache.get('shopId'),
orderId: orderinfo.id,
})
} else {
await APIrmPlaceOrder({
shopId: uni.cache.get('shopId'),
orderId: orderinfo.id,
placeNum: key
})
}
Historicalorders()
}
//
const orderinfo = ref({})
const confirmorderref = ref(null)
//
const orderdetail = async () => {
try {
let res = await APIhistoryOrder({
tableCode: uni.cache.get('tableCode'),
})
orderinfo.value = {
id: res.id,
detailMap: res.detailMap,
placeNum: res.placeNum
}
await Historicalorders()
} catch (error) {}
confirmordershow.value = true
}
//
const Historicalorders = async (W) => {
let res = await APIhistoryOrder({
tableCode: uni.cache.get('tableCode'),
})
orderinfo.value = {
id: res.id,
detailMap: res.detailMap,
placeNum: res.placeNum
}
if (W) {
showCart.value = !showCart.value
}
}
// ifcartNumber
const ifcartNumber = computed(() => {
return (item) => {
@ -1320,38 +1347,6 @@
}));
})
// //
// const getCurrentDateTime = () => {
// const now = new Date();
// const dayOfWeek = ['', '', '', '', '', '', ''][now.getDay()];
// const hours = now.getHours().toString().padStart(2, '0');
// const minutes = now.getMinutes().toString().padStart(2, '0');
// const currentTime = `${hours}:${minutes}`;
// return {
// dayOfWeek,
// currentTime
// };
// };
// //
// const isBusinessTime = computed(() => {
// const {
// dayOfWeek,
// currentTime
// } = getCurrentDateTime();
// console.log(shopInfo)
// const [startDay, endDay] = [shopInfo.businessStartDay, shopInfo.businessEndDay];
// const [startTime, endTime] = shopInfo.businessTime.split('-');
// const dayIndex = ['', '', '', '', '', '', ''].indexOf(dayOfWeek);
// const startDayIndex = ['', '', '', '', '', '', ''].indexOf(startDay);
// const endDayIndex = ['', '', '', '', '', '', ''].indexOf(endDay);
// console.log(shopInfo.businessTime, 1111)
// const isInDayRange = dayIndex >= startDayIndex && dayIndex <= endDayIndex;
// const isInTimeRange = currentTime >= startTime && currentTime <= endTime;
// console.log(isInDayRange, isInTimeRange, 1111)
// return isInDayRange && isInTimeRange;
// });
const endTimeref = reactive({
startTime: '',
endTime: ''

View File

@ -65,9 +65,10 @@ export const useCartStore = defineStore('cart', () => {
}, 0);
cart = cart.toFixed(2)
console.log(parseFloat(cart))
// 向上取整并保留两位小数
// let result = roundUpToTwoDecimals(cart, 'upward')
return cart;
return parseFloat(cart);
});
// 计算商品卷所选择的总价格