代码更新

This commit is contained in:
GaoHao
2025-03-10 09:14:57 +08:00
parent 4f65b08c06
commit 490c513f48
48 changed files with 1162 additions and 537 deletions

View File

@@ -4,13 +4,13 @@
<text class="">桌号</text>
<text class="">{{orderInfo.tableName||""}}</text>
</view>
<view class=" font-bold u-p-b-32 border-bottom u-m-b-24" v-if="orderInfo.tableName&&orderInfo.status=='unpaid'">
<!-- <view class=" font-bold u-p-b-32 border-bottom u-m-b-24" v-if="orderInfo.tableName&&orderInfo.status=='unpaid'">
<view class="block" @tap="rotatingTables"
style="display: flex;align-items: center;justify-content: space-between;">
<view>转桌/并桌</view>
<uni-icons type="right" color="#999" size="16"></uni-icons>
</view>
</view>
</view> -->
<view class=" color-999 border-bottom u-p-b-24">
<text></text>
<text class="color-333 "> {{goodsNumber}}</text>
@@ -55,7 +55,7 @@
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnAmount">
<view class="color-666">退款金额:</view>
<view class="color-999 u-m-l-6">{{item.returnAmount}}</view>
<view class="color-999 u-m-l-6">{{item.returnAmount*item.returnNum}}</view>
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnNum">
<view class="color-666">退菜数量:</view>
@@ -70,7 +70,6 @@
</view>
</view>
<view class="u-text-right u-m-t-28">
{{isTui(item)}}
<template v-if="isTui(item)">
<view>0.00</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}</view>
@@ -79,6 +78,10 @@
<view>0.00</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}</view>
</template>
<template v-else-if="user.isVip == 1">
<view>{{item.num*item.memberPrice}}</view>
<view class="line-th color-666 ">{{item.num*item.price}}</view>
</template>
<template v-else>
<template v-if="returnCanTuiMoney(item)*1!=returnTotalMoney(item)*1">
<view>{{returnTotalMoney(item)}}</view>
@@ -96,7 +99,7 @@
</view>
</view>
<template v-if="canTuicai(orderInfo,item)">
<view class="u-flex u-row-right gap-20 u-m-t-24">
<view class="u-flex u-row-right gap-20 u-m-t-24" v-if="item.returnNum*item.returnAmount<item.payAmount">
<!-- <my-button :height="60" color="#333" plain type="cancel" shape="circle">更多操作</my-button> -->
<my-button :width="128" :height="48" plain shape="circle" @tap="tuicai(item,index)"><text
class="no-wrap">退菜</text></my-button>
@@ -134,10 +137,10 @@
已优惠{{youhuiAllPrice}}
</view>
</view>
<view>
<!-- <view>
<text>小计</text>
<text class="font-bold u-font-32">{{allPrice}}</text>
</view>
</view> -->
</view>
</view>
@@ -162,18 +165,25 @@
</view>
</view>
</template>
<template v-if="canTuiKuan(orderInfo)">
<view class="u-flex u-row-right gap-20 u-m-t-20">
<my-button :width="168" :height="48" plain shape="circle" @tap="tuikuan(data,index)"><text
class="no-wrap">全部退款</text> </my-button>
</view>
</template>
<view class="u-flex u-row-between u-m-t-20">
<view></view>
<template v-if="orderInfo.status=='unpaid'">
<view>
<text>总计</text>
<text class="font-bold u-font-32">{{orderInfo.orderAmount }}</text>
<text class="font-bold u-font-32">{{orderInfo.orderAmount.toFixed(2)}}</text>
</view>
</template>
<template v-else>
<view>
<text>总计</text>
<text class="font-bold u-font-32">{{orderInfo.payAmount}}</text>
<text class="font-bold u-font-32">{{orderInfo.payAmount.toFixed(2)}}</text>
</view>
</template>
@@ -358,7 +368,20 @@
function returnTotalMoney(item) {
return (item.payAmount).toFixed(2)
}
function returnCanTuiMoney(item) {
// if (props.orderInfo.status == 'unpaid') {
// return returnTotalMoney(item)
// } else {
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
return item.canReturnAmount
} else if (item.price != item.unitPrice) {
return item.price*item.num
} else {
return item.payAmount
}
// }
}
const canTuiKuanPrice = computed(() => {
const goodsTotal = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => !isTui(v) && !v.userCouponId)
@@ -396,19 +419,7 @@
return seatFee
})
function returnCanTuiMoney(item) {
if (props.orderInfo.status == 'unpaid') {
return returnTotalMoney(item)
} else {
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
return item.canReturnAmount
} else if (item.price != item.unitPrice) {
return item.price*item.num
} else {
return item.payAmount
}
}
}
function to2(n) {
if (!n) {
@@ -424,10 +435,27 @@
function tuikuan(item, index) {
hasPermission('允许退款').then(res => {
if (res) {
emits('tuikuan', {
...item,
payAmount: item.payAmount
}, index)
if (Array.isArray(item)) {
let arr = [];
console.log(item)
item.map(v=>{
v.info.map(obj=>{
obj.number = 0
obj.skuName = obj.skuName || ''
obj.priceAmount = obj.priceAmount ? obj.priceAmount : (obj.num*obj.unitPrice).toFixed(2)
obj.unitPrice = obj.unitPrice
})
arr = [...arr,...v.info]
})
emits('tuikuan', arr)
} else {
emits('tuikuan', {
...item,
payAmount: item.payAmount
}, index)
}
}
})
}
@@ -448,7 +476,6 @@
if (props.orderInfo.discountAmount) {
return props.orderInfo.discountAmount
}
console.log(props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio));
return (props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio))
})
const goodsOriginAllPrice = computed(() => {
@@ -513,7 +540,7 @@
* 已优惠金额
*/
const youhuiAllPrice = computed(() => {
const n = props.orderInfo.orderAmount - props.orderInfo.payAmount + vipDiscountPrice.value * 1
const n = props.orderInfo.originAmount - props.orderInfo.orderAmount + vipDiscountPrice.value * 1
return (n < 0 ? 0 : n).toFixed(2)
})
@@ -531,7 +558,6 @@
})
const allPrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.reduce((a,
b) => {

View File

@@ -29,11 +29,11 @@
</template>
<view class="u-flex u-m-t-24 u-row-between u-font-28">
<view class="">
<view class="font-bold ">{{user.amount}}</view>
<view class="font-bold ">{{user.amount||0}}</view>
<view class="color-666 u-m-t-8 u-font-24">余额</view>
</view>
<view class="">
<view class="font-bold">{{user.accountPoints}}</view>
<view class="font-bold">{{user.accountPoints||0}}</view>
<view class="color-666 u-m-t-8 u-font-24">积分</view>
</view>
<view class="">

View File

@@ -15,7 +15,7 @@
<view style="height: 200rpx;"></view>
<view class="u-fixed bottom bg-fff ">
<view class="u-flex u-abso">
<template v-if="orderDetail.info.useType=='take-out'||!orderDetail.info.tableCode||orderDetail.info.useType=='dine-in-before'">
<template v-if="orderDetail.info.dineMode=='take-out'||!orderDetail.info.tableCode||pageData.shopInfo.registerType=='before'">
<view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'">
<my-button @tap="toPay" borderRadius="100rpx" shape="circle"
type="primary">结账</my-button>
@@ -41,6 +41,8 @@
</template>
<script setup>
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import * as Api from '@/http/yskApi/Instead.js'
import userVue from './components/user.vue';
import orderVue from './components/order.vue';
@@ -48,19 +50,16 @@
import stepVue from './components/step.vue';
import extraVue from './components/extra.vue';
import tuicaiVue from './components/tuicai.vue';
import go from '@/commons/utils/go.js'
import infoBox from '@/commons/utils/infoBox.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import { onLoad, onShow } from '@dcloudio/uni-app';
import {
reactive,
ref
} from 'vue';
import OrderDetail from './page.js'
import { getHistoryOrder, refundOrder,getOrderById } from '@/api/order.js'
import { getHistoryOrder, refundOrder,getOrderById,printOrder } from '@/api/order.js'
import { shopStaffDetail } from '@/api/staff.js'
import { shopUserDetail } from '@/api/shopUser.js'
import { getShopInfo } from '@/api/shop.js'
const tuicai = reactive({
show: false,
@@ -82,9 +81,13 @@
amount:'0.00',
accountPoints:'0.00'
})
const pageData = reactive({
shopInfo: {},
})
onLoad((opt) => {
Object.assign(options, opt)
console.log(options);
console.log("opt===",options);
getShopInfoData()
})
onShow(() => {
watchEmit()
@@ -92,7 +95,14 @@
getOrderDetail()
})
/**
* 获取店铺信息
*/
function getShopInfoData () {
getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{
pageData.shopInfo = res;
})
}
/**
* 获取订单详情
@@ -101,7 +111,7 @@
let res = await getHistoryOrder({orderId: options.id})
console.log(res)
if(res.userId){
shopUserDetail({id:res.userId}).then(res=>{
shopUserDetail({userId:res.userId}).then(res=>{
if(res){
user.value = res
}
@@ -115,7 +125,7 @@
info: value,
placeNum: key
}))
console.log(orderDetail.goodsList);
console.log("goodsList===",orderDetail.goodsList);
orderDetail.info = res
}
@@ -156,7 +166,7 @@
productName,
num,
number: 0,
productSkuName: '',
skuName: '',
priceAmount,
price
})
@@ -177,28 +187,24 @@
getOrderDetail()
}
}
async function printDishes() {
try {
const res = await Api.$printDishes({
tableId: orderDetail.info.tableId
})
infoBox.showToast('已发送打印请求')
} catch (e) {
infoBox.showToast('发送打印请求失败')
//TODO handle the exception
}
}
/**
* 打印订单
*/
function onPrintOrder() {
uni.showModal({
title: '提示',
content: '是否打印当前台桌菜品',
success(res) {
async success(res) {
if (res.confirm) {
printDishes()
try {
const res = await printOrder({
id: orderDetail.info.id
})
infoBox.showToast('已发送打印请求')
} catch (e) {
infoBox.showToast('发送打印请求失败')
}
}
}
})
@@ -211,32 +217,22 @@
return
}
console.log(goods,'debug');
const {
id,
productId,
productSkuId,
productName,
productSkuName,
cartId,
orderId,
num,
priceAmount,
price,userCouponId
} = goods
go.to('PAGES_ORDER_TUIKUAN', {
id,
cartId,
orderId,
productId,
productSkuId,
productName,
num,
number: 0,
productSkuName: productSkuName || '',
priceAmount:priceAmount?priceAmount:(num*price).toFixed(2),
price,
userCouponId:userCouponId?userCouponId:''
})
if (Array.isArray(goods)) {
go.to('PAGES_ORDER_TUIKUAN', {
goodsList:JSON.stringify(goods)
})
} else {
goods.number = 0
goods.skuName = goods.skuName || ''
goods.priceAmount = goods.priceAmount ? goods.priceAmount : (goods.num*goods.unitPrice).toFixed(2)
goods.unitPrice = goods.unitPrice
goods.userCouponId = goods.userCouponId ? goods.userCouponId:''
go.to('PAGES_ORDER_TUIKUAN', {
goodsList:JSON.stringify([goods])
})
}
}
@@ -256,10 +252,10 @@
clearEmit()
go.to('PAGES_CREATE_ORDER', {
tableId: options.tableId || orderDetail.info.tableId,
tableCode: options.tableCode || orderDetail.info.tableCode,
name: options.name || orderDetail.info.tableName,
masterId:orderDetail.info.masterId,
type: 'add',
vipUserId:orderDetail.userId?orderDetail.userId:''
vipUserId: orderDetail.info.userId?orderDetail.info.userId:''
})
}
@@ -272,8 +268,8 @@
clearEmit()
go.to('PAGES_ORDER_PAY', {
tableId: options.tableId|| orderDetail.info.tableId,
tableName: options.name,
masterId: options.masterId,
tableCode: options.tableCode || orderDetail.info.tableCode,
tableName: options.name || orderDetail.info.tableName,
orderId: orderDetail.info.id,
discount: 1,
userId