You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
4.5 KiB
Vue

<template>
<view class="content">
<view class=" bg-white sticky top-0 z-50">
<wd-search @search="search" v-model="params.keywords" hide-cancel>
<template #prefix>
<wd-popover v-model="popover" mode="menu" :content="menu" @menuclick="changeSearchType">
<view class="search-type">
<text>{{ searchType }}</text>
<wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
</view>
</wd-popover>
</template>
</wd-search>
<wd-drop-menu custom-class="flex w-full bg-white" v-show="classifyList.length">
<wd-drop-menu-item custom-class="flex-1" v-model="value2" :options="classifyList" label-key="name"
value-key="id" />
</wd-drop-menu>
</view>
<div class="goodsBox p-2">
<myList ref="myListRef" :apiObj="goods.list" :params="params">
<template #default="{ list }">
<div>
<div v-for="item of list" class="goods">
<wd-card type="rectangle">
<template #title>
<view class="title">
<view>库存:<span class="font-bold">{{ item.stock_num }}</span></view>
<view v-if="!(item.stock_num > 0)" class="title-tip">
<wd-icon name="warning" size="14px" custom-style="vertical-align: bottom" />
商品库存不足
</view>
</view>
</template>
<view style="height: 60px;" class="content">
<image :src="item.pic_url" width="40" height="40" alt="joy"
style="border-radius: 4px; margin-right: 12px;width: 60px;height: 60px;min-width: 60px;" />
<view>
<view style="color: rgba(0,0,0,0.85); font-size: 16px;">{{ item.name }}</view>
<view class="font-bold" style="color: rgb(255, 0, 0); font-size: 16px;">¥{{ item.price_min }}</view>
</view>
</view>
<template #footer>
<view>
<wd-button @click="changeS(item)" v-if="item.status == 1" size="small" plain
style="margin-right: 8px;">下架</wd-button>
<wd-button @click="changeS(item)" v-if="item.status !== 1" size="small"
style="margin-right: 8px;">上架</wd-button>
<wd-button size="small"></wd-button>
</view>
</template>
</wd-card>
</div>
</div>
</template>
</myList>
</div>
<wd-toast />
</view>
</template>
<script setup>
import { ref } from 'vue'
import goods from '@/api/store/goods.js'
import myList from "/components/myList/index.vue"
import { useToast } from '@/uni_modules/wot-design-uni'
const toast = useToast()
const option2 = ref([
{ label: '综合', value: 0 },
{ label: '销量', value: 1 },
{ label: '上架时间', value: 2 }
])
const value2 = ref(0)
// const tab = ref(0)
const params = {
keywords: "",
calssify_id: 0,
status: "",
}
const myListRef = ref(null)
const search = ({ value }) => {
myListRef.value.upData({
keywords: value
})
}
const searchType = ref('全部')
const popover = ref(false)
const menu = ref([
{
content: '全部'
},
{
content: '已上架'
},
{
content: '已下架'
}
])
function changeSearchType({ item, index }) {
searchType.value = item.content
if (item.content == '全部') {
params.status = ""
}
if (item.content == '已上架') {
params.status = 1
}
if (item.content == '已下架') {
params.status = 0
}
search({
value: ""
})
}
const changeS = (row) => {
goods.goodsEditAttribute({
id: row.id,
value: [1, 0][row.status],
type: "status"
}).then(res => {
if (res.code == 0) {
toast.success('操作成功')
row.status = [1, 0][row.status]
} else {
showNotify({ type: 'error', message: '出错了' })
}
})
}
const classifyList = ref([])
const getClassify = () => {
goods.classify.list().then(res => {
classifyList.value = res.data
classifyList.value.unshift({
id: 0,
name: "店铺分类"
})
})
}
getClassify()
</script>
<style lang="scss" scoped>
.search-type {
position: relative;
height: 30px;
line-height: 30px;
padding: 0 8px 0 16px;
font-size: 24rpx;
color: rgba(0, 0, 0, .45);
}
.search-type::after {
position: absolute;
content: '';
width: 1px;
right: 0;
top: 5px;
bottom: 5px;
background: rgba(0, 0, 0, 0.25);
}
.search-type {
:deep(.icon-arrow) {
display: inline-block;
font-size: 20px;
vertical-align: middle;
}
}
.goodsBox {
.content,
.title {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.content {
justify-content: flex-start;
}
.title {
justify-content: space-between;
}
.title-tip {
color: rgba(0, 0, 0, 0.25);
font-size: 12px;
}
}
</style>