feat:商品管理

This commit is contained in:
weiwei committed 2025-09-12 12:19:58 +08:00
1 parent 0071f79580
commit dcf971dd8d
6 files changed
+120 -29

No files matched your search

+16 -7
View File
@@ -19,7 +19,7 @@ const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa)
}
onLoad(() => { })
onLoad(() => {})
onShow(() => {
if (pageRef.value) {
pageRef.value.reload(false)
@@ -49,9 +49,20 @@ const doDel = (id: string) => {
<template>
<crud-layout title="人脸管理" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="10"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<z-paging
ref="pageRef"
height="100%"
:fixed="false"
v-model="pageHook.list"
:default-page-size="10"
safe-area-inset-bottom
:loading-more-enabled="true"
:show-scrollbar="false"
@query="query"
:auto-clean-list-when-reload="false"
:auto-scroll-to-top-when-reload="false"
@scroll="pageHook.scroll"
>
<view class="h-20rpx" />
<view class="flex-col card p-x-20rpx p-y-30rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="v.id">
<view class="flex items-center justify-between second-text-26">
@@ -70,9 +81,7 @@ const doDel = (id: string) => {
</view>
</view>
<template #bottom>
<view v-if="false"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doAdd">
<view v-if="false" class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!" @tap="doAdd">
添加
</view>
<view class="h-30rpx" />
+37 -5
View File
@@ -144,7 +144,7 @@
<tm-button block size="s" skin="dashed" color="#E5F1FF" @click.stop="addSkuListItem()">添 加</tm-button>
</view>
<tm-button form-type="submit" block>提交</tm-button>
<tm-button form-type="submit" block>提 交</tm-button>
</tm-form>
<tm-drawer
@@ -170,8 +170,10 @@ import { hooks } from "@@/index"
import { prosperityShopApi } from "@/sheep/api"
import ShopCategaryPicker from "@/sheep/components/shop-categary-picker.vue"
import { onLoad } from "@dcloudio/uni-app"
import { filePath } from "@/sheep/utils/file"
const form = reactive<any>({
id: "",
title: "",
unit: "",
categoryId: "",
@@ -202,6 +204,7 @@ const _saleStartTimeStr = ref("")
const _saleEndTimeStr = ref("")
const showCategaryPicker = ref(false)
const categoryTree = ref([])
const categoryList = ref<any>([])
const rules: Record<string, TM.FORM_RULE[]> = {
title: [{ required: true, message: "请输入商品标题" }],
@@ -213,16 +216,41 @@ const rules: Record<string, TM.FORM_RULE[]> = {
coverImage: [{ required: true, message: "请上传商品图" }],
}
onLoad((options: any) => {
onLoad(async (options: any) => {
const { id = "" } = options
if (!id) return
getGoodsDetail(id)
await getGoodsCategory()
await getGoodsDetail(id)
})
const getGoodsDetail = async (id: string) => {
uni.showLoading({ title: "加载中..." })
const { code, data, msg } = await prosperityShopApi.getGoodsDetail(id)
if (code != 0 || !data) return uni.showToast({ title: msg || "商品详情获取失败", icon: "none" })
Object.assign(form, data, { status: data.status.toString(), priceType: data.priceType.toString() })
const skuList = data.skuList.map((item: any) => ({ ...item, status: item.status.toString() }))
const coverImage = [{ path: filePath(data.coverImage), response: JSON.stringify({ data: { url: data.coverImage } }) }]
const categoryName = categoryList.value.find((item: any) => item.id == data.categoryId)?.name
const saleStartTime = data.saleStartTime.split(" ")[0]
const saleEndTime = data.saleEndTime.split(" ")[0]
_saleStartTimeStr.value = saleStartTime
_saleEndTimeStr.value = saleEndTime
Object.assign(form, {
...data,
status: data.status.toString(),
priceType: data.priceType.toString(),
coverImage,
categoryName,
saleStartTime,
saleEndTime,
skuList,
})
uni.hideLoading()
}
const getGoodsCategory = async () => {
const { code, data, msg } = await prosperityShopApi.getGoodsCategory()
if (code != 0) return uni.showToast({ title: msg || "商品分类获取失败", icon: "none" })
categoryList.value = data
}
const selectCategary = () => {
@@ -280,12 +308,16 @@ const onsubmit = async (evt: TM.FORM_SUBMIT_RESULT) => {
}
try {
const { code, msg } = await prosperityShopApi.addGoods({ ...form, coverImage: JSON.parse(form.coverImage[0].response).data.url })
const params = { ...form, coverImage: JSON.parse(form.coverImage[0].response).data.url }
uni.showLoading({ title: "提交中..." })
const { code, msg } = await (form.id ? prosperityShopApi.editGoods(params) : prosperityShopApi.addGoods(params))
if (code != 0) return uni.showToast({ title: msg || "提交失败", icon: "none" })
uni.showToast({ title: "提交成功", icon: "success" })
uni.navigateBack()
} catch (error: any) {
uni.showToast({ title: error.message || "提交失败", icon: "none" })
} finally {
uni.hideLoading()
}
}
</script>
+2 -1
View File
@@ -69,7 +69,8 @@
<text>{{ v.email }}</text>
</view>
<view>
<text class="c-#0094ff! sub-text-26 px-2 bg-#0094ff22 rounded-2">营业:{{ v.businessHours }}</text>
<text class="c-#0094ff! sub-text-26 px-2 bg-#0094ff22 rounded-2 mr-2">营业</text>
<text class="c-#0094ff! sub-text-26 px-2 bg-#0094ff22 rounded-2">{{ v.businessHours }}</text>
</view>
<view class="second-text-26">
<image class="w-24rpx h-24rpx mr-1" src="@/static/page/address.svg" />