订单结算修改,增加限时折扣

This commit is contained in:
2025-10-24 16:13:40 +08:00
parent 5aa469a7b7
commit 26532150b5
36 changed files with 4989 additions and 1885 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -45,62 +45,66 @@
</view>
<view class="card">
<orderItemVue
<!-- <orderItemVue
:useVipPrice="useVipPrice"
v-if="nowCarts.length"
:nowCarts="nowCarts"
:limitDiscount="cartStore.limitTimeDiscount"
></orderItemVue> -->
<orderItemVue
:useVipPrice="useVipPrice"
v-if="cartStore.allGoods.length"
:nowCarts="cartStore.allGoods"
:limitDiscount="cartStore.limitTimeDiscount"
></orderItemVue>
<!-- 订单头部 -->
<view
class="card_item"
v-for="(value, key) in listinfo.detailMap"
:key="key"
>
<!-- <view class="head">
<view class="head_left">
<text class="placeNum" v-if="key!=0">{{key}}次下单</text>
</view>
</view> -->
<!-- 订单详情 -->
<view class="shop-info">
<view class="item" v-for="item in value" :key="item.id">
<view class="cover">
<up-image
width="76"
height="76"
radius="16"
:src="item.productImg"
v-if="item.productId != -999"
></up-image>
<up-image
width="76"
height="76"
radius="16"
: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.skuName">{{
item.skuName
}}</text>
</view>
<view class="price">
<view class="priceAmount">
<text v-if="isBwc">{{ item.price }}</text>
<text v-else>
{{
useVipPrice ? item.memberPrice || item.price : item.price
}}
</text>
<template v-if="false">
<view
class="card_item"
v-for="(value, key) in listinfo.detailMap"
:key="key"
>
<view class="shop-info">
<view class="item" v-for="item in value" :key="item.id">
<view class="cover">
<up-image
width="76"
height="76"
radius="6"
:src="item.productImg"
v-if="item.productId != -999"
></up-image>
<up-image
width="76"
height="76"
radius="6"
: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.skuName">{{
item.skuName
}}</text>
</view>
<view class="price">
<view class="priceAmount">
<text v-if="isBwc">{{ item.price }}</text>
<text v-else>
{{
useVipPrice
? item.memberPrice || item.price
: item.price
}}
</text>
</view>
<view class="num">x{{ item.num }}</view>
</view>
<view class="num">x{{ item.num }}</view>
</view>
</view>
</view>
</view>
</template>
<view
class="total-wrap u-m-t-30"
@@ -154,7 +158,7 @@
"
>
<view class="u-m-t-40 u-p-l-20 u-p-r-20">
<view class="youhui-item" v-if="discountActivity">
<view class="youhui-item" v-if="cartStore.orderCostSummary.fullReduction.actualAmount">
<view class="u-flex align-center">
<image
src="/static/icon/coup.png"
@@ -165,13 +169,13 @@
</view>
<view class="red font-12 u-flex align-center"
>-¥{{ discountActivity.discountAmount }}</view
>-¥{{ cartStore.orderCostSummary.fullReduction.actualAmount }}</view
>
</view>
<view class="youhui-item" v-if="newUserDiscount">
<view class="u-flex align-center">
<image
src="/static/icon/coup.png"
src="/static/icon/newUserDiscount.png"
bgColor="#fff"
style="width: 40rpx; height: 34rpx"
></image>
@@ -304,7 +308,10 @@
</view>
</block>
<block v-else>
<view class="cell-item column" v-if="listinfo.discountInfo">
<view
class="cell-item column"
v-if="listinfo.discountInfo && listinfo.discountInfo != '{}'"
>
<view class="label">优惠折扣</view>
<view class="val column">
<view
@@ -387,6 +394,7 @@ import {
defineExpose,
toRaw,
onMounted,
provide,
nextTick,
} from "vue";
import { returnHasCouponCanUse } from "@/utils/coupon.js";
@@ -588,8 +596,6 @@ const tabClick = (item, index) => {
};
cartStore.setDinnerType(tebtypeList[is_type.value].val);
// 清空
const bwcclear = () => {
IntegralInputclose();
@@ -833,16 +839,13 @@ function calcDiscountActivity() {
const res = discountActivityRes.value;
const user = uni.cache.get("shopUserInfo");
//不与会员同享
if (!res.vipPriceShare && user.isVip) {
return;
}
console.log("calcDiscountActivity:originalPrice", originalPrice.value);
const usedFullReductionActivityFullAmount=cartStore.orderCostSummary.fullReduction.usedFullReductionActivityFullAmount;
console.log("usedFullReductionActivityFullAmount", usedFullReductionActivityFullAmount);
if (res && res.thresholds && res.thresholds.length > 0) {
const canUseThresholds = res.thresholds
.filter((v) => {
return originalPrice.value >= v.fullAmount;
return usedFullReductionActivityFullAmount >= v.fullAmount;
})
.sort((a, b) => {
return b.discountAmount - a.discountAmount;
@@ -859,9 +862,7 @@ function calcDiscountActivity() {
}
console.log("当前满减门槛", discountActivity.value);
if (discountActivity.value) {
cartStore.fullReductionActivities = [discountActivityRes.value];
}
}
async function getDiscountActivity() {
const res = await discountActivityApi.config({
@@ -871,6 +872,8 @@ async function getDiscountActivity() {
return;
}
discountActivityRes.value = res;
cartStore.fullReductionActivities = [res];
calcDiscountActivity();
}
onMounted(async () => {
@@ -1174,6 +1177,7 @@ onMounted(async () => {
display: flex;
.cover {
position: relative;
}
.info {
@@ -1561,4 +1565,19 @@ onMounted(async () => {
.align-center {
align-items: center;
}
.limitDiscount {
background-color: #cc5617;
padding: 2rpx 10rpx;
white-space: nowrap;
text-align: center;
position: absolute;
top: 0;
left: 0;
font-weight: 400;
font-size: 24rpx;
color: #ffffff;
border-radius: 20rpx 0rpx 20rpx 0rpx;
z-index: 9;
color: #fff;
}
</style>

View File

@@ -223,7 +223,7 @@
@close="ispws = false"
/>
<!-- 私域引流配置 -->
<OrderFinshModal v-model="showDrainage" ></OrderFinshModal>
<OrderFinshModal v-model="showDrainage"></OrderFinshModal>
</view>
</template>
<script setup>
@@ -243,8 +243,10 @@ import {
watch,
onBeforeMount,
onBeforeUnmount,
provide,
} from "vue";
provide("shopUserInfo", ref(uni.cache.get("shopUserInfo")));
provide("shopInfo", ref(uni.cache.get("shopInfo")));
import { getTableInfo } from "@/common/api/shop/index.js";
import {
APIgetOrderById,
@@ -278,8 +280,8 @@ const cartStore = useCartsStore();
//充值相关start
//充值和余额支付是否可用
const isCanUseCharge = ref(false);
function updateIsShow(e){
const isCanUseCharge = ref(true);
function updateIsShow(e) {
isCanUseCharge.value = e;
}
const rechargeItem = ref({
@@ -437,20 +439,22 @@ let historyTotalPrices = 0;
// * 获取订单详情接口
const orderorderInfo = async () => {
console.log("listinfo.id", listinfo.id);
if (!listinfo.id && !options.tableCode) {
return;
}
let res = listinfo.id
? await APIgetOrderById({
orderId: listinfo.id,
})
: await APIhistoryOrder({
tableCode: options.tableCode||"",
tableCode: options.tableCode || "",
});
orderRemarker.value = res.remark;
Object.assign(listinfo, res);
if (res && res.tableCode) {
socketInitPar.table_code = res.tableCode;
let tableRes = await getTableInfo({
tableCode: options.tableCode||"",
tableCode: options.tableCode || "",
});
console.log(tableRes);
listinfo.tableName = tableRes.name;
@@ -458,7 +462,7 @@ const orderorderInfo = async () => {
if (options.tableCode) {
socketInitPar.table_code = options.tableCode;
let tableRes = await getTableInfo({
tableCode: options.tableCode||"",
tableCode: options.tableCode || "",
});
console.log(tableRes);
listinfo.tableName = tableRes.name;
@@ -634,8 +638,17 @@ const createOrder = async () => {
placeNum: listinfo.id ? listinfo.placeNum * 1 + 1 : 1, //当前订单下单次数
waitCall: "", //是否等叫 0 否 1 等叫
orderId: listinfo.id || "",
tableCode: options.tableCode||'',
tableCode: options.tableCode || "",
userId: uni.cache.get("userInfo").id || "", //
limitRate: (cartStore.limitTimeDiscount&&cartStore.limitTimeDiscount.id)
? {
id: cartStore.limitTimeDiscount.id,
discountRate: cartStore.limitTimeDiscount.discountRate,
discountPriority: cartStore.limitTimeDiscount.discountPriority,
foodType: cartStore.limitTimeDiscount.foodType,
foods: cartStore.limitTimeDiscount.foods,
}
: null,
});
// 清空购物车
if (res) {
@@ -716,7 +729,18 @@ function returnPayParams() {
: "",
remark: orderRemarker.value, //用户备注
discountActAmount: cartStore.orderCostSummary.fullReduction.actualAmount, //满减抵扣金额
discountActId:cartStore.orderCostSummary.fullReduction.usedActivity?cartStore.orderCostSummary.fullReduction.usedActivity.id:null,
userId: uni.cache.get("userInfo").id || "", //
limitRate: (cartStore.limitTimeDiscount&&cartStore.limitTimeDiscount.id)
? {
id: cartStore.limitTimeDiscount.id,
discountRate: cartStore.limitTimeDiscount.discountRate,
discountPriority: cartStore.limitTimeDiscount.discountPriority,
foodType: cartStore.limitTimeDiscount.foodType,
foods: cartStore.limitTimeDiscount.foods,
}
: null,
vipDiscountAmount: cartStore.orderCostSummary.vipDiscountAmount, //会员折扣减免金额
};
return {
isBwc: isBwc.value,
@@ -919,7 +943,6 @@ const goToPay = async (payParams) => {
orderorderInfo();
};
//
const clickPointsamount = (Pointsamount) => {
listinfo.pointsDiscountAmount = Pointsamount.pointsDiscountAmount;
@@ -1063,9 +1086,13 @@ async function init(opt) {
if (res) {
uni.cache.set("tableCode", res.tableCode);
uni.cache.set("tableCode", res.seatNum);
options.tableCode = res.tableCode||'';
options.tableCode = res.tableCode || "";
cartStore.setSeatFeeConfig("personCount", res.seatNum);
cartStore.setDinnerType(res.dineMode || "dine-in");
cartStore.setOldOrder(res);
if(res.limitRate){
cartStore.limitTimeDiscount=res.limitRate
}
orderRemarker.value = res.remark;
Object.assign(listinfo, res);
}
@@ -1162,7 +1189,7 @@ const disablePayType = computed(() => {
// if (cartStore.orderCostSummary.orderOriginFinalPayAmount <= 0) {
// arr.add("微信支付");
// }
if(!isCanUseCharge.value){
if (!isCanUseCharge.value) {
arr.add("余额支付");
}

View File

@@ -328,7 +328,8 @@ function formatCoupon(){
goodsOrderPrice,
user,
selCoupon:selCoupon,
shopInfo
shopInfo,
limitTimeDiscount:cartStore.limitTimeDiscount
});
const { canUse, reason } = canuseResult;
if (coupon.type == 2) {
@@ -353,7 +354,7 @@ function formatCoupon(){
}
//商品券
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo,cartStore.limitTimeDiscount);
return {
...v,
discount,
@@ -362,7 +363,7 @@ function formatCoupon(){
});
//非商品券
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo,cartStore.limitTimeDiscount);
return {
...v,
discount,
@@ -518,7 +519,7 @@ watch(
let goodsCoupon = newval.filter((v) => v.type == 2);
let otherCoupon = newval.filter((v) => v.type != 2);
goodsCoupon = goodsCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, [], shopInfo);
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, [], shopInfo,cartStore.limitTimeDiscount);
return {
...v,
discount,
@@ -526,7 +527,7 @@ watch(
};
});
otherCoupon = otherCoupon.map((v) => {
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, goodsCoupon, shopInfo);
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, goodsCoupon, shopInfo,cartStore.limitTimeDiscount);
return {
...v,
discount,

View File

@@ -0,0 +1,196 @@
<template>
<up-overlay :show="show">
<view class="box" v-if="SelData">
<view class="bg-fff u-p-30 item">
<view class="u-flex coverImg">
<up-image
width="204rpx"
height="228rpx"
radius="6"
:src="SelData.goods.coverImg"
></up-image>
<view class="limitDiscount" v-if="showLimitDiscount(SelData.goods)"
>限时折扣</view
>
</view>
<view class="u-flex-1 u-p-l-36">
<view class="u-flex u-col-center justify-between u-m-t-10">
<view class="u-line-1 font-16 color-333 font-bold u-p-r-16">{{
SelData.title
}}</view>
<up-icon
size="20"
name="close-circle"
color="#666"
@click="close"
></up-icon>
</view>
<view class="color-333 font-14 u-m-t-32 u-line-1">{{
SelData.guideDetail
}}</view>
<view class="u-flex justify-between u-m-t-30">
<view class="price"
>¥
<GoodsPrice
:limitDiscount="cartStore.limitTimeDiscount"
:cart="SelData.goods"
:shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"
></GoodsPrice
></view>
<view class="buy" @click="buy">立即下单</view>
</view>
</view>
</view>
</view>
</up-overlay>
</template>
<script setup>
import * as orderUtils from "@/utils/order-utils.js";
import GoodsPrice from "@/components/goods-price.vue";
import * as suggestApi from "@/common/api/market/suggest.js";
import { ref, onMounted, inject, watch } from "vue";
const cartStore = inject("cartStore");
const shopUserInfo = inject("shopUserInfo");
const shopInfo = inject("shopInfo");
function showLimitDiscount(item) {
if (!cartStore.limitTimeDiscount) {
return false;
}
return orderUtils.canUseLimitTimeDiscount(
item,
cartStore.limitTimeDiscount,
shopInfo,
shopUserInfo.value,
"id"
);
}
const show = ref(false);
let timer = null;
function taskEnd() {
clearInterval(timer);
show.value = false;
}
function statTime() {
clearInterval(timer);
timer = setTimeout(() => {
const item = list.value[nowIndex.value];
if (item) {
SelData.value = item;
show.value = true;
} else {
taskEnd();
}
}, suggestTime.value * 1000);
}
const list = ref([]);
const SelData = ref(null);
const nowIndex = ref(0);
function close() {
suggestTime.value = 30;
taskEnd();
nowIndex.value += 1;
if (nowIndex.value == list.value.length) {
return;
}
statTime();
}
const suggestTime = ref(100);
const emits = defineEmits(["onBuyClick"]);
function buy() {
emits("onBuyClick", SelData.value.goods);
}
onMounted(() => {
suggestApi
.getGoods({
shopId: uni.cache.get("shopId"),
})
.then((res) => {
if (res) {
suggestTime.value = res.suggestTime;
list.value = (res.list || [])
.map((v) => {
return {
...v,
goods: cartStore.returnGoods(v.foods),
};
})
.filter((v) => v.goods);
console.log('list.value ', list.value )
startWatch();
}
});
});
function startWatch() {
watch(
() => cartStore.isEmpty,
(newval) => {
if (newval && list.value.length) {
statTime();
} else {
clearInterval(timer);
nowIndex.value = 0;
show.value = false;
}
},
{
immediate: true,
}
);
}
</script>
<style scoped lang="scss">
.box {
position: fixed;
z-index: 100;
left: 30rpx;
right: 30rpx;
bottom: calc(var(--safe-area-inset-bottom) + 0px);
.item {
padding: 32rpx 28rpx;
border-radius: 16rpx;
background: #fff;
box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
display: flex;
}
.price {
font-size: 40rpx;
color: #333;
}
.buy {
padding: 4rpx 28rpx;
border-radius: 36rpx;
background: #e8ad7b;
color: #ffffff;
font-size: 28rpx;
line-height: 48rpx;
}
}
.coverImg{
position: relative;
}
.limitDiscount {
background-color: #cc5617;
padding: 2rpx 10rpx;
white-space: nowrap;
text-align: center;
position: absolute;
top: 0;
left: 0;
font-weight: 400;
font-size: 24rpx;
color: #ffffff;
border-radius: 20rpx 0rpx 20rpx 0rpx;
z-index: 9;
color: #fff;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -58,6 +58,9 @@
v-for="(item, index) in shopProductList.hots"
:key="index"
>
<view class="limitDiscount" v-if="showLimitDiscount(item)"
>限时折扣</view
>
<image
class="panelfiveitemimage"
:src="item.coverImg"
@@ -151,6 +154,10 @@
<text class="unit" v-if="item.unitName"
>/{{ item.unitName }}</text
>
<text class="old-price"
>¥{{ item.salePrice }}</text
>
</view>
</view>
<view class="panelfiveitemNum">
@@ -189,16 +196,21 @@
>¥</text
>
<!-- 会员价与价格 -->
<text class="price">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? item.memberPrice || item.salePrice
: item.salePrice
}}
</text>
<view class="price">
<GoodsPrice
:limitDiscount="limitTimeDiscountRes"
:cart="item"
:shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"
></GoodsPrice>
</view>
<text class="unit" v-if="item.unitName"
>/{{ item.unitName }}</text
>
<text class="old-price"
>¥{{ item.salePrice }}</text
>
<!-- <text v-if="item.suitNum>1 && item.type!= 'sku'"
style="font-size: 16rpx;">「{{item.suitNum}}{{item.unitName}}起点」</text> -->
</view>
@@ -357,12 +369,16 @@
mode=""
></image>
</view>
<view
v-if="index == '0'"
class="topSort"
:class="'c' + (index1 + 1)"
>TOP{{ index1 + 1 }}</view
>
<view class="limitDiscount" v-else-if="showLimitDiscount(item1)"
>限时折扣</view
>
<view class="goods_right" style="overflow: hidden">
<view class="name">{{ item1.name }}</view>
<!-- <view class="lookBack" v-if="index=='0'">本店销量第{{index1+1}}名</view>-->
@@ -417,16 +433,21 @@
<view v-else class="flex-between" style="flex-wrap: inherit">
<view class="money">
<view>¥</view>
<text class="money_num">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? item1.memberPrice || item1.salePrice
: item1.salePrice
}}
</text>
<view class="money_num">
<GoodsPrice
:limitDiscount="limitTimeDiscountRes"
:cart="item1"
:shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"
></GoodsPrice>
</view>
<text class="money_num" v-if="item1.unitName"
>/{{ item1.unitName }}</text
>
<text class="old-price"
>¥{{ item1.salePrice }}</text
>
<!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'"
style="font-size: 14rpx;">
「{{item1.suitNum}}{{item1.unitName}}起点」
@@ -513,6 +534,7 @@
:cartLists_count="cartLists_count"
:cartList="matchedProducts"
:showCart="showCart"
:limitDiscount="limitTimeDiscountRes"
@customevent="websocketsendMessage"
@close="showCart = !showCart"
:orderinfo="orderinfo"
@@ -772,11 +794,23 @@
</view>
<Loading :isLoading="!useSocket.isConnected" />
<ModalList></ModalList>
<recommendGoodsModal
v-if="isDataLoaded"
@onBuyClick="onBuyClick"
></recommendGoodsModal>
</view>
</template>
<script setup>
//价格计算辅助函数
import * as orderUtils from "@/utils/order-utils.js";
import BigNumber from "bignumber.js";
import GoodsPrice from "@/components/goods-price.vue";
import * as limitTimeDiscountapi from "@/common/api/market/limitTimeDiscount.js";
import ModalList from "@/components/modal-list.vue";
import recommendGoodsModal from "./components/recommend-goods-modal.vue";
import {
ref,
reactive,
@@ -784,6 +818,7 @@ import {
watchEffect,
getCurrentInstance,
computed,
provide,
watch,
} from "vue";
@@ -805,6 +840,49 @@ import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
dayjs.extend(isBetween);
//点单智能推荐
function onBuyClick(item) {
console.log("onBuyClick", item);
console.log("shopProductList", shopProductList);
let index = -1;
let index1 = -1;
if (!item.isHot) {
if (
item.type == "sku" ||
(item.type == "package" && item.groupType == "1")
) {
for (let i in shopProductList.productInfo) {
const cate = shopProductList.productInfo[i];
const goodsList = cate.productList;
const index1 = goodsList.findIndex((goods) => goods.id == item.id);
if (index1 > -1) {
index = i;
clickspecifications(item, index, index1);
break;
}
}
} else {
uni.$u.throttle(() => singleclick(item, "+"), 500);
}
} else {
if (
item.type == "sku" ||
(item.type == "package" && item.groupType == "1")
) {
for (let i in shopProductList.hots) {
const goods = shopProductList.hots[i];
if (goods.id==item.id) {
index = i;
clickspecifications(item, index, index);
break;
}
}
} else {
uni.$u.throttle(() => singleclick(item, "+"), 500);
}
}
}
// 获取全局属性
const { proxy } = getCurrentInstance();
@@ -852,8 +930,8 @@ store.updateNavbarConfig({
isTransparent: false,
hasPlaceholder: false, //是否要占位符
});
const shopInfo = uni.cache.get("shopInfo");
const shopInfo = reactive({});
Object.assign(shopInfo, uni.cache.get("shopInfo"));
const shopTable = uni.cache.get("shopTable");
const distance = uni.cache.get("distance"); //距离
@@ -1082,6 +1160,8 @@ const selectSpec = async (specType, option) => {
}
};
const shopUserInfo = ref(uni.cache.get("shopUserInfo"));
// 监听 specifications 的变化
watch(
() => specifications.item.groupSnap,
@@ -1567,8 +1647,21 @@ const updateProductQuantities = () => {
//websocket产值
const websocketsendMessage = (data) => {
console.log(data);
uni.$u.debounce(useSocket.sendMessage(data), 500);
const sendData = { ...data, is_time_discount: 0 };
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && data.discount_sale_amount*1<=0) {
if (
orderUtils.canUseLimitTimeDiscount(
data,
cartStore.limitTimeDiscount,
shopInfo,
shopUserInfo.value,
"product_id"
)
) {
sendData.is_time_discount = 1;
}
}
uni.$u.debounce(useSocket.sendMessage(sendData), 500);
};
// 用于记录已经处理过的消息的 msg_id
@@ -1627,6 +1720,7 @@ async function onMessage(Message) {
// 初始化
if (Message.operate_type == "init") {
cartStore.carts = Message.data;
cartStore.limitTimeDiscount = Message.time_dis_info;
uni.hideLoading();
isLoading.value = false;
// 初始化商品数量
@@ -1697,6 +1791,10 @@ async function onMessage(Message) {
},
});
}
if (Message.operate_type == "time_discount_save") {
console.log("time_discount_save", Message.data);
cartStore.limitTimeDiscount = Message.data;
}
//除去p 每次返回都回执消息
await websocketsendMessage({
@@ -1835,35 +1933,6 @@ function combineOrderInfoDetailMap(orderinfo) {
// 计算购物车商品费用
const totalPrices = computed(() => {
// 待支付订单
let cartone = 0;
if (orderinfo.value) {
let combinedArray = [];
for (const key in orderinfo.value.detailMap) {
if (orderinfo.value.detailMap.hasOwnProperty(key)) {
let subArray = orderinfo.value.detailMap[key];
combinedArray = [...combinedArray, ...subArray];
}
}
// 购物车总数价格
cartone = combinedArray.reduce((total, item) => {
// 是否启用会员价 0否1是
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice会员价
return (
total +
parseFloat(item.memberPrice || item.price) *
parseFloat(item.num - item.returnNum)
);
} else {
// salePrice销售价
return (
total +
parseFloat(item.price || 0) * parseFloat(item.num - item.returnNum)
);
}
}, 0);
}
// 购物车总数价格
let cart = 0;
if (matchedProducts.value.length > 0) {
@@ -1877,6 +1946,18 @@ const totalPrices = computed(() => {
}
});
}
if (limitTimeDiscountRes.value && limitTimeDiscountRes.value.id) {
//限时折扣
const price = orderUtils.returnPrice({
goods: item,
shopInfo,
limitTimeDiscountRes: limitTimeDiscountRes.value,
shopUserInfo: shopUserInfo.value,
idKey: "id",
});
console.log("限时折扣", item, price);
return total + parseFloat(price) * parseFloat(item.cartNumber);
}
// 是否启用会员价 0否1是
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice会员价
@@ -2059,6 +2140,7 @@ const productqueryProduct = async () => {
);
cartStore.setGoodsMap(i.id, i);
});
cartStore.goodsIsloading = true;
scrollTopSize.value = 0;
topArr.value = [];
@@ -2081,11 +2163,49 @@ const productqueryProduct = async () => {
}
};
provide("cartStore", cartStore);
provide("shopUserInfo", shopUserInfo);
provide("shopInfo", shopInfo);
onLoad(async (e) => {
await proxy.$onLaunched;
});
const limitTimeDiscountRes = ref(null);
function showLimitDiscount(item) {
if (!limitTimeDiscountRes.value) {
return false;
}
return orderUtils.canUseLimitTimeDiscount(
item,
limitTimeDiscountRes.value,
shopInfo,
shopUserInfo.value,
"id"
);
}
onShow(async () => {
limitTimeDiscountapi
.getConfig({
shopId: uni.cache.get("shopId"),
})
.then((res) => {
console.log("limitTimeDiscountapi", res);
if (res && typeof res == "object") {
limitTimeDiscountRes.value = res;
cartStore.limitTimeDiscount = res;
websocketsendMessage({
type: "shopping",
operate_type: "time_discount_save",
table_code: uni.cache.get("tableCode"),
shop_id: uni.cache.get("shopId"),
operate_type: "time_discount_save",
data: res,
});
}
});
// 监听页面显示和隐藏
useSocket.setOnMessage(onMessage);
useSocket.onShowconnect();
@@ -2304,6 +2424,8 @@ function toHistory() {
.panelfiveitemsex {
.panelfiveitemsex_oen {
display: flex;
align-items: baseline;
.tips {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
@@ -2412,7 +2534,8 @@ function toHistory() {
position: relative;
.left {
width: 200rpx;
// width: 200rpx;
width: 156rpx;
background-color: #f6f6f6;
line-height: normal;
box-sizing: border-box;
@@ -2554,6 +2677,7 @@ function toHistory() {
width: 200rpx;
height: 100%;
position: absolute;
border-radius: 18rpx;
top: 0;
left: 0;
z-index: 9;
@@ -2578,6 +2702,7 @@ function toHistory() {
font-size: 24rpx;
color: #ffffff;
border-radius: 20rpx 0rpx 20rpx 0rpx;
z-index: 10;
}
.topSort.c1 {
@@ -2632,10 +2757,11 @@ function toHistory() {
.money {
font-weight: bold;
font-size: 24rpx;
font-size: 20rpx;
color: #333;
display: flex;
align-items: flex-end;
align-items: baseline;
white-space: nowrap;
.money_num {
font-size: 28rpx;
@@ -3073,4 +3199,25 @@ function toHistory() {
height: 36rpx;
}
}
.old-price {
color: #999;
font-size: 24rpx;
text-decoration: line-through;
margin-left: 8rpx;
}
.limitDiscount {
background-color: #cc5617;
padding: 2rpx 10rpx;
white-space: nowrap;
text-align: center;
position: absolute;
top: 0;
left: 0;
font-weight: 400;
font-size: 24rpx;
color: #ffffff;
border-radius: 20rpx 0rpx 20rpx 0rpx;
z-index: 9;
color: #fff;
}
</style>

View File

@@ -1,6 +1,9 @@
<template>
<view class="container">
<view class="header-wrap">
<view class="u-flex" style="justify-content: flex-end;">
<view @click="toExchangeCode" class="color-333 font-12 u-m-b-26 font-700">优惠券兑换码</view>
</view>
<view class="search-wrap">
<view class="input-wrap">
<view class="icon left">
@@ -137,7 +140,11 @@ onReachBottom(() => {
getCouponList();
}
});
function toExchangeCode(){
uni.navigateTo({
url: '/user/exchange/index'
})
}
const showDetail = ref(false);
const selectListItem = ref('');
const selectListItemDetails = ref([]);

View File

@@ -63,7 +63,9 @@
<text v-if="item.bizCode == 'freeIn'">
霸王餐充值
</text>
<text v-if="item.bizCode == 'rechargeRedemption'">
兑换券充值
</text>
</view>
<view v-else>
{{item.content}}

View File

@@ -25,6 +25,7 @@
<text class="n t">{{ shopUserInfo.amount || 0 }}</text>
</view>
<view class="right">
<text class="t" @click="toduihuan">兑换码</text>
<text class="t" @click="toDetail">明细</text>
<text class="t" @click="toPwd">密码设置</text>
</view>
@@ -161,7 +162,7 @@ import * as rechargeApi from "@/common/api/market/recharge.js";
import { recharge } from "@/common/api/order/index.js";
import { joinMember } from "@/common/api/order/index.js";
import { ref, onMounted, computed, reactive, watch } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { pay } from "@/utils/pay.js";
function toShopList() {
@@ -170,6 +171,12 @@ function toShopList() {
});
}
function toduihuan() {
uni.navigateTo({
url: "/user/exchange/index",
});
}
function couponNum(list) {
return list.reduce((prve, cur) => {
return prve + cur.num;
@@ -285,7 +292,7 @@ const charge_money = computed(() => {
});
onLoad((opt) => {
Object.assign(option, opt);
init();
// init();
});
watch(
@@ -296,6 +303,9 @@ watch(
}
}
);
onShow(() => {
init();
});
</script>
<style scoped lang="scss">
@@ -367,7 +377,7 @@ watch(
display: flex;
justify-content: space-between;
position: relative;
padding-top: 40upx;
padding-top: 20rpx;
.left {
display: flex;

View File

@@ -224,7 +224,7 @@
<!-- <l-qrcode :value="wechatAcQrcode" @complete="e=>qrcodeResult(e)"/> -->
<view
class="qrcode u-flex u-col-center justify-between"
v-if="qrcode"
v-if="showQrcode"
>
<view>
<view class="color-000 font-14 font-bold">扫码关注公众号</view>
@@ -259,10 +259,8 @@ import * as rechargeApi from "@/common/api/market/recharge.js";
import { pointsShopList } from "@/common/api/account/points.js";
const qrcode = ref("");
function qrcodeResult(res) {
console.log("qrcodeResult", res);
qrcode.value = res
}
@@ -470,7 +468,14 @@ onShow(() => {
getData();
});
const qrcode = ref("");
const showQrcode = computed(() => {
const followIndex = uni.cache.get("followIndex");
if ( followIndex == "mine" && qrcode.value) {
return true;
}
});
</script>
<style scoped lang="scss">