代码更新

This commit is contained in:
GaoHao
2025-03-04 18:30:16 +08:00
parent fd0c452a76
commit 4f65b08c06
32 changed files with 622 additions and 1616 deletions

View File

@@ -38,7 +38,7 @@
</view>
</view>
<view class="u-flex u-m-t-8">
<view class="u-m-r-20 u-flex " v-if="item.payAmount<=0">
<view class="u-m-r-20 u-flex" v-if="item.isGift">
<uni-tag text="赠送"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
@@ -57,8 +57,12 @@
<view class="color-666">退款金额:</view>
<view class="color-999 u-m-l-6">{{item.returnAmount}}</view>
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnNum">
<view class="color-666">退菜数量:</view>
<view class="color-999 u-m-l-6">{{item.returnNum}}</view>
</view>
</view>
<view class="color-999 u-font-24 u-m-t-8">{{item.productSkuName||''}}</view>
<view class="color-999 u-font-24 u-m-t-8">{{item.skuName||''}}</view>
<view class="u-m-t-12 color-666 u-font-24" v-if="item.remark">
@@ -66,21 +70,20 @@
</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>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}</view>
</template>
<template v-else-if="isGift(item)||item.userCouponId">
<template v-else-if="item.userCouponId">
<view>0.00</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}
</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}</view>
</template>
<template v-else>
<template v-if="returnCanTuiMoney(item)*1!=returnTotalMoney(item)*1">
<view>{{returnCanTuiMoney(item)}}</view>
<view>{{returnTotalMoney(item)}}</view>
<view class=" color-666 line-th">
{{returnTotalMoney(item)}}</view>
{{returnCanTuiMoney(item)}}</view>
</template>
<template v-else>
<view>{{returnTotalMoney(item)}}</view>
@@ -353,7 +356,7 @@
}
function returnTotalMoney(item) {
return (item.payAmount * item.num).toFixed(2)
return (item.payAmount).toFixed(2)
}
const canTuiKuanPrice = computed(() => {
@@ -394,12 +397,13 @@
})
function returnCanTuiMoney(item) {
return props.orderInfo.status == 'unpaid' ? item.payAmount : item.payAmount
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
}
@@ -476,8 +480,8 @@
return 0
}
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" && (v.isMember &&
v.memberPrice) && (v.memberPrice != v.price)).reduce((
const curTotal = cur.info.filter(v => v.discountSaleAmount <= 0 && v.isGift != 1 && v.status !== "return" && (v.price !=
v.unitPrice) && (v.memberPrice != v.price)).reduce((
a,
b) => {
return a + (b.num * (b.price - b.memberPrice))
@@ -504,20 +508,15 @@
}, 0)
return goodsPrice.toFixed(2)
})
/**
* 已优惠金额
*/
const youhuiAllPrice = computed(() => {
const n = props.orderInfo.originAmount - props.orderInfo.amount + vipDiscountPrice.value * 1
const n = props.orderInfo.orderAmount - props.orderInfo.payAmount + vipDiscountPrice.value * 1
return (n < 0 ? 0 : n).toFixed(2)
// if(props.orderInfo.status!='unpaid'){
// const seatfee=(props.orderInfo.amount==0&&allPrice.value==0)?seatFeePrice.value:0
// return (goodsOriginAllPrice.value-allPrice.value+seatfee*1).toFixed(2)
// }
// return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
// .orderInfo.pointsDiscountAmount + (props.orderInfo.status == 'unpaid' ? productCoupPrice.value :
// productCouponDiscountAmount.value) * 1 + (props.orderInfo.discountAmount ||
// 0)).toFixed(2)
})
const packFee = computed(() => {
//不是退菜只要有打包费的都计算,包括赠送
const goodsPrice = props.data.reduce((prve, cur) => {

View File

@@ -18,7 +18,7 @@
</view>
<view class="u-flex u-row-between u-m-t-24">
<view>支付方式</view>
<view>{{data.payType||''}}</view>
<view>{{returnPayType(data.payType)||''}}</view>
</view>
<view class="u-flex u-row-between u-m-t-24">
<view>下单时间</view>
@@ -45,6 +45,7 @@
</template>
<script setup>
import { ref } from 'vue';
import orderEnum from '@/commons/orderEnum.js'
const props = defineProps({
data: {
@@ -62,7 +63,24 @@
}
}
})
const payTypeList = [
{name: '主扫', type:'main_scan'},
{name: '被扫', type:'back_scan'},
{name: '微信小程序', type:'wechat_mini'},
{name: '支付宝小程序', type:'alipay_mini'},
{name: '会员支付', type:'vip_pay'},
{name: '现金支付', type:'cash_pay'},
]
const payTypeName = ref(null)
/**
* 获取支付方式
*/
function returnPayType(payType) {
let item = payTypeList.find( v=> v.type == payType )
return item ? item.name : ''
}
function returnStatus(status) {
const item = orderEnum.status.find(v => v.key == status)
return item ? item.label : ''

View File

@@ -60,12 +60,9 @@
</template>
<script setup>
import {
reactive,
ref,
watch
} from 'vue';
import { reactive, ref, watch } from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
const emits = defineEmits(['update:show', 'confirm'])
const props = defineProps({
data: {
type: Object,
@@ -83,7 +80,6 @@
const form = reactive({
note: ''
})
const emits = defineEmits(['update:show', 'confirm'])
let model = ref(null)
let modelShow = ref(props.show)
let number = ref(0)
@@ -101,7 +97,18 @@
checked: false
}])
let timer = null
watch(() => props.show, (newval) => {
modelShow.value = newval
})
watch(() => modelShow.value, (newval) => {
emits('update:show', newval)
if (newval) {
open()
} else {
close()
}
})
function parseIntNumber(val, isNow) {
let newval = val * 1
if (newval > props.data.num) {
@@ -125,18 +132,7 @@
function changeTagSel(item) {
item.checked = !item.checked
}
watch(() => props.show, (newval) => {
modelShow.value = newval
})
watch(() => modelShow.value, (newval) => {
emits('update:show', newval)
if (newval) {
open()
} else {
close()
}
})
function toggleModelShow(show) {
modelShow.value = show ? true : false
}
@@ -165,7 +161,10 @@
})
form.note = ''
}
/**
* 确认退菜
*/
function confirm() {
const selTag = tags.value.filter(item => item.checked).map(item => item.label).join(",")
const note = selTag + (form.note.length > 0 ? "," + form.note : "");
@@ -176,10 +175,17 @@
if (!note) {
return infoBox.showToast("请输入退菜原因");
}
emits('confirm', {
note,
num: number.value
})
let par = {
orderId: props.data.orderId,
refundAmount: number.value*props.data.unitPrice,
refundReason: note,
refundDetails: [{
id: props.data.id,
returnAmount: number.value*props.data.unitPrice,
num: number.value,
}],
}
emits('confirm', par)
}
</script>

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=='takeout'||!orderDetail.info.tableId||orderDetail.info.useType=='dine-in-before'">
<template v-if="orderDetail.info.useType=='take-out'||!orderDetail.info.tableCode||orderDetail.info.useType=='dine-in-before'">
<view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'">
<my-button @tap="toPay" borderRadius="100rpx" shape="circle"
type="primary">结账</my-button>
@@ -42,11 +42,6 @@
<script setup>
import * as Api from '@/http/yskApi/Instead.js'
import * as orderApi from '@/http/yskApi/order.js'
import {queryAllShopUser} from '@/http/yskApi/shop-user.js'
import {
objToArrary
} from '@/commons/utils/returrn-data.js'
import userVue from './components/user.vue';
import orderVue from './components/order.vue';
import goodsList from './components/list.vue';
@@ -62,7 +57,7 @@
ref
} from 'vue';
import OrderDetail from './page.js'
import { getHistoryOrder } from '@/api/order.js'
import { getHistoryOrder, refundOrder,getOrderById } from '@/api/order.js'
import { shopStaffDetail } from '@/api/staff.js'
import { shopUserDetail } from '@/api/shopUser.js'
@@ -172,17 +167,14 @@
tuicai.selGoods = goods
}
async function tuicaiConfirm(e) {
const res = await Api.$returnCart({
...e,
cartId: tuicai.selGoods.hasOwnProperty('cartId') ? tuicai.selGoods.cartId : tuicai.selGoods.id,
tableId: orderDetail.info.tableId,
})
console.log(e)
const res = await refundOrder(e)
tuicai.show = false
console.log(res)
if(res){
go.back()
}else{
init()
getOrderDetail()
}
}
@@ -293,7 +285,7 @@
uni.$off('orderDetail:update')
uni.$once('orderDetail:update', (newval) => {
console.log(newval);
init()
getOrderDetail()
})
}
@@ -309,7 +301,7 @@
}
Object.assign(submitPar, par)
const res=await Api.$setUser(submitPar)
init()
getOrderDetail()
return res
}

View File

@@ -17,7 +17,7 @@
<view class="line"></view>
<view class=" color-main">
<text>
{{sendTypeFilter(data.sendType)}}
{{sendTypeFilter(data.dineMode)}}
</text>
</view>
</view>
@@ -35,30 +35,23 @@
<view>
<view class=""> {{item.productName}}</view>
<view class="color-999 u-font-24 u-m-t-8">
{{item.productSkuName}}
{{item.skuName}}
</view>
</view>
<view class="u-flex u-flex-1 u-row-right">
<view>×{{item.num}}</view>
<template v-if="item.gift||item.userCouponId">
<template v-if="item.userCouponId">
<view class="u-text-right u-relative" :style="computedPriceStyle()">
<text class="line-th">{{goodsPriceAmount(item)}}</text>
<text class="line-th">{{item.payAmount}}</text>
<view class="u-absolute" style="bottom: 100%;right: 0;">
0
</view>
</view>
</template>
<template v-else-if="item.isMember&&data.userId&&item.memberPrice&&item.memberPrice!=item.price">
<view class="u-text-right u-relative" :style="computedPriceStyle()">
<text class="line-th">{{goodsPriceAmount(item)}}</text>
<view class="u-absolute" style="bottom: 100%;right: 0;">
{{goodsVipPriceAmount(item)}}
</view>
</view>
</template>
<template v-else>
<view class="u-text-right u-relative" :style="computedPriceStyle()">
<text>{{goodsPriceAmount(item)}}</text>
<text>{{item.payAmount}}</text>
</view>
</template>
</view>
@@ -119,17 +112,7 @@
import dayjs from 'dayjs';
import orderEnum from '@/commons/orderEnum.js'
import go from '@/commons/utils/go.js'
import {
isTui,
canTuiKuan,
canTuicai
} from '@/commons/utils/goodsUtil.js'
import {
computed,
reactive,
ref,
watch
} from 'vue';
import { computed, reactive, ref, watch } from 'vue';
const emits = defineEmits(['printOrder'])
const props = defineProps({
data: {
@@ -156,31 +139,24 @@
const priceSize = 9
let minWidth=ref(36)
/**
* 计算菜品价格
* @param {Object} item
*/
function goodsPriceAmount(item) {
const total=(item.price * item.num).toFixed(2)
const total=(item.payAmount * item.num).toFixed(2)
const minW=total.length * priceSize + 15
minWidth.value=minW<minWidth.value?minWidth.value:minW
return total
}
function goodsVipPriceAmount(item) {
const price = item.memberPrice ? item.memberPrice : item.price
return (price * item.num).toFixed(2)
}
// const packeFee=computed(()=>{
// return props.data.goods.reduce((prve,cur)=>{
// return prve+cur.packAmount
// },0).toFixed(2)
// })
function computedPriceStyle() {
return {
'min-width':minWidth.value + 'px'
}
}
// const computedPriceStyle = computed(() => {
// })
function goodsMapInit() {
for (let i in props.data.goods) {
const goods = props.data.goods[i]
@@ -211,9 +187,8 @@
}
function sendTypeFilter(t) {
console.log(t);
if (t) {
const item = orderEnum.sendType.find(item => item.key == t)
const item = orderEnum.dineMode.find(item => item.key == t)
return item ? item.label : '';
} else {
return t;

View File

@@ -99,15 +99,15 @@
<text class="u-m-l-10 no-wrap">{{item.payName}}</text>
</view>
<view class="u-flex color-999 u-font-24">
<view class="u-m-r-20" v-if="item.payType=='virtual'&&user.id"
<view class="u-m-r-20" v-if="item.payType=='virtual'&&pageData.user.id"
@click.stop="chooseUser">
<view>
<text>会员</text>
<text class="u-m-r-4">{{user.telephone||user.nickName}}</text>
<text class="u-m-r-4">{{pageData.user.phone||pageData.user.nickName}}</text>
</view>
<view>
<text>余额</text>
<text>{{user.amount||'0'}}</text>
<text>{{pageData.user.amount||'0'}}</text>
</view>
<!-- <view>
<text>积分</text>
@@ -125,12 +125,12 @@
</view>
</view>
<view class="border-bottom-dashed "></view>
<view class="u-flex u-row-between u-p-t-24" v-if="user.id" @click="changeAccountPoints">
<view class="u-flex u-row-between u-p-t-24" v-if="pageData.user.id" @click="changeAccountPoints">
<view class="u-flex ">
<view class="">积分抵扣</view>
<view class="color-999 u-m-l-10">
<text>(</text>
<text>{{user.accountPoints||'0'}}</text>
<text>{{pageData.user.accountPoints||'0'}}</text>
<text>)</text>
</view>
<!-- <view><text class="color-red font-bold">{{accountPoints.price}}</text></view> -->
@@ -260,7 +260,13 @@
let option = {
isNowPay: false
}
const pageData = reactive({
goodsList: [], //菜品列表
user: { //会员信息
userId: null,
amount: 0
}
})
const order = reactive({
orderAmount: 0
})
@@ -294,10 +300,7 @@
price: 0
})
let timer = null
let user = ref({
amount: 0
});
const refPoints = ref(null)
let payCodeUrl = ref('') //收款二维码地址
onShow(() => {
@@ -319,6 +322,43 @@
uni.$emit('orderDetail:update')
console.log('onBackPress');
})
/**
* 初始化
*/
async function init() {
// 获取订单详情
const orderRes = await getHistoryOrder({orderId:order.orderId})
Object.assign(order, orderRes)
$goodsPayPriceMap = returnGoodsPayPriceMap(order.detailMap)
pageData.goodsList = [];
Object.values(orderRes.detailMap).forEach(item=>{
pageData.goodsList = [...pageData.goodsList,...item]
})
const hasSelQuan = orderRes.couponInfoList ? JSON.parse(orderRes.couponInfoList) : {
fullReductionCoupon: [],
productCoupon: []
};
const fullReductionCoupon = hasSelQuan.fullReductionCoupon.filter(v => v.type == 1)
const productCoupon = hasSelQuan.productCoupon.filter(v => v.type == 2)
setQuan([...fullReductionCoupon, ...productCoupon])
// 获取用户信息
console.log(order.userId)
console.log(!pageData.user.userId)
if (order.userId&&!pageData.user.userId) {
calcUsablePoints()
if (orderRes.pointsNum) {
accountPoints.sel = true
}
shopUserDetail({
userId: order.userId || pageData.user.userId
}).then(res => {
pageData.user = res
})
}
}
const coupAllPrice = computed(() => {
const n = pays.quan.reduce((prve, cur) => {
return prve + cur.discountAmount * 1
@@ -326,43 +366,60 @@
return n
})
/**
* 支付金额
*/
const payPrice = computed(() => {
const total = (originPrice.value) - vipDiscount.value - productCouponDiscountAmount.value - discount
.value -
fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
return (total < 0 ? 0 : total).toFixed(2)
})
/**
* 菜品打包费
*/
const packAmount = computed(() => {
if(pageData.goodsList){
let price = pageData.goodsList.filter(v => v.packNumber > 0 && v.status !== "return").reduce((a, b) => {
return a + (b.packNumber * b.packAmount)
}, 0)
return price
}
})
/**
* 订单金额
*/
const originPrice = computed(() => {
console.log(order)
const n = (order.orderAmount || 0) * 1 + vipDiscount.value * 1 + (order.fullCouponDiscountAmount || 0) + (order
.productCouponDiscountAmount || 0) +
(order.pointsDiscountAmount || 0)
console.log(n)
return n.toFixed(2)
console.log(packAmount)
if(pageData.goodsList){
let goodsPrice = pageData.goodsList.filter(v => v.price != 0 && v.status !== "return").reduce((a, b) => {
return a + (b.num * b.price)
}, 0)
return (goodsPrice + order.seatNum + packAmount.value).toFixed(2)
}
})
/**
* 会员优惠金额
*/
const vipDiscount = computed(() => {
if (!user.value.isVip) {
if (!pageData.user.isVip) {
return 0
}
let goods_list = []
Object.values(order.detailMap).forEach(item=>{
goods_list = [...goods_list,...item]
})
const goodsPrice = goods_list.filter(v => v.price != 0 && v.status !== "return" && v.memberPrice && (v.memberPrice != v.price)).reduce((
a,
b) => {
return a + (b.num * (b.price - b.memberPrice))
}, 0)
console.log(goodsPrice)
return goodsPrice.toFixed(2)
if(pageData.goodsList){
let price = pageData.goodsList.filter(v => v.price != 0 && v.discountSaleAmount <= 0 && v.status !== "return" && v.memberPrice && (v.memberPrice != v.price)).reduce((a, b) => {
return a + (b.num * (b.price - b.memberPrice))
}, 0)
return price.toFixed(2)
}
})
/**
* 菜品折扣金额
*/
const discountSaleAmount = computed(() => {
if(pageData.goodsList){
let price = pageData.goodsList.filter(v => v.discountSaleAmount > 0 && v.status !== "return").reduce((a, b) => {
return a + (b.num * b.discountSaleAmount)
}, 0)
return price
}
})
/**
* 优惠券金额
*/
@@ -372,6 +429,7 @@
return prve + cur.discountAmount * 1
}, 0)
})
/**
* 商品券金额
*/
@@ -385,11 +443,30 @@
* 积分计算
*/
const pointCanDicountPrice = computed(() => {
const total = (order.orderAmount || 0) - productCouponDiscountAmount.value - discount.value -
let total = (originPrice.value || 0) - productCouponDiscountAmount.value - discount.value -
fullCouponDiscountAmount.value
return (total < 0 ? 0 : total).toFixed(2)
})
/**
* 支付金额
*/
const payPrice = computed(() => {
console.log("originPrice===",originPrice.value)
console.log("vipDiscount===",vipDiscount.value)
console.log("discountSaleAmount===",discountSaleAmount.value)
console.log("pointCanDicountPrice===",pointCanDicountPrice.value)
console.log("productCouponDiscountAmount===",productCouponDiscountAmount.value)
console.log("discount===",discount.value)
console.log("fullCouponDiscountAmount===",fullCouponDiscountAmount.value)
console.log("accountPoints===",accountPoints)
let total = (originPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
.value - fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
console.log(total)
return (total < 0 ? 0 : total).toFixed(2)
})
watch(() => accountPoints.sel, (newval) => {
if (newval) {
calcDeDuctionPoints()
@@ -442,58 +519,26 @@
* 获取店铺订单支付URL
*/
function getPayUrl() {
getOrderPayUrl({
console.log(vipDiscount.value)
let par = {
shopId: uni.getStorageSync("shopInfo").id,
orderId: order.id,
orderAmount: payPrice.value,
userId: order.userId||user.value.userId,
seatNum: order.seatNum, // 用餐人数
discountRatio: (discount.discount/100).toFixed(0), // 折扣比例
discountAmount: discount.value, // 手动优惠金额
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
orderAmount: originPrice.value, // 订单金额
pointsNum: accountPoints.sel ? accountPoints.num : 0,
// couponList: pays.quan.map(v => {
// return {
// userCouponId: v.id,
// num: v.number
// }
// }),
}).then(res => {
vipPrice: vipDiscount.value > 0 ? 1: 0, // 是否使用会员价
}
if( order.userId||pageData.user.userId ){
par.userId = order.userId||pageData.user.userId
}
getOrderPayUrl(par).then(res => {
payCodeUrl.value = res
})
}
/**
* 初始化
*/
async function init() {
// 获取订单详情
const orderRes = await getHistoryOrder({orderId:order.orderId})
Object.assign(order, orderRes)
$goodsPayPriceMap = returnGoodsPayPriceMap(order.detailMap)
const hasSelQuan = orderRes.couponInfoList ? JSON.parse(orderRes.couponInfoList) : {
fullReductionCoupon: [],
productCoupon: []
};
const fullReductionCoupon = hasSelQuan.fullReductionCoupon.filter(v => v.type == 1)
const productCoupon = hasSelQuan.productCoupon.filter(v => v.type == 2)
setQuan([...fullReductionCoupon, ...productCoupon])
// 获取用户信息
if (order.userId||user.value.userId) {
calcUsablePoints()
if (orderRes.pointsNum) {
accountPoints.sel = true
}
shopUserDetail({
userId: order.userId || user.value.userId
}).then(res => {
user.value = res
})
}
}
/**
* 获取支付方式
@@ -581,12 +626,11 @@
accountPoints.num = e
}
async function calcUsablePoints(orderAmount) {
if (!order.userId&&!user.value.userId) {
if (!order.userId&&!pageData.user.userId) {
return
}
console.log(orderAmount);
const res = await Api.$calcUsablePoints({
userId: order.userId||user.value.userId,
userId: order.userId||pageData.user.userId,
orderAmount: orderAmount ? orderAmount : payPrice.value
})
accountPoints.calcRes = res
@@ -600,7 +644,7 @@
return ''
}
const res = await Api.$calcDeDuctionPoints({
userId: order.userId||user.value.userId,
userId: order.userId||pageData.user.userId,
orderAmount: originPrice.value,
points: accountPoints.num
})
@@ -626,14 +670,14 @@
*/
function toQuan() {
console.log(order);
if (!order.userId&&!user.value.id) {
if (!order.userId&&!pageData.user.id) {
return infoBox.showToast('请先选择会员', 0.5).then(() => {
chooseUser()
})
}
go.to('PAGES_ORDER_QUAN', {
orderId: order.id,
userId: order.userId||user.value.userId,
shopUserId: pageData.user.id,
orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2)
})
}
@@ -683,7 +727,7 @@
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
user.value = data
pageData.user = data
pays.quan = []
init()
})
@@ -723,8 +767,8 @@
}
pays.payTypes.selIndex = i
console.log(item.payType)
console.log(user.value.id)
if (item.payType == 'virtual' && !user.value.id) {
console.log(pageData.user.id)
if (item.payType == 'virtual' && !pageData.user.id) {
chooseUser()
}
}
@@ -761,7 +805,7 @@
if (payType == 'cash' && payPrice.value * 1 > 0) {
return cashConfirmShow()
}
if (payType == 'virtual' && user.value.amount * 1 < order.orderAmount * 1) {
if (payType == 'virtual' && pageData.user.amount * 1 < order.orderAmount * 1) {
infoBox.showToast('余额不足')
return
}
@@ -789,12 +833,12 @@
shopId: uni.getStorageSync("shopInfo").id,
checkOrderPay: {
orderId: order.id || order.orderId,
userId: order.userId||user.value.userId,
seatNum: order.seatNum, // 用餐人数
discountRatio: (discount.discount/100).toFixed(0), // 折扣比例
discountAmount: discount.value, // 手动优惠金额
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
orderAmount: originPrice.value, // 订单金额
orderAmount: payPrice.value, // 订单金额
vipPrice: vipDiscount.value > 0 ? 1: 0, // 是否使用会员价
pointsNum: accountPoints.sel ? accountPoints.num : 0,
couponList: pays.quan.map(v => {
return {
@@ -806,16 +850,29 @@
},
}
if( order.userId||pageData.user.userId ){
params.checkOrderPay.userId = order.userId||pageData.user.userId
}
console.log(params)
if (payType == 'scanCode' || payType == 'deposit' || payType == 'bank') {
}
if (payType == 'cash' && payPrice.value * 1 > 0) {
await cashPay(params)
try {
await cashPay(params)
} catch (error) {
payStatus = '';
return false;
}
}
if (payType == 'virtual' && user.value.amount * 1 > order.orderAmount * 1) {
if (payType == 'virtual' && pageData.user.amount * 1 > order.orderAmount * 1) {
params.payType = 'userPay'
params.shopUserId = user.value.id
await vipPay(params)
params.shopUserId = pageData.user.id
try {
await vipPay(params)
} catch (error) {
payStatus = '';
return false;
}
}
paySuccess()

View File

@@ -146,7 +146,7 @@
} from '../quan_util.js'
import { getHistoryOrder } from '@/api/order.js'
import { shopUserDetail } from '@/api/shopUser.js'
import { getCouponList } from '@/api/coupon.js'
import { getFindCoupon } from '@/api/coupon.js'
const modal = reactive({
@@ -161,7 +161,7 @@
const option = reactive({
orderId: '',
userId: '',
shopUserId: '',
orderPrice: 0
})
const pageData = reactive({
@@ -218,13 +218,16 @@
* 获取优惠券
*/
async function getQuan() {
shopUserDetail({ id: option.userId }).then(res=>{
shopUserDetail({ id: option.shopUserId }).then(res=>{
pageData.user = res
})
pageData.order = await getHistoryOrder({orderId:option.orderId})
console.log(pageData.order);
const res = await getCouponList()
const res = await getFindCoupon({
shopUserId: option.shopUserId,
type: pageData.types.sel
})
let fullReductionCoupon = res.filter(v => v.type == 1)
let productCoupon = res.filter(v => v.type == 2)