diff --git a/pages/publish/publishInvestment/publishInvestment.vue b/pages/publish/publishInvestment/publishInvestment.vue
index 7b24bf5..ee9e852 100644
--- a/pages/publish/publishInvestment/publishInvestment.vue
+++ b/pages/publish/publishInvestment/publishInvestment.vue
@@ -25,8 +25,8 @@
v-model="form.region" @confirm="regionConfirm">
-
+
@@ -38,14 +38,21 @@
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
@@ -59,18 +66,19 @@
export default {
data() {
return {
- imageLength: '0',
+ imageLength: 0,
fileList1: [],
- regionColumns: [JSON.parse(uni.getStorageSync('regionList'))] || [],
-
+ regionColumns: [],
form: {
title: '',
region: '',
address: '',
business: '',
- mobile: '',
- contact:'',
- content: '',
+ area: '',
+ rent: '',
+ phone: '',
+ contactPerson: '',
+ details: '',
images: [],
longitude: '',
latitude: '',
@@ -100,12 +108,22 @@
message: '请选择地区',
trigger: ['change']
}],
- 'contact': [{
+ 'area': [{
+ required: true,
+ message: '请输入面积',
+ trigger: ['change', 'blur']
+ }],
+ 'rent': [{
+ required: true,
+ message: '请输入租金',
+ trigger: ['change', 'blur']
+ }],
+ 'contactPerson': [{
required: true,
message: '请输入姓名',
trigger: ['change', 'blur']
}],
- 'content': [{
+ 'details': [{
required: true,
message: '请输入介绍',
trigger: ['change', 'blur']
@@ -115,7 +133,7 @@
message: '请输入地址',
trigger: ['change', 'blur']
}],
- 'mobile': [{
+ 'phone': [{
required: true,
message: '请输入电话号码',
},
@@ -192,40 +210,76 @@
})
},
submit() {
- const temp = []
- if (this.fileList1.length > 0) {
- this.fileList1.map(item => {
- const url = item.url
- temp.push(url.replace(this.imgUrl + '/', ''))
- })
- }
- console.log('images---', temp.join(','));
this.$refs.uForm.validate().then(res => {
- console.log("提交表单信息:" + JSON.stringify(this.form))
- uni.$u.toast('发布成功')
- this.$api.publishInvestment(this.form).then(res => {
+ const temp = []
+ if (this.fileList1.length > 0) {
+ this.fileList1.map(item => {
+ const url = item.url
+ temp.push(url.replace(this.imgUrl + '/', ''))
+ })
+ }
+ if (this.form.latitude && this.form.longitude) {
+ console.log('经纬度都存在');
+ } else {
+ uni.$u.toast('请输入准确地址')
+ return false
+ }
+ let data = {
+ ...this.form,
+ images: temp.join(',')
+ }
+ console.log("项目招商:", data)
+ this.$api.publishInvestment(data).then(res => {
console.log(res);
+ if (res.data.code == 1) {
+ uni.$u.toast('发布成功')
+ } else {
+ uni.$u.toast(res.data.msg)
+ }
})
}).catch(errors => {
console.log("失败信息:" + JSON.stringify(errors))
// uni.$u.toast('校验失败')
})
},
+ changeAddressFocus() {
+ if (!this.form.region) {
+ uni.$u.toast('请先选择区域')
+ return false
+ }
+ },
changeAddress(e) {
// console.log('changeAddress', e);
this.getAddressList(e)
},
+ 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);
+ }
+ })
+ },
getAddressList(value) {
var that = this
uni.request({
- url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + value + '&key=' +
+ url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + that.form.region + value + '&key=' +
that.$api.key,
success(res) {
console.log('diz', res.data.result.location);
- // console.log('lat', res.data.result.location.lat);
- that.form.latitude = res.data.result.location.lat
- // console.log('lng', res.data.result.location.lng);
- that.form.longitude = res.data.result.location.lng
+ if (res.data.message == "query ok") {
+ // console.log('lat', res.data.result.location.lat);
+ that.form.latitude = res.data.result.location.lat
+ // console.log('lng', res.data.result.location.lng);
+ that.form.longitude = res.data.result.location.lng
+ } else {
+ uni.$u.toast('请输入准确地址')
+ }
},
fail(err) {
console.log('请求区域失败:', err);
@@ -257,6 +311,7 @@
},
onLoad() {
+ this.getRegionList()
this.$api.getClassList().then(res => {
// console.log(res.data.data.length);
this.Classcolumns = res.data.data.map((item) => {
@@ -305,6 +360,7 @@
.count {
margin-bottom: 30px;
}
+
// margin-right: 20px;
}
diff --git a/pages/publish/publishRent/publishRent.vue b/pages/publish/publishRent/publishRent.vue
index fd4ed8d..16cc9d1 100644
--- a/pages/publish/publishRent/publishRent.vue
+++ b/pages/publish/publishRent/publishRent.vue
@@ -26,7 +26,7 @@
+ @focus="changeAddressFocus" @blur="changeAddress">
@@ -38,15 +38,15 @@
-
- {{form.commercial}}
- 请选择店铺业态
+
@@ -86,7 +86,7 @@
commercial: '',
area: '',
rent: '',
- contact:'',
+ contact: '',
mobile: '',
content: '',
images: [],
@@ -225,40 +225,75 @@
})
},
submit() {
- const temp = []
- if (this.fileList1.length > 0) {
- this.fileList1.map(item => {
- const url = item.url
- temp.push(url.replace(this.imgUrl + '/', ''))
- })
- }
- console.log('images---', temp.join(','));
this.$refs.uForm.validate().then(res => {
- console.log("提交表单信息:" + JSON.stringify(this.form))
- uni.$u.toast('发布成功')
- this.$api.publishRent(this.form).then(res => {
- console.log(res);
+ const temp = []
+ if (this.fileList1.length > 0) {
+ this.fileList1.map(item => {
+ const url = item.url
+ temp.push(url.replace(this.imgUrl + '/', ''))
+ })
+ }
+ if (this.form.latitude && this.form.longitude) {
+ console.log('经纬度都存在');
+ } else {
+ uni.$u.toast('请输入准确地址')
+ return false
+ }
+ let data = {
+ ...this.form,
+ images: temp.join(',')
+ }
+ console.log("提交表单信息:", data)
+ this.$api.publishRent(data).then(res => {
+ console.log('发布店铺出租', res);
+ if (res.data.code == 1) {
+ uni.$u.toast('发布成功')
+ } else {
+ uni.$u.toast(res.data.msg)
+ }
})
}).catch(errors => {
console.log("失败信息:" + JSON.stringify(errors))
// uni.$u.toast('校验失败')
})
},
+ chooseCommercial() {
+ if (!this.form.business) {
+ uni.$u.toast('请先选择行业')
+ return false
+ } else {
+ this.show3 = true
+ }
+ },
+ changeAddressFocus() {
+ if (!this.form.region) {
+ uni.$u.toast('请先选择区域')
+ return false
+ }
+ },
changeAddress(e) {
// console.log('changeAddress', e);
this.getAddressList(e)
},
getAddressList(value) {
+ if (!this.form.region) {
+ uni.$u.toast('请先选择区域')
+ return false
+ }
var that = this
uni.request({
- url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + value + '&key=' +
+ url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + that.form.region + value + '&key=' +
that.$api.key,
success(res) {
console.log('diz', res.data.result.location);
- // console.log('lat', res.data.result.location.lat);
- that.form.latitude = res.data.result.location.lat
- // console.log('lng', res.data.result.location.lng);
- that.form.longitude = res.data.result.location.lng
+ if (res.data.message == "query ok") {
+ // console.log('lat', res.data.result.location.lat);
+ that.form.latitude = res.data.result.location.lat
+ // console.log('lng', res.data.result.location.lng);
+ that.form.longitude = res.data.result.location.lng
+ } else {
+ uni.$u.toast('请输入准确地址')
+ }
},
fail(err) {
console.log('请求区域失败:', err);
@@ -338,6 +373,7 @@
.count {
margin-bottom: 30px;
}
+
// margin-right: 20px;
}