feat:修改部分金额格式化显示

This commit is contained in:
weiwei committed 2025-09-12 19:12:56 +08:00
1 parent 0ff5f79b8d
commit 0150025b45
9 files changed
+170 -123

No files matched your search

+7 -9
View File
@@ -7,7 +7,7 @@
<text class="c-#0094ff! sub-text-24 mr-20rpx px-2 bg-#0094ff22 rounded-2">{{ item.status == "0" ? "正常" : "禁用" }}</text>
</view>
<view class="flex-row-center gap-2">
<tm-button class="px-2" size="xs" @click="editCategary(item)">编辑</tm-button>
<tm-button class="px-2" size="xs" :linear="['to right', '#62abff', '#0779FD99']" @click="editCategary(item)">编辑</tm-button>
<tm-button class="px-2" size="xs" :linear="['to right', '#FFC328', '#E2000099']" @click="delCategary(item.id)">删除</tm-button>
</view>
</view>
@@ -48,9 +48,9 @@
</tm-form-item>
<view class="prefix_title mb-2">父级分类</view>
<view class="card my-2">
<shop-categary-tree v-model="selectedNode" :node-data="categoryTree" @currentNode="currentNode" />
<shop-categary-tree v-model="selectedNode" :node-data="categoryTree" />
</view>
<tm-button form-type="submit" block>提 交</tm-button>
<tm-button form-type="submit" block>保 存</tm-button>
</tm-form>
</view>
</tm-drawer>
@@ -90,6 +90,7 @@ const getCategaryTree = async () => {
categoryTree.value = data ?? []
}
// 新增分类
const addCategary = () => {
getCategaryTree()
Object.assign(form, {
@@ -102,6 +103,7 @@ const addCategary = () => {
categaryFormDrawer.value = true
}
// 编辑分类
const editCategary = (item) => {
getCategaryTree()
Object.assign(form, item)
@@ -109,18 +111,14 @@ const editCategary = (item) => {
categaryFormDrawer.value = true
}
const currentNode = (item) => {
// form.parentId = item.categoryId
}
// 提交保存
const saveCategary = async () => {
console.log(form)
if (!form.name) return uni.showToast({ title: "请填写分类名称", icon: "none" })
if (selectedNode.value.id === form.id) return uni.showToast({ title: "父级分类不能是自身", icon: "none" })
try {
const params = { ...form, parentId: selectedNode.value.id }
uni.showLoading({ title: "保存中..." })
const { code, data, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params))
const { code, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params))
if (code != 0) return uni.showToast({ title: msg || "保存失败", icon: "none" })
uni.showToast({ title: "保存成功", icon: "none" })
categaryFormDrawer.value = false
+10 -5
View File
@@ -2,20 +2,25 @@
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
<image :src="filePath(state.detail.coverImage)" class="w-full h-500rpx bg-#eeeeee" mode="aspectFill" />
<view v-if="state.detail.id" class="card p-20rpx mt-10rpx mx-20rpx bg-gradient-to-b from-#0094ff33 to-#fff">
<view class="w-full flex justify-between items-center">
<view v-if="state.detail.priceType == '2'" class="w-full flex justify-between items-center">
<view class="flex items-center">
<text class="second-text-34 line-through">¥</text>
<text class="font-bold second-text-40 line-through mr-2">{{ state.detail.originalPrice.toFixed(2) }}</text>
<text class="font-bold second-text-40 line-through mr-2">{{ displayPrice(state.detail.originalPrice, "") }}</text>
<text class="text-34rpx color-red!">¥</text>
<text class="text-46rpx font-bold color-red!">{{ state.detail.spuPrice.toFixed(2) }}</text>
<text class="text-46rpx font-bold color-red!">{{ displayPrice(state.detail.spuPrice, "") }}</text>
<text class="view-clip px-2 text-22rpx c-white bg-red ml-2 rounded-r-1 rounded-lt-1">到手价</text>
</view>
<view class="main-text-32 c-red! font-italic">
<text>约省</text>
<text class="text-44rpx mx-1">{{ Number(state.detail.originalPrice) - Number(state.detail.spuPrice) }}</text>
<text class="text-44rpx mx-1">{{ displayPrice(Number(state.detail.originalPrice) - Number(state.detail.spuPrice), "") }}</text>
<text>元</text>
</view>
</view>
<view v-else class="w-full flex justify-start items-center">
<text class="text-34rpx color-red!">¥</text>
<text class="text-46rpx font-bold color-red!">{{ displayPrice(state.detail.skuList[0].price, "") }}</text>
<text class="view-clip px-2 text-22rpx c-white bg-red ml-2 rounded-r-1 rounded-lt-1">到手价</text>
</view>
<view class="w-full sub-text-36 flex items-center mt-1">
<text class="c-#0094ff! sub-text-24 px-2 bg-#0094ff22 rounded-1 mr-2 whitespace-nowrap">
{{ state.detail.status == "0" ? "在售" : "未售" }}
@@ -28,7 +33,7 @@
<text class="mr-20rpx">剩余库存 {{ state.detail.totalStock }}</text>
</view>
</view>
<view class="mt-20rpx card p-20rpx mx-20rpx">
<view v-if="state.detail.priceType == '1'" class="mt-20rpx card p-20rpx mx-20rpx">
<view class="prefix_title">包装单位</view>
<view class="bg-#1879ff09 rounded-1 my-2 p-3" v-for="(item, index) in state.detail.skuList" :key="index">
<view class="sub-text-30">{{ item.skuName }}</view>
+82 -70
View File
@@ -74,11 +74,7 @@
</tm-form-item>
<view class="sub-text-20 c-red! mb-2">注:图片大小不超过5M</view>
<tm-form-item name="description" label="详情描述" direction="vertical" required="">
<rich-text-input
v-model="form.description"
placeholder="点击编辑详情描述..."
label="详情描述"
/>
<rich-text-input v-model="form.description" placeholder="点击编辑详情描述..." label="详情描述" />
</tm-form-item>
<tm-form-item name="priceType" label="定价方式">
<tm-radio-group v-model="form.priceType" align="flex-end">
@@ -96,12 +92,12 @@
<view v-if="form.priceType == '2'">
<tm-form-item name="spuPrice" label="SPU售价(元)" labelWidth="200">
<view class="flex justify-end">
<tm-stepper width="300" v-model="form.spuPrice"></tm-stepper>
<tm-stepper :max="10000" width="300" v-model="form.spuPrice"></tm-stepper>
</view>
</tm-form-item>
<tm-form-item name="originalPrice" label="划线价(元)" labelWidth="200">
<view class="flex justify-end">
<tm-stepper width="300" v-model="form.originalPrice"></tm-stepper>
<tm-stepper :max="10000" width="300" v-model="form.originalPrice"></tm-stepper>
</view>
</tm-form-item>
</view>
@@ -126,17 +122,17 @@
</tm-form-item>
<tm-form-item name="skuList[index].price" label="售价(元)">
<view class="flex justify-end">
<tm-stepper width="300" v-model="item.price"></tm-stepper>
<tm-stepper :max="10000" width="300" v-model="item.price"></tm-stepper>
</view>
</tm-form-item>
<tm-form-item name="skuList[index].stock" label="库存">
<view class="flex justify-end">
<tm-stepper width="300" v-model="item.stock"></tm-stepper>
<tm-stepper :max="10000" width="300" v-model="item.stock"></tm-stepper>
</view>
</tm-form-item>
<tm-form-item name="skuList[index].weightG" label="重量(克)">
<view class="flex justify-end">
<tm-stepper width="300" v-model="item.weightG"></tm-stepper>
<tm-stepper :max="10000" width="300" v-model="item.weightG"></tm-stepper>
</view>
</tm-form-item>
<tm-form-item name="skuList[index].status" label="状态">
@@ -175,6 +171,7 @@ import ShopCategaryPicker from "@/sheep/components/shop-categary-picker.vue"
import RichTextInput from "@/sheep/components/rich-text-input/rich-text-input.vue"
import { onLoad } from "@dcloudio/uni-app"
import { filePath } from "@/sheep/utils/file"
import { displayPrice, storePrice } from "@/sheep/utils/formatMoney"
const form = reactive<any>({
id: "",
@@ -238,21 +235,28 @@ const getGoodsDetail = async (id: string) => {
const saleEndTime = data.saleEndTime
_saleStartTimeStr.value = saleStartTime
_saleEndTimeStr.value = saleEndTime
// 转换HTML为Markdown格式
const description = convertHtmlToMarkdown(data.description || '')
console.log('原始HTML:', data.description)
console.log('转换后Markdown:', description)
const description = convertHtmlToMarkdown(data.description || "")
console.log("原始HTML:", data.description)
console.log("转换后Markdown:", description)
Object.assign(form, {
...data,
status: data.status.toString(),
priceType: data.priceType.toString(),
spuPrice: displayPrice(data.spuPrice, ""),
originalPrice: displayPrice(data.originalPrice, ""),
coverImage,
categoryName,
saleStartTime,
saleEndTime,
skuList,
skuList: data.skuList.map((item: any) => {
return {
...item,
price: displayPrice(item.price, ""),
}
}),
description,
})
uni.hideLoading()
@@ -260,48 +264,48 @@ const getGoodsDetail = async (id: string) => {
// HTML转Markdown函数
const convertHtmlToMarkdown = (html: string): string => {
if (!html) return ''
if (!html) return ""
// 移除HTML标签,保留文本内容
let markdown = html
// 处理标题
.replace(/<h1[^>]*>(.*?)<\/h1>/gi, '# $1\n')
.replace(/<h2[^>]*>(.*?)<\/h2>/gi, '## $1\n')
.replace(/<h3[^>]*>(.*?)<\/h3>/gi, '### $1\n')
.replace(/<h4[^>]*>(.*?)<\/h4>/gi, '#### $1\n')
.replace(/<h5[^>]*>(.*?)<\/h5>/gi, '##### $1\n')
.replace(/<h6[^>]*>(.*?)<\/h6>/gi, '###### $1\n')
.replace(/<h1[^>]*>(.*?)<\/h1>/gi, "# $1\n")
.replace(/<h2[^>]*>(.*?)<\/h2>/gi, "## $1\n")
.replace(/<h3[^>]*>(.*?)<\/h3>/gi, "### $1\n")
.replace(/<h4[^>]*>(.*?)<\/h4>/gi, "#### $1\n")
.replace(/<h5[^>]*>(.*?)<\/h5>/gi, "##### $1\n")
.replace(/<h6[^>]*>(.*?)<\/h6>/gi, "###### $1\n")
// 处理段落
.replace(/<p[^>]*>(.*?)<\/p>/gi, '$1\n\n')
.replace(/<p[^>]*>(.*?)<\/p>/gi, "$1\n\n")
// 处理换行
.replace(/<br\s*\/?>/gi, '\n')
.replace(/<br\s*\/?>/gi, "\n")
// 处理粗体
.replace(/<strong[^>]*>(.*?)<\/strong>/gi, '**$1**')
.replace(/<b[^>]*>(.*?)<\/b>/gi, '**$1**')
.replace(/<strong[^>]*>(.*?)<\/strong>/gi, "**$1**")
.replace(/<b[^>]*>(.*?)<\/b>/gi, "**$1**")
// 处理斜体
.replace(/<em[^>]*>(.*?)<\/em>/gi, '*$1*')
.replace(/<i[^>]*>(.*?)<\/i>/gi, '*$1*')
.replace(/<em[^>]*>(.*?)<\/em>/gi, "*$1*")
.replace(/<i[^>]*>(.*?)<\/i>/gi, "*$1*")
// 处理下划线
.replace(/<u[^>]*>(.*?)<\/u>/gi, '__$1__')
.replace(/<u[^>]*>(.*?)<\/u>/gi, "__$1__")
// 处理链接
.replace(/<a[^>]*href=["']([^"']*)["'][^>]*>(.*?)<\/a>/gi, '[$2]($1)')
.replace(/<a[^>]*href=["']([^"']*)["'][^>]*>(.*?)<\/a>/gi, "[$2]($1)")
// 处理图片 - 更全面的图片处理
.replace(/<img[^>]*src=["']([^"']*)["'][^>]*alt=["']([^"']*)["'][^>]*>/gi, (match, src, alt) => {
// 直接使用原始URL,不添加额外前缀
console.log('HTML图片转换 - 原始:', match)
console.log('HTML图片转换 - src:', src)
console.log('HTML图片转换 - alt:', alt)
return `![${alt || '图片'}](${src})`
console.log("HTML图片转换 - 原始:", match)
console.log("HTML图片转换 - src:", src)
console.log("HTML图片转换 - alt:", alt)
return `![${alt || "图片"}](${src})`
})
.replace(/<img[^>]*src=["']([^"']*)["'][^>]*>/gi, (match, src) => {
// 直接使用原始URL,不添加额外前缀
console.log('HTML图片转换 - 原始:', match)
console.log('HTML图片转换 - src:', src)
console.log("HTML图片转换 - 原始:", match)
console.log("HTML图片转换 - src:", src)
return `![图片](${src})`
})
// 处理列表
.replace(/<ul[^>]*>(.*?)<\/ul>/gis, (match, content) => {
return content.replace(/<li[^>]*>(.*?)<\/li>/gi, '- $1\n')
return content.replace(/<li[^>]*>(.*?)<\/li>/gi, "- $1\n")
})
.replace(/<ol[^>]*>(.*?)<\/ol>/gis, (match, content) => {
let index = 1
@@ -309,30 +313,30 @@ const convertHtmlToMarkdown = (html: string): string => {
})
// 处理引用
.replace(/<blockquote[^>]*>(.*?)<\/blockquote>/gis, (match, content) => {
return content.replace(/\n/g, '\n> ') + '\n'
return content.replace(/\n/g, "\n> ") + "\n"
})
// 处理代码
.replace(/<code[^>]*>(.*?)<\/code>/gi, '`$1`')
.replace(/<pre[^>]*>(.*?)<\/pre>/gis, '```\n$1\n```')
.replace(/<code[^>]*>(.*?)<\/code>/gi, "`$1`")
.replace(/<pre[^>]*>(.*?)<\/pre>/gis, "```\n$1\n```")
// 处理分割线
.replace(/<hr[^>]*>/gi, '---\n')
.replace(/<hr[^>]*>/gi, "---\n")
// 处理表格(简单处理)
.replace(/<table[^>]*>(.*?)<\/table>/gis, (match, content) => {
// 这里可以添加更复杂的表格处理逻辑
return content.replace(/<tr[^>]*>(.*?)<\/tr>/gi, (trMatch, trContent) => {
const cells = trContent.match(/<t[hd][^>]*>(.*?)<\/t[hd]>/gi)
if (cells) {
return '| ' + cells.map(cell => cell.replace(/<[^>]*>/g, '')).join(' | ') + ' |\n'
return "| " + cells.map((cell) => cell.replace(/<[^>]*>/g, "")).join(" | ") + " |\n"
}
return ''
return ""
})
})
// 移除剩余的HTML标签
.replace(/<[^>]*>/g, '')
.replace(/<[^>]*>/g, "")
// 清理多余的换行
.replace(/\n{3,}/g, '\n\n')
.replace(/\n{3,}/g, "\n\n")
.trim()
return markdown
}
@@ -379,48 +383,48 @@ const addSkuListItem = () => {
// Markdown转HTML函数
const convertMarkdownToHtml = (markdown: string): string => {
if (!markdown) return ''
if (!markdown) return ""
let html = markdown
// 处理标题
.replace(/^# (.*$)/gim, '<h1>$1</h1>')
.replace(/^## (.*$)/gim, '<h2>$1</h2>')
.replace(/^### (.*$)/gim, '<h3>$1</h3>')
.replace(/^#### (.*$)/gim, '<h4>$1</h4>')
.replace(/^##### (.*$)/gim, '<h5>$1</h5>')
.replace(/^###### (.*$)/gim, '<h6>$1</h6>')
.replace(/^# (.*$)/gim, "<h1>$1</h1>")
.replace(/^## (.*$)/gim, "<h2>$1</h2>")
.replace(/^### (.*$)/gim, "<h3>$1</h3>")
.replace(/^#### (.*$)/gim, "<h4>$1</h4>")
.replace(/^##### (.*$)/gim, "<h5>$1</h5>")
.replace(/^###### (.*$)/gim, "<h6>$1</h6>")
// 处理粗体
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
// 处理斜体
.replace(/\*(.*?)\*/g, '<em>$1</em>')
.replace(/\*(.*?)\*/g, "<em>$1</em>")
// 处理链接
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>')
// 处理图片
.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" style="max-width: 100%; height: auto;" />')
// 处理段落
.replace(/^(?!<[h1-6]|<img|<ul|<ol|<li)(.+)$/gim, '<p>$1</p>')
.replace(/^(?!<[h1-6]|<img|<ul|<ol|<li)(.+)$/gim, "<p>$1</p>")
// 处理换行
.replace(/\n/g, '<br>')
.replace(/\n/g, "<br>")
return html
}
// 保存
const onsubmit = async (evt: TM.FORM_SUBMIT_RESULT) => {
// console.log("校验结果:", evt)
// 将Markdown格式的description转换为HTML
const htmlDescription = convertMarkdownToHtml(form.description)
console.log("原始Markdown:", form.description)
console.log("转换后HTML:", htmlDescription)
const submitData = {
...form,
const submitData = {
...form,
description: htmlDescription, // 使用转换后的HTML
coverImage: JSON.parse(form.coverImage[0].response).data.url
coverImage: JSON.parse(form.coverImage[0].response).data.url,
}
console.log("提交的数据:", submitData)
if (!evt.isPass) return
if (form.priceType == "1") {
@@ -437,10 +441,18 @@ const onsubmit = async (evt: TM.FORM_SUBMIT_RESULT) => {
}
try {
const params = {
...form,
const params = {
...form,
spuPrice: storePrice(form.spuPrice),
originalPrice: storePrice(form.originalPrice),
skuList: form.skuList.map((item) => {
return {
...item,
price: storePrice(item.price),
}
}),
description: htmlDescription, // 使用转换后的HTML
coverImage: JSON.parse(form.coverImage[0].response).data.url
coverImage: JSON.parse(form.coverImage[0].response).data.url,
}
uni.showLoading({ title: "提交中..." })
const { code, msg } = await (form.id ? prosperityShopApi.editGoods(params) : prosperityShopApi.addGoods(params))
+19 -9
View File
@@ -70,15 +70,24 @@
<text class="second-text-26">库存 {{ v.totalStock }}</text>
</view>
<view>
<text class="second-text-32 line-through mr-1">
<text class="text-30rpx">¥</text>
<text class="font-bold">{{ v.originalPrice.toFixed(2) }}</text>
</text>
<text class="color-red">
<text class="text-30rpx">¥</text>
<text class="text-40rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[0] }}.</text>
<text class="text-32rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[1] }}</text>
</text>
<template v-if="v.priceType == '2'">
<text class="second-text-32 line-through mr-1">
<text class="text-30rpx">¥</text>
<text class="font-bold">{{ displayPrice(v.originalPrice, "") }}</text>
</text>
<text class="color-red">
<text class="text-30rpx">¥</text>
<text class="text-40rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[0] }}.</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[1] }}</text>
</text>
</template>
<template v-else>
<text class="color-red">
<text class="text-30rpx">¥</text>
<text class="text-40rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[0] }}.</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[1] }}</text>
</text>
</template>
<text class="view-clip px-1 text-18rpx c-white bg-red ml-1 rounded-r-1 rounded-lt-1">到手价</text>
</view>
</view>
@@ -110,6 +119,7 @@ import { prosperityShopApi } from "@/sheep/api"
import { hooks } from "@/sheep"
import { filePath } from "@/sheep/utils/file"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { displayPrice } from "@/sheep/utils/formatMoney"
const state = reactive<any>({
params: {
+19 -9
View File
@@ -49,15 +49,24 @@
<text class="second-text-26">库存 {{ v.totalStock }}</text>
</view>
<view>
<text class="second-text-28 line-through mr-1">
<text class="text-26rpx">¥</text>
<text class="font-bold">{{ v.originalPrice.toFixed(2) }}</text>
</text>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[1] }}</text>
</text>
<template v-if="v.priceType == '2'">
<text class="second-text-28 line-through mr-1">
<text class="text-26rpx">¥</text>
<text class="font-bold">{{ displayPrice(v.originalPrice, "") }}</text>
</text>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[1] }}</text>
</text>
</template>
<template v-else>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[1] }}</text>
</text>
</template>
<text class="view-clip px-1 text-18rpx c-white bg-red ml-1 rounded-r-1 rounded-lt-1">到手价</text>
</view>
</view>
@@ -72,6 +81,7 @@ import { prosperityShopApi } from "@/sheep/api"
import { reactive, ref } from "vue"
import { filePath } from "@/sheep/utils/file"
import { onLoad } from "@dcloudio/uni-app"
import { displayPrice } from "@/sheep/utils/formatMoney"
const state = reactive<any>({
params: {
+19 -9
View File
@@ -59,15 +59,24 @@
<text class="second-text-26">库存 {{ v.totalStock }}</text>
</view>
<view>
<text class="second-text-28 line-through mr-1">
<text class="text-26rpx">¥</text>
<text class="font-bold">{{ v.originalPrice.toFixed(2) }}</text>
</text>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ v.spuPrice.toFixed(2).split(".")[1] }}</text>
</text>
<template v-if="v.priceType == '2'">
<text class="second-text-28 line-through mr-1">
<text class="text-26rpx">¥</text>
<text class="font-bold">{{ displayPrice(v.originalPrice, "") }}</text>
</text>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ displayPrice(v.spuPrice, "").split(".")[1] }}</text>
</text>
</template>
<template v-else>
<text class="color-red">
<text class="text-26rpx">¥</text>
<text class="text-32rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[0] }}.</text>
<text class="text-30rpx font-bold">{{ displayPrice(v.minPrice, "").split(".")[1] }}</text>
</text>
</template>
<text class="view-clip px-1 text-18rpx c-white bg-red ml-1 rounded-r-1 rounded-lt-1">到手价</text>
</view>
</view>
@@ -84,6 +93,7 @@ import { prosperityShopApi } from "@/sheep/api"
import { onLoad } from "@dcloudio/uni-app"
import { filePath } from "@/sheep/utils/file"
import treeToList from "@/sheep/utils/tree-to-list"
import { displayPrice } from "@/sheep/utils/formatMoney"
interface scrollDetail {
deltaX: number
+6 -3
View File
@@ -86,14 +86,16 @@
<view class="w-full flex justify-between pr-1">
<text class="main-text-26 color-red!">
<text class="text-22rpx">¥</text>
<text>{{ pV.spuPrice.toFixed(2) }}</text>
<text>{{ pV.priceType == "1" ? displayPrice(pV.minPrice, "") : displayPrice(pV.spuPrice, "") }}</text>
</text>
<text class="sub-text-24">{{ pV.unit || "" }}</text>
</view>
<view class="w-full flex justify-between pr-1">
<text class="second-text-24 line-through">
<text class="text-22rpx">¥</text>
<text>{{ pV.originalPrice.toFixed(2) }}</text>
<template v-if="pV.priceType == '2'">
<text class="text-22rpx">¥</text>
<text>{{ displayPrice(pV.originalPrice, "") }}</text>
</template>
</text>
<text class="second-text-24">库存{{ pV.totalStock }}</text>
</view>
@@ -114,6 +116,7 @@ import { reactive, ref } from "vue"
import { filePath } from "@@/utils/file"
import { getAppInfo } from "@/sheep/utils/app"
import { APPENV } from "@/sheep/constant"
import { displayPrice } from "@/sheep/utils/formatMoney"
const state = reactive<any>({
params: {
@@ -1,12 +1,12 @@
<template>
<view class="max-h-[60vh] overflow-y-auto mb-20rpx">
<shop-categary-tree v-model="selectedNode" :node-data="categoryTree" @currentNode="currentNode" />
<shop-categary-tree v-model="selectedNode" :node-data="categoryTree" />
<view v-if="categoryTree.length === 0" class="text-center text-[#888] py-[40rpx]">暂无数据</view>
</view>
<view class="px-[20rpx] py-2 flex justify-between sticky bottom-0 bg-white">
<tm-button skin="thin" block @click="emit('cancel')">取消</tm-button>
&nbsp;&nbsp;
<tm-button block :disabled="!selectedCategary" @click="onConfirm">确定</tm-button>
<tm-button block :disabled="!selectedNode" @click="onConfirm">确定</tm-button>
</view>
</template>
@@ -23,11 +23,6 @@ defineProps({
const emit = defineEmits(["confirm", "cancel"])
const selectedNode = ref<any>({})
const selectedCategary = ref<any>({})
const currentNode = (item) => {
selectedCategary.value = item
}
function onConfirm() {
if (!selectedNode.value) {
+6 -2
View File
@@ -1,7 +1,11 @@
<template>
<view class="tree-container">
<view v-for="item in nodeData" :key="item.id">
<view class="tree-item" :style="{ backgroundColor: item.id == selectedNode.id ? '#4b93ff' : '' }" @click.stop="toCurrentNode(item)">
<view
class="tree-item"
:style="item.id == selectedNode.id ? { backgroundColor: '#4b93ff', color: '#fff' } : { color: '#000' }"
@click.stop="toCurrentNode(item)"
>
<text>{{ item.name }}</text>
</view>
@@ -29,7 +33,7 @@ const emit = defineEmits(["currentNode"])
const selectedNode = defineModel<any>("modelValue")
const toCurrentNode = (item) => {
// emit("currentNode", item)
emit("currentNode", item)
selectedNode.value = item
}