修复bug
This commit is contained in:
+13
-8
@@ -317,6 +317,10 @@
|
||||
"discountedPrice": "Actual selling price:",
|
||||
"enterPlaceholder": "Enter",
|
||||
"frequentlyBoughtTogether": "Frequently Bought Together",
|
||||
"specManagement": "Specification Management",
|
||||
"priceAutoFillTip": "Price is auto-filled from the first specification",
|
||||
"originalPriceAutoFillTip": "Auto-filled from the first specification's list price",
|
||||
"discountPriceAutoFillTip": "Auto-filled from the first specification's member price",
|
||||
"itemActiveDesc": "Customers can view and order this dish",
|
||||
"itemIsActive": "Item is Active",
|
||||
"itemIsNot": "The dish is not activated",
|
||||
@@ -346,19 +350,20 @@
|
||||
},
|
||||
"add-item": {
|
||||
"add": "Add",
|
||||
"addSideDishes": "+ Add Side Dishes",
|
||||
"enterPlaceholder": "Enter",
|
||||
"isRequired": "Is Required",
|
||||
"name": "Name",
|
||||
"price": "Price($)",
|
||||
"sideDish": "Side Dish",
|
||||
"sideDishesFlavorValue": "Side Dishes/Flavor Value:",
|
||||
"title": "Add Side Dish",
|
||||
"typeOfSideDishes": "Type of Side Dishes/Flavor:",
|
||||
"memberPrice": "Member price($)",
|
||||
"actualSalePrice": "Actual sale price($)",
|
||||
"spec": "Specification",
|
||||
"specValue": "Specification Value:",
|
||||
"title": "Add Specification",
|
||||
"specType": "Specification Type:",
|
||||
"validation": {
|
||||
"addAtLeastOne": "Please add at least one side dish",
|
||||
"completeAllFields": "Please complete all fields for side dish {index}",
|
||||
"enterSideDishName": "Please enter side dish name for item {index}",
|
||||
"addAtLeastOne": "Please add at least one specification",
|
||||
"completeAllFields": "Please complete all fields for specification {index}",
|
||||
"enterSpecName": "Please enter specification name for item {index}",
|
||||
"submittedSuccessfully": "Submitted successfully"
|
||||
},
|
||||
"value": "Value"
|
||||
|
||||
+13
-8
@@ -317,6 +317,10 @@
|
||||
"discountedPrice": "实际销售价格:",
|
||||
"enterPlaceholder": "输入",
|
||||
"frequentlyBoughtTogether": "经常一起购买",
|
||||
"specManagement": "规格管理",
|
||||
"priceAutoFillTip": "价格由第一项规格自动填充",
|
||||
"originalPriceAutoFillTip": "由第一项规格中的「价格」自动填充",
|
||||
"discountPriceAutoFillTip": "由第一项规格中的「会员价」自动填充",
|
||||
"itemActiveDesc": "客户可以查看并订购此菜品",
|
||||
"itemIsActive": "菜品已激活",
|
||||
"itemIsNot": "菜品未激活",
|
||||
@@ -346,19 +350,20 @@
|
||||
},
|
||||
"add-item": {
|
||||
"add": "添加",
|
||||
"addSideDishes": "+ 添加配菜",
|
||||
"enterPlaceholder": "输入",
|
||||
"isRequired": "是否必选",
|
||||
"name": "名称",
|
||||
"price": "价格($)",
|
||||
"sideDish": "配菜",
|
||||
"sideDishesFlavorValue": "配菜/口味值:",
|
||||
"title": "添加配菜",
|
||||
"typeOfSideDishes": "配菜类型/口味:",
|
||||
"memberPrice": "会员价($)",
|
||||
"actualSalePrice": "实际支付价格($)",
|
||||
"spec": "规格",
|
||||
"specValue": "规格值:",
|
||||
"title": "添加规格",
|
||||
"specType": "规格类型:",
|
||||
"validation": {
|
||||
"addAtLeastOne": "请至少添加一个配菜",
|
||||
"completeAllFields": "请完成配菜 {index} 的所有字段",
|
||||
"enterSideDishName": "请输入配菜 {index} 的配菜名称",
|
||||
"addAtLeastOne": "请至少添加一个规格",
|
||||
"completeAllFields": "请完成规格 {index} 的所有字段",
|
||||
"enterSpecName": "请输入规格 {index} 的规格名称",
|
||||
"submittedSuccessfully": "提交成功"
|
||||
},
|
||||
"value": "值"
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
"name" : "CHEFLINK Merchant",
|
||||
"appid" : "__UNI__BB8E3C9",
|
||||
"description" : "美国外卖商户端",
|
||||
"versionName" : "2.0.1",
|
||||
"versionCode" : 201,
|
||||
"versionName" : "3.0.0",
|
||||
"versionCode" : 300,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
||||
@@ -80,15 +80,24 @@ const btnLoading = ref(false)
|
||||
function codeSubmit() {
|
||||
// console.log(data)
|
||||
btnLoading.value = true
|
||||
const body: Record<string, any> = {
|
||||
...logicStore.registerForm,
|
||||
phone: logicStore.registerForm.phone,
|
||||
areaCode: areaCode.value,
|
||||
// captcha: data.code,
|
||||
// uuid: data.uuid,
|
||||
userPort: 2, // 登录端口2 商户端
|
||||
}
|
||||
if (!body.email) {
|
||||
delete body.email
|
||||
delete body.confirmEmail
|
||||
}
|
||||
if (logicStore.registerForm.type === 'email' && !String(body.phone ?? '').trim()) {
|
||||
delete body.phone
|
||||
delete body.areaCode
|
||||
}
|
||||
appUserRegisterPost({
|
||||
body: {
|
||||
...logicStore.registerForm,
|
||||
phone: logicStore.registerForm.phone,
|
||||
areaCode: areaCode.value,
|
||||
// captcha: data.code,
|
||||
// uuid: data.uuid,
|
||||
userPort: 2, // 登录端口2 商户端
|
||||
}
|
||||
body
|
||||
}).then((res) => {
|
||||
;(userStore as any).token = (res as any).data?.token;
|
||||
logicStore.reset()
|
||||
|
||||
@@ -45,16 +45,12 @@ const FormSchema = z.object({
|
||||
},
|
||||
{message: t('pages-user.food.add-food.schema.discountPricePositive') ?? '折扣价必须大于0'},
|
||||
),
|
||||
// dishImage: z.array(z.string()).min(1, t('pages-user.food.add-food.schema.dishImage')),
|
||||
stock: z.string()
|
||||
.min(1, t('pages-user.food.add-food.stockRequired'))
|
||||
.refine(
|
||||
(val) => {
|
||||
// 检查是否为空字符串或仅包含空格
|
||||
const trimmed = val.trim()
|
||||
if (trimmed === '') return false
|
||||
|
||||
// 检查是否为整数
|
||||
const num = Number(trimmed)
|
||||
return Number.isInteger(num)
|
||||
},
|
||||
@@ -68,12 +64,9 @@ const FormSchema = z.object({
|
||||
{message: t('pages-user.food.add-food.stockMustBeNonNegative')}
|
||||
)
|
||||
}).refine((data) => {
|
||||
// 验证折扣价不能高于原价
|
||||
if (data.discountPrice && data.discountPrice.trim() !== '') {
|
||||
const originalPrice = parseFloat(data.originalPrice)
|
||||
const discountPrice = parseFloat(data.discountPrice)
|
||||
|
||||
// 检查是否为有效数字
|
||||
if (!isNaN(originalPrice) && !isNaN(discountPrice)) {
|
||||
return discountPrice <= originalPrice
|
||||
}
|
||||
@@ -99,9 +92,56 @@ const removeImage = (index: number) => {
|
||||
formData.value.dishImage.splice(index, 1)
|
||||
}
|
||||
|
||||
// 配菜数据
|
||||
const merchantSideDishVoList = ref([])
|
||||
|
||||
function syncPriceFromSpec() {
|
||||
const specList = merchantSideDishVoList.value.merchantSideDishBoList
|
||||
if (specList && specList.length > 0) {
|
||||
const firstGroup = specList[0]
|
||||
const items = firstGroup.merchantSideDishItemBoList
|
||||
if (items && items.length > 0) {
|
||||
const first = items[0] as { price?: string; memberPrice?: string }
|
||||
const listPrice = first.price != null && String(first.price).trim() !== '' ? String(first.price).trim() : ''
|
||||
const memberPrice =
|
||||
first.memberPrice != null && String(first.memberPrice).trim() !== '' ? String(first.memberPrice).trim() : ''
|
||||
if (listPrice) {
|
||||
formData.value.originalPrice = listPrice
|
||||
}
|
||||
if (memberPrice) {
|
||||
formData.value.discountPrice = memberPrice
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交用:保持规格完整传递(包含第一项) */
|
||||
function buildMerchantSideDishBoListForSubmit() {
|
||||
const raw = merchantSideDishVoList.value.merchantSideDishBoList
|
||||
if (!raw || !Array.isArray(raw) || raw.length === 0) {
|
||||
return raw || []
|
||||
}
|
||||
return JSON.parse(JSON.stringify(raw)) as any[]
|
||||
}
|
||||
|
||||
/** 保存/编辑请求体:去掉详情里的 Vo 列表与旧 Bo 列表,只传去重后的 merchantSideDishBoList,避免修改时重复提交 */
|
||||
function buildDishSaveBody(stockValue: number) {
|
||||
const fd = formData.value as Record<string, unknown>
|
||||
const {
|
||||
merchantSideDishVoList: _vo,
|
||||
merchantSideDishBoList: _bo,
|
||||
dishImage: _dishImgArr,
|
||||
...rest
|
||||
} = fd
|
||||
return {
|
||||
...rest,
|
||||
tax: Number(formData.value.tax) / 100 || 0,
|
||||
stock: stockValue,
|
||||
merchantSideDishBoList: buildMerchantSideDishBoListForSubmit(),
|
||||
dishImage: formData.value.dishImage.join(','),
|
||||
delFlag: formData.value.isActive ? 1 : 3
|
||||
}
|
||||
}
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({
|
||||
url,
|
||||
@@ -110,11 +150,11 @@ function navigateTo(url: string) {
|
||||
console.log(data)
|
||||
if (data) {
|
||||
merchantSideDishVoList.value = data
|
||||
syncPriceFromSpec()
|
||||
}
|
||||
},
|
||||
},
|
||||
success: function (res) {
|
||||
// 通过eventChannel向被打开页面传送数据
|
||||
res.eventChannel.emit('acceptDataFromOpenerPage', {data: merchantSideDishVoList.value.merchantSideDishBoList || []})
|
||||
}
|
||||
})
|
||||
@@ -297,17 +337,11 @@ function saveDish() {
|
||||
|
||||
// 安全处理库存值
|
||||
const stockValue = formData.value.stock ? Number(formData.value.stock.trim()) : 0
|
||||
const body = buildDishSaveBody(stockValue)
|
||||
|
||||
if (formData.value.id) {
|
||||
appMerchantDishEditDishPost({
|
||||
body: {
|
||||
...formData.value,
|
||||
tax: Number(formData.value.tax) / 100 || 0,
|
||||
stock: stockValue,
|
||||
merchantSideDishBoList: merchantSideDishVoList.value.merchantSideDishBoList,
|
||||
dishImage: formData.value.dishImage.join(','),
|
||||
delFlag: formData.value.isActive ? 1 : 3
|
||||
}
|
||||
body
|
||||
}).then(() => {
|
||||
uni.showToast({
|
||||
title: t('toast.submitSuccess'),
|
||||
@@ -317,14 +351,7 @@ function saveDish() {
|
||||
})
|
||||
} else {
|
||||
appMerchantDishAddDishPost({
|
||||
body: {
|
||||
...formData.value,
|
||||
tax: Number(formData.value.tax) / 100 || 0,
|
||||
stock: stockValue,
|
||||
merchantSideDishBoList: merchantSideDishVoList.value.merchantSideDishBoList,
|
||||
dishImage: formData.value.dishImage.join(','),
|
||||
delFlag: formData.value.isActive ? 1 : 3
|
||||
}
|
||||
body
|
||||
}).then(() => {
|
||||
uni.showToast({
|
||||
title: t('toast.submitSuccess'),
|
||||
@@ -455,7 +482,7 @@ function saveDish() {
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 价格输入 -->
|
||||
<!-- 价格(自动从第一项规格填充,只读) -->
|
||||
<view class="form-item mb-52rpx">
|
||||
<text class="label text-36rpx lh-36rpx text-#333 mb-20rpx block font-500">{{
|
||||
t('pages-user.food.add-food.price')
|
||||
@@ -466,8 +493,8 @@ function saveDish() {
|
||||
<wd-input
|
||||
v-model="formData.originalPrice"
|
||||
:focus-when-clear="false"
|
||||
clearable
|
||||
custom-class="!text-30rpx !bg-transparent flex-1"
|
||||
disabled
|
||||
no-border
|
||||
placeholder="0.00"
|
||||
placeholderStyle="font-size: 30rpx;color: #999;"
|
||||
@@ -475,9 +502,10 @@ function saveDish() {
|
||||
>
|
||||
</wd-input>
|
||||
</view>
|
||||
<text class="text-24rpx text-#999 mt-10rpx block">{{ t('pages-user.food.add-food.originalPriceAutoFillTip') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 折扣价输入 -->
|
||||
<!-- 实际销售价格(自动从第一项规格会员价填充,只读) -->
|
||||
<view class="form-item mb-52rpx">
|
||||
<text class="label text-36rpx lh-36rpx text-#333 mb-20rpx block font-500">
|
||||
{{ t('pages-user.food.add-food.discountedPrice') }}
|
||||
@@ -487,8 +515,8 @@ function saveDish() {
|
||||
<wd-input
|
||||
v-model="formData.discountPrice"
|
||||
:focus-when-clear="false"
|
||||
clearable
|
||||
custom-class="!text-30rpx !bg-transparent flex-1"
|
||||
disabled
|
||||
no-border
|
||||
placeholder="0.00"
|
||||
placeholderStyle="font-size: 30rpx;color: #999;"
|
||||
@@ -496,6 +524,7 @@ function saveDish() {
|
||||
>
|
||||
</wd-input>
|
||||
</view>
|
||||
<text class="text-24rpx text-#999 mt-10rpx block">{{ t('pages-user.food.add-food.discountPriceAutoFillTip') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 重量: -->
|
||||
@@ -580,7 +609,7 @@ function saveDish() {
|
||||
<view class="form-item mb-52rpx">
|
||||
<view class="flex-center-sb">
|
||||
<text class="text-36rpx lh-36rpx text-#333 mb-20rpx block font-500">
|
||||
{{ t('pages-user.food.add-food.frequentlyBoughtTogether') }}
|
||||
{{ t('pages-user.food.add-food.specManagement') }}
|
||||
</text>
|
||||
<view class="bg-#F2F2F2 rounded-32rpx w-158rpx h-64rpx center font-500 text-26rpx text-#333"
|
||||
@click="navigateTo('/pages-user/pages/food/add-item')">
|
||||
|
||||
@@ -1,68 +1,65 @@
|
||||
<script lang="ts" setup>
|
||||
const {t} = useI18n()
|
||||
|
||||
// 配菜值的类型定义
|
||||
interface SideDishValue {
|
||||
interface SpecValue {
|
||||
name: string
|
||||
price: string
|
||||
memberPrice: string
|
||||
actualSalePrice: string
|
||||
}
|
||||
|
||||
// 配菜组的类型定义
|
||||
interface SideDishGroup {
|
||||
interface SpecGroup {
|
||||
sideDishName: string
|
||||
isRequired: 1 | 2, // 是否必选,1表示必选 2非必选
|
||||
merchantSideDishItemBoList: SideDishValue[]
|
||||
isRequired: 1 | 2,
|
||||
merchantSideDishItemBoList: SpecValue[]
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
merchantSideDishBoList: [] as SideDishGroup[]
|
||||
merchantSideDishBoList: [] as SpecGroup[]
|
||||
})
|
||||
|
||||
// 添加配菜组
|
||||
const addSideDishGroup = () => {
|
||||
const newGroup: SideDishGroup = {
|
||||
const addSpecGroup = () => {
|
||||
const newGroup: SpecGroup = {
|
||||
sideDishName: '',
|
||||
isRequired: 1,
|
||||
merchantSideDishItemBoList: [
|
||||
{
|
||||
name: '',
|
||||
price: ''
|
||||
price: '',
|
||||
memberPrice: '',
|
||||
actualSalePrice: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
formData.merchantSideDishBoList.push(newGroup)
|
||||
}
|
||||
|
||||
// 删除配菜组
|
||||
const removeSideDishGroup = (groupIndex: number) => {
|
||||
const removeSpecGroup = (groupIndex: number) => {
|
||||
formData.merchantSideDishBoList.splice(groupIndex, 1)
|
||||
}
|
||||
|
||||
// 添加配菜值
|
||||
const addSideDishValue = (groupIndex: number) => {
|
||||
const newValue: SideDishValue = {
|
||||
const addSpecValue = (groupIndex: number) => {
|
||||
const newValue: SpecValue = {
|
||||
name: '',
|
||||
price: ''
|
||||
price: '',
|
||||
memberPrice: '',
|
||||
actualSalePrice: ''
|
||||
}
|
||||
formData.merchantSideDishBoList[groupIndex].merchantSideDishItemBoList.push(newValue)
|
||||
}
|
||||
|
||||
// 删除配菜值
|
||||
const removeSideDishValue = (groupIndex: number, valueIndex: number) => {
|
||||
const removeSpecValue = (groupIndex: number, valueIndex: number) => {
|
||||
if (formData.merchantSideDishBoList[groupIndex].merchantSideDishItemBoList.length > 1) {
|
||||
formData.merchantSideDishBoList[groupIndex].merchantSideDishItemBoList.splice(valueIndex, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = () => {
|
||||
// 验证表单
|
||||
for (let i = 0; i < formData.merchantSideDishBoList.length; i++) {
|
||||
const group = formData.merchantSideDishBoList[i]
|
||||
if (!group.sideDishName.trim()) {
|
||||
uni.showToast({
|
||||
title: t('pages-user.food.add-item.validation.enterSideDishName', {index: i + 1}),
|
||||
title: t('pages-user.food.add-item.validation.enterSpecName', {index: i + 1}),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
@@ -70,7 +67,7 @@ const submitForm = () => {
|
||||
|
||||
for (let j = 0; j < group.merchantSideDishItemBoList.length; j++) {
|
||||
const value = group.merchantSideDishItemBoList[j]
|
||||
if (!value.name.trim() || !value.price.trim()) {
|
||||
if (!value.name.trim() || !value.price.trim() || !value.memberPrice.trim() || !value.actualSalePrice.trim()) {
|
||||
uni.showToast({
|
||||
title: t('pages-user.food.add-item.validation.completeAllFields', {index: i + 1}),
|
||||
icon: 'none'
|
||||
@@ -88,7 +85,6 @@ const submitForm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// 这里可以调用API提交数据
|
||||
console.log('Submit form:', formData)
|
||||
|
||||
uni.showToast({
|
||||
@@ -108,7 +104,20 @@ onMounted(() => {
|
||||
eventChannel.on('acceptDataFromOpenerPage', function (data) {
|
||||
console.log('acceptDataFromOpenerPage', data.data)
|
||||
if (data.data && data.data.length > 0) {
|
||||
formData.merchantSideDishBoList = data.data
|
||||
formData.merchantSideDishBoList = data.data.map((group: SpecGroup) => ({
|
||||
...group,
|
||||
merchantSideDishItemBoList: (group.merchantSideDishItemBoList || []).map((item) => ({
|
||||
...item,
|
||||
memberPrice:
|
||||
item.memberPrice !== undefined && item.memberPrice !== null && String(item.memberPrice) !== ''
|
||||
? String(item.memberPrice)
|
||||
: '',
|
||||
actualSalePrice:
|
||||
item.actualSalePrice !== undefined && item.actualSalePrice !== null && String(item.actualSalePrice) !== ''
|
||||
? String(item.actualSalePrice)
|
||||
: ''
|
||||
}))
|
||||
}))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -117,10 +126,9 @@ onUnload(() => {
|
||||
eventChannel = null
|
||||
})
|
||||
|
||||
// 初始化一个配菜组
|
||||
addSideDishGroup()
|
||||
addSpecGroup()
|
||||
|
||||
function handleClickItem(group: SideDishGroup) {
|
||||
function handleClickItem(group: SpecGroup) {
|
||||
group.isRequired = group.isRequired === 1 ? 2 : 1
|
||||
}
|
||||
</script>
|
||||
@@ -132,33 +140,28 @@ function handleClickItem(group: SideDishGroup) {
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<view class="content px-30rpx pt-40rpx pb-200rpx">
|
||||
<!-- 配菜组列表 -->
|
||||
<view
|
||||
v-for="(group, groupIndex) in formData.merchantSideDishBoList"
|
||||
:key="groupIndex"
|
||||
class="side-dish-group mb-40rpx"
|
||||
class="spec-group mb-40rpx"
|
||||
>
|
||||
<!-- 配菜组容器 -->
|
||||
<view class="flex-center-sb mb-26rpx">
|
||||
<!-- 配菜组标题 -->
|
||||
<text class="text-28rpx text-#999 block">{{ t('pages-user.food.add-item.sideDish') }} {{
|
||||
<text class="text-28rpx text-#999 block">{{ t('pages-user.food.add-item.spec') }} {{
|
||||
groupIndex + 1
|
||||
}}:
|
||||
</text>
|
||||
|
||||
<!-- 删除配菜组按钮 -->
|
||||
<view
|
||||
class="w-48rpx h-48rpx"
|
||||
@tap="removeSideDishGroup(groupIndex)"
|
||||
@tap="removeSpecGroup(groupIndex)"
|
||||
>
|
||||
<image class="w-48rpx h-48rpx" src="@img/chef/190.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bg-white rounded-20rpx px-20rpx py-30rpx relative">
|
||||
<!-- 配菜类型输入 -->
|
||||
<view class="mb-20rpx">
|
||||
<text class="text-36rpx text-#333 font-500 mb-20rpx block">{{
|
||||
t('pages-user.food.add-item.typeOfSideDishes')
|
||||
t('pages-user.food.add-item.specType')
|
||||
}}
|
||||
</text>
|
||||
<view class="bg-#F6F6F6 rounded-16rpx h-98rpx px-24rpx flex items-center">
|
||||
@@ -177,13 +180,11 @@ function handleClickItem(group: SideDishGroup) {
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 配菜组必选状态 -->
|
||||
<view class="mb-44rpx flex-center-sb">
|
||||
<text class="text-36rpx text-#333 font-500 mb-20rpx block">
|
||||
{{ t('pages-user.food.add-item.isRequired') }}
|
||||
</text>
|
||||
<view class="shrink-0" @click="handleClickItem(group)">
|
||||
<!-- 单选按钮 -->
|
||||
<image
|
||||
:src="
|
||||
group.isRequired === 1
|
||||
@@ -196,35 +197,29 @@ function handleClickItem(group: SideDishGroup) {
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 配菜值标题 -->
|
||||
<text class="text-36rpx text-#333 font-500 mb-30rpx block">
|
||||
{{ t('pages-user.food.add-item.sideDishesFlavorValue') }}
|
||||
{{ t('pages-user.food.add-item.specValue') }}
|
||||
</text>
|
||||
|
||||
<!-- 配菜值列表 -->
|
||||
<view class="values-list">
|
||||
<view
|
||||
v-for="(value, valueIndex) in group.merchantSideDishItemBoList"
|
||||
:key="valueIndex"
|
||||
class="mb-10rpx last:mb-0"
|
||||
>
|
||||
<!-- 配菜值容器 -->
|
||||
<view class="bg-white py-28rpx border-2rpx border-solid border-#DFDFDF rounded-16rpx px-20rpx">
|
||||
<view class="flex-center-sb mb-26rpx">
|
||||
<!-- 配菜组标题 -->
|
||||
<text class="text-26rpx text-#333 font-500 block">{{ t('pages-user.food.add-item.value') }}
|
||||
{{ valueIndex + 1 }}:
|
||||
</text>
|
||||
|
||||
<!-- 删除配菜组按钮 -->
|
||||
<view
|
||||
class="w-48rpx h-48rpx"
|
||||
@click="removeSideDishValue(groupIndex, valueIndex)"
|
||||
@click="removeSpecValue(groupIndex, valueIndex)"
|
||||
>
|
||||
<image class="w-48rpx h-48rpx" src="@img/chef/190.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 名称输入 -->
|
||||
<view class="form-row flex items-center mb-24rpx">
|
||||
<text class="label text-28rpx text-#333 w-120rpx">{{ t('pages-user.food.add-item.name') }}</text>
|
||||
<view class="bg-#F6F6F6 rounded-16rpx h-88rpx px-20rpx flex-1 flex items-center">
|
||||
@@ -243,8 +238,7 @@ function handleClickItem(group: SideDishGroup) {
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 价格输入 -->
|
||||
<view class="form-row flex items-center">
|
||||
<view class="form-row flex items-center mb-24rpx">
|
||||
<text class="label text-28rpx text-#333 w-120rpx">{{ t('pages-user.food.add-item.price') }}</text>
|
||||
<view class="bg-#F6F6F6 rounded-16rpx h-88rpx px-20rpx flex-1 flex items-center">
|
||||
<wd-input
|
||||
@@ -261,27 +255,54 @@ function handleClickItem(group: SideDishGroup) {
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-row flex items-center mb-24rpx">
|
||||
<text class="label text-28rpx text-#333 w-120rpx">{{ t('pages-user.food.add-item.memberPrice') }}</text>
|
||||
<view class="bg-#F6F6F6 rounded-16rpx h-88rpx px-20rpx flex-1 flex items-center">
|
||||
<wd-input
|
||||
v-model="value.memberPrice"
|
||||
:focus-when-clear="false"
|
||||
:placeholder="t('pages-user.food.add-item.enterPlaceholder')"
|
||||
clearable
|
||||
confirm-type="search"
|
||||
custom-class="!text-30rpx !bg-transparent flex-1"
|
||||
no-border
|
||||
placeholderStyle="font-size: 30rpx;color: #999;"
|
||||
use-prefix-slot
|
||||
>
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-row flex items-center">
|
||||
<text class="label text-28rpx text-#333 w-120rpx">{{ t('pages-user.food.add-item.actualSalePrice') }}</text>
|
||||
<view class="bg-#F6F6F6 rounded-16rpx h-88rpx px-20rpx flex-1 flex items-center">
|
||||
<wd-input
|
||||
v-model="value.actualSalePrice"
|
||||
:focus-when-clear="false"
|
||||
:placeholder="t('pages-user.food.add-item.enterPlaceholder')"
|
||||
clearable
|
||||
confirm-type="search"
|
||||
custom-class="!text-30rpx !bg-transparent flex-1"
|
||||
no-border
|
||||
placeholderStyle="font-size: 30rpx;color: #999;"
|
||||
use-prefix-slot
|
||||
>
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 添加配菜值按钮 -->
|
||||
<view
|
||||
class="bg-#F2F2F2 rounded-20rpx h-88rpx center mt-24rpx"
|
||||
@click="addSideDishValue(groupIndex)"
|
||||
@click="addSpecValue(groupIndex)"
|
||||
>
|
||||
<text class="text-30rpx text-#333 font-500">+ {{ t('pages-user.food.add-item.add') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 添加配菜组按钮 -->
|
||||
<view
|
||||
class="bg-#F6F6F6 border-2rpx border-solid border-#333 rounded-16rpx h-88rpx flex items-center justify-center mb-40rpx"
|
||||
@click="addSideDishGroup"
|
||||
>
|
||||
<text class="text-30rpx text-#333 font-500">{{ t('pages-user.food.add-item.addSideDishes') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部提交按钮 -->
|
||||
|
||||
+63
-15
@@ -211,6 +211,14 @@ function getStock(item: any) {
|
||||
return Number(stock).toFixed(0)
|
||||
}
|
||||
|
||||
/** 已售完:有明确库存且数量 <= 0(未返回 stock 时不视为售完,避免误盖) */
|
||||
function isSoldOut(item: any) {
|
||||
const stock = (item as any)?.stock
|
||||
if (stock === undefined || stock === null || stock === '') return false
|
||||
const n = Number(stock)
|
||||
return !Number.isNaN(n) && n <= 0
|
||||
}
|
||||
|
||||
function initData() {
|
||||
console.log('页面回来的时候获取最新的数据', props.currentIndex)
|
||||
if (+props.currentIndex === +props.tabIndex) {
|
||||
@@ -382,11 +390,21 @@ const isMerchant = computed(() => {
|
||||
<template v-for="(item, index) in searchResult" :key="item.item.id || index">
|
||||
<view :class="[index === 0 ? '' : 'mt-46rpx']" @click="handleClickDish(item.item)">
|
||||
<view class="flex-center-sb">
|
||||
<image
|
||||
:src="item.item.dishImage"
|
||||
class="w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view
|
||||
class="relative w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx overflow-hidden"
|
||||
>
|
||||
<image
|
||||
:src="item.item.dishImage"
|
||||
class="w-full h-full block"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<image
|
||||
v-if="isSoldOut(item.item)"
|
||||
class="sold-out-cover"
|
||||
mode="aspectFill"
|
||||
src="/static/app/images/SoldOut.png"
|
||||
></image>
|
||||
</view>
|
||||
<view class="flex-1 h-176rpx">
|
||||
<view class="text-33rpx lh-34rpx text-#333 font-500 mb-22rpx line-clamp-1 tracking-[.04em]">
|
||||
{{ item.item.dishName }}
|
||||
@@ -414,11 +432,21 @@ const isMerchant = computed(() => {
|
||||
<view :class="[index === 0 ? '' : 'mt-46rpx']">
|
||||
<wd-swipe-action v-model="swipeActionValue">
|
||||
<view class="flex-center-sb" @click="handleClickDish(item)">
|
||||
<image
|
||||
:src="item.dishImage ? item.dishImage.split(',')[0] : ''"
|
||||
class="w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view
|
||||
class="relative w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx overflow-hidden"
|
||||
>
|
||||
<image
|
||||
:src="item.dishImage ? item.dishImage.split(',')[0] : ''"
|
||||
class="w-full h-full block"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<image
|
||||
v-if="isSoldOut(item)"
|
||||
class="sold-out-cover"
|
||||
mode="aspectFill"
|
||||
src="/static/app/images/SoldOut.png"
|
||||
></image>
|
||||
</view>
|
||||
<view class="flex-1 h-176rpx">
|
||||
<view class="text-33rpx lh-34rpx text-#333 font-500 mb-22rpx line-clamp-1 tracking-[.04em]">
|
||||
{{ item.dishName }}
|
||||
@@ -495,11 +523,21 @@ const isMerchant = computed(() => {
|
||||
</view>
|
||||
<template v-for="(item, index) in dataList" :key="item.id || index">
|
||||
<view :class="[index === 0 ? '' : 'mt-46rpx']" class="flex-center-sb" @click="handleClickDish(item)">
|
||||
<image
|
||||
:src="item.dishImage ? item.dishImage.split(',')[0] : ''"
|
||||
class="w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx bg-common"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view
|
||||
class="relative w-176rpx h-176rpx mr-28rpx shrink-0 rounded-24rpx overflow-hidden bg-common"
|
||||
>
|
||||
<image
|
||||
:src="item.dishImage ? item.dishImage.split(',')[0] : ''"
|
||||
class="w-full h-full block"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<image
|
||||
v-if="isSoldOut(item)"
|
||||
class="sold-out-cover"
|
||||
mode="aspectFill"
|
||||
src="/static/app/images/SoldOut.png"
|
||||
></image>
|
||||
</view>
|
||||
<view class="flex-1 h-176rpx">
|
||||
<view class="text-33rpx lh-34rpx text-#333 font-500 mb-22rpx line-clamp-1 tracking-[.04em]">
|
||||
{{ item.dishName }}
|
||||
@@ -533,6 +571,16 @@ const isMerchant = computed(() => {
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sold-out-cover {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 2;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
:deep(.wd-input__clear) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Reference in New Issue
Block a user