Commit 93311fcb by 匡雅琴

修改省市展示

1 parent 160089b4
...@@ -42,15 +42,12 @@ export default { ...@@ -42,15 +42,12 @@ export default {
methods: { methods: {
init(provinceName, cityName) { init(provinceName, cityName) {
console.log(provinceName, cityName) console.log(provinceName, cityName)
console.log(111111)
console.log(this.AllData)
this.provinceForm = { this.provinceForm = {
provinceName: provinceName, provinceName: provinceName,
cityName: cityName cityName: cityName
} }
this.AllData.map(item => { this.AllData.map(item => {
if (provinceName == item.provinceName) { if (item.provinceName.indexOf(provinceName) != -1) {
console.log(111111)
this.cityList = item.cityInfoList this.cityList = item.cityInfoList
this.provinceForm.provinceCode = item.provinceCode this.provinceForm.provinceCode = item.provinceCode
this.cityList.map(itm => { this.cityList.map(itm => {
......
...@@ -261,6 +261,7 @@ export default { ...@@ -261,6 +261,7 @@ export default {
return data.label.indexOf(value) !== -1 return data.label.indexOf(value) !== -1
}, },
getAddress() { getAddress() {
console.log(this.$refs.mapForm.geocoderAddress)
if (!this.$refs.mapForm.address) { if (!this.$refs.mapForm.address) {
this.$message.error('请选择地址') this.$message.error('请选择地址')
return return
...@@ -270,20 +271,16 @@ export default { ...@@ -270,20 +271,16 @@ export default {
let lnglat = this.$refs.mapForm.lnglat let lnglat = this.$refs.mapForm.lnglat
this.accountAddForm.lat = lnglat.lat this.accountAddForm.lat = lnglat.lat
this.accountAddForm.lng = lnglat.lng this.accountAddForm.lng = lnglat.lng
// 截取省市 var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
var provinceIdx = address.indexOf('省') // 获取省市
var cityIdx = address.indexOf('市') var provinceIdx = fullAddress.province
// provinceIdx == -1 ? (provinceIdx = 0) : provinceIdx var cityIdx = fullAddress.city
var province = address.slice(0, provinceIdx) var province = provinceIdx.slice(0, 2)
var city = address.slice(provinceIdx + 1, cityIdx) var city = cityIdx.slice(0, 2)
// 如果没有省
if (provinceIdx == -1) {
provinceIdx = 0
city = address.slice(provinceIdx, cityIdx)
province = city
}
// 判断省市是否匹配 // 判断省市是否匹配
if (this.accountAddForm.provinceName) { if (this.accountAddForm.provinceName) {
this.accountAddForm.provinceName = this.accountAddForm.provinceName.slice(0, 2)
this.accountAddForm.cityName = this.accountAddForm.cityName.slice(0, 2)
if (this.accountAddForm.provinceName !== province || this.accountAddForm.cityName !== city) { if (this.accountAddForm.provinceName !== province || this.accountAddForm.cityName !== city) {
this.$message.error('您选择的地址错误,请重新选择') this.$message.error('您选择的地址错误,请重新选择')
this.accountAddForm.merchantAddress = '' this.accountAddForm.merchantAddress = ''
......
...@@ -151,13 +151,16 @@ export default { ...@@ -151,13 +151,16 @@ export default {
let lnglat = this.$refs.mapForm.lnglat let lnglat = this.$refs.mapForm.lnglat
this.infoForm.lat = lnglat.lat this.infoForm.lat = lnglat.lat
this.infoForm.lng = lnglat.lng this.infoForm.lng = lnglat.lng
// 截取省市 var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
var provinceIdx = address.indexOf('省') // 获取省市
var cityIdx = address.indexOf('市') var provinceIdx = fullAddress.province
var province = address.slice(0, provinceIdx) var cityIdx = fullAddress.city
var city = address.slice(provinceIdx + 1, cityIdx) var province = provinceIdx.slice(0, 2)
var city = cityIdx.slice(0, 2)
// 判断省市是否匹配 // 判断省市是否匹配
if (this.infoForm.provinceName) { if (this.infoForm.provinceName) {
this.infoForm.provinceName = this.infoForm.provinceName.slice(0, 2)
this.infoForm.cityName = this.infoForm.cityName.slice(0, 2)
if (this.infoForm.provinceName !== province || this.infoForm.cityName !== city) { if (this.infoForm.provinceName !== province || this.infoForm.cityName !== city) {
this.$message.error('您选择的地址错误,请重新选择') this.$message.error('您选择的地址错误,请重新选择')
this.infoForm.merchantAddress = '' this.infoForm.merchantAddress = ''
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!