From 181f305f9126d700fdad299df9d0759b12c9f989 Mon Sep 17 00:00:00 2001 From: weiwei Date: Mon, 15 Sep 2025 19:39:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=B1=E5=AF=8C=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/prosperity-shop/categary-manage.vue | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/pages/prosperity-shop/categary-manage.vue b/src/pages/prosperity-shop/categary-manage.vue index 393aea8..5c3208a 100644 --- a/src/pages/prosperity-shop/categary-manage.vue +++ b/src/pages/prosperity-shop/categary-manage.vue @@ -53,6 +53,17 @@ + 分类图 + + 注:图片大小不超过5M 保 存 @@ -66,14 +77,16 @@ import { onLoad } from "@dcloudio/uni-app" import { reactive, ref } from "vue" import NodeTree from "@/sheep/components/node-tree.vue" import { useCategaryManage } from "./use-categary-manage" +import { hooks } from "@@/index" import { filePath } from "@/sheep/utils/file" const categaryFormDrawer = ref(false) -const form = reactive({ +const form = reactive({ id: "", name: "", status: "0", // 状态(0正常,1下架) parentId: "", + picUrl: [], }) const categoryTree = ref([]) const selectedNode = ref({}) @@ -98,6 +111,7 @@ const addCategary = () => { name: "", status: "0", parentId: "", + picUrl: [], }) selectedNode.value = {} categaryFormDrawer.value = true @@ -106,7 +120,8 @@ const addCategary = () => { // 编辑分类 const editCategary = (item) => { getCategaryTree() - Object.assign(form, item) + const picUrl = [{ path: filePath(item.picUrl), response: JSON.stringify({ data: { url: item.picUrl } }) }] + Object.assign(form, { ...item, picUrl }) selectedNode.value = { id: item.parentId } categaryFormDrawer.value = true } @@ -116,7 +131,11 @@ const saveCategary = async () => { 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 } + const params = { + ...form, + parentId: selectedNode.value.id, + picUrl: JSON.parse(form.picUrl[0].response).data.url, + } uni.showLoading({ title: "保存中..." }) const { code, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params)) if (code != 0) return uni.showToast({ title: msg || "保存失败", icon: "none" })