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" })