修改订单结算积分

This commit is contained in:
2026-01-05 10:11:32 +08:00
parent 55207667b0
commit 85aedcbedb
2 changed files with 1643 additions and 1706 deletions

View File

@@ -3,13 +3,12 @@
<template #desc> <template #desc>
<view class="u-text-left u-p-30 color-666 u-font-28"> <view class="u-text-left u-p-30 color-666 u-font-28">
<view class="u-m-t-32 u-flex"> <view class="u-m-t-32 u-flex">
<view class="" v-if="accountPoints.calcRes.usable"> <view class="" v-if="pointDeductionRule.enableRewards">
<text class="color-red">*</text> <text class="color-red">*</text>
<text class="" v-if="accountPoints.calcRes.equivalentPoints" <text class=""
>{{ accountPoints.calcRes.equivalentPoints }}积分等于1元,</text v-if="pointDeductionRule.equivalentPoints">{{ pointDeductionRule.equivalentPoints }}积分等于1元,</text>
>
<text> <text>
最大抵扣积分{{ accountPoints.calcRes.maxUsablePoints }} 最大抵扣积分{{ maxCanUsePoints }}
</text> </text>
<text>, 最小抵扣积分0 </text> <text>, 最小抵扣积分0 </text>
</view> </view>
@@ -17,15 +16,8 @@
<view class="u-m-t-40 u-flex"> <view class="u-m-t-40 u-flex">
<view>积分</view> <view>积分</view>
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1"> <view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
<uni-easyinput <uni-easyinput type="number" @input="pointsInput" @change="pointsChange" paddingNone
type="number" :inputBorder="false" v-model="form.points" placeholder="输入积分抵扣数量"></uni-easyinput>
@input="pointsInput"
@change="pointsChange"
paddingNone
:inputBorder="false"
v-model="form.points"
placeholder="输入积分抵扣数量"
></uni-easyinput>
</view> </view>
</view> </view>
</view> </view>
@@ -33,13 +25,9 @@
<template #btn> <template #btn>
<view class="u-p-30"> <view class="u-p-30">
<view class="u-m-t-10"> <view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" fontWeight="700" <my-button @tap="confirm" shape="circle" fontWeight="700">修改</my-button>
>修改</my-button
>
<view class=""> <view class="">
<my-button @tap="close" type="cancel" bgColor="#fff" <my-button @tap="close" type="cancel" bgColor="#fff">取消</my-button>
>取消</my-button
>
</view> </view>
</view> </view>
</view> </view>
@@ -48,7 +36,12 @@
</template> </template>
<script setup> <script setup>
import { reactive, nextTick, ref, watch } from "vue"; import {
reactive,
nextTick,
ref,
watch
} from "vue";
import myModel from "@/components/my-components/my-model.vue"; import myModel from "@/components/my-components/my-model.vue";
import myButton from "@/components/my-components/my-button.vue"; import myButton from "@/components/my-components/my-button.vue";
import myTabs from "@/components/my-components/my-tabs.vue"; import myTabs from "@/components/my-components/my-tabs.vue";
@@ -58,16 +51,18 @@ const props = defineProps({
type: String, type: String,
default: "积分抵扣", default: "积分抵扣",
}, },
accountPoints: { maxCanUsePoints: {
type: Number,
default: 0
},
pointDeductionRule: {
type: Object, type: Object,
default: () => { default: () => {
return { return {
calcRes: { enableRewards: false,
usable: false,
unusableReason: "", unusableReason: "",
minDeductionPoints: 0, minDeductionPoints: 0,
maxUsablePoints: 0, maxUsablePoints: 0,
},
}; };
}, },
}, },
@@ -96,10 +91,10 @@ function pointsChange(newval) {
form.points = 0; form.points = 0;
return infoBox.showToast("积分抵扣不能小于0"); return infoBox.showToast("积分抵扣不能小于0");
} }
if (newval > props.accountPoints.calcRes.maxUsablePoints) { if (newval > props.maxCanUsePoints) {
form.points = props.price; form.points = props.price;
return infoBox.showToast( return infoBox.showToast(
"积分抵扣不能大于" + props.accountPoints.calcRes.maxUsablePoints "积分抵扣不能大于" + props.maxCanUsePoints
); );
} }
} }

