Merge branch 'prod' of https://newgitea.sxczgkj.cn/czg_team/cashier_wx into test
This commit is contained in:
@@ -3,19 +3,11 @@
|
|||||||
<view class="paymentMethod">
|
<view class="paymentMethod">
|
||||||
<view class="paymentMethod_content">
|
<view class="paymentMethod_content">
|
||||||
<view class="paymentMethod_title">支付方式</view>
|
<view class="paymentMethod_title">支付方式</view>
|
||||||
<up-radio-group
|
<up-radio-group v-model="radiovalue.type" iconPlacement="right" @change="groupChanges" :size="28"
|
||||||
v-model="radiovalue.type"
|
placement="column">
|
||||||
iconPlacement="right"
|
|
||||||
@change="groupChanges"
|
|
||||||
:size="28"
|
|
||||||
placement="column"
|
|
||||||
>
|
|
||||||
<block v-for="(item, index) in paymentMethodList" :key="index">
|
<block v-for="(item, index) in paymentMethodList" :key="index">
|
||||||
<view
|
<view class="method_list" @click="groupChanges(item.type)"
|
||||||
class="method_list"
|
:class="{ disabled: returnDisabled(item) }">
|
||||||
@click="groupChanges(item.type)"
|
|
||||||
:class="{ disabled: returnDisabled(item) }"
|
|
||||||
>
|
|
||||||
<view class="method_list_top">
|
<view class="method_list_top">
|
||||||
<view class="method_list_top_left">
|
<view class="method_list_top_left">
|
||||||
<image class="icon" :src="item.url" mode="aspectFill" />
|
<image class="icon" :src="item.url" mode="aspectFill" />
|
||||||
@@ -23,19 +15,13 @@
|
|||||||
<view class="name"> {{ item.name }} </view>
|
<view class="name"> {{ item.name }} </view>
|
||||||
<view class="method_list_bom" v-if="item.name == '余额支付'">
|
<view class="method_list_bom" v-if="item.name == '余额支付'">
|
||||||
<text class="balance">
|
<text class="balance">
|
||||||
当前余额¥{{ orderVIP ? orderVIP.amount || 0 : 0 }}</text
|
当前余额¥{{ orderVIP ? orderVIP.amount || 0 : 0 }}</text>
|
||||||
>
|
|
||||||
<text class="topUpNow" @click="goRecharge">去充值</text>
|
<text class="topUpNow" @click="goRecharge">去充值</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<up-radio
|
<up-radio :disabled="returnDisabled(item)" activeColor="#E8AD7B" icon-size="18" size="18"
|
||||||
:disabled="returnDisabled(item)"
|
:name="item.type">
|
||||||
activeColor="#E8AD7B"
|
|
||||||
icon-size="18"
|
|
||||||
size="18"
|
|
||||||
:name="item.type"
|
|
||||||
>
|
|
||||||
</up-radio>
|
</up-radio>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -56,6 +42,7 @@ import {
|
|||||||
watch,
|
watch,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
defineExpose,
|
defineExpose,
|
||||||
|
onMounted // 新增:用于初始化默认值
|
||||||
} from "vue";
|
} from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -77,18 +64,17 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
disablePayType: {
|
disablePayType: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => {
|
default: () => [],
|
||||||
return [];
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 工具函数 - 深拷贝对象(切断引用)
|
||||||
|
const deepClone = (obj) => {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
};
|
||||||
|
|
||||||
function returnDisabled(item) {
|
function returnDisabled(item) {
|
||||||
if (props.disablePayType.includes(item.name)) {
|
return props.disablePayType.includes(item.name);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderVIP = ref(null);
|
const orderVIP = ref(null);
|
||||||
@@ -101,6 +87,7 @@ const orderVIPfun = (data) => {
|
|||||||
orderVIP.value = data;
|
orderVIP.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 支付方式列表(保持不变)
|
||||||
const paymentMethodList = ref([
|
const paymentMethodList = ref([
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
{
|
{
|
||||||
@@ -126,80 +113,94 @@ const paymentMethodList = ref([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const paymentMethodName = ref([
|
// 修复核心:defineModel 先声明为空对象(无本地变量依赖)
|
||||||
{
|
|
||||||
name: "余额支付",
|
|
||||||
type: 1,
|
|
||||||
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png",
|
|
||||||
payType: "accountPay",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "微信支付",
|
|
||||||
type: 2,
|
|
||||||
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/weChat.png",
|
|
||||||
payType: "wechatPay",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "支付宝支付",
|
|
||||||
type: 3,
|
|
||||||
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/alipay.png",
|
|
||||||
payType: "aliPay",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
// const radiovalue = ref(2); // 支付方式
|
|
||||||
const radiovalue = defineModel({
|
const radiovalue = defineModel({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => ({}), // 基础默认值,不引用任何本地变量
|
||||||
return {
|
|
||||||
name: "微信支付",
|
|
||||||
type: 2,
|
|
||||||
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/weChat.png",
|
|
||||||
payType: "wechatPay",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 新增:在 onMounted 中初始化 defineModel 的真实默认值
|
||||||
|
onMounted(() => {
|
||||||
|
// 1. 找到默认的微信支付项(兼容不同平台)
|
||||||
|
let defaultItem = paymentMethodList.value.find(item => item.type === 2);
|
||||||
|
// 兜底:如果没有微信支付(如支付宝平台),取第一个可用项
|
||||||
|
if (!defaultItem) {
|
||||||
|
defaultItem = paymentMethodList.value[0];
|
||||||
|
}
|
||||||
|
// 2. 深拷贝后赋值,避免引用污染
|
||||||
|
if (defaultItem) {
|
||||||
|
radiovalue.value = deepClone(defaultItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 触发一次 disablePayType 的监听逻辑(确保初始值符合禁用规则)
|
||||||
|
const canUsePayType = paymentMethodList.value.filter((item) => {
|
||||||
|
return !props.disablePayType.includes(item.name);
|
||||||
|
});
|
||||||
|
if (canUsePayType.length > 0 && !canUsePayType.find(v => v.type === radiovalue.value.type)) {
|
||||||
|
radiovalue.value = deepClone(canUsePayType[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 修复:watch 监听 disablePayType(调整逻辑,依赖 radiovalue 已初始化)
|
||||||
watch(
|
watch(
|
||||||
() => props.disablePayType,
|
() => props.disablePayType,
|
||||||
(newval) => {
|
(newval) => {
|
||||||
console.log('props.disablePayType',newval)
|
console.log('props.disablePayType', newval);
|
||||||
|
// 加兜底:radiovalue 未初始化时不处理
|
||||||
|
if (Object.keys(radiovalue.value).length === 0) return;
|
||||||
|
|
||||||
const canUsePayType = paymentMethodList.value.filter((item) => {
|
const canUsePayType = paymentMethodList.value.filter((item) => {
|
||||||
return !newval.includes(item.name);
|
return !newval.includes(item.name);
|
||||||
});
|
});
|
||||||
if (canUsePayType.find((v) => v.type == radiovalue.value.type)) {
|
if (canUsePayType.length === 0) return;
|
||||||
return;
|
|
||||||
|
const currentValid = canUsePayType.find((v) => v.type === radiovalue.value.type);
|
||||||
|
if (!currentValid) {
|
||||||
|
radiovalue.value = deepClone(canUsePayType[0]);
|
||||||
}
|
}
|
||||||
radiovalue.value = canUsePayType[0];
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: false, // 改为 false,避免在 radiovalue 初始化前执行
|
||||||
|
deep: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// * 监听支付方式切换
|
// 支付方式切换逻辑(保持之前的修复)
|
||||||
const groupChanges = (type) => {
|
const groupChanges = (type) => {
|
||||||
if (props.freeCheck && type == 1) {
|
console.log('type(原始入参)', type);
|
||||||
|
const typeNum = Number(type);
|
||||||
|
if (isNaN(typeNum)) {
|
||||||
|
uni.showToast({ title: "支付方式选择异常", icon: "none" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const item = paymentMethodList.value.find((v) => v.type == type);
|
|
||||||
|
|
||||||
if (item && returnDisabled(item)) {
|
if (props.freeCheck && typeNum === 1) {
|
||||||
uni.showToast({
|
|
||||||
title: "当前支付方式不可用",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if (props.payAmount <= 0 && type != 1) {
|
|
||||||
// return;
|
console.log('paymentMethodList', paymentMethodList.value);
|
||||||
// }
|
const item = paymentMethodList.value.find((v) => v.type === typeNum);
|
||||||
radiovalue.value = item;
|
console.log('匹配到的item', item);
|
||||||
|
|
||||||
|
if (!item) {
|
||||||
|
uni.showToast({ title: "当前支付方式不存在", icon: "none" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnDisabled(item)) {
|
||||||
|
uni.showToast({ title: "当前支付方式不可用", icon: "none" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
radiovalue.value = deepClone(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(()=> radiovalue.value.type,(newval)=>{
|
// 监听 radiovalue 变化触发事件
|
||||||
|
watch(() => radiovalue.value.type, (newval) => {
|
||||||
|
if (newval) { // 加兜底:避免初始值为空时触发
|
||||||
emits("groupChange", radiovalue.value);
|
emits("groupChange", radiovalue.value);
|
||||||
})
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 去充值
|
// 去充值
|
||||||
const goRecharge = () => {
|
const goRecharge = () => {
|
||||||
@@ -207,23 +208,10 @@ const goRecharge = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/user/member/czzx?shopId=" + orderVIP.value.shopId,
|
url: `/pages/user/member/czzx?shopId=${orderVIP.value?.shopId || ''}`,
|
||||||
});
|
});
|
||||||
// if (orderVIP.value.isVip) {
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: "/pages/user/member/czzx?shopId=" + orderVIP.value.shopId,
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: "/user/vip/buy-vip?shopId=" + orderVIP.value.shopId,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// uni.pro.navigateTo('user/member/index', {
|
|
||||||
// shopId: orderVIP.value.shopId
|
|
||||||
// })
|
|
||||||
};
|
};
|
||||||
// 将方法暴露给父组件
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
groupChanges,
|
groupChanges,
|
||||||
orderVIPfun,
|
orderVIPfun,
|
||||||
@@ -231,7 +219,7 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.paymentMethod {
|
.paymentMethod {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
@@ -252,9 +240,11 @@ defineExpose({
|
|||||||
.method_list {
|
.method_list {
|
||||||
padding: 40rpx 0;
|
padding: 40rpx 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&.disabled {
|
&.disabled {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.method_list_top {
|
.method_list_top {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -301,9 +291,10 @@ defineExpose({
|
|||||||
.method_list:nth-child(odd) {
|
.method_list:nth-child(odd) {
|
||||||
border-bottom: 2rpx solid #e5e5e5;
|
border-bottom: 2rpx solid #e5e5e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.method_list:nth-child(2) {
|
.method_list:nth-child(2) {
|
||||||
padding-bottom: 22rpx;
|
padding-bottom: 22rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
<text class="productSkuName" v-if="item.skuName">{{
|
<text class="productSkuName" v-if="item.skuName">{{
|
||||||
item.skuName
|
item.skuName
|
||||||
}}</text>
|
}}</text>
|
||||||
|
<view class="color-666 u-font-24 u-m-t-4" style="max-width: 328rpx;word-break: break-all;" v-if="item.remark">备注:{{item.remark}}</view>
|
||||||
<template v-if="showLimitDiscount(item)">
|
<template v-if="showLimitDiscount(item)">
|
||||||
<text
|
<text
|
||||||
class="limitDiscount-time"
|
class="limitDiscount-time"
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
</view> -->
|
</view> -->
|
||||||
<view class="status-wrap">
|
<view class="status-wrap">
|
||||||
<view class="item" :class="{ active: querForm.statusActiveIndex == 0 }" @click="tabChange(0)">
|
<view class="item" :class="{ active: querForm.statusActiveIndex == 0 }" @click="tabChange(0)">
|
||||||
<text class="t">商品兑换券 {{ returnSelNumber(0) }}</text>
|
<text class="t">商品兑换券</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" :class="{ active: querForm.statusActiveIndex == 1 }" @click="tabChange(1)">
|
<view class="item" :class="{ active: querForm.statusActiveIndex == 1 }" @click="tabChange(1)">
|
||||||
<text class="t">折扣优惠券{{ returnSelNumber(1) }}</text>
|
<text class="t">折扣优惠券</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="icon-wrap" :style="{
|
<view class="icon-wrap" :style="{
|
||||||
|
|||||||
97
pages/product/components/modal.vue
Normal file
97
pages/product/components/modal.vue
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<up-popup
|
||||||
|
:show="show"
|
||||||
|
mode="center"
|
||||||
|
:safeAreaInsetBottom="mode === 'bottom' ? true : false"
|
||||||
|
>
|
||||||
|
<view class="popup-content">
|
||||||
|
<view class="top u-flex u-row-between">
|
||||||
|
<text class="font-bold u-font-32 color-333">{{ title }}</text>
|
||||||
|
<up-icon size="18" name="close" @click="show = false"></up-icon>
|
||||||
|
</view>
|
||||||
|
<up-line></up-line>
|
||||||
|
<scroll-view style="max-height: 50vh" :scroll-y="true">
|
||||||
|
<slot></slot>
|
||||||
|
</scroll-view>
|
||||||
|
<template v-if="showBottom">
|
||||||
|
<up-line></up-line>
|
||||||
|
|
||||||
|
<view class="bottom">
|
||||||
|
<view class="btn cancel" @click="close">{{ cancelText }}</view>
|
||||||
|
<view class="btn success" @click="confirm">{{ confirmText }}</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
const props = defineProps({
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
default: "center",
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: "标题",
|
||||||
|
},
|
||||||
|
confirmText: {
|
||||||
|
type: String,
|
||||||
|
default: "确认",
|
||||||
|
},
|
||||||
|
cancelText: {
|
||||||
|
type: String,
|
||||||
|
default: "取消",
|
||||||
|
},
|
||||||
|
showBottom: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const show = defineModel({
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["close", "confirm"]);
|
||||||
|
function close() {
|
||||||
|
show.value = false;
|
||||||
|
emits("close");
|
||||||
|
}
|
||||||
|
function confirm() {
|
||||||
|
emits("confirm");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.popup-content {
|
||||||
|
background: #fff;
|
||||||
|
width: 640rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
}
|
||||||
|
.top {
|
||||||
|
padding: 40rpx 48rpx;
|
||||||
|
}
|
||||||
|
.bottom {
|
||||||
|
padding: 48rpx 52rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 50rpx;
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
padding: 18rpx 60rpx;
|
||||||
|
border-radius: 100rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
border: 2rpx solid transparent;
|
||||||
|
&.success {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
&.cancel {
|
||||||
|
border-color: $my-main-color;
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,13 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<up-popup
|
<up-popup :show="showCart" :round="20" :safeAreaInsetBottom="false" :zIndex="98" :overlayStyle="{ zIndex: 98 }"
|
||||||
:show="showCart"
|
@close="close">
|
||||||
:round="20"
|
|
||||||
:safeAreaInsetBottom="false"
|
|
||||||
:zIndex="98"
|
|
||||||
:overlayStyle="{ zIndex: 98 }"
|
|
||||||
@close="close"
|
|
||||||
>
|
|
||||||
<view class="cart-list-wrap">
|
<view class="cart-list-wrap">
|
||||||
<!-- <view class="cart-header flex-between">
|
<!-- <view class="cart-header flex-between">
|
||||||
<view class="num">已点 {{ cartLists_count }} 份</view>
|
<view class="num">已点 {{ cartLists_count }} 份</view>
|
||||||
@@ -26,23 +20,14 @@
|
|||||||
<text class="clear-btn">清空购物车</text>
|
<text class="clear-btn">清空购物车</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="shop-item" v-for="(item, index) in cartList" :key="item.id">
|
||||||
class="shop-item"
|
|
||||||
v-for="(item, index) in cartList"
|
|
||||||
:key="item.id"
|
|
||||||
>
|
|
||||||
<view class="shop-item-content">
|
<view class="shop-item-content">
|
||||||
<view class="cover" v-if="item.productId != -999">
|
<view class="cover" v-if="item.productId != -999">
|
||||||
<view class="limit-discount" v-if="showLimitDiscount(item)">
|
<view class="limit-discount" v-if="showLimitDiscount(item)">
|
||||||
限时折扣
|
限时折扣
|
||||||
</view>
|
</view>
|
||||||
<up-image
|
<up-image :src="item.coverImg" width="124rpx" height="124rpx" mode="aspectFill"
|
||||||
:src="item.coverImg"
|
radius="10"></up-image>
|
||||||
width="124rpx"
|
|
||||||
height="124rpx"
|
|
||||||
mode="aspectFill"
|
|
||||||
radius="10"
|
|
||||||
></up-image>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="name">
|
<view class="name">
|
||||||
@@ -58,34 +43,27 @@
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="select-sku-wrap" v-if="item.type == 'package'">
|
<view class="select-sku-wrap" v-if="item.type == 'package'">
|
||||||
<view
|
<view v-for="(a, b) in dataprocessing(item.cartListinfo)" :key="b">
|
||||||
v-for="(a, b) in dataprocessing(item.cartListinfo)"
|
|
||||||
:key="b"
|
|
||||||
>
|
|
||||||
<!-- <view>{{a.title}}</view> -->
|
<!-- <view>{{a.title}}</view> -->
|
||||||
<text
|
<text v-for="i in a.goods" :key="i.proId" style="margin-left: 4rpx">
|
||||||
v-for="i in a.goods"
|
|
||||||
:key="i.proId"
|
|
||||||
style="margin-left: 4rpx"
|
|
||||||
>
|
|
||||||
{{ i.proName }}
|
{{ i.proName }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="u-font-24 color-666 u-flex">
|
||||||
|
<text style="max-width: 296rpx;" class="u-line-1">备注:{{item.cartListinfo.remark||''}}</text>
|
||||||
|
<image @click="editRemark(item)"
|
||||||
|
src="https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/3/9fe4df7c6c8b4290aa5f78282b143900.png"
|
||||||
|
style="width: 34rpx;height: 34rpx;"></image>
|
||||||
|
</view>
|
||||||
<view class="price-wrap" style="padding-top: 0">
|
<view class="price-wrap" style="padding-top: 0">
|
||||||
<view class="price">
|
<view class="price">
|
||||||
<text class="i">¥</text>
|
<text class="i">¥</text>
|
||||||
<goodsPrice
|
<goodsPrice :limitDiscount="limitDiscount" :cart="item"
|
||||||
:limitDiscount="limitDiscount"
|
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></goodsPrice>
|
||||||
:cart="item"
|
|
||||||
:shopUserInfo="shopUserInfo"
|
|
||||||
:shopInfo="shopInfo"
|
|
||||||
></goodsPrice>
|
|
||||||
|
|
||||||
<text
|
<text class="originalprice"
|
||||||
class="originalprice" v-if="showLimitDiscount(item)"
|
v-if="showLimitDiscount(item)">{{ item.salePrice }}</text>
|
||||||
>{{ item.salePrice }}</text
|
|
||||||
>
|
|
||||||
|
|
||||||
<!-- <text class="originalprice"
|
<!-- <text class="originalprice"
|
||||||
v-if="item.originPrice">¥{{item.originPrice}}</text>
|
v-if="item.originPrice">¥{{item.originPrice}}</text>
|
||||||
@@ -94,33 +72,21 @@
|
|||||||
|
|
||||||
<view class="operation-wrap">
|
<view class="operation-wrap">
|
||||||
<view class="btn">
|
<view class="btn">
|
||||||
<up-icon
|
<up-icon color="#E8AD7B" name="minus-circle" size="18"></up-icon>
|
||||||
color="#E8AD7B"
|
<view class="btnClick" @click="cartListadd(item, '-')"></view>
|
||||||
name="minus-circle"
|
|
||||||
size="18"
|
|
||||||
></up-icon>
|
|
||||||
<view
|
|
||||||
class="btnClick"
|
|
||||||
@click="cartListadd(item, '-')"
|
|
||||||
></view>
|
|
||||||
</view>
|
</view>
|
||||||
<text class="num">{{ ifcartNumber(item) }}</text>
|
<text class="num">{{ ifcartNumber(item) }}</text>
|
||||||
<view class="btn" v-if="item.type != 'package'">
|
<view class="btn" v-if="item.type != 'package'">
|
||||||
<!-- <up-icon name="plus-circle-fill"
|
<!-- <up-icon name="plus-circle-fill"
|
||||||
:color="{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? '#CECECE' : '#E9AB7A'"
|
:color="{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? '#CECECE' : '#E9AB7A'"
|
||||||
size="25"></up-icon> -->
|
size="25"></up-icon> -->
|
||||||
<up-icon
|
<up-icon name="plus-circle-fill" color="#E8AD7B"
|
||||||
name="plus-circle-fill"
|
size="18"></up-icon>
|
||||||
color="#E8AD7B"
|
<view class="btnClick" @click="cartListadd(item, '+')"></view>
|
||||||
size="18"
|
|
||||||
></up-icon>
|
|
||||||
<view
|
|
||||||
class="btnClick"
|
|
||||||
@click="cartListadd(item, '+')"
|
|
||||||
></view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -129,19 +95,66 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</up-popup>
|
</up-popup>
|
||||||
|
|
||||||
|
|
||||||
|
<model v-model="modelData.show" title="单品备注" @confirm="modelDataConfirm">
|
||||||
|
<view class="u-p-40">
|
||||||
|
<up-input v-model="modelData.item.cartListinfo.remark" placeholder="备注(50字以内)" :maxlength="50"></up-input>
|
||||||
|
</view>
|
||||||
|
</model>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineProps, computed, defineEmits, watch } from "vue";
|
import {
|
||||||
import { productStore } from "@/stores/user.js";
|
ref,
|
||||||
import goodsPrice from "@/components/goods-price.vue";
|
defineProps,
|
||||||
import * as orderUtils from "@/utils/order-utils.js";
|
computed,
|
||||||
|
defineEmits,
|
||||||
|
watch,
|
||||||
|
reactive
|
||||||
|
} from "vue";
|
||||||
|
import {
|
||||||
|
productStore
|
||||||
|
} from "@/stores/user.js";
|
||||||
|
import goodsPrice from "@/components/goods-price.vue";
|
||||||
|
import * as orderUtils from "@/utils/order-utils.js";
|
||||||
|
import model from './modal.vue'
|
||||||
|
import _ from 'lodash'
|
||||||
|
const modelData = reactive({
|
||||||
|
show: false,
|
||||||
|
item: {
|
||||||
|
cartListinfo:{
|
||||||
|
remark: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 定义自定义事件
|
function editRemark(item) {
|
||||||
const emits = defineEmits(["customevent", "close", "clickcancelOrder"]);
|
console.log('editRemark', item)
|
||||||
|
modelData.item = _.cloneDeep(item)
|
||||||
|
modelData.show = true
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
function modelDataConfirm() {
|
||||||
|
emits('customevent', {
|
||||||
|
id: modelData.item.cartListinfo.id,
|
||||||
|
product_id: modelData.item.cartListinfo.product_id,
|
||||||
|
sku_id: modelData.item.cartListinfo.sku_id,
|
||||||
|
number: modelData.item.cartListinfo.number,
|
||||||
|
type: "shopping",
|
||||||
|
table_code: uni.cache.get('tableCode'),
|
||||||
|
shop_id: uni.cache.get('shopId'),
|
||||||
|
operate_type: "edit",
|
||||||
|
remark:modelData.item.cartListinfo.remark
|
||||||
|
})
|
||||||
|
modelData.show = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义自定义事件
|
||||||
|
const emits = defineEmits(["customevent", "close", "clickcancelOrder", 'updateRemark']);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
nextFullAmountActivty: {
|
nextFullAmountActivty: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
@@ -166,11 +179,11 @@ const props = defineProps({
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: {},
|
default: {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function showLimitDiscount(item){
|
function showLimitDiscount(item) {
|
||||||
if (!props.limitDiscount||!props.limitDiscount.id) {
|
if (!props.limitDiscount || !props.limitDiscount.id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return orderUtils.canUseLimitTimeDiscount(
|
return orderUtils.canUseLimitTimeDiscount(
|
||||||
@@ -180,21 +193,20 @@ function showLimitDiscount(item){
|
|||||||
shopUserInfo.value,
|
shopUserInfo.value,
|
||||||
"id"
|
"id"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.cartList,
|
() => props.cartList,
|
||||||
(newCartList) => {
|
(newCartList) => {
|
||||||
console.log("购物车数据变化", newCartList);
|
console.log("购物车数据变化", newCartList);
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
deep: true,
|
deep: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const shopInfo = ref(uni.cache.get("shopInfo"));
|
const shopInfo = ref(uni.cache.get("shopInfo"));
|
||||||
const shopUserInfo = ref(uni.cache.get("shopUserInfo"));
|
const shopUserInfo = ref(uni.cache.get("shopUserInfo"));
|
||||||
|
|
||||||
function returnRealPrice(cart) {
|
function returnRealPrice(cart) {
|
||||||
const price = orderUtils.returnPrice({
|
const price = orderUtils.returnPrice({
|
||||||
goods: cart,
|
goods: cart,
|
||||||
shopInfo: shopInfo,
|
shopInfo: shopInfo,
|
||||||
@@ -205,10 +217,10 @@ function returnRealPrice(cart) {
|
|||||||
console.log("returnRealPrice", price);
|
console.log("returnRealPrice", price);
|
||||||
}
|
}
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义 ifcartNumber 计算属性方法
|
// 定义 ifcartNumber 计算属性方法
|
||||||
const ifcartNumber = computed(() => {
|
const ifcartNumber = computed(() => {
|
||||||
return (item) => {
|
return (item) => {
|
||||||
// 如果 item 为空或者 cartNumber 不是字符串类型,返回 0
|
// 如果 item 为空或者 cartNumber 不是字符串类型,返回 0
|
||||||
if (!item || typeof item.cartNumber !== "string") {
|
if (!item || typeof item.cartNumber !== "string") {
|
||||||
@@ -230,13 +242,13 @@ const ifcartNumber = computed(() => {
|
|||||||
// 如果类型不匹配,返回原始值
|
// 如果类型不匹配,返回原始值
|
||||||
return item.cartNumber;
|
return item.cartNumber;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
emits("close", false);
|
emits("close", false);
|
||||||
};
|
};
|
||||||
// 购物车加减
|
// 购物车加减
|
||||||
const cartListadd = async (item, i) => {
|
const cartListadd = async (item, i) => {
|
||||||
// 是否起售 如果小于或者大于都是1
|
// 是否起售 如果小于或者大于都是1
|
||||||
const cartNumberFloat = parseFloat(item.cartNumber);
|
const cartNumberFloat = parseFloat(item.cartNumber);
|
||||||
const suitNum =
|
const suitNum =
|
||||||
@@ -247,21 +259,18 @@ const cartListadd = async (item, i) => {
|
|||||||
type: "shopping",
|
type: "shopping",
|
||||||
table_code: uni.cache.get("tableCode"),
|
table_code: uni.cache.get("tableCode"),
|
||||||
shop_id: uni.cache.get("shopId"),
|
shop_id: uni.cache.get("shopId"),
|
||||||
operate_type:
|
operate_type: calculateValue(item.cartNumber, i, suitNum) == "del" ?
|
||||||
calculateValue(item.cartNumber, i, suitNum) == "del"
|
"del" : item.cartListId && item.cartNumber > 0 ?
|
||||||
? "del"
|
"edit" : "add",
|
||||||
: item.cartListId && item.cartNumber > 0
|
|
||||||
? "edit"
|
|
||||||
: "add",
|
|
||||||
product_id: item.id,
|
product_id: item.id,
|
||||||
sku_id: item.skuId,
|
sku_id: item.skuId,
|
||||||
number: await calculateValue(item.cartNumber, i, suitNum),
|
number: await calculateValue(item.cartNumber, i, suitNum),
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
suitNum: item.suitNum,
|
suitNum: item.suitNum,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataprocessing = computed(() => {
|
const dataprocessing = computed(() => {
|
||||||
return (item) => {
|
return (item) => {
|
||||||
let res = null;
|
let res = null;
|
||||||
try {
|
try {
|
||||||
@@ -271,9 +280,9 @@ const dataprocessing = computed(() => {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const clickcancelOrder = (i, key) => {
|
const clickcancelOrder = (i, key) => {
|
||||||
emits("clickcancelOrder", {
|
emits("clickcancelOrder", {
|
||||||
i,
|
i,
|
||||||
key,
|
key,
|
||||||
@@ -284,9 +293,9 @@ const clickcancelOrder = (i, key) => {
|
|||||||
shop_id: uni.cache.get("shopId"),
|
shop_id: uni.cache.get("shopId"),
|
||||||
operate_type: "clearOrder",
|
operate_type: "clearOrder",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateValue = (cartNumber, i, step = 1) => {
|
const calculateValue = (cartNumber, i, step = 1) => {
|
||||||
if (i == "+") {
|
if (i == "+") {
|
||||||
const result = parseFloat(cartNumber) + parseFloat(step);
|
const result = parseFloat(cartNumber) + parseFloat(step);
|
||||||
return result.toFixed(2);
|
return result.toFixed(2);
|
||||||
@@ -295,10 +304,10 @@ const calculateValue = (cartNumber, i, step = 1) => {
|
|||||||
const result = parseFloat(cartNumber) - parseFloat(step);
|
const result = parseFloat(cartNumber) - parseFloat(step);
|
||||||
return result == 0 ? "del" : result.toFixed(2);
|
return result == 0 ? "del" : result.toFixed(2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 菜品备注修改
|
// 菜品备注修改
|
||||||
const productBlur = (item) => {
|
const productBlur = (item) => {
|
||||||
let params = {
|
let params = {
|
||||||
skuId: item.skuId,
|
skuId: item.skuId,
|
||||||
num: item.number, //数量
|
num: item.number, //数量
|
||||||
@@ -311,26 +320,27 @@ const productBlur = (item) => {
|
|||||||
tableId: this.tableCode,
|
tableId: this.tableCode,
|
||||||
};
|
};
|
||||||
this.$emit("addCart", params);
|
this.$emit("addCart", params);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 清空购物车
|
// 清空购物车
|
||||||
const cartclear = () => {
|
const cartclear = () => {
|
||||||
emits("customevent", {
|
emits("customevent", {
|
||||||
type: "shopping",
|
type: "shopping",
|
||||||
table_code: uni.cache.get("tableCode"),
|
table_code: uni.cache.get("tableCode"),
|
||||||
shop_id: uni.cache.get("shopId"),
|
shop_id: uni.cache.get("shopId"),
|
||||||
operate_type: "cleanup",
|
operate_type: "cleanup",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.clear-btn {
|
.clear-btn {
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.cart-list-wrap {
|
|
||||||
|
.cart-list-wrap {
|
||||||
.cart-header {
|
.cart-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 72rpx;
|
height: 72rpx;
|
||||||
@@ -364,9 +374,11 @@ const cartclear = () => {
|
|||||||
|
|
||||||
.list-wrap {
|
.list-wrap {
|
||||||
padding: 0 28rpx;
|
padding: 0 28rpx;
|
||||||
&.pb-20{
|
|
||||||
|
&.pb-20 {
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ShoppingCart {
|
.ShoppingCart {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -390,8 +402,10 @@ const cartclear = () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.cover {
|
.cover {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.limit-discount {
|
.limit-discount {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #cc5617;
|
background: #cc5617;
|
||||||
@@ -454,7 +468,7 @@ const cartclear = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.price-wrap {
|
.price-wrap {
|
||||||
margin-top: 16rpx;
|
margin-top: 8rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -470,8 +484,7 @@ const cartclear = () => {
|
|||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.i {
|
.i {}
|
||||||
}
|
|
||||||
|
|
||||||
.price {
|
.price {
|
||||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
@@ -918,5 +931,5 @@ const cartclear = () => {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1181,7 +1181,7 @@
|
|||||||
memberPrice: specifications.item.memberPrice,
|
memberPrice: specifications.item.memberPrice,
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
product_type: specifications.item.type,
|
product_type: specifications.item.type,
|
||||||
is_time_discount: specifications.item.is_time_discount
|
is_time_discount: specifications.item.is_time_discount,
|
||||||
});
|
});
|
||||||
// 清空套餐选中
|
// 清空套餐选中
|
||||||
selectedGroupSnap.value = [];
|
selectedGroupSnap.value = [];
|
||||||
@@ -1201,7 +1201,7 @@
|
|||||||
memberPrice: specifications.item.memberPrice,
|
memberPrice: specifications.item.memberPrice,
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
product_type: specifications.item.type,
|
product_type: specifications.item.type,
|
||||||
is_time_discount: specifications.item.is_time_discount
|
is_time_discount: specifications.item.is_time_discount,
|
||||||
});
|
});
|
||||||
showShopsku.value = false;
|
showShopsku.value = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user