357 lines
9.8 KiB
Vue
357 lines
9.8 KiB
Vue
<template>
|
|
<view class="form">
|
|
<u-form :model="form" ref="uForm">
|
|
<u-form-item label="标题" label-position="top" border-bottom="true" prop="title" label-width="auto">
|
|
<u-input v-model="form.title" placeholder="请输入标题以便吸引人的注意哦" placeholder-class="input-class"
|
|
border="none"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="区域" label-position="top" border-bottom="true" right-icon="arrow-right" prop="region"
|
|
label-width="auto">
|
|
<text @click="show1 = true" class="checkedtext" v-if="form.region">{{form.region}}</text>
|
|
<text @click="show1 = true" class="checktext" v-else>请选择所属区域</text>
|
|
|
|
<view class="arrow-icon">
|
|
<u-icon name="arrow-right" size="30px" @click="show1 = true"></u-icon>
|
|
</view>
|
|
<u-picker :columns="regionColumns" :show="show1" :closeOnClickOverlay="true" @close="show1 = false"
|
|
v-model="form.region" @confirm="regionConfirm"></u-picker>
|
|
</u-form-item>
|
|
<u-form-item label="行业" label-position="top" border-bottom="true" class="picker" label-width="auto"
|
|
prop="business">
|
|
<text @click="show2 = true" class="checkedtext" v-if="form.business">{{form.business}}</text>
|
|
<text @click="show2 = true" class="checktext" v-else>请选择行业</text>
|
|
<view class="arrow-icon">
|
|
<u-icon name="arrow-right" size="30px" @click="show2 = true"></u-icon>
|
|
</view>
|
|
<u-picker mode="region" :show="show2" :closeOnClickOverlay="true" @close="show2 = false"
|
|
:columns="[Classcolumns]" v-model="form.business" @confirm="tradeConfirm"></u-picker>
|
|
</u-form-item>
|
|
<u-form-item label="业态" label-position="top" border-bottom="true" label-width="auto" prop="commercialForm">
|
|
<text @click="choosecommercialForm" class="checkedtext"
|
|
v-if="form.commercialForm">{{form.commercialForm}}</text>
|
|
<text @click="choosecommercialForm" class="checktext" v-else>请选择业态</text>
|
|
<view class="arrow-icon">
|
|
<u-icon name="arrow-right" size="30px" @click="choosecommercialForm"></u-icon>
|
|
</view>
|
|
<u-picker mode="region" :show="show3" :closeOnClickOverlay="true" @close="show3 = false"
|
|
:columns="[Karmacolumns]" v-model="form.commercialForm" @confirm="karmaConfirm"></u-picker>
|
|
</u-form-item>
|
|
<u-form-item label="面积" label-position="top" border-bottom="true" label-width="auto" prop="area">
|
|
<u-input v-model="form.area" placeholder="请输入店铺面积" placeholder-class="input-class" border="none" type="number"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="预计投资" label-position="top" border-bottom="true" label-width="auto" prop="transferFee">
|
|
<u-input v-model="form.transferFee" placeholder="请输入预计投资" placeholder-class="input-class" type="number"
|
|
border="none"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="租金(元/月)" label-position="top" border-bottom="true" label-width="auto" prop="rent">
|
|
<u-input v-model="form.rent" placeholder="请输入店铺租金" placeholder-class="input-class" border="none" type="number"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="联系人" label-position="top" border-bottom="true" label-width="auto" prop="contactPerson">
|
|
<u-input v-model="form.contactPerson" placeholder="请输入联系人姓名" placeholder-class="input-class"
|
|
border="none"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="手机号码" label-position="top" border-bottom="true" label-width="auto" prop="phone">
|
|
<u-input v-model="form.phone" placeholder="请输入联系人手机号码" placeholder-class="input-class" border="none" type="number"></u-input>
|
|
</u-form-item>
|
|
<u-form-item label="详情介绍" label-position="top" border-bottom="true" label-width="auto" prop="details">
|
|
<u-input v-model="form.details" placeholder="请输入介绍详情" placeholder-class="input-class" border="none"></u-input>
|
|
</u-form-item>
|
|
</u-form>
|
|
<view class="bug-figure"></view>
|
|
<u-button @click="submit" color="linear-gradient(to right, #E86262, #CC3333)" :size="normal" shape="circle"
|
|
class="submit-btn">发布</u-button>
|
|
<view class="bug-figure"></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
regionColumns: [],
|
|
form: {
|
|
title: '',
|
|
region: '',
|
|
business: '',
|
|
commercialForm: '',
|
|
area: '',
|
|
transferFee: '',
|
|
rent: '',
|
|
contactPerson: '',
|
|
phone: '',
|
|
details: '',
|
|
id: '',
|
|
},
|
|
Classcolumns: [],
|
|
ClassCheckId: '',
|
|
Karmacolumns: [],
|
|
pid: [],
|
|
show1: false,
|
|
show2: false,
|
|
show3: false,
|
|
rules: {
|
|
'title': [{
|
|
required: true,
|
|
message: '请输入标题',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'business': [{
|
|
required: true,
|
|
message: '请选择行业',
|
|
trigger: ['change']
|
|
}],
|
|
'region': [{
|
|
required: true,
|
|
message: '请选择地区',
|
|
trigger: ['change']
|
|
}],
|
|
'commercialForm': [{
|
|
required: true,
|
|
message: '请选择业态',
|
|
trigger: ['change']
|
|
}],
|
|
'area': [{
|
|
required: true,
|
|
message: '请输入面积',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'transferFee': [{
|
|
required: true,
|
|
message: '请输入转让金',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'contactPerson': [{
|
|
required: true,
|
|
message: '请输入姓名',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'details': [{
|
|
required: true,
|
|
message: '请输入介绍',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'area': [{
|
|
required: true,
|
|
message: '请输入面积',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'rent': [{
|
|
required: true,
|
|
message: '请输入租金',
|
|
trigger: ['change', 'blur']
|
|
}],
|
|
'phone': [{
|
|
required: true,
|
|
message: '请输入电话号码',
|
|
},
|
|
{
|
|
validator: (rule, value, callback) => {
|
|
if (value) {
|
|
return this.$u.test.mobile(value);
|
|
} else {
|
|
return true
|
|
}
|
|
},
|
|
message: '号码不正确',
|
|
trigger: ['change', 'blur'],
|
|
}
|
|
]
|
|
},
|
|
}
|
|
},
|
|
methods: {
|
|
getDetail(type, id) {
|
|
console.log('type, id', type, id);
|
|
this.$api.getShopDetail(type, id).then(res => {
|
|
console.log(',re', res);
|
|
const data = res.data.data
|
|
if (res.data.code == 1) {
|
|
this.form = {
|
|
title: data.tt,
|
|
region: data.area1,
|
|
business: data.trade1,
|
|
commercialForm: data.trade2,
|
|
area: data.mianji,
|
|
transferFee: data.zhuanrangfei,
|
|
rent: data.zujin,
|
|
contactPerson: data.lianxiren,
|
|
phone: data.mobile,
|
|
details: data.content,
|
|
id: id
|
|
}
|
|
}
|
|
})
|
|
},
|
|
preview(e) {
|
|
console.log('预览', e);
|
|
},
|
|
handleSearchAddress() {
|
|
uni.navigateTo({
|
|
url: '/pages/publish/chooseAddress/chooseAddress'
|
|
})
|
|
},
|
|
submit() {
|
|
this.$refs.uForm.validate().then(res => {
|
|
console.log("提交表单信息:", this.form, this.form.id)
|
|
this.$api.publishAddress(this.form).then(res => {
|
|
console.log('发布找店地址', res);
|
|
if (res.data.code == 1) {
|
|
uni.$u.toast(res.data.msg)
|
|
uni.reLaunch({
|
|
url: '/pages/my/my'
|
|
})
|
|
} else {
|
|
uni.$u.toast(res.data.msg)
|
|
}
|
|
})
|
|
}).catch(errors => {
|
|
console.log("失败信息:", JSON.stringify(errors))
|
|
// uni.$u.toast('校验失败')
|
|
})
|
|
},
|
|
choosecommercialForm() {
|
|
if (!this.form.business) {
|
|
uni.$u.toast('请先选择行业')
|
|
return false
|
|
} else {
|
|
this.show3 = true
|
|
}
|
|
},
|
|
getRegionList() {
|
|
var that = this
|
|
uni.request({
|
|
url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + uni.getStorageSync('city_code') + '&key=' +
|
|
that.$api.key,
|
|
success(res) {
|
|
that.regionColumns = [res.data.result[0].map(item => item.fullname)]
|
|
},
|
|
fail(err) {
|
|
console.log('请求区域失败:', err);
|
|
}
|
|
})
|
|
},
|
|
tradeConfirm(e) {
|
|
this.show2 = false
|
|
this.form.business = e.value[0]
|
|
this.ClassCheckId = this.pid[e.indexs[0]]
|
|
this.$api.getClassList(this.ClassCheckId).then(res => {
|
|
// console.log(res);
|
|
this.Karmacolumns = res.data.data.map((item) => {
|
|
return item = item.name
|
|
})
|
|
})
|
|
},
|
|
karmaConfirm(e) {
|
|
this.show3 = false
|
|
this.form.commercialForm = e.value[0]
|
|
},
|
|
regionConfirm(e) {
|
|
this.show1 = false
|
|
this.form.region = e.value[0]
|
|
},
|
|
},
|
|
onReady() {
|
|
this.$refs.uForm.setRules(this.rules)
|
|
|
|
},
|
|
onLoad(options) {
|
|
console.log('修改找店地址', options);
|
|
if (options.item) {
|
|
console.log('修改');
|
|
if (options.id) {
|
|
this.getDetail(2, options.id)
|
|
}
|
|
} else {
|
|
console.log('发布');
|
|
}
|
|
this.getRegionList()
|
|
this.$api.getClassList().then(res => {
|
|
// console.log(res.data.data.length);
|
|
this.Classcolumns = res.data.data.map((item) => {
|
|
return item = item.name
|
|
})
|
|
this.pid = res.data.data.map((item) => {
|
|
return item = item.id
|
|
})
|
|
|
|
})
|
|
},
|
|
computed: {
|
|
isChecked(index) {
|
|
if (index.length > 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.count {}
|
|
|
|
.form {
|
|
margin-left: 20px;
|
|
margin-right: 20px;
|
|
}
|
|
|
|
.input-class {
|
|
font-size: 30rpx;
|
|
font-weight: 1px;
|
|
border-style: none;
|
|
|
|
}
|
|
|
|
.upload {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
background-color: #F8F8F8;
|
|
|
|
// height: 300rpx;
|
|
.count {
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
// margin-right: 20px;
|
|
}
|
|
|
|
.submit-btn {
|
|
width: 80%;
|
|
}
|
|
|
|
.bug-figure {
|
|
height: 100rpx;
|
|
}
|
|
|
|
.checkbox1 {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.checktext {
|
|
margin-top: 5rpx;
|
|
font-size: 30rpx;
|
|
font-weight: 1px;
|
|
color: #c1c4c7;
|
|
}
|
|
|
|
.checkedtext {
|
|
margin-top: 5rpx;
|
|
font-size: 28rpx;
|
|
font-weight: 1px;
|
|
border-style: none;
|
|
}
|
|
|
|
.picker {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.arrow-icon {
|
|
position: absolute;
|
|
right: 10rpx;
|
|
transform: translateY(-20rpx);
|
|
}
|
|
</style> |