Files
jjx-wap/pages/goods/goods.vue
T
2026-10-08 18:34:09 +08:00

424 lines
11 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 class="wrap">
<!-- 吸顶 -->
<u-sticky offset-top="0" customNavHeight="0">
<!-- 顶部 -->
<uiheader title="现货市场"></uiheader>
<!-- 搜索栏 -->
<cmsearch :k="keyword" @search="afterSearch"></cmsearch>
<!-- 轮播图-传值:list="数组" -->
<cmswiper page="spot" height="320rpx"></cmswiper>
<!-- 选择器 -->
<view class="bg-white p-20 flex justify-center items-center">
<view class="flex-1 mx-20">
<u-button type="primary" shape="circle" size="mini" @click="toRelease">发布现货</u-button>
</view>
<view class="flex-1 mx-20">
<u-button type="primary" shape="circle" size="mini" plain @click="toMy">我的现货</u-button>
</view>
</view>
<view class="layout-pick flex justify-between align-center bg-white">
<view class="ip down" @click="isPick=true">现货类型:{{ pickValue }}</view>
<view class="ip down" @click="showAddress">供货地:{{ locationValue }}</view>
</view>
</u-sticky>
<!-- 列表数据 -->
<view class="layout-goods">
<view class="goods-box p-top-10">
<uiswiper :ad="9" :category-id="cateId" :category-ids="cateId ? [cateId] : []" :region="region"
padding="10rpx 0"></uiswiper>
<uiswiper :ad="10" :category-id="cateId" :category-ids="cateId ? [cateId] : []" :region="region"
padding="10rpx 0"></uiswiper>
<view class="item bg-white" @click="detailLink(item._id)" v-for="(item, index) in goodsData.rows"
:key="index">
<view class="top" v-if="item.isTop">特别推荐</view>
<view class="top" v-if="!item.isTop && index < 10">最新</view>
<view class="askfor">立即查看</view>
<view class="title text-single">{{ item.name }}</view>
<view class="text m-top-10">
<text class="red">库存:{{ parseInt(item.stock) }}吨</text>
</view>
<view class="text">供货地:{{ item.address.province.name }}-{{
item.address.city.name
}}-{{ item.address.area.name }}
</view>
<view class="flex justify-between align-center">
<view class="company flex justify-center align-center flex-nowrap">
<view class="text flex-1 text-single" v-if="item.user && item.user.company">
<template v-if="item.user">
<text v-if="item.user.accountType === 1">{{
item.user.person.personName.replace(/^(.).*$/, "$1**")
}}
</text>
<text v-if="item.user.accountType === 2">{{
item.user.company.companyName.replace(/^(.)(.).*(.)(.)(.)(.)$/, "$1$2***$3$4$5$6")
}}
</text>
</template>
</view>
</view>
</view>
<view class="date">{{ item._add_time_str }} 更新</view>
</view>
</view>
</view>
<!-- 没有数据 -->
<cmempty></cmempty>
<!-- 按钮 -->
<!-- <view class="issue" @click="toRelease">-->
<!-- <u-icon name="plus" color="#fff" size="24"></u-icon>-->
<!-- </view>-->
<!-- <view class="my" @click="toMy">-->
<!-- <u-icon name="account" color="#A92924" size="24"></u-icon>-->
<!-- </view>-->
<!-- 选择器 -->
<u-picker v-if="isPick" :show="isPick" :columns="[categoryTreeData, categoryTreeData[cateIndex[0]].children]"
key-name="name" @confirm="handConfirmPick" @change="handleChangeCate" @cancel="isPick = false">
<template #more>
<text @click="resetCate">重置</text>
</template>
</u-picker>
<AddressSelect ref="AddressSelect" @confirm="regionConfirm"/>
<collapse></collapse>
</view>
</template>
<script>
import uiheader from '@/components/index/header'
import cmsearch from '@/components/common/search'
import cmempty from '@/components/common/empty'
import cmswiper from '@/components/common/swiper'
import AddressSelect from "@/components/AddressSelect.vue";
import Collapse from "@/components/index/collapse.vue";
import uiswiper from "@/components/index/swiper.vue";
export default {
components: {
uiswiper,
Collapse,
AddressSelect,
uiheader,
cmsearch,
cmempty,
cmswiper,
},
data() {
return {
isLogin: false,
sex: '',
isPick: false,
pickValue: '全部',
isLocation: false,
locationValue: '全国',
region: {
province: {
code: null,
name: null,
}
},
pageSize: 500,
goodsData: {
rows: []
},
keyword: '',
categoryTreeData: [],
cateIndex: [0, 0],
cateId: null,
};
},
methods: {
getCategoryTreeData() {
vk.callFunction({
url: 'client/spot/category/pub/getTree',
data: {},
success: (data) => {
this.categoryTreeData = data.rows
}
});
},
showAddress() {
this.$refs.AddressSelect.open(this.region, 1, true);
},
regionConfirm({province}) {
this.region = {province}
this.locationValue = `${province.name}`
this.search(1)
},
detailLink(id) {
vk.navigateTo(`/pages/goods/detail?id=${id}`);
},
handleChangeCate({indexs}) {
this.cateIndex = indexs
},
handConfirmPick({value}) {
this.pickValue = value[1].name
this.cateId = value[1]._id
this.isPick = false
this.search(1)
},
resetCate() {
this.cateIndex = [0, 0]
this.pickValue = '全部'
this.cateId = null
this.isPick = false
this.search(1)
},
async toRelease() {
const {userInfo, accountNum} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
if (!userInfo.fadadaConfirm || [-1, 2].includes(userInfo.authStatus)) {
uni.showModal({
title: '提示',
content: '您尚未认证, 是否前往认证?',
success: res => {
if (res.confirm) {
uni.setStorageSync('user_tab', 0)
uni.switchTab({url: '/pages/user/user'})
}
}
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
uni.showModal({
title: '提示',
content: '请完善名片信息',
success: res => {
if (res.confirm) {
uni.setStorageSync('user_tab', 1)
uni.switchTab({url: '/pages/user/user'})
}
}
})
} else if (accountNum === 0) {
uni.showModal({
title: '提示',
content: '请先到个人中心添加收款账户',
success: res => {
if (res.confirm) {
uni.setStorageSync('user_tab', 7)
uni.switchTab({url: '/pages/user/user'})
}
}
})
} else {
vk.navigateTo({
url: '/pages/goods/publish'
})
}
},
async toMy() {
const {userInfo} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
if (!userInfo.fadadaConfirm || [-1, 2].includes(userInfo.authStatus)) {
uni.showModal({
title: '提示',
content: '您尚未认证, 是否前往认证?',
success: res => {
if (res.confirm) {
uni.setStorageSync('user_tab', 0)
uni.switchTab({url: '/pages/user/user'})
}
}
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
uni.showModal({
title: '提示',
content: '请完善名片信息',
success: res => {
if (res.confirm) {
uni.setStorageSync('user_tab', 1)
uni.switchTab({url: '/pages/user/user'})
}
}
})
} else this.$jump('/pages/goods/my')
},
afterSearch(keyword) {
this.keyword = keyword
this.search(1)
},
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.cateId ? [this.cateId] : null,
// categoryIds: this.checkCategoryList,
provinceCodes: this.region.province.code ? [this.region.province.code] : null
},
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
}
});
},
getCertUrl() {
vk.callFunction({
url: 'client/fadada.getVerifyUrl',
success: (res) => {
location.href = res.data.url
}
});
},
},
onLoad(option) {
if (option.keyword) this.keyword = option.keyword
this.getCategoryTreeData()
this.search()
}
}
</script>
<style lang="scss">
page {
}
.layout-pick {
// width: 690rpx;
height: 68rpx;
padding: 0 30rpx;
font-size: 24rpx;
line-height: 40rpx;
color: #4F4F4F;
.ip {
position: relative;
max-width: 50%;
height: 40rpx;
padding-right: 30rpx;
overflow: hidden;
box-sizing: border-box;
}
.down::after {
position: absolute;
right: 10rpx;
top: 50%;
z-index: 9;
content: '';
margin-top: -6rpx;
width: 0;
height: 0;
border-left: 10rpx solid transparent;
border-right: 10rpx solid transparent;
border-top: 12rpx solid #999999;
}
}
.layout-goods {
// width: 690rpx;
padding: 10rpx 30rpx;
.item {
position: relative;
margin-top: 10rpx;
padding: 10rpx 20rpx 20rpx;
border-radius: 12rpx;
.title {
width: 80%;
font-size: 30rpx;
font-weight: 600;
line-height: 48rpx;
color: #101010;
}
.link, .askfor {
position: absolute;
right: 20rpx;
top: 16rpx;
z-index: 9;
font-size: 24rpx;
line-height: 36rpx;
color: #A92924;
padding: 4rpx 8rpx;
}
.link {
border: 1px solid #A92924;
}
.text {
font-size: 24rpx;
line-height: 36rpx;
color: #999999;
}
.red {
margin-right: 20rpx;
color: #A92924;
}
.date {
font-size: 24rpx;
line-height: 36rpx;
color: #9a9a9a;
}
.company {
height: 40rpx;
.icon {
width: 40rpx;
height: 40rpx;
}
.text {
//width: 300rpx;
height: 40rpx;
font-size: 26rpx;
line-height: 40rpx;
color: #4f4f4f;
}
}
}
.item:nth-child(1) {
margin-top: 0 !important;
}
}
.red {
color: #A92924 !important;
}
.my {
position: fixed;
right: 30rpx;
bottom: 220rpx;
z-index: 99;
display: flex;
justify-content: center;
align-items: center;
width: 90rpx;
height: 90rpx;
border-radius: 50%;
background: white;
border: 1px solid #A92924;
}
.top {
position: absolute;
right: 0;
bottom: 0;
background-color: rgba(169, 41, 36, 1);
padding: 2px 5px;
border-radius: 5px 0 5px 0;
color: #FFFFFF;
font-size: 25rpx;
}
</style>