View File

@@ -7,10 +7,7 @@
orderCostSummary.finalPayAmount orderCostSummary.finalPayAmount
}}</text> }}</text>
</view> </view>
<view <view class="u-m-t-10 color-999 old-price" v-if="orderCostSummary.merchantReduction.actualAmount">
class="u-m-t-10 color-999 old-price"
v-if="orderCostSummary.merchantReduction.actualAmount"
>
<text class=""></text> <text class=""></text>
<text class=" ">{{ returnMerchantReductionBeforeMoney }}</text> <text class=" ">{{ returnMerchantReductionBeforeMoney }}</text>
</view> </view>
@@ -23,10 +20,7 @@
</view> </view>
<view class="content bg-fff border-r-12"> <view class="content bg-fff border-r-12">
<view class="u-p-l-26 u-p-r-26 card top u-m-t-30"> <view class="u-p-l-26 u-p-r-26 card top u-m-t-30">
<view <view class="border-bottom-dashed u-p-b-30 u-p-t-30" v-if="orderCostSummary.newUserDiscount">
class="border-bottom-dashed u-p-b-30 u-p-t-30"
v-if="orderCostSummary.newUserDiscount"
>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between"> <view class="u-flex u-p-l-24 u-p-r-24 u-row-between">
<view>新客立减</view> <view>新客立减</view>
<view class="color-red"> <view class="color-red">
@@ -34,10 +28,7 @@
</view> </view>
</view> </view>
</view> </view>
<view <view class="border-bottom-dashed u-p-b-30 u-p-t-30" v-if="orderCostSummary.vipDiscountAmount">
class="border-bottom-dashed u-p-b-30 u-p-t-30"
v-if="orderCostSummary.vipDiscountAmount"
>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between"> <view class="u-flex u-p-l-24 u-p-r-24 u-row-between">
<view>会员折扣</view> <view>会员折扣</view>
<view class="color-red"> <view class="color-red">
@@ -45,10 +36,8 @@
</view> </view>
</view> </view>
</view> </view>
<view <view class="border-bottom-dashed u-p-b-30 u-p-t-30"
class="border-bottom-dashed u-p-b-30 u-p-t-30" v-if="orderCostSummary.merchantReduction.actualAmount">
v-if="orderCostSummary.merchantReduction.actualAmount"
>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between"> <view class="u-flex u-p-l-24 u-p-r-24 u-row-between">
<view>商家减免</view> <view>商家减免</view>
<view class="color-red"> <view class="color-red">
@@ -56,13 +45,10 @@
</view> </view>
</view> </view>
</view> </view>
<view <view class="border-bottom-dashed u-p-b-30 u-p-t-30" v-if="
class="border-bottom-dashed u-p-b-30 u-p-t-30"
v-if="
orderCostSummary.fullReduction.actualAmount && orderCostSummary.fullReduction.actualAmount &&
orderCostSummary.fullReduction.usedThreshold orderCostSummary.fullReduction.usedThreshold
" ">
>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between"> <view class="u-flex u-p-l-24 u-p-r-24 u-row-between">
<view>满减活动</view> <view>满减活动</view>
<view class="color-red"> <view class="color-red">
@@ -75,52 +61,32 @@
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between" @click="toQuan"> <view class="u-flex u-p-l-24 u-p-r-24 u-row-between" @click="toQuan">
<view>优惠券</view> <view>优惠券</view>
<view class="color-999 u-flex u-col-center"> <view class="color-999 u-flex u-col-center">
<text <text class="color-red"
class="color-red" v-if="orderCostSummary.fullReduction.usedThreshold">满减活动不可与优惠券同享</text>
v-if="orderCostSummary.fullReduction.usedThreshold" <text v-else-if="orderCostSummary.couponDeductionAmount <= 0">选择优惠券</text>
>满减活动不可与优惠券同享</text
>
<text v-else-if="orderCostSummary.couponDeductionAmount <= 0"
>选择优惠券</text
>
<text class="color-red" v-else> <text class="color-red" v-else>
-¥{{ orderCostSummary.couponDeductionAmount }} -¥{{ orderCostSummary.couponDeductionAmount }}
</text> </text>
<view <view class="u-flex u-col-center" v-if="!orderCostSummary.fullReduction.usedThreshold">
class="u-flex u-col-center"
v-if="!orderCostSummary.fullReduction.usedThreshold"
>
<uni-icons type="right" color="#999"></uni-icons> <uni-icons type="right" color="#999"></uni-icons>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view <view class="border-bottom u-p-b-30" v-if="discount.value || accountPoints.sel">
class="border-bottom u-p-b-30" <view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30" v-if="discount.value">
v-if="discount.value || accountPoints.sel"
>
<view
class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30"
v-if="discount.value"
>
<view>服务员改价</view> <view>服务员改价</view>
<view class="u-flex u-col-center"> <view class="u-flex u-col-center">
<text style="color: rgb(255, 95, 46)" <text style="color: rgb(255, 95, 46)">-¥{{ to2(discount.value) }}</text>
>-¥{{ to2(discount.value) }}</text
>
</view> </view>
</view> </view>
<view <view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30"
class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30" v-if="orderCostSummary.pointDeductionAmount && accountPoints.sel">
v-if="orderCostSummary.pointDeductionAmount && accountPoints.sel"
>
<view>积分抵扣</view> <view>积分抵扣</view>
<view class="u-flex u-col-center"> <view class="u-flex u-col-center">
<text style="color: rgb(255, 95, 46)" <text style="color: rgb(255, 95, 46)">-¥{{ orderCostSummary.pointDeductionAmount }}</text>
>-¥{{ orderCostSummary.pointDeductionAmount }}</text
>
</view> </view>
</view> </view>
</view> </view>
@@ -130,44 +96,28 @@
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs> <my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
<template v-if="pays.selIndex == 0"> <template v-if="pays.selIndex == 0">
<view class="list"> <view class="list">
<view <view class="item" @click="changePayType(index, item)" :class="{ disabled: item.disabled }"
class="item" v-for="(item, index) in pays.payTypes.list" :key="index">
@click="changePayType(index, item)" <view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom">
:class="{ disabled: item.disabled }"
v-for="(item, index) in pays.payTypes.list"
:key="index"
>
<view
class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom"
>
<view class="u-flex"> <view class="u-flex">
<image class="icon" :src="item.icon" mode=""></image> <image class="icon" :src="item.icon" mode=""></image>
<text class="u-m-l-10 no-wrap">{{ item.payName }}</text> <text class="u-m-l-10 no-wrap">{{ item.payName }}</text>
</view> </view>
<view class="u-flex color-999 u-font-24"> <view class="u-flex color-999 u-font-24">
<view <view class="u-m-r-20" v-if="item.payType == 'arrears' && pageData.buyer.id"
class="u-m-r-20" @click.stop="chooseBuyer">
v-if="item.payType == 'arrears' && pageData.buyer.id"
@click.stop="chooseBuyer"
>
<view> <view>
<text>挂账人:</text> <text>挂账人:</text>
<text class="u-m-r-4">{{ pageData.buyer.debtor }}</text> <text class="u-m-r-4">{{ pageData.buyer.debtor }}</text>
</view> </view>
<view> <view>
<text>挂账额度:</text> <text>挂账额度:</text>
<text <text>¥{{ pageData.buyer.remainingAmount || "0" }}</text>
>¥{{ pageData.buyer.remainingAmount || "0" }}</text
>
</view> </view>
</view> </view>
<view <view class="u-m-r-20" v-if="
class="u-m-r-20"
v-if="
item.payType == 'member-account' && pageData.user.id item.payType == 'member-account' && pageData.user.id
" " @click.stop="chooseUser">
@click.stop="chooseUser"
>
<view> <view>
<text>会员:</text> <text>会员:</text>
<text class="u-m-r-4">{{ <text class="u-m-r-4">{{
@@ -184,10 +134,8 @@
</view> --> </view> -->
</view> </view>
<view :class="{ op3: item.disabled }"> <view :class="{ op3: item.disabled }">
<my-radio <my-radio @click="changePayType(index, item)"
@click="changePayType(index, item)" :modelValue="index == pays.payTypes.selIndex">
:modelValue="index == pays.payTypes.selIndex"
>
</my-radio> </my-radio>
</view> </view>
</view> </view>
@@ -195,11 +143,8 @@
</view> </view>
</view> </view>
<view class="border-bottom-dashed"></view> <view class="border-bottom-dashed"></view>
<view <view class="u-flex u-row-between u-p-t-24" v-if="pageData.user.id"
class="u-flex u-row-between u-p-t-24" @click="changeAccountPoints">
v-if="pageData.user.id"
@click="changeAccountPoints"
>
<view class="u-flex"> <view class="u-flex">
<view class="">积分抵扣</view> <view class="">积分抵扣</view>
<view class="color-999 u-m-l-10"> <view class="color-999 u-m-l-10">
@@ -211,37 +156,28 @@
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="u-flex"> <view class="u-flex">
<view <view><text>{{ userPoints }}</text></view>
><text>{{ accountPoints.num }}</text></view <view v-if="pointDeductionRule.enableRewards&&accountPoints.sel" @click.stop="refPointsOpen">
>
<view
v-if="pointDeductionRule.enableRewards"
@click.stop="refPointsOpen"
>
<up-icon name="edit-pen" size="16" color="#999"></up-icon> <up-icon name="edit-pen" size="16" color="#999"></up-icon>
</view> </view>
</view> </view>
<view <view class="u-m-l-32 u-relative" v-if="pointDeductionRule.enableRewards">
class="u-m-l-32 u-relative"
v-if="pointDeductionRule.enableRewards"
>
<view class="u-absolute position-all"></view> <view class="u-absolute position-all"></view>
<my-radio :modelValue="accountPoints.sel"> </my-radio> <my-radio :modelValue="accountPoints.sel"> </my-radio>
</view> </view>
</view> </view>
</view> </view>
<view class="color-999 u-font-24 u-m-t-16"> <view class="color-999 u-font-24 u-m-t-16">
<view class="" v-if="accountPoints.calcRes.unusableReason"> <view class="" v-if="!pointDeductionRule.enableRewards">
<text class="color-red">*</text> <text class="color-red">*</text>
<text>{{ accountPoints.calcRes.unusableReason }}</text> <text>积分不可用</text>
</view> </view>
<view class="" v-if="accountPoints.calcRes.usable"> <view class="" v-if="pointDeductionRule.enableRewards">
<text class="color-red">*</text> <text class="color-red">*</text>
<text class="" v-if="pointDeductionRule.enableRewards" <text class=""
>「可用积分{{ pageData.user.id?pageData.user.pointBalance:0}},最大可抵扣{{ v-if="pointDeductionRule.enableRewards">「可用积分{{ pageData.user.id?pageData.user.pointBalance:0}},最大可抵扣{{
maxPointDiscount maxPointDiscount
}}元」</text }}元」</text>
>
</view> </view>
</view> </view>
@@ -250,9 +186,7 @@
</view> </view>
</template> </template>
<template v-if="pays.selIndex == 1"> <template v-if="pays.selIndex == 1">
<view class="u-font-32 u-m-t-40 u-text-center" <view class="u-font-32 u-m-t-40 u-text-center">请让顾客使用微信/支付宝扫码</view>
>请让顾客使用微信/支付宝扫码</view
>
<view class="u-flex u-row-center u-m-t-40"> <view class="u-flex u-row-center u-m-t-40">
<up-qrcode cid="code" :size="140" :val="payCodeUrl"></up-qrcode> <up-qrcode cid="code" :size="140" :val="payCodeUrl"></up-qrcode>
</view> </view>
@@ -264,18 +198,14 @@
<view class="card border-bottom top u-m-t-32"> </view> <view class="card border-bottom top u-m-t-32"> </view>
<view class="bg-fff card bottom border-r-12 u-p-32"> <view class="bg-fff card bottom border-r-12 u-p-32">
<view class="font-bold u-font-32 u-text-center"> <view class="font-bold u-font-32 u-text-center">
¥{{ payPrice }}</view ¥{{ payPrice }}</view>
>
<view class="u-flex u-row-center u-m-t-24"> <view class="u-flex u-row-center u-m-t-24">
<template v-if="order.status == 'unpaid'"> <template v-if="order.status == 'unpaid'">
<up-loading-icon size="14" text="等待支付"></up-loading-icon> <up-loading-icon size="14" text="等待支付"></up-loading-icon>
</template> </template>
<template v-if="order.status == 'done'"> <template v-if="order.status == 'done'">
<view class="u-flex pay-success"> <view class="u-flex pay-success">
<up-icon <up-icon color="#5CBB6F" name="checkmark-circle-fill"></up-icon>
color="#5CBB6F"
name="checkmark-circle-fill"
></up-icon>
<view class="u-m-l-6">支付成功</view> <view class="u-m-l-6">支付成功</view>
</view> </view>
</template> </template>
@@ -285,35 +215,15 @@
</view> </view>
</view> </view>
<edit-discount <edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
@confirm="editDiscountConfirm" :price="returnMerchantReductionBeforeMoney" :discount="discount.discount"></edit-discount>
title="优惠金额"
:ref="setModel"
name="editMoney"
:price="returnMerchantReductionBeforeMoney"
:discount="discount.discount"
></edit-discount>
<up-modal <up-modal :title="modal.title" :content="modal.content" :show="modal.show" :confirmText="modal.confirmText"
:title="modal.title" :cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
:content="modal.content" @cancel="confirmModelCancel" @close="confirmModelCancel" width="300px" />
:show="modal.show"
:confirmText="modal.confirmText"
:cancelText="modal.cancelText"
showCancelButton
closeOnClickOverlay
@confirm="confirmModelConfirm"
@cancel="confirmModelCancel"
@close="confirmModelCancel"
width="300px"
/>
<edit-accountPoints <edit-accountPoints @confirm="pointsConfirm" :price="userPoints" :pointDeductionRule="pointDeductionRule"
@confirm="pointsConfirm" :maxCanUsePoints="maxCanUsePoints" ref="refPoints"></edit-accountPoints>
:price="accountPoints.num"
:accountPoints="accountPoints"
ref="refPoints"
></edit-accountPoints>
</view> </view>
</template> </template>
@@ -328,11 +238,17 @@ import {
computed, computed,
inject, inject,
} from "vue"; } from "vue";
import { onLoad, onBackPress, onShow } from "@dcloudio/uni-app"; import {
onLoad,
onBackPress,
onShow
} from "@dcloudio/uni-app";
import BigNumber from "bignumber.js"; import BigNumber from "bignumber.js";
import go from "@/commons/utils/go.js"; import go from "@/commons/utils/go.js";
import infoBox from "@/commons/utils/infoBox.js"; import infoBox from "@/commons/utils/infoBox.js";
import { hasPermission } from "@/commons/utils/hasPermission.js"; import {
hasPermission
} from "@/commons/utils/hasPermission.js";
import editDiscount from "@/components/my-components/edit-discount.vue"; import editDiscount from "@/components/my-components/edit-discount.vue";
import editAccountPoints from "./components/edit-accountPoints.vue"; import editAccountPoints from "./components/edit-accountPoints.vue";
import { import {
@@ -341,18 +257,34 @@ import {
returnProductCoupAllPrice, returnProductCoupAllPrice,
returnProductCanUseNum, returnProductCanUseNum,
} from "../quan_util.js"; } from "../quan_util.js";
import { mathFloorPrice } from "@/commons/utils/goodsUtil.js"; import {
import { getDiscountByUserId } from "@/http/yskApi/market/consumeDiscount.js"; mathFloorPrice
import { useCartStore } from "@/stores/cart.js"; } from "@/commons/utils/goodsUtil.js";
import {
getDiscountByUserId
} from "@/http/yskApi/market/consumeDiscount.js";
import {
useCartStore
} from "@/stores/cart.js";
const cartStore = useCartStore(); const cartStore = useCartStore();
// import { getCouponList } from '@/http/api/coupon.js' // import { getCouponList } from '@/http/api/coupon.js'
import { getHistoryOrder } from "@/http/api/order.js"; import {
import { getPayTypeList } from "@/http/api/payType.js"; getHistoryOrder
import { shopUserDetail } from "@/http/api/shopUser.js"; } from "@/http/api/order.js";
import { pointsConfig } from "@/http/yskApi/market/points.js"; import {
import { discountActivity } from "@/http/yskApi/market/discountActivity.js"; getPayTypeList
} from "@/http/api/payType.js";
import {
shopUserDetail
} from "@/http/api/shopUser.js";
import {
pointsConfig
} from "@/http/yskApi/market/points.js";
import {
discountActivity
} from "@/http/yskApi/market/discountActivity.js";
import { import {
scanPay, scanPay,
@@ -499,7 +431,9 @@ async function init() {
onMessage(); onMessage();
}); });
// 获取订单详情 // 获取订单详情
const orderRes = await getHistoryOrder({ orderId: order.orderId }); const orderRes = await getHistoryOrder({
orderId: order.orderId
});
if (orderRes.status == "cancelled") { if (orderRes.status == "cancelled") {
uni.showToast({ uni.showToast({
title: "订单已取消", title: "订单已取消",
@@ -669,8 +603,7 @@ const orderCostSummary = computed(() => {
options.dinnerType, options.dinnerType,
selCoupon.value, selCoupon.value,
activityList.value, activityList.value,
orderExtraConfig.value, orderExtraConfig.value, {},
{},
new Date() new Date()
); );
console.log(" 订单费用汇总", costSummary); console.log(" 订单费用汇总", costSummary);
@@ -703,14 +636,7 @@ watch(
} }
} }
); );
watch(
() => accountPoints.num,
(newval) => {
if (accountPoints.sel) {
userPoints.value = newval;
}
}
);
watch( watch(
() => pointsCanDicountMaxMoney.value, () => pointsCanDicountMaxMoney.value,
(newval) => { (newval) => {
@@ -719,6 +645,15 @@ watch(
} }
} }
); );
watch(
() => accountPoints.sel,
(newval) => {
if (pageData.user.id) {
getCalcUsablePoints();
}
}
);
watch( watch(
() => pageData.user.id, () => pageData.user.id,
(newval) => { (newval) => {
@@ -751,8 +686,7 @@ watch(
v.disabled = false; v.disabled = false;
}); });
} }
}, }, {
{
immediate: true, immediate: true,
} }
); );
@@ -763,7 +697,9 @@ watch(
clearInterval(timer); clearInterval(timer);
if (newval) { if (newval) {
timer = setInterval(() => { timer = setInterval(() => {
getHistoryOrder({ orderId: order.orderId }).then((res) => { getHistoryOrder({
orderId: order.orderId
}).then((res) => {
order.status = res.status; order.status = res.status;
if (res.status == "done") { if (res.status == "done") {
paySuccess(); paySuccess();
@@ -793,28 +729,25 @@ function getPayParam() {
pointsNum: orderCostSummary.value.pointUsed, //(扣除各类折扣 enable_deduction后使用) pointsNum: orderCostSummary.value.pointUsed, //(扣除各类折扣 enable_deduction后使用)
seatNum: options.dinnerType == "dine-in" ? seatFeeConfig.personCount : 0, //用餐人数 seatNum: options.dinnerType == "dine-in" ? seatFeeConfig.personCount : 0, //用餐人数
newCustomerDiscountAmount: orderCostSummary.value.newUserDiscount, //新客立减 newCustomerDiscountAmount: orderCostSummary.value.newUserDiscount, //新客立减
newCustomerDiscountId: newCustomerDiscountId: orderCostSummary.value.newUserDiscount > 0 ?
orderCostSummary.value.newUserDiscount > 0 newUserDiscountRes.value.id :
? newUserDiscountRes.value.id "",
: "",
discountActAmount: orderCostSummary.value.fullReduction.actualAmount, //满减抵扣金额 discountActAmount: orderCostSummary.value.fullReduction.actualAmount, //满减抵扣金额
discountActId: discountActId: orderCostSummary.value.fullReduction.usedActivity &&
orderCostSummary.value.fullReduction.usedActivity && orderCostSummary.value.fullReduction.usedThreshold ?
orderCostSummary.value.fullReduction.usedThreshold orderCostSummary.value.fullReduction.usedActivity.id :
? orderCostSummary.value.fullReduction.usedActivity.id null,
: null,
vipPrice: isVip.value ? 1 : 0, // 是否使用会员价 vipPrice: isVip.value ? 1 : 0, // 是否使用会员价
limitRate: limitRate: order.limitRate && order.limitRate.id ?
order.limitRate && order.limitRate.id {
? {
id: order.limitRate.id, id: order.limitRate.id,
discountRate: order.limitRate.discountRate, discountRate: order.limitRate.discountRate,
discountPriority: order.limitRate.discountPriority, discountPriority: order.limitRate.discountPriority,
foodType: order.limitRate.foodType, foodType: order.limitRate.foodType,
foods: order.limitRate.foods, foods: order.limitRate.foods,
} } :
: null, null,
vipDiscountAmount: orderCostSummary.value.vipDiscountAmount, //会员折扣减免金额 vipDiscountAmount: orderCostSummary.value.vipDiscountAmount, //会员折扣减免金额
}; };
if (pays.quan.length > 0) { if (pays.quan.length > 0) {
@@ -885,7 +818,7 @@ function setQuan(arr) {
* 积分选择 * 积分选择
*/ */
function refPointsOpen() { function refPointsOpen() {
if (!accountPoints.calcRes.usable && accountPoints.sel) { if (!pointDeductionRule.enableRewards && accountPoints.sel) {
return; return;
} }
refPoints.value.open(); refPoints.value.open();
@@ -896,7 +829,7 @@ function refPointsOpen() {
* @param {Object} e * @param {Object} e
*/ */
function pointsConfirm(e) { function pointsConfirm(e) {
accountPoints.num = e; userPoints.value = e
} }
@@ -920,21 +853,26 @@ async function getCalcUsablePoints() {
const onePointsMoney = pointDeductionRule.pointsPerYuan ? ((1 || 0) / pointDeductionRule.pointsPerYuan) : 0 const onePointsMoney = pointDeductionRule.pointsPerYuan ? ((1 || 0) / pointDeductionRule.pointsPerYuan) : 0
const calcMaxDiscount = Math.floor(pointsCanDicountMaxMoney.value * (pointDeductionRule.maxDeductionRatio / 100)) const calcMaxDiscount = Math.floor(pointsCanDicountMaxMoney.value * (pointDeductionRule.maxDeductionRatio /
const userMaxDiscount = BigNumber(userAccountPoints).times(onePointsMoney).decimalPlaces(2, BigNumber.ROUND_DOWN) 100))
const userMaxDiscount = BigNumber(userAccountPoints).times(onePointsMoney).decimalPlaces(2, BigNumber
.ROUND_DOWN)
.toNumber() .toNumber()
maxPointDiscount.value = Math.min(calcMaxDiscount, userMaxDiscount) maxPointDiscount.value = Math.min(calcMaxDiscount, userMaxDiscount)
console.log('积分最大可抵扣金额', maxPointDiscount.value) console.log('积分最大可抵扣金额', maxPointDiscount.value)
pointDeductionRule.maxDeductionAmount = maxPointDiscount.value || 0 pointDeductionRule.maxDeductionAmount = maxPointDiscount.value || 0
if (accountPoints.sel && pointDeductionRule.enableRewards) { if (pointDeductionRule.enableRewards) {
let num = (maxPointDiscount.value || 0) * pointDeductionRule.pointsPerYuan let num = (maxPointDiscount.value || 0) * pointDeductionRule.pointsPerYuan
if (num > userAccountPoints) { if (num > userAccountPoints) {
num = userAccountPoints num = userAccountPoints
} }
maxCanUsePoints.value = num maxCanUsePoints.value = num
if (accountPoints.sel) {
userPoints.value = num userPoints.value = num
} }
}
if (!pointDeductionRule.enableRewards) { if (!pointDeductionRule.enableRewards) {
userPoints.value = 0 userPoints.value = 0
} }
@@ -1065,9 +1003,9 @@ function uodateCartAndHistory() {
pageData.shopInfo, pageData.shopInfo,
pageData.user, pageData.user,
"productId" "productId"
) ) ?
? 1 1 :
: 0; 0;
if (canUseLimitTimeDiscount != cart.isTimeDiscount) { if (canUseLimitTimeDiscount != cart.isTimeDiscount) {
newData.history.push({ newData.history.push({
id: cart.id, id: cart.id,
@@ -1186,6 +1124,7 @@ const tipsMap = {
paying: "支付中", paying: "支付中",
success: "已支付成功", success: "已支付成功",
}; };
function payOrderClick() { function payOrderClick() {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType; const payType = pays.payTypes.list[pays.payTypes.selIndex].payType;
if (payType == "scanCode" || payType == "deposit") { if (payType == "scanCode" || payType == "deposit") {
@@ -1268,7 +1207,9 @@ async function pay(par) {
title: "支付中...", title: "支付中...",
}); });
timer = setInterval(async () => { timer = setInterval(async () => {
res = await queryOrderStatus({ orderId: pars.orderId }); res = await queryOrderStatus({
orderId: pars.orderId
});
if (res == "done") { if (res == "done") {
clearInterval(timer); clearInterval(timer);
uni.hideLoading(); uni.hideLoading();
@@ -1352,6 +1293,7 @@ async function confirmModelConfirm() {
return; return;
} }
} }
function objToArrary(obj) { function objToArrary(obj) {
if (Object.values(obj) && Array.isArray(Object.values(obj)[0])) { if (Object.values(obj) && Array.isArray(Object.values(obj)[0])) {
// 是数组 // 是数组
@@ -1405,7 +1347,9 @@ function cashConfirmShow() {
*/ */
async function getHistoryAndUpdateGoodsList() { async function getHistoryAndUpdateGoodsList() {
// 获取订单详情 // 获取订单详情
const orderRes = await getHistoryOrder({ orderId: order.orderId }); const orderRes = await getHistoryOrder({
orderId: order.orderId
});
if (orderRes.status == "cancelled") { if (orderRes.status == "cancelled") {
uni.showToast({ uni.showToast({
title: "订单已取消", title: "订单已取消",
@@ -1471,11 +1415,9 @@ $quan-color: #318afe;
.hui { .hui {
// background-color: $quan-color; // background-color: $quan-color;
background-image: linear-gradient( background-image: linear-gradient(to right bottom,
to right bottom,
rgb(254, 103, 4), rgb(254, 103, 4),
rgb(241, 50, 42) rgb(241, 50, 42));
);
padding: 4rpx 10rpx; padding: 4rpx 10rpx;
border-radius: 10rpx; border-radius: 10rpx;
font-size: 24rpx; font-size: 24rpx;