diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue index 2b4ce84..6077706 100644 --- a/pages/detail/detail.vue +++ b/pages/detail/detail.vue @@ -29,7 +29,7 @@ - 行业:{{shopInfo.trade1}} + 行业:{{shopInfo.trade1+'-'}}{{shopInfo.trade2}} 区域:{{shopInfo.area1}} 地址:{{shopInfo.adress}} diff --git a/pages/publish/publishAddress/publishAddress.vue b/pages/publish/publishAddress/publishAddress.vue index 21c0b2c..8d4021a 100644 --- a/pages/publish/publishAddress/publishAddress.vue +++ b/pages/publish/publishAddress/publishAddress.vue @@ -37,21 +37,24 @@ :columns="[Karmacolumns]" v-model="form.commercialForm" @confirm="karmaConfirm"> - + - + - + diff --git a/pages/publish/publishInvestment/publishInvestment.vue b/pages/publish/publishInvestment/publishInvestment.vue index 4055179..7597e3f 100644 --- a/pages/publish/publishInvestment/publishInvestment.vue +++ b/pages/publish/publishInvestment/publishInvestment.vue @@ -21,8 +21,9 @@ - + - + - + - + @@ -69,6 +73,9 @@ imageLength: 0, fileList1: [], regionColumns: [], + regionSecondColumns: [], + regionId: [], + regionCheckId: '', form: { title: '', region: '', @@ -226,6 +233,8 @@ } let data = { ...this.form, + address: this.form.region.split('-')[1] + this.form.address, + region: this.form.region.split('-')[0], images: temp.join(',') } console.log("项目招商:", data) @@ -255,13 +264,53 @@ // console.log('changeAddress', e); this.getAddressList(e) }, + changeRegionHandler(e) { + const { + columnIndex, + value, + values, // values为当前变化列的数组内容 + index, + // 微信小程序无法将picker实例传出来,只能通过ref操作 + picker = this.$refs.regionPicker + } = e + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 + if (columnIndex === 0) { + // picker为选择器this实例,变化第二列对应的选项 + this.regionCheckId = this.regionId[index] + const that = this + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that.regionCheckId + '&key=' + + that.$api.key, + success(res) { + that.regionSecondColumns = res.data.result[0].map(item => item.fullname) + picker.setColumnValues(1, that.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) + } + }, 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)] + that.regionColumns = res.data.result[0].map(item => item.fullname) + that.regionId = res.data.result[0].map(item => item.id) + var that1 = that + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that1.regionId[0] + '&key=' + + that1.$api.key, + success(res) { + that1.regionSecondColumns = res.data.result[0].map(item => item.fullname) + that1.$refs.regionPicker.setColumnValues(1, that1.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) }, fail(err) { console.log('请求区域失败:', err); @@ -274,7 +323,6 @@ 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); if (res.data.message == "query ok") { // console.log('lat', res.data.result.location.lat); that.form.latitude = res.data.result.location.lat @@ -306,7 +354,7 @@ }, regionConfirm(e) { this.show1 = false - this.form.region = e.value[0] + this.form.region = e.value[0] + '-' + e.value[1] }, getDetail(type, id) { console.log('type, id', type, id); diff --git a/pages/publish/publishRent/publishRent.vue b/pages/publish/publishRent/publishRent.vue index a9c2a65..d6cb80f 100644 --- a/pages/publish/publishRent/publishRent.vue +++ b/pages/publish/publishRent/publishRent.vue @@ -21,8 +21,9 @@ - + - {{form.business}}-{{form.commercial}} + {{form.business}}-{{form.commercial}} 请选择店铺行业与业态 @@ -48,16 +50,19 @@ :columns="[Karmacolumns]" v-model="form.commercial" @confirm="karmaConfirm"> --> - + - + - + @@ -76,8 +81,10 @@ return { imageLength: '0', fileList1: [], - regionColumns: [JSON.parse(uni.getStorageSync('regionList'))] || [], - + regionColumns: [], + regionSecondColumns: [], + regionId: [], + regionCheckId: '', form: { title: '', region: '', @@ -241,6 +248,8 @@ } let data = { ...this.form, + address: this.form.region.split('-')[1] + this.form.address, + region: this.form.region.split('-')[0], images: temp.join(',') } console.log("提交表单信息:", data) @@ -278,6 +287,59 @@ // console.log('changeAddress', e); this.getAddressList(e) }, + changeRegionHandler(e) { + const { + columnIndex, + value, + values, // values为当前变化列的数组内容 + index, + // 微信小程序无法将picker实例传出来,只能通过ref操作 + picker = this.$refs.regionPicker + } = e + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 + if (columnIndex === 0) { + // picker为选择器this实例,变化第二列对应的选项 + this.regionCheckId = this.regionId[index] + const that = this + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that.regionCheckId + '&key=' + + that.$api.key, + success(res) { + that.regionSecondColumns = res.data.result[0].map(item => item.fullname) + picker.setColumnValues(1, that.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) + } + }, + 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) + that.regionId = res.data.result[0].map(item => item.id) + var that1 = that + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that1.regionId[0] + '&key=' + + that1.$api.key, + success(res) { + that1.regionSecondColumns = res.data.result[0].map(item => item.fullname) + that1.$refs.regionPicker.setColumnValues(1, that1.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) + }, getAddressList(value) { if (!this.form.region) { uni.$u.toast('请先选择区域') @@ -304,34 +366,32 @@ }) }, changeHandler(e) { - const { - columnIndex, - value, - values, // values为当前变化列的数组内容 - index, - // 微信小程序无法将picker实例传出来,只能通过ref操作 - picker = this.$refs.uPicker - } = e - // 当第一列值发生变化时,变化第二列(后一列)对应的选项 - console.log(e); - if (columnIndex === 0) { - // picker为选择器this实例,变化第二列对应的选项 - this.ClassCheckId = this.pid[index] - this.$api.getClassList(this.ClassCheckId).then(res => { - console.log(res); - this.Karmacolumns = res.data.data.map((item) => { - return item = item.name - }) - picker.setColumnValues(1, this.Karmacolumns) - }) - - } - }, + const { + columnIndex, + value, + values, // values为当前变化列的数组内容 + index, + // 微信小程序无法将picker实例传出来,只能通过ref操作 + picker = this.$refs.uPicker + } = e + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 + console.log(e); + if (columnIndex === 0) { + // picker为选择器this实例,变化第二列对应的选项 + this.ClassCheckId = this.pid[index] + this.$api.getClassList(this.ClassCheckId).then(res => { + console.log(res); + this.Karmacolumns = res.data.data.map((item) => { + return item = item.name + }) + picker.setColumnValues(1, this.Karmacolumns) + }) + } + }, tradeConfirm(e) { this.show2 = false this.form.business = e.value[0] this.form.commercial = e.value[1] - }, karmaConfirm(e) { this.show3 = false @@ -339,7 +399,7 @@ }, regionConfirm(e) { this.show1 = false - this.form.region = e.value[0] + this.form.region = e.value[0] + '-' + e.value[1] }, getDetail(type, id) { console.log('type, id', type, id); @@ -396,6 +456,7 @@ } else { console.log('发布'); } + this.getRegionList() this.$api.getClassList().then(res => { // console.log(res.data.data.length); this.Classcolumns = res.data.data.map((item) => { @@ -403,13 +464,13 @@ }) this.pid = res.data.data.map((item) => { return item = item.id - + }) this.$api.getClassList(9).then(res => { this.Karmacolumns = res.data.data.map((item) => { return item = item.name - }) - this.$refs.uPicker.setColumnValues(1,this.Karmacolumns) + }) + this.$refs.uPicker.setColumnValues(1, this.Karmacolumns) }) }) }, diff --git a/pages/publish/publishTransfer/publishTransfer.vue b/pages/publish/publishTransfer/publishTransfer.vue index e1ed415..7cf9555 100644 --- a/pages/publish/publishTransfer/publishTransfer.vue +++ b/pages/publish/publishTransfer/publishTransfer.vue @@ -20,8 +20,9 @@ - + - {{form.business}}-{{form.commercial}} + {{form.business}}-{{form.commercial}} 请选择店铺行业与业态 @@ -38,10 +40,12 @@ :columns="[Classcolumns]" v-model="form.business" @confirm="tradeConfirm" @change="changeHandler"> - + - + - + @@ -70,7 +75,9 @@ imageLength: 0, fileList1: [], regionColumns: [], - + regionSecondColumns: [], + regionId: [], + regionCheckId: '', form: { title: '', region: '', @@ -238,11 +245,14 @@ uni.$u.toast('请输入准确地址') return false } + let data = { ...this.form, + address: this.form.region.split('-')[1] + this.form.address, + region: this.form.region.split('-')[0], images: temp.join(',') } - console.log('提交表单信息', data, this.form); + console.log('提交表单信息', data); this.$api.publishTransfer(data).then(res => { console.log('发布店铺转让', res); if (res.data.code == 1) { @@ -277,13 +287,53 @@ // console.log('changeAddress', e); this.getAddressList(e) }, + changeRegionHandler(e) { + const { + columnIndex, + value, + values, // values为当前变化列的数组内容 + index, + // 微信小程序无法将picker实例传出来,只能通过ref操作 + picker = this.$refs.regionPicker + } = e + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 + if (columnIndex === 0) { + // picker为选择器this实例,变化第二列对应的选项 + this.regionCheckId = this.regionId[index] + const that = this + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that.regionCheckId + '&key=' + + that.$api.key, + success(res) { + that.regionSecondColumns = res.data.result[0].map(item => item.fullname) + picker.setColumnValues(1, that.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) + } + }, 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)] + that.regionColumns = res.data.result[0].map(item => item.fullname) + that.regionId = res.data.result[0].map(item => item.id) + var that1 = that + uni.request({ + url: 'https://apis.map.qq.com/ws/district/v1/getchildren?id=' + that1.regionId[0] + '&key=' + + that1.$api.key, + success(res) { + that1.regionSecondColumns = res.data.result[0].map(item => item.fullname) + that1.$refs.regionPicker.setColumnValues(1, that1.regionSecondColumns) + }, + fail(err) { + console.log('请求区域失败:', err); + } + }) }, fail(err) { console.log('请求区域失败:', err); @@ -301,7 +351,7 @@ url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + that.form.region + value + '&key=' + that.$api.key, success(res) { - console.log('地址转经纬度', res.data); + console.log('地址转经纬度', that.form.region, res.data); if (res.data.message == "query ok") { // console.log('lat', res.data.result.location.lat); that.form.latitude = res.data.result.location.lat @@ -317,29 +367,29 @@ }) }, changeHandler(e) { - const { - columnIndex, - value, - values, // values为当前变化列的数组内容 - index, - // 微信小程序无法将picker实例传出来,只能通过ref操作 - picker = this.$refs.uPicker - } = e - // 当第一列值发生变化时,变化第二列(后一列)对应的选项 - console.log(e); - if (columnIndex === 0) { - // picker为选择器this实例,变化第二列对应的选项 - this.ClassCheckId = this.pid[index] - this.$api.getClassList(this.ClassCheckId).then(res => { - console.log(res); - this.Karmacolumns = res.data.data.map((item) => { - return item = item.name - }) - picker.setColumnValues(1, this.Karmacolumns) - }) - - } - }, + const { + columnIndex, + value, + values, // values为当前变化列的数组内容 + index, + // 微信小程序无法将picker实例传出来,只能通过ref操作 + picker = this.$refs.uPicker + } = e + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 + console.log(e); + if (columnIndex === 0) { + // picker为选择器this实例,变化第二列对应的选项 + this.ClassCheckId = this.pid[index] + this.$api.getClassList(this.ClassCheckId).then(res => { + console.log(res); + this.Karmacolumns = res.data.data.map((item) => { + return item = item.name + }) + picker.setColumnValues(1, this.Karmacolumns) + }) + + } + }, tradeConfirm(e) { this.show2 = false this.form.business = e.value[0] @@ -347,11 +397,10 @@ }, karmaConfirm(e) { this.show3 = false - }, regionConfirm(e) { this.show1 = false - this.form.region = e.value[0] + this.form.region = e.value[0] + '-' + e.value[1] }, getDetail(type, id) { console.log('type, id', type, id); @@ -419,12 +468,10 @@ this.$api.getClassList(9).then(res => { this.Karmacolumns = res.data.data.map((item) => { return item = item.name - }) - this.$refs.uPicker.setColumnValues(1,this.Karmacolumns) + }) + this.$refs.uPicker.setColumnValues(1, this.Karmacolumns) }) }) - - }, computed: { isChecked(index) { diff --git a/service/request.js b/service/request.js index 2ba90a3..6fc96ff 100644 --- a/service/request.js +++ b/service/request.js @@ -3,9 +3,9 @@ function isOutTime(res) { if (res.data.msg == '登录超时,请重新登录') { uni.showToast('登录信息已过期,请重新登录') // setTimeout(() => { - uni.redirectTo({ - url: '/pages/login/login' - }) + uni.redirectTo({ + url: '/pages/login/login' + }) // }, 1000) uni.removeStorageSync('loginToken') } else { @@ -25,11 +25,10 @@ const service = { header: header, success: res => { resolve(res) - console.log('res===',res); isOutTime(res); }, fail: err => { - console.log('错误',err); + console.log('错误', err); reject(err) } })