幼教产品B2B生态平台小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
5.8 KiB

11 months ago
<template>
<view>
<view class="page">
<ul class="tab">
<li :class="{active: curTab === ''}" @click="tabChange('')">全部</li>
11 months ago
<li :class="{active: curTab === 0}" @click="tabChange(0)">已上架({{ status0 }})</li>
<li :class="{active: curTab === 2}" @click="tabChange(2)">已下架({{ status2 }})</li>
<li :class="{active: curTab === 3}" @click="tabChange(3)">草稿({{ status3 }})</li>
<li :class="{active: curTab === 4}" @click="tabChange(4)">审核中({{ status4 }})</li>
11 months ago
</ul>
<template v-if="list.length">
<view class="list">
11 months ago
<view class="item" v-for="item in list" @click="toDetail(item)">
11 months ago
<view class="metas">
11 months ago
<view class="time">{{ item.putawayTime }}</view>
<view :class="['status', {grounding: !item.status}]">{{ Goods.goodsStatus.find(e => e.id === item.status).name }}</view>
11 months ago
</view>
<view class="info">
11 months ago
<image class="pic" :src="item.pic"></image>
11 months ago
<view class="texts">
11 months ago
<view class="name">{{ item.prodName }}</view>
11 months ago
<view class="meta">
市场价20.00
<text class="sell">售价10</text>
</view>
<view class="meta">
库存1000
已售500
</view>
<view class="btns">
<!-- <view class="btn" @click.stop="toDetail(item)">查看</view> -->
11 months ago
<template v-if="item.status === 2 || item.status === 3">
<view class="btn del" @click.stop="del(item)">删除</view>
<view class="btn" @click.stop="toEdit(item)">编辑</view>
</template>
<view v-else-if="!item.status" class="btn off" @click.stop="changeStatus(item)">下架</view>
11 months ago
</view>
</view>
</view>
</view>
</view>
<uni-load-more :status="status" />
</template>
<empty v-else text="暂无商品"></empty>
<uni-icons class="plus" type="plus-filled" size="60" color="#007eff" @click="$util.to('../addGoods/addGoods')"></uni-icons>
</view>
</view>
</template>
<script>
import { page, batchDelete, prodStatus } from '@/apis/modules/goods.js'
11 months ago
import Goods from '@/config/goods.js'
11 months ago
export default {
data() {
return {
11 months ago
Goods,
11 months ago
curTab: '',
tabs: [],
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
searchTimer: null,
keyword: '',
list: [],
page: 1,
11 months ago
pageSize: 10,
status0: 0,
status2: 0,
status3: 0,
status4: 0,
11 months ago
}
},
watch: {
keyword () {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initList()
}, 500)
}
},
// 下拉刷新
onPullDownRefresh() {
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
this.getList()
}
},
onShow() {
11 months ago
this.status0 = 0
this.status2 = 0
this.status3 = 0
this.status4 = 0
11 months ago
this.initList()
},
methods: {
// 获取列表
getList() {
uni.showLoading({
title: '加载中'
})
page({
status: this.curTab
}).then(({ data }) => {
uni.hideLoading()
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值
11 months ago
const list = data.records
list.forEach(e => {
if (e.pic) e.pic = e.pic.split(',')[0]
})
this.list = this.reachBottom > 0 ? [...this.list, ...list] : list
11 months ago
this.page++ // 每次获取了数据后page+1
const noMore = this.list.length === data.total // 是否加载完所有数据
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1
}).catch(e => {
uni.hideLoading()
})
},
initList() {
this.page = 1
this.reachBottom = 0
this.getList()
},
// tab切换
tabChange(id) {
this.curTab = id
this.initList()
},
11 months ago
// 下架
async changeStatus(row, status) {
const that = this
uni.showModal({
title: '提示',
content: `确定要下架吗?`,
async success(res) {
if (res.confirm) {
await prodStatus(row.prodId, 2)
that.initList()
}
}
})
},
// 删除
del(row) {
const that = this
uni.showModal({
title: '提示',
content: '确定要删除吗?',
async success(res) {
if (res.confirm) {
await batchDelete([row.prodId])
that.$util.sucMsg('删除成功')
that.initList()
}
}
})
11 months ago
},
// 跳转详情
toDetail(item) {
11 months ago
this.$util.to(`../addGoods/addGoods?prodId=${item.prodId}&show=1`)
11 months ago
},
// 跳转编辑
toEdit(item) {
11 months ago
this.$util.to(`../addGoods/addGoods?prodId=${item.prodId}`)
11 months ago
},
}
}
</script>
<style scoped lang="scss">
.page {
padding-bottom: 90px;
}
.list {
margin-top: 20rpx;
11 months ago
padding: 20rpx;
.item {
11 months ago
padding: 20rpx;
margin-bottom: 20rpx;
// border-bottom: 1px solid #f1f1f1;
background-color: #fff;
}
.metas {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
}
.time {
font-size: 24rpx;
color: #333;
}
.status {
font-size: 24rpx;
color: #333;
}
11 months ago
.grounding {
color: #1fc133;
}
11 months ago
.info {
display: flex;
align-items: center;
}
.pic {
11 months ago
width: 280rpx;
height: 180rpx;
11 months ago
margin-right: 20rpx;
11 months ago
border-radius: 8px;
}
.texts {
width: calc(100% - 300rpx);
11 months ago
}
.name {
font-size: 30rpx;
color: #333;
}
.meta {
display: flex;
margin: 10rpx 0;
11 months ago
font-size: 24rpx;
11 months ago
color: #999;
}
.btns {
11 months ago
display: flex;
justify-content: flex-end;
margin-top: 20rpx;
11 months ago
}
.btn {
11 months ago
padding: 10rpx 50rpx;
11 months ago
margin-left: 20rpx;
font-size: 28rpx;
color: #fff;
background-color: $uni-primary;
11 months ago
border-radius: 20px;
11 months ago
&.del {
11 months ago
background-color: #ff982e;
11 months ago
}
&.off {
11 months ago
background-color: #e23636;
11 months ago
}
}
}
</style>