Files
jjx-web-sign-only/pages/spot/goods/goods.vue
T
2026-10-08 18:20:51 +08:00

576 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<!-- <view class="page-nav">
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item><navigator url="/pages/spot/goods/goods">现货市场</navigator></el-breadcrumb-item>
</el-breadcrumb>
</view> -->
<view class="carousel">
<common-swiper page="spot"/>
<view class="goods-options">
<el-row class="">
<el-button @click="toRelease" type="primary" round>发布现货</el-button>
<el-button @click="toMy" type="primary" round plain class="empty-bg-plain-btn">我发布的现货
</el-button>
</el-row>
</view>
</view>
<!-- 筛选表单 -->
<view class="filter-outer">
<el-form @submit.native.prevent label-width="80px">
<el-form-item label="关键词" class="border-bottom pb-30">
<el-input @keyup.enter.native="search(1)" clearable placeholder="输入关键字搜索" v-model="keyword">
<i slot="prefix" class="el-input__icon el-icon-search"></i>
<el-button @click="search(1)" type="primary" slot="append" style="border-radius: 0">搜索
</el-button>
</el-input>
</el-form-item>
<el-form-item label="现货分类" class="border-bottom pb-30">
<view class="flex justify-start items-center flex-wrap">
<text @click="clickedCateIndex = -1" class="pointer mr-25"
:class="[clickedCateIndex === -1 ? 'text-main selected-cate' : '']">全部
</text>
<view v-for="(item, index) in categoryTreeData" :key="index">
<text @click="clickedCateIndex = index" class="pointer mr-25"
:class="[clickedCateIndex === index ? 'text-main selected-cate' : '']"
v-if="index < 10">
{{ item.name }}
</text>
</view>
</view>
<view class="child-cate flex justify-start items-center flex-wrap">
<template v-if="clickedCateIndex === -1">
<text class="pointer mr-25" @click="selectCate(item._id)"
:class="[checkCategoryList.includes(item._id) ? 'text-main' : '']"
v-for="(item, index) in allChildCate" :key="index">{{ item.name }}
</text>
</template>
<template v-else>
<text class="pointer mr-25" @click="selectCate(item._id)"
:class="[checkCategoryList.includes(item._id) ? 'text-main' : '']"
v-for="(item, index) in categoryTreeData[clickedCateIndex].children" :key="index">
{{ item.name }}
</text>
</template>
</view>
</el-form-item>
<el-form-item label="城市" class="border-bottom pb-30">
<view class="flex justify-start items-center flex-wrap">
<text @click="selectProvince(-1)" class="pointer mr-25 flex-grow-0"
:class="[checkProvinceList.length === 0 ? 'text-main selected-cate' : '']">全国
</text>
<view v-for="(item, index) in provinceData" :key="index" class="flex-grow-0 pointer mr-25">
<text @click="selectProvince(item.code)"
:class="[checkProvinceList.includes(item.code)? 'text-main selected-cate' : '']"
v-if="index < 10 || showAllProvince">
{{ item.name }}
</text>
</view>
<!-- <text @click="showAllProvince = !showAllProvince" class="pointer mr-25">查看更多-->
<!-- </text>-->
</view>
</el-form-item>
<el-form-item label="已选择">
<view class="tags">
<el-tag v-for="(item, index) in checkCategoryArr" :key="index">{{ item.name }}</el-tag>
</view>
</el-form-item>
</el-form>
</view>
<div class="flex justify-between items-center w-1200 m-a">
<template v-if="ad9.length">
<el-carousel :height="`100px`" :style="{width: ad10.length ? '50%' : '100%'}" class="m-a">
<el-carousel-item v-for="(item, index) in ad9" :key="index" :style="{width: '100%'}">
<image @click="vk.navigateTo(`/pages/yellowPage/info?id=${item.companyId}`)"
class="pointer carousel-img" :src="item.swiper" mode="aspectFill"
:style="{width: '100%'}"/>
</el-carousel-item>
</el-carousel>
</template>
<template v-if="ad10.length">
<el-carousel :height="`100px`" :style="{width: ad9.length ? '50%' : '100%'}" class="m-a">
<el-carousel-item v-for="(item, index) in ad10" :key="index" :style="{width: '100%'}">
<image @click="vk.navigateTo(`/pages/yellowPage/info?id=${item.companyId}`)"
class="pointer carousel-img" :src="item.swiper" mode="aspectFill"
:style="{width: '100%'}"/>
</el-carousel-item>
</el-carousel>
</template>
</div>
<!-- 商品列表 -->
<template v-if="!loading">
<template v-if="goodsData.rows.length > 0">
<view class="goods-list">
<view v-for="(item, index) in goodsData.rows" :key="index" class="goods"
:style="{marginRight:( (index + 1) % 5 === 0 && index > 0) ? 0 : '28px'}">
<view class="top" v-if="item.isTop">特别推荐</view>
<view class="top" v-if="!item.isTop && index < 10">最新</view>
<view class="goods-title">{{ item.name }}</view>
<view class="goods-stock mt-40">现货库存:{{ item.stock }}吨</view>
<view class="goods-address text-gray">供货地:{{ item.addressStr }}</view>
<!-- <view class="goods-image">-->
<!-- <image :src="item.user.businessCard.logo" mode="aspectFit"></image>-->
<!-- </view>-->
<view class="goods-company">
<template v-if="item.user">
<view v-if="item.user.accountType == 1">{{
item.user.person.personName.replace(/^(.).*$/, "$1**")
}}
</view>
<view v-if="item.user.accountType == 2">{{
item.user.company.companyName.replace(/^(.)(.).*(.)(.)(.)(.)$/, "$1$2***$3$4$5$6")
}}
</view>
</template>
</view>
<el-button @click="vk.navigateTo('/pages/spot/goods/detail?id=' + item._id);" type="primary"
plain
class="empty-bg-plain-btn"
size="small">立即查看
</el-button>
</view>
</view>
</template>
<view v-else class="flex justify-center items-center flex-col">
<data-null theme="outline" size="24" fill="#9b9b9b" strokeLinecap="square"/>
<text class="text-gray mt-20">暂无内容</text>
</view>
</template>
<view class="paginatio">
<el-pagination
:page-size="pageSize"
:current-page="pageIndex"
@current-change="search"
background
layout="prev, pager, next"
:total="goodsData.total">
</el-pagination>
</view>
<right-bar></right-bar>
<common-footer></common-footer>
</view>
</template>
<script>
import provinces from "@/uni_modules/vk-uview-ui/libs/address/provinces.json";
import {DataNull} from '@icon-park/vue'
export default {
components: {DataNull},
data() {
return {
pageSize: 20,
pageIndex: 1,
categoryTreeData: [],
allChildCate: [],
checkCategoryList: [],
clickedCateIndex: -1,
provinceData: provinces,
checkProvinceList: [],
keyword: '',
goodsData: {
total: 0,
rows: []
},
showAllProvince: true,
loading: false,
ad9: [],
ad10: [],
};
},
onLoad(options) {
if (options && options.keyword) this.keyword = options.keyword
},
onShow() {
this.search(1)
vk.callFunction({
url: 'client/spot/category/pub/getTree',
data: {},
success: (data) => {
this.categoryTreeData = data.rows
this.allChildCate = []
this.categoryTreeData.forEach(item => {
item.children.forEach(child => {
this.allChildCate.push(child)
})
})
}
});
},
methods: {
selectCate(id) {
const index = this.checkCategoryList.indexOf(id)
if (index === -1) this.checkCategoryList.push(id)
else this.checkCategoryList.splice(index, 1)
this.search(1)
},
selectProvince(code) {
if (code === -1) this.checkProvinceList = []
else {
// const index = this.checkProvinceList.indexOf(code)
// if (index === -1) this.checkProvinceList.push(code)
// else this.checkProvinceList.splice(index, 1)
this.checkProvinceList = [code]
}
this.search(1)
},
async toRelease() {
const {userInfo, accountNum} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
console.log(userInfo.businessCard)
if (!userInfo.fadadaConfirm || [-1, 2].includes(userInfo.authStatus)) {
this.$confirm('您尚未认证, 是否前往个人中心认证?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
this.$confirm('您尚未认证和完善名片,是否前往个人中心?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (accountNum === 0) {
this.$confirm('请先到个人中心添加收款账户', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=account'});
})
} else {
if (userInfo.businessCard.status !== 1) {
this.$confirm('您的名片信息未审核,请耐心等待', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
return
}
if (userInfo.userLevel < 1) {
this.$confirm('非年费会员,无法发布现货', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
return
}
vk.navigateTo({
url: '/pages/spot/release/release'
})
}
},
async toMy() {
const {userInfo} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
if (!userInfo.fadadaConfirm && userInfo.authStatus === 1) {
this.$confirm('您尚未认证, 是否前往个人中心认证?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
this.$confirm('您尚未认证和完善名片,是否前往个人中心?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo('/pages/user/user?menu=fadada');
})
} else {
if (userInfo.businessCard.status !== 1) {
this.$confirm('您的名片信息未审核,请耐心等待', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
return
}
if (userInfo.userLevel < 1) {
this.$confirm('非年费会员,无法发布现货', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
return
}
vk.navigateTo({
url: '/pages/spot/goods/my'
})
}
},
search(pageIndex) {
this.loading = true
vk.callFunction({
url: 'client/spot/goods/pub/getList',
title: '请求中...',
data: {
pageIndex: pageIndex,
pageSize: this.pageSize,
keyword: this.keyword,
// categoryIds: this.allChildCate.filter(item => this.checkCategoryList.includes(item._id)).map(item => item.name),
categoryIds: this.checkCategoryList,
provinceCodes: this.checkProvinceList
},
success: (data) => {
this.loading = false
data.rows.forEach(item => {
try {
item.addressStr = item.address.province.name + "-" + item.address.city.name + "-" + item.address.area.name
} catch (err) {
item.addressStr = ""
}
})
this.goodsData = data
this.getAd9()
this.getAd10()
}
});
},
getCertUrl() {
vk.callFunction({
url: 'client/fadada.getVerifyUrl',
success: (res) => {
location.href = res.data.url
}
});
},
async getAd9() {
this.ad9 = []
// if (this.checkProvinceList.length === 0) {
const res = await vk.callFunction({
url: 'client/ad/pub/getList',
data: {
adKey: 9,
region: this.checkProvinceList.length > 0 ? this.checkProvinceList[0] : null
}
})
if (res.data) this.ad9 = res.data
// }else {
// const {rows} = await vk.callFunction({
// url: 'client/user/pub/getCompany',
// data: {
// pageIndex: 1,
// pageSize: 5,
// isCoop: 1,
// province: this.checkProvinceList
// }
// })
// rows.forEach(item => {
// if (item.businessCard.album && item.businessCard.album.length > 0) {
// this.ad9.push({
// swiper: Array.isArray(item.businessCard.album) ? item.businessCard.album[0] : item.businessCard.album,
// companyId: item._id
// })
// }
// })
// }
},
async getAd10() {
this.ad10 = []
// if (this.checkProvinceList.length === 0) {
const res = await vk.callFunction({
url: 'client/ad/pub/getList',
data: {
adKey: 10,
region: this.checkProvinceList.length > 0 ? this.checkProvinceList[0] : null
}
})
if (res.data) this.ad10 = res.data
// } else {
// const {rows} = await vk.callFunction({
// url: 'client/user/pub/getCompany',
// data: {
// pageIndex: 2,
// pageSize: 5,
// isCoop: 1,
// province: this.checkProvinceList
// }
// })
// rows.forEach(item => {
// if (item.businessCard.album && item.businessCard.album.length > 0) {
// this.ad10.push({
// swiper: Array.isArray(item.businessCard.album) ? item.businessCard.album[0] : item.businessCard.album,
// companyId: item._id
// })
// }
// })
// }
},
},
computed: {
checkCategoryArr() {
const arr = []
this.allChildCate.forEach(item => {
if (this.checkCategoryList.includes(item._id)) arr.push(item)
})
this.provinceData.forEach(item => {
if (this.checkProvinceList.includes(item.code)) {
arr.push(item)
}
})
return arr
}
}
}
</script>
<style lang="scss" scoped>
.carousel {
width: 1200px;
margin: 20px auto;
}
.carousel-img {
width: 100%;
height: 100%;
}
.goods-options {
background-color: #FFFFFF;
padding: 20px;
}
.filter-outer {
width: 1200px;
margin: 20px auto;
background-color: #FFFFFF;
padding: 20px;
}
.tags {
display: flex;
flex-wrap: wrap;
.el-tag {
margin-right: 10px;
}
}
.goods-list {
width: 1200px;
margin: 20px auto;
display: flex;
flex-wrap: wrap;
}
.goods {
width: 217px;
background-color: #FFFFFF;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.05);
text-align: center;
margin-right: 20px;
margin-bottom: 25px;
padding: 10px 20px;
position: relative;
.top {
position: absolute;
right: 0;
top: 0;
background-color: rgba(169, 41, 36, 1);
padding: 2px 5px;
border-radius: 0 0 0 5px;
color: #FFFFFF;
}
&-title {
font-size: 15px;
color: #101010;
height: 62px;
padding-top: 20px;
font-weight: bold;
}
&-stock {
font-size: 12px;
color: #BD3124;
}
&-address {
font-size: 12px;
margin: 10px 0;
height: 35px;
}
&-image {
width: 200px;
height: 70px;
margin: 0 auto;
image {
width: 100%;
height: 100%;
}
}
&-company {
color: #4F4F4F;
font-size: 14px;
margin: 10px 0;
height: 45px;
}
&-buy {
width: 108px;
height: 30px;
line-height: 30px;
background-color: rgba(255, 255, 255, 1);
color: rgba(169, 41, 36, 1);
font-size: 13px;
text-align: center;
font-family: Roboto;
border: 1px solid rgba(169, 41, 36, 1);
margin: 0 auto;
cursor: pointer;
}
.goods-image {
width: 100%;
}
}
.paginatio {
float: none;
width: 1200px;
margin: 20px auto;
display: flex;
justify-content: center;
}
.selected-cate {
border-bottom: 2px solid #BD3124;
line-height: 40rpx;
}
.child-cate {
background-color: #DB8382;
color: white;
margin-top: 10rpx;
border-radius: 15rpx;
padding: 0 20rpx;
}
</style>