This commit is contained in:
2026-10-08 18:20:51 +08:00
parent dec4ebc773
commit 6f1b2dc03a
621 changed files with 47117 additions and 43176 deletions
+264 -208
View File
@@ -10,33 +10,42 @@
<el-breadcrumb-item>
<navigator style="display: inline-block;" url="/pages/spot/goods/goods">现货市场</navigator>
</el-breadcrumb-item>
<el-breadcrumb-item>{{ product.name }}</el-breadcrumb-item>
</el-breadcrumb>
</view>
<view class="card">
<div class="card-header">
<view class="card-header-left">
<image class="logo" :src="product.user.businessCard.logo" mode="aspectFit"></image>
<image class="logo" :src="product.user.businessCard.logo" mode="aspectFit"
v-if="product.user.businessCard"></image>
<view class="info">
<view v-if="product.user.accountType === 1" class="info-name">
{{ product.user.person.personName }}
</view>
<view v-if="product.user.accountType === 2" class="info-name">
{{ product.user.company.companyName }}
</view>
<template v-if="product.user">
<view v-if="product.user.accountType === 1" class="info-name">
{{ product.user.person.personName }}
</view>
<view v-if="product.user.accountType === 2"
class="info-name flex justify-start items-center">
<text class="mr-25">{{ product.user.company.companyName }}</text>
<el-button type="primary" v-if="product.user.showInYellow === 1" size="small"
@click="navTo(`/pages/yellowPage/info?id=${product.user._id}`)">查看主页
</el-button>
</view>
</template>
<view class="info-update">
<view class="info-update-time">
{{ product._add_time_str }}
</view>
<view class="info-update-business">
主营业务:{{ product.user.businessCard.mainBusiness }}
主营业务:{{
(product.user.company.mainSpotCategory && product.user.company.mainSpotCategory.length > 0) ? product.user.company.mainSpotCategory.join() : ''
}}
</view>
</view>
</view>
</view>
<view class="card-header-right">
<view class="card-header-right flex flex-col justify-center items-center">
<text class="mb-20 text-main">{{ product.quoteNum }}家已申请合作</text>
<el-button v-if="vk.getVuex('$user.userInfo._id') !== product.userId" @click="toCooperate"
type="primary">申请合作
</el-button>
@@ -50,20 +59,36 @@
<div class="part-head">
<h3>现货详情</h3>
</div>
<view v-if="product.user.accountType == 1" class="card-body-name">{{ product.user.person.personName }}
</view>
<view v-if="product.user.accountType == 2" class="card-body-name">{{ product.user.company.companyName }}
</view>
<view class="card-body-stock">库存:{{ product.stock }}吨</view>
<!-- <template v-if="product.user">-->
<!-- <view v-if="product.user.accountType == 1" class="card-body-name">{{-->
<!-- product.user.person.personName-->
<!-- }}-->
<!-- </view>-->
<!-- <view v-if="product.user.accountType == 2" class="card-body-name">-->
<!-- {{ product.user.company.companyName }}-->
<!-- </view>-->
<!-- </template>-->
<view class="card-body-stock">库存约:{{ product.stock }}吨</view>
<view class="card-body-address">
供货地:{{ product.address.province.name + "-" + product.address.city.name + "-" + product.address.area.name }}
供货地:{{
product.address.province.name + "-" + product.address.city.name + "-" + product.address.area.name
}}
</view>
</view>
<view class="card-body">
<div class="part-head">
<h3>报价有效期</h3>
</div>
<view class="card-body-stock">截止: {{
dayjs(product.answerEndTime).format('YYYY-MM-DD HH:mm:ss')
}}
</view>
</view>
<view class="card-body">
<div class="part-head">
<h3>附件</h3>
<h3>产品规格单价</h3>
</div>
<ul class="el-upload-list el-upload-list--text">
<li @click="downloadFile(item)" v-for="(item,index) in product.files" :key="index" tabindex="0"
@@ -76,6 +101,14 @@
</ul>
</view>
<view class="card-body">
<div class="part-head">
<h3>产品现场图片</h3>
</div>
<el-image :preview-src-list="product.images" v-for="(item, index) in product.images" :key="index"
:src="item" style="width: 100px; height: 100px" class="mr-10 mb-15" fit="cover"/>
</view>
<view class="card-body">
<div class="part-head">
<h3>已收到的合作申请</h3>
@@ -84,7 +117,8 @@
:customRightBtns="table1.customRightBtns"></vk-data-table>
</view>
</view>
<Gap/>
<common-footer></common-footer>
<el-dialog :visible.sync="showDialog" width="70%" :show-close="false">
<view slot="title" class="text-main text-40 m-30 flex justify-between items-center">
@@ -93,20 +127,22 @@
</view>
<view class="mt-15" v-if="product">
<view class="request-header">
<text class="flex-1">企业</text>
<text class="flex-1">申请人</text>
<text class="flex-1">申请时间</text>
<text class="flex-1">联系方式</text>
<text class="flex-1">合作留言</text>
<text class="flex-1">申请时间</text>
<text class="flex-1">操作</text>
</view>
<view class="quote" v-for="(item, index) in product.cooperateList" :key="index">
<text class="flex-1">{{
item.user.accountType === 1 ? item.user.person.personName : item.user.company.companyName
item.user.userId !== product.userId ? item.user.company.companyName.replace(/^(.)(.).*(.)(.)(.)(.)$/, "$1$2***$3$4$5$6") : item.user.person.personName.replace(/^(.).*(.)$/, "$1*$2")
}}
</text>
<text class="flex-1">{{ item.name }}</text>
<text class="flex-1">{{ item.mobile }}</text>
<text class="flex-1">{{ item.remark }}</text>
<text class="flex-1">{{ item._add_time_str }}</text>
<text class="flex-1">
{{ item.user.accountType === 1 ? item.user.person.mobile : item.user.company.mobile }}
</text>
<text class="flex-1">
<el-button type="primary" @click.native="doShowInfo(item)">查看申请详情</el-button>
</text>
@@ -115,17 +151,39 @@
</el-dialog>
<el-dialog :visible.sync="form1.props.show" title="申请合作" width="60%" mode="form">
<vk-data-form ref="table1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"
:rules="form1.props.rules" :form-type="form1.props.formType"
:loading.sync="form1.props.loading"
:beforeAction="form1.props.beforeAction" :auto-close="true" label-width="140px"
@success="onFormSuccess"></vk-data-form>
<el-form ref="form" :model="formData" label-width="120px">
<el-form-item label="企业名称" v-if="parseInt(vk.getVuex('$user.userInfo.accountType')) === 2">
<el-input v-model="formData.companyName" placeholder="请输入企业名称"/>
</el-form-item>
<el-form-item label="联系人姓名">
<el-input v-model="formData.name" placeholder="请输入联系人姓名"/>
</el-form-item>
<el-form-item label="联系人电话">
<el-input v-model="formData.mobile" placeholder="请输入联系人电话"/>
</el-form-item>
<el-form-item label="合作留言">
<el-input v-model="formData.remark" placeholder="请输入合作留言"/>
</el-form-item>
<el-form-item label="附件">
<vk-data-upload v-model="formData.files" list-type="text"
accept=".jpg,.jpeg,.png,.xlsx,.doc,.docx,.pdf"/>
</el-form-item>
</el-form>
<view class="text-center">
<el-button type="primary" @click.native="addCoop">确定</el-button>
</view>
<!-- <vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"-->
<!-- :rules="form1.props.rules" :form-type="form1.props.formType"-->
<!-- :loading.sync="form1.props.loading" :show-cancel="false"-->
<!-- :beforeAction="form1.props.beforeAction" :auto-close="true" label-width="140px"-->
<!-- @success="onFormSuccess">-->
<!-- </vk-data-form>-->
</el-dialog>
<vk-data-dialog
v-model="showInfo"
title="申请详情"
width="600px"
width="60%"
top="14vh"
center
:close-on-click-modal="true"
@@ -145,17 +203,38 @@
</template>
<script>
import Gap from "../../../components/gap/gap.vue";
import dayjs from "dayjs";
export default {
components: {Gap},
data() {
return {
showDialog: false,
showInfo: false,
info: null,
allChildCate: [],
infoColumns: [
{key: "company.companyName", title: "申请人", type: "text"},
{key: "company.mobile", title: "联系方式", type: "text"},
{key: "manager.personName", title: "代理人", type: "text"},
{key: "manager.mobile", title: "代理人联系方式", type: "text"},
{key: "user.company.companyName", title: "企业", type: "text"},
{key: "name", title: "联系人", type: "text"},
{key: "mobile", title: "联系方式", type: "text"},
{key: "remark", title: "合作留言", type: "text"},
{
key: "files", title: "附件", type: "html",
formatter: (val = [], row, column, index) => {
let content = ''
val.forEach((item, itemIndex) => {
content += `<a href="${item}" target="_blank">预览:文件${itemIndex + 1}</a> `
})
return content
}
},
{
key: "_add_time_str",
title: "申请时间",
type: "text",
align: "left",
},
],
product: {
name: '现货详情',
@@ -169,123 +248,52 @@ export default {
},
cooperateList: []
},
formData: {
companyName: '',
name: '',
mobile: '',
remark: '',
accountType: parseInt(vk.getVuex('$user.userInfo.accountType')),
goodsId: null,
goodsUserId: null,
files: [],
},
// 表单相关开始-----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {},
data: {
companyName: '',
name: '',
mobile: '',
remark: '',
},
// 表单属性
props: {
// 表单请求地址
action: "client/spot/goods/kh/addCooperate",
// 表单字段显示规则
columns: [{
key: "person",
title: "个人",
type: "object",
showLabel: false,
showRule: (formData) => {
return formData.person.personName != null
},
columns: [{
key: "personName",
title: "姓名",
columns: [
{
key: "companyName",
title: "企业名称",
type: "text",
readonly: true,
disabled: true
},
// {
// key: "idCard",
// title: "身份证号",
// type: "text",
// readonly: true,
// disabled: true
// },
{
key: "mobile",
title: "电话",
type: "text",
readonly: true,
disabled: true
},
]
},
{
key: "company",
title: "企业信息",
type: "object",
showLabel: false,
showRule: (formData) => {
return formData.company.companyName != null
return parseInt(vk.getVuex('$user.userInfo.accountType')) === 2
},
columns: [{
key: "companyName",
title: "企业名称",
type: "text",
readonly: true,
disabled: true
},
{
key: "organization",
title: "统一社会信用代码",
type: "text",
readonly: true,
disabled: true
},
{
key: "legalName",
title: "法人",
type: "text",
readonly: true,
disabled: true
},
{
key: "legalMobile",
title: "法人电话",
type: "text",
readonly: true,
disabled: true
},
]
},
{
key: "manager",
title: "代理人",
type: "object",
showLabel: false,
showRule: (formData) => {
return formData.manager.personName != null
},
columns: [{
key: "personName",
title: "代理人",
type: "text",
readonly: true,
disabled: true
},
// {
// key: "idCard",
// title: "代理人身份证号",
// type: "text",
// readonly: true,
// disabled: true
// },
{
key: "mobile",
title: "代理人电话",
type: "text",
readonly: true,
disabled: true
},
]
key: "name",
title: "联系人姓名",
type: "text",
},
{
key: "mobile",
title: "联系人电话",
type: "text",
},
{
key: "remark",
title: "备注",
title: "合作留言",
type: "textarea",
maxlength: 200,
showWordLimit: true,
@@ -293,11 +301,12 @@ export default {
],
// 表单验证规则
rules: {
text: [{
required: true,
message: "text不能为空",
trigger: "change"
},
text: [
{
required: true,
message: "text不能为空",
trigger: "change"
},
{
required: true,
message: "text不能为空",
@@ -323,55 +332,53 @@ export default {
// 表格数据
data: [],
// 表格字段显示规则
columns: [{
key: "subjectName",
title: "申请人",
type: "text",
width: 400,
formatter: (val, row, column, index) => {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
if (row.accountType === 1) {
return vk.pubfn.hidden(val, 1, 1);
} else {
return vk.pubfn.hidden(val, 2, 4);
}
}
},
columns: [
{
key: "subjectMobile",
title: "联系方式",
key: "user.company.companyName",
title: "企业",
type: "text",
width: 120,
formatter: (val, row, column, index) => {
let str = val
if (row.managerMobile) {
str = row.managerMobile
if (val) {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return val.slice(0, 2) + "******";
}
if (vk.getVuex('$user.userInfo._id') == this.product.userId) {
return str
}
return vk.pubfn.hidden(str, 3, 4);
return ''
}
},
// {
// key: "remark",
// title: "备注",
// type: "textarea",
// width: 280,
// formatter: (val, row, column, index) => {
// let str = val
// if (row.managerMobile) {
// str = row.managerMobile
// }
// if (vk.getVuex('$user.userInfo._id') == this.product.userId) {
// return val
// }
// return "******";
// }
// },
{
key: "name",
title: "申请人",
type: "text",
formatter: (val, row, column, index) => {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return val.slice(0, 1) + "**";
}
},
{
key: "mobile",
title: "联系方式",
type: "text",
formatter: (val, row, column, index) => {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return "******";
}
},
{
key: "remark",
title: "合作留言",
type: "textarea",
},
{
key: "_add_time",
title: "申请时间",
type: "time",
},
],
customRightBtns: [{
@@ -389,23 +396,9 @@ export default {
}
},
onLoad({
id
}) {
onLoad({id}) {
// 获取现货数据
vk.callFunction({
url: 'client/spot/goods/pub/getDetail',
title: '请求中...',
data: {
_id: id,
},
success: (data) => {
console.log(data);
this.product = data.data
}
});
this.getCategoryTreeData(id)
// 获取用户数据
vk.userCenter.getCurrentUserInfo({
success: (data) => {
@@ -416,22 +409,64 @@ export default {
console.log('form1: ', {
...this.form1.data
});
if (data.userInfo.accountType === 1) {
this.formData.name = data.userInfo.person.personName
this.formData.mobile = data.userInfo.person.mobile
} else {
this.formData.companyName = data.userInfo.company.companyName
this.formData.mobile = data.userInfo.company.mobile
if (data.userInfo.manager) this.formData.name = data.userInfo.manager.personName
}
}
});
},
methods: {
dayjs,
getCategoryTreeData(id) {
vk.callFunction({
url: 'client/spot/category/pub/getTree',
title: '请求中...',
data: {},
success: (data) => {
this.allChildCate = []
data.rows.forEach(item => {
item.children.forEach(child => {
this.allChildCate.push(child)
})
})
this.getInfo(id)
}
});
},
getInfo(id) {
vk.callFunction({
url: 'client/spot/goods/pub/getDetail',
title: '请求中...',
data: {
_id: id,
},
success: (data) => {
this.product = data.data
this.product.user.company.mainSpotCategory = []
if (this.product.user.company && this.product.user.company.mainSpotCategoryIds) {
this.allChildCate.forEach(child => {
if (this.product.user.company.mainSpotCategoryIds.includes(child._id)) {
this.product.user.company.mainSpotCategory.push(child.name)
}
})
}
}
});
},
downloadFile(url) {
location.href = url
},
showCooperate() {
this.table2.show = true
},
async toCooperate() {
const {userInfo} = await vk.callFunction({
const {userInfo, accountNum} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
if (!userInfo.fadadaConfirm || [-1, 2].includes(userInfo.authStatus)) {
this.$confirm('您尚未认证, 是否前往认证?', '提示', {
this.$confirm('您尚未认证, 是否前往个人中心认证?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@@ -439,12 +474,20 @@ export default {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
this.$confirm('请完善名片信息', '提示', {
this.$confirm('您尚未认证和完善名片,是否前往个人中心?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=business-card'});
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 {
this.form1.props.show = true
@@ -459,12 +502,25 @@ export default {
}
});
},
onFormSuccess() {
this.form1.props.show = false
},
doShowInfo(info) {
this.info = info
this.showInfo = true
},
addCoop() {
if (!this.formData.name) return this.$message.error('请填写联系人姓名')
if (!this.formData.mobile) return this.$message.error('请填写联系方式')
this.formData.goodsId = this.product._id
this.formData.goodsUserId = this.product.userId
vk.callFunction({
url: 'client/spot/goods/kh/addCooperate',
data: this.formData
})
this.form1.props.show = false
this.$message.success('提交成功')
this.getInfo(this.product._id)
},
navTo(url) {
vk.navigateTo({url})
}
},
filters: {
+521 -357
View File
@@ -1,411 +1,575 @@
<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<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="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">
<el-carousel height="170px">
<el-carousel-item v-for="item in 4" :key="item">
<image class="carousel-img"
src="/static/images/600fc93e6b85324b3ea1373ee264290d.jpg"
mode="aspectFill"></image>
</el-carousel-item>
</el-carousel>
<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>
<!-- 商品列表 -->
<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="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 v-if="item.user.accountType == 1" class="goods-company">{{ item.user.person.personName }}</view>
<view v-if="item.user.accountType == 2" class="goods-company">{{ item.user.company.companyName }}</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>
<view class="paginatio">
<el-pagination
:page-size="pageSize"
:current-page="goodsData.page"
@current-change="search"
background
layout="prev, pager, next"
:total="goodsData.total">
</el-pagination>
</view>
<right-bar></right-bar>
<common-footer></common-footer>
<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 {
data() {
return {
pageSize: 20,
categoryTreeData: [],
allChildCate: [],
checkCategoryList: [],
clickedCateIndex: -1,
provinceData: provinces,
checkProvinceList: [],
keyword: '',
goodsData: {
total: 0,
rows: []
},
showAllProvince: false
};
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)
},
onShow() {
this.search(1)
vk.callFunction({
url: 'client/spot/category/pub/getTree',
title: '请求中...',
data: {},
success: (data) => {
this.categoryTreeData = data.rows
this.allChildCate = []
this.categoryTreeData.forEach(item => {
item.children.forEach(child => {
this.allChildCate.push(child)
})
})
}
});
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)
},
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.search(1)
},
async toRelease() {
const {userInfo} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
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=business-card'});
})
} else {
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(() => {
this.getCertUrl()
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
this.$confirm('请完善名片信息', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo('/pages/user/user?menu=business-card');
})
} else {
vk.navigateTo({
url: '/pages/spot/goods/my'
})
}
},
search(pageIndex) {
vk.callFunction({
url: 'client/spot/goods/pub/getList',
data: {
pageIndex: pageIndex,
pageSize: this.pageSize,
keyword: this.keyword,
categoryIds: this.checkCategoryList,
provinceCodes: this.checkProvinceList
},
success: (data) => {
console.log('data: ', data);
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
}
});
},
},
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
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;
width: 1200px;
margin: 20px auto;
}
.carousel-img {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
.goods-options {
background-color: #FFFFFF;
padding: 20px;
background-color: #FFFFFF;
padding: 20px;
}
.filter-outer {
width: 1200px;
margin: 20px auto;
background-color: #FFFFFF;
padding: 20px;
width: 1200px;
margin: 20px auto;
background-color: #FFFFFF;
padding: 20px;
}
.tags {
display: flex;
flex-wrap: wrap;
display: flex;
flex-wrap: wrap;
.el-tag {
margin-right: 10px;
}
.el-tag {
margin-right: 10px;
}
}
.goods-list {
width: 1200px;
margin: 20px auto;
display: flex;
flex-wrap: wrap;
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);
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;
margin-right: 20px;
margin-bottom: 25px;
padding: 10px 20px;
font-family: Roboto;
border: 1px solid rgba(169, 41, 36, 1);
margin: 0 auto;
cursor: pointer;
}
&-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;
}
&-image {
width: 200px;
height: 70px;
margin: 0 auto;
image {
width: 100%;
height: 100%;
}
}
&-company {
color: #4F4F4F;
font-size: 14px;
margin: 10px 0;
}
&-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%;
}
.goods-image {
width: 100%;
}
}
.paginatio {
float: none;
width: 1200px;
margin: 20px auto;
display: flex;
justify-content: center;
float: none;
width: 1200px;
margin: 20px auto;
display: flex;
justify-content: center;
}
.selected-cate {
border-bottom: 2px solid #BD3124;
line-height: 40rpx;
border-bottom: 2px solid #BD3124;
line-height: 40rpx;
}
.child-cate {
background-color: #DB8382;
color: white;
margin-top: 10rpx;
border-radius: 15rpx;
padding: 0 20rpx;
background-color: #DB8382;
color: white;
margin-top: 10rpx;
border-radius: 15rpx;
padding: 0 20rpx;
}
</style>
+14 -13
View File
@@ -4,13 +4,14 @@
<common-header></common-header>
<category-bar></category-bar>
<view class="carousel">
<el-carousel height="170px">
<el-carousel-item v-for="item in 4" :key="item">
<image class="carousel-img"
src="/static/images/600fc93e6b85324b3ea1373ee264290d.jpg"
mode="aspectFill"></image>
</el-carousel-item>
</el-carousel>
<!-- <el-carousel height="170px">-->
<!-- <el-carousel-item v-for="item in 4" :key="item">-->
<!-- <image class="carousel-img"-->
<!-- src="/static/images/600fc93e6b85324b3ea1373ee264290d.jpg"-->
<!-- mode="aspectFill"></image>-->
<!-- </el-carousel-item>-->
<!-- </el-carousel>-->
<common-swiper page="spot-mine" :height="200"/>
<view class="goods-options">
<el-row class="">
<el-button @click="toRelease" type="primary" round>发布现货</el-button>
@@ -67,7 +68,7 @@
type: 'warning'
}).then(() => {
vk.callFunction({
url: 'client/enquiry/sheet/kh/delete',
url: 'client/spot/goods/kh/delete',
title: '请求中...',
data: {
_id: item._id
@@ -101,7 +102,7 @@
},
{
key: "_add_time_srt",
key: "_add_time_str",
title: "发布时间",
type: "time",
width: 160
@@ -123,20 +124,20 @@
toRelease() {
if (!vk.getVuex('$user.userInfo.fadadaConfirm')) {
this.$confirm('您尚未认证, 是否前往认证?', '提示', {
this.$confirm('您尚未认证, 是否前往个人中心认证?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.getCertUrl()
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (vk.pubfn.isNull(vk.getVuex('$user.userInfo.businessCard'))) {
this.$confirm('请完善名片信息', '提示', {
this.$confirm('您尚未认证和完善名片,是否前往个人中心?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo('/pages/user/user?menu=business-card');
vk.navigateTo('/pages/user/user?menu=fadada');
})
} else {
uni.navigateTo({
+357 -162
View File
@@ -1,177 +1,372 @@
<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<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 style="display: inline-block;" url="/pages/spot/goods/goods">现货市场</navigator></el-breadcrumb-item>
<el-breadcrumb-item>发布现货</el-breadcrumb-item>
</el-breadcrumb>
</view>
<view class="page-nav">
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>
<navigator style="display: inline-block;" url="/pages/spot/goods/goods">现货市场</navigator>
</el-breadcrumb-item>
<el-breadcrumb-item>发布现货</el-breadcrumb-item>
</el-breadcrumb>
</view>
<view class="form-view">
<vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"
:rules="form1.props.rules" :form-type="form1.props.formType" :loading.sync="form1.props.loading"
:before-action="form1.props.beforeAction" :auto-close="true" label-width="140px"
@success="onFormSuccess">
<template v-slot:name="{ form, keyName }">
<el-input v-model="productName" readonly placeholder="请添加现货分类"></el-input>
</template>
</vk-data-form>
</view>
</view>
<view class="form-view">
<!-- <vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"-->
<!-- :rules="form1.props.rules" :form-type="form1.props.formType"-->
<!-- :loading.sync="form1.props.loading"-->
<!-- :before-action="form1.props.beforeAction" :auto-close="true" label-width="140px"-->
<!-- :show-cancel="false"-->
<!-- @success="onFormSuccess">-->
<!-- <template v-slot:name="{ form, keyName }">-->
<!-- <el-input v-model="productName" readonly placeholder="请添加现货分类"></el-input>-->
<!-- </template>-->
<!-- </vk-data-form>-->
<el-form ref="form" :model="form1.data" label-width="140px">
<el-form-item label="现货名称">
<el-input v-model="form1.data.name" placeholder="请输入现货名称" readonly></el-input>
</el-form-item>
<el-form-item label="现货分类" required>
<el-checkbox-group v-model="form1.data.categoryIds" @change="makeTitle">
<el-checkbox v-for="(item, index) in category" :key="index" :label="item._id">{{
item.name
}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="库存(吨)" required>
<el-input v-model="form1.data.stock" placeholder="请输入库存(吨)" type="number"/>
</el-form-item>
<el-form-item label="现货存放地" required>
<vk-data-input-address :level="3" v-model="form1.data.address" @change="getAmount()"/>
</el-form-item>
<el-form-item label="产品规格单价">
<vk-data-upload v-model="form1.data.files" list-type="text"
accept=".jpg,.jpeg,.png,.xlsx,.doc,.docx,.pdf"/>
</el-form-item>
<el-form-item label="报价有效期">
<el-date-picker :picker-options="pickerOptions"
v-model="form1.data.answerEndTime"
type="datetime"/>
</el-form-item>
<el-form-item label="产品现场图片">
<vk-data-upload v-model="form1.data.images" list-type="text" accept=".jpg,.jpeg,.png"/>
</el-form-item>
<el-form-item label="是否购买全国广告位">
<el-radio-group v-model="form1.data.buyAll" @change="getAmount(true)">
<el-radio :label="true">是</el-radio>
<el-radio :label="false">否</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="是否购买省份广告位">
<el-radio-group v-model="form1.data.buyTop" @change="getAmount()"
:disabled="form1.data.buyAll || JSON.stringify(form1.data.address) === '{}' || totalAmount === 0">
<el-radio :label="true">是</el-radio>
<el-radio :label="false">否</el-radio>
</el-radio-group>
</el-form-item>
<p class="text-main text-25 my-20" v-if="form1.data.buyAll">
您已选择购买全国广告位,无法继续购买省份广告位</p>
<el-form-item label="购买时长(月)">
<el-input-number v-model="form1.data.buyTopNum" :min="1"/>
</el-form-item>
<el-form-item label="广告位价格">
{{ totalAmount }}元
</el-form-item>
</el-form>
<div class="text-center">
<el-button type="primary" @click="add">发布</el-button>
</div>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 表单相关开始-----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {
},
// 表单属性
props: {
// 表单请求地址
action: "client/spot/goods/kh/addUpdate",
// 表单字段显示规则
columns: [{
key: "name",
title: "现货名称",
type: "text",
},
{
key: "categoryIds",
title: "现货分类",
type: "checkbox",
action: "client/spot/category/pub/getList",
actionData: {
whereJson: {
level: 2
}
},
props: {
list: "data",
value: "_id",
label: "name"
},
watch: ({
option
}) => {
console.log('res: ', option)
this.form1.data.name = option.map(item => item.name).join('、')
this.productName = option.map(item => item.name).join('、')
console.log(this.form1);
}
export default {
data() {
return {
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
},
},
category: [],
// 表单相关开始-----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {
name: '',
stock: '',
buyTop: false,
buyAll: false,
buyTopNum: 1,
categoryIds: [],
files: [],
images: [],
address: {},
answerEndTime: null
},
// 表单属性
props: {
// 表单请求地址
action: "client/spot/goods/kh/addUpdate",
// 表单字段显示规则
columns: [{
key: "name",
title: "现货名称",
type: "text",
},
{
key: "categoryIds",
title: "现货分类",
type: "checkbox",
action: "client/spot/category/pub/getList",
actionData: {
whereJson: {
level: 2
}
},
props: {
list: "data",
value: "_id",
label: "name"
},
watch: ({
option
}) => {
if (this.form1.data.categoryIds.length > 5) {
this.$message.error('最多选择五个分类')
this.form1.data.categoryIds.splice(-1, 1)
return
}
},
{
key: "stock",
title: "库存(吨)",
type: "number"
},
{
key: "address",
title: "供货地",
type: "address"
},
{
key: "files",
title: "附件文档",
type: "file",
buttonText: "点击上传",
limit: 9,
accept: ".jpg,.png,.xlsx,.doc,.docx",
tips: '上传自有采购单图片或文档,支持jpg/png/word/excel'
},
this.form1.data.name = option.map(item => item.name).join('、')
this.productName = option.map(item => item.name).join('、')
},
},
{
key: "stock",
title: "库存(吨)",
type: "number"
},
{
key: "address",
title: "供货地",
type: "address"
},
{
key: "files",
title: "附件文档",
type: "file",
buttonText: "点击上传",
limit: 9,
accept: ".jpg,.jpeg,.png,.xlsx,.doc,.docx,.pdf",
tips: '上传自有采购单图片或文档,支持jpg/png/word/excel'
},
{
key: "buyAll",
title: "是否购买全国广告位",
type: "radio",
data: [
{
value: true,
label: "是"
},
{
value: false,
label: "否"
}
],
watch: ({value, formData}) => {
if (value) {
formData.buyTop = false
}
}
},
{
key: "buyTop",
title: "是否购买广告位",
type: "radio",
data: [
{
value: true,
label: "是"
},
{
value: false,
label: "否"
}
],
disabled: formData => {
return formData.buyAll
}
},
{
key: "buyTopNum",
title: "购买广告位时长(月)",
type: "number",
controls: true,
precision: 0,
min: 1,
step: 1,
rightText: '月'
},
{
key: "amount",
title: "价格",
type: "text",
readonly: true,
placeholder: '请选择供货地'
},
],
// 表单验证规则
rules: {
categoryIds: [
{
required: true,
message: "现货名称不能为空",
trigger: ['blur', 'change']
},
{
validator: (rule, value, callback) => {
if (value.length > 5) {
callback(new Error('最多选择五个分类'));
} else {
callback()
}
},
trigger: ['blur', 'change']
},
],
stock: [
{
required: true,
message: "请填写库存",
trigger: ['blur', 'change']
},
{
min: 0,
type: 'number',
message: "库存不能小于0",
trigger: ['blur', 'change']
},
],
address: [
{
required: true,
message: "请填写地址",
trigger: ['blur', 'change']
}
]
},
// add 代表添加 update 代表修改
formType: "add",
// 表单是否在请求中
loading: false,
// 是否显示表单1 的弹窗
show: false
}
},
productName: ''
// 表单相关结束-----------------------------------------------------------
};
},
onLoad() {
vk.callFunction({
url: 'client/spot/goods/kh/getSelfOne',
success: (res) => {
if(res.data) {
this.$refs.form1.setResetFormData(res.data);
this.$refs.form1.resetForm();
this.productName = res.data.name
}
}
});
},
methods: {
onFormSuccess() {
vk.navigateBack()
],
// 表单验证规则
rules: {
categoryIds: [
{
required: true,
message: "现货名称不能为空",
trigger: ['blur', 'change']
},
{
validator: (rule, value, callback) => {
if (value.length > 5) {
callback(new Error('最多选择五个分类'));
} else {
callback()
}
},
trigger: ['blur', 'change']
},
],
stock: [
{
required: true,
message: "请填写库存",
trigger: ['blur', 'change']
},
{
min: 0,
type: 'number',
message: "库存不能小于0",
trigger: ['blur', 'change']
},
],
address: [
{
required: true,
message: "请填写地址",
trigger: ['blur', 'change']
}
]
},
// add 代表添加 update 代表修改
formType: "add",
// 表单是否在请求中
loading: false,
// 是否显示表单1 的弹窗
show: false
}
},
productName: '',
amount: '',
// 表单相关结束-----------------------------------------------------------
};
},
onLoad() {
this.getCategory()
vk.callFunction({
url: 'client/spot/goods/kh/getSelfOne',
success: (res) => {
if (res.data) {
this.$refs.form1.setResetFormData(res.data);
this.$refs.form1.resetForm();
this.productName = res.data.name
}
}
}
}
});
},
methods: {
onFormSuccess(res) {
if (this.form1.data.buyTop) {
vk.navigateTo({
url: `/pages/index/shop/pay?id=${res.data.data}`
})
} else vk.redirectTo({url: '/pages/spot/goods/goods'});
},
getCategory() {
vk.callFunction({
url: 'client/spot/category/pub/getList',
data: {
whereJson: {
level: 2
},
},
success: (res) => {
if (res.data) {
this.category = res.data;
}
}
});
},
makeTitle(val) {
if (val.length > 5) {
this.form1.data.categoryIds.splice(-1)
return this.$message.error('最多选择五个分类');
}
this.form1.data.name = this.category.filter(item => val.includes(item._id)).map(item => item.name).join('、')
this.$forceUpdate()
},
getAmount(isAll = false) {
if (!isAll && JSON.stringify(this.form1.data.address) === '{}') return
vk.callFunction({
url: 'client/spot/amount/pub/getDetail',
data: {
province: isAll ? -1 : this.form1.data.address.province.code,
},
success: (res) => {
if (res.data) {
this.amount = parseFloat(res.data.amount)
}
}
});
},
async add() {
if (this.form1.data.categoryIds.length === 0) return this.$message.error('请选择分类')
if (!this.form1.data.stock) return this.$message.error('请填写库存')
if (JSON.stringify(this.form1.data.address) === '{}') return this.$message.error('请选择供货地')
const res = await vk.callFunction({
title: '请求中...',
url: 'client/spot/goods/kh/addUpdate',
data: this.form1.data
})
if (this.form1.data.buyTop || this.form1.data.buyAll) {
vk.navigateTo({
url: `/pages/index/shop/pay?id=${res.data}`
})
} else vk.redirectTo({url: '/pages/spot/goods/goods'});
}
},
computed: {
totalAmount() {
let amount = 0
if (this.amount) amount = this.amount * this.form1.data.buyTopNum
return amount
}
}
}
</script>
<style lang="scss">
.form-view {
width: 1200px;
margin: 0 auto;
background-color: #FFFFFF;
padding: 20rpx;
}
.form-view {
width: 1200px;
margin: 0 auto;
background-color: #FFFFFF;
padding: 20rpx;
}
</style>