feat:共富商城商品搜索和基本管理

This commit is contained in:
weiwei committed 2025-09-10 19:06:03 +08:00
1 parent 4cc0ac316e
commit f716bd685f
10 files changed
+213 -49

No files matched your search

+2 -2
View File
@@ -66,7 +66,7 @@ const tabbar: TabbarItem[] = [
text: "共富商城",
iconPath: "/static/tabbar/prosperity-shop.png",
selectedIconPath: "/static/tabbar/prosperity-shop-select.png",
launchParam: ["onlineShop"],
launchParam: ["prosperityShop"],
auth: ["user"],
},
{
@@ -114,7 +114,7 @@ const tabbar: TabbarItem[] = [
text: "我的",
iconPath: "/static/tabbar/my.png",
selectedIconPath: "/static/tabbar/my-select.png",
launchParam: ["canteen", "selfMerchant", "onlineShop", "coopMerchant", "integrated"],
launchParam: ["canteen", "selfMerchant", "onlineShop", "coopMerchant", "integrated", "prosperityShop"],
auth: ["user", "merchant", "doorAdmin"],
},
]
+14
View File
@@ -151,6 +151,20 @@
"navigationBarTitleText": "超市详情",
"disableScroll": true
}
},
{
"path": "goods-search",
"style": {
"navigationBarTitleText": "商品搜索",
"disableScroll": true
}
},
{
"path": "goods-manage",
"style": {
"navigationBarTitleText": "商品管理",
"disableScroll": true
}
}
]
},
@@ -0,0 +1,30 @@
<template>
<crud-layout bg="/static/page/blue-bg.png">
<template #top> </template>
</crud-layout>
</template>
<script setup lang="ts">
import { reactive } from "vue"
import { prosperityShopApi } from "@/sheep/api"
import { onLoad } from "@dcloudio/uni-app"
const state = reactive({
goodsList: [],
})
onLoad(async () => {
await getGoodsList()
})
const getGoodsList = async () => {
const params = {
current: 1,
size: 99999,
// categoryId: state.category[state.curCategoryIndex].id,
}
const { code, data, msg } = await prosperityShopApi.getGoodsList(params)
if (code != 0) return uni.showToast({ title: msg || "商品列表获取失败", icon: "none" })
state.goodsList = data?.records ?? []
}
</script>
+106
View File
@@ -0,0 +1,106 @@
<template>
<crud-layout mainIsScroll 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"
>
<template #top>
<view class="w-full my-2">
<tm-input
class="flex-1"
v-model="state.params.keyword"
type="text"
height="72"
minHeight="72"
fontSize="28"
:showClear="true"
:focus="false"
placeholder="请输入商品名称"
style="border: 4rpx solid #0779fd; border-radius: 14rpx"
:focus-highlight="false"
color="#ECF4F9"
>
<template v-slot:rightIcon>
<tm-button class="mr-1 px-3 py-26rpx text-30rpx!" size="xs" @click="search">搜 索</tm-button>
</template>
</tm-input>
</view>
</template>
<view v-for="v in pageHook.list" :key="v.id" class="card flex mx-20rpx mb-2 p-2" @click="doGoodsDetail(v.id)">
<image :src="filePath(v.coverImage)" class="size-160rpx rounded-12rpx bg-#eeeeee" mode="aspectFill" />
<view class="flex-1 ml-2 overflow-hidden">
<view class="truncate sub-text-30">{{ v.title }}</view>
<view>
<text class="c-#0094ff! sub-text-24 px-2 bg-#0094ff22 rounded-2">{{ v.status == "0" ? "在售" : "未售" }}</text>
</view>
<view>
<text class="second-text-26 mr-2">单位 {{ v.unit }}</text>
<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>
<text class="view-clip px-1 text-18rpx c-white bg-red ml-1 rounded-r-1 rounded-lt-1">到手价</text>
</view>
</view>
</view>
</z-paging>
</crud-layout>
</template>
<script setup lang="ts">
import { hooks } from "@/sheep"
import { prosperityShopApi } from "@/sheep/api"
import { reactive, ref } from "vue"
import { filePath } from "@/sheep/utils/file"
import { onLoad } from "@dcloudio/uni-app"
const state = reactive<any>({
params: {
keyword: "",
merchantId: "",
},
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, prosperityShopApi.getGoodsList, null, "data.records")
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.params)
}
onLoad((options: any) => {
const { merchantId } = options
if (!merchantId) return uni.showToast({ title: "参数错误", icon: "none" })
state.params.merchantId = merchantId
})
// 点击搜索
const search = () => {
pageRef.value && pageRef.value.reload(true)
}
const doGoodsDetail = (id: string) => {
if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" })
uni.navigateTo({
url: `/pages/prosperity-shop/goods-detail?id=${id}`,
})
}
</script>
+15 -5
View File
@@ -7,6 +7,7 @@
<view
class="fixed right-20 h-72rpx bg-#ECF4F9cc px-20rpx top-20 flex items-center flex-nowrap overflow-hidden rounded-20rpx"
:style="searchStyle"
@click="goSearch"
>
<image class="w-36rpx h-36rpx" src="@/static/page/shop-goods-search.png" />
<text v-if="scrollDetail.scrollTop > 30" class="bg-#eeeeee44 whitespace-nowrap overflow-hidden second-text-26 ml-2">搜索商品</text>
@@ -40,8 +41,13 @@
<view class="menu_item_title show-line">{{ v.name }}</view>
</view>
</scroll-view>
<scroll-view v-if="state.goodsList.length > 0" scroll-y class="flex-1 overflow-hidden pb-20rpx flex">
<view v-for="v in state.goodsList" :key="v.id" class="card flex mx-15rpx mb-2 p-2" @click="doGoods(v.id)">
<scroll-view
v-if="state.goodsList.length > 0"
scroll-y
class="flex-1 overflow-hidden pb-20rpx flex"
style="height: calc(100vh - 420rpx)"
>
<view v-for="v in state.goodsList" :key="v.id" class="card flex mx-15rpx mb-2 p-2" @click="doGoodsDetail(v.id)">
<image :src="filePath(v.coverImage)" class="size-160rpx rounded-12rpx bg-#eeeeee" mode="aspectFill" />
<view class="flex-1 ml-2 overflow-hidden">
<view class="truncate sub-text-30">{{ v.title }}</view>
@@ -141,7 +147,6 @@ const doCategory = async (index: number) => {
const scroll = (e: any) => {
scrollDetail.value = e.detail
console.log(e)
}
const filterStyle = computed(() => {
@@ -163,16 +168,21 @@ const searchStyle = computed(() => {
return {
width: `${calcWidth + minWidth}%`,
border: `2rpx solid #1879ff`,
// opacity: Math.max(1,),
opacity: (calcWidth / 100) * 2,
}
})
const doGoods = (id: string) => {
const doGoodsDetail = (id: string) => {
if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" })
uni.navigateTo({
url: `/pages/prosperity-shop/goods-detail?id=${id}`,
})
}
const goSearch = () => {
if (!state.detail.id) return uni.showToast({ title: "超市id不存在", icon: "none" })
uni.navigateTo({ url: `/pages/prosperity-shop/goods-search?merchantId=${state.detail.id}` })
}
</script>
<style lang="scss" scoped>
+10
View File
@@ -28,6 +28,12 @@ const moduleList = [
iconPath: "/static/tabbar/online-shop-select.png",
launchParam: "onlineShop",
},
{
pagePath: "/pages/tabbar/prosperityShop",
text: "共富商城",
iconPath: "/static/tabbar/prosperity-shop-select.png",
launchParam: "prosperityShop",
},
{
pagePath: "/pages/tabbar/cabinet",
text: "智能柜",
@@ -106,6 +112,10 @@ const jumpByParam = async () => {
uni.setStorageSync("launchParam", launchParam)
return uni.reLaunch({ url: "/pages/tabbar/onlineShop" })
}
if (launchParam === "prosperityShop") {
uni.setStorageSync("launchParam", launchParam)
return uni.reLaunch({ url: "/pages/tabbar/prosperityShop" })
}
if (launchParam === "coopMerchant") {
uni.setStorageSync("launchParam", launchParam)
return uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
+18 -10
View File
@@ -3,10 +3,13 @@
<tm-sticky>
<tm-sticky-header>
<view class="flex-row items-center bg-#ECF4F9 py-3">
<image v-if="state.userInfo?.sysUser?.avatar" class="w-100rpx h-100rpx rounded-full"
:src="filePath(state.userInfo.sysUser.avatar)" mode="aspectFill" />
<image v-else class="w-100rpx h-100rpx rounded-full" src="/static/icon/default-avatar.png"
mode="aspectFill" />
<image
v-if="state.userInfo?.sysUser?.avatar"
class="w-100rpx h-100rpx rounded-full"
:src="filePath(state.userInfo.sysUser.avatar)"
mode="aspectFill"
/>
<image v-else class="w-100rpx h-100rpx rounded-full" src="/static/icon/default-avatar.png" mode="aspectFill" />
<view class="m-l-30rpx" v-if="state.userInfo?.sysUser?.userId">
<view class="flex-row items-center">
<text class="sub-text-30">{{ state.userInfo?.sysUser?.name }}</text>
@@ -22,8 +25,7 @@
</tm-sticky-header>
<view class="m-t-10rpx rounded-20rpx shadow-main p-30rpx p-b-40rpx bg-white!">
<view class="service_item flex-row items-center justify-between" v-for="(v, i) in state.menuList"
:key="i" @tap="onTabMenu(v)">
<view class="service_item flex-row items-center justify-between" v-for="(v, i) in state.menuList" :key="i" @tap="onTabMenu(v)">
<view class="flex-row-center">
<image class="w-40rpx h-40rpx" :src="v.icon" mode="aspectFill" />
<text class="sub-text-28 m-l-20rpx">{{ v.text }}</text>
@@ -33,15 +35,13 @@
</view>
<view v-if="isDevEnv()" class="flex-col-center m-t-40rpx m-x-30rpx">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff"
@tap="doLogout">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff" @tap="doLogout">
退出登录
</view>
</view>
<view class="h-30rpx" />
<view v-if="state.appInfo == APPENV.SH" class="flex-col-center m-t-40rpx m-x-30rpx">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff"
@tap="doChangeRole">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff" @tap="doChangeRole">
切换角色
</view>
</view>
@@ -426,10 +426,18 @@ onLoad(async () => {
await userApi.userRole()
await isMerchant()
// 获取存储中的用户信息
storage.getUserInfo()
})
const isMerchant = async () => {
const { data } = await userApi.isMerchant()
if (data)
state.menuList.unshift({ text: "共富商城商品管理", icon: "/static/icon/service_4.png", router: "/pages/prosperity-shop/goods-manage" })
}
onShow(() => {
// 获取存储中的用户信息
storage.getUserInfo()
+10 -24
View File
@@ -19,7 +19,7 @@
<tm-text font-size="40" color="#0779FD" class="font-bold">共富商城</tm-text>
<tm-text font-size="30" color="#0779FD">优质商户,品质商品,欢迎联系购买</tm-text>
</view>
<view class="w-full flex items-center">
<view class="w-full flex items-center mb-2">
<tm-input
class="flex-1"
v-model="state.params.keyword"
@@ -40,7 +40,7 @@
</tm-input>
</view>
<scroll-view scroll-x>
<!-- <scroll-view scroll-x>
<view class="w-full flex my-2">
<view
class="w-300rpx mr-2 sub-text-28 py-1 px-2 rounded-1 bg-#fff border border-solid border-transparent whitespace-nowrap"
@@ -52,7 +52,7 @@
{{ v.name }}
</view>
</view>
</scroll-view>
</scroll-view> -->
</template>
<view class="card p-20rpx mb-20rpx" v-for="(v, i) in pageHook.list" :key="i" @tap="toDetail(v)">
@@ -64,7 +64,7 @@
<text class="mr-20rpx">{{ v.contactName }}</text>
<text class="mr-20rpx">
<image class="w-24rpx h-24rpx mr-1" src="@/static/page/phone.svg" />
<text @tap="doPhone(v.contactPhone)">{{ v.contactPhone }}</text>
<text @tap.stop="doPhone(v.contactPhone)">{{ v.contactPhone }}</text>
</text>
<text>{{ v.email }}</text>
</view>
@@ -116,10 +116,8 @@ import { APPENV } from "@/sheep/constant"
const state = reactive<any>({
params: {
categoryId: "",
keyword: "",
},
classifyList: [],
shopList: [],
})
const pageRef = ref<any>(null)
@@ -132,30 +130,18 @@ const query = (page: number, pagesize: number) => {
onLoad(async () => {
const app = getApp()
app._initTabbar()
await getShopCategory()
})
// 获取超市分类
const getShopCategory = async () => {
const { data } = await prosperityShopApi.getShopCategory()
state.classifyList = data ?? []
state.classifyList.unshift({ id: "", name: "全部分类" })
if (!isEmpty(state.classifyList)) {
state.params.categoryId = state.classifyList[0].id
}
}
// 切换分类
const doClassify = async (categoryId: string) => {
if (state.params.categoryId == categoryId) return
state.params.categoryId = categoryId
pageRef.value && pageRef.value.reload(true)
}
// const doClassify = async (categoryId: string) => {
// if (state.params.categoryId == categoryId) return
// state.params.categoryId = categoryId
// pageRef.value && pageRef.value.reload(true)
// }
// 点击搜索
const search = () => {
state.params.categoryId = ""
// state.params.categoryId = ""
pageRef.value && pageRef.value.reload(true)
}
+1 -1
View File
@@ -27,7 +27,7 @@
<view class="w-64 h-64 rounded-full flex-col-center mr-8">
<image src="@/static/page/merchantRole.svg" />
</view>
<view class="main-text-32 mb-1">我是商户</view>
<view class="main-text-32 mb-1">我是合作商户</view>
</view>
</view>
+7 -7
View File
@@ -10,13 +10,13 @@ export default {
})
},
// 获取超市商户分类列表
getShopCategory: (): Promise<any> => {
return request({
url: "/supermarket/app/mall/merchant/category/list",
method: "GET",
})
},
// 获取超市商户所属分类列表
// getShopCategory: (): Promise<any> => {
// return request({
// url: "/supermarket/app/mall/merchant/category/list",
// method: "GET",
// })
// },
// 获取超市详情
getShopDetail: (id: string): Promise<any> => {
return request({
url: `/supermarket/app/mall/merchant/${id}`,