Commit 165232c6 by 匡雅琴

省市修改

1 parent 0eb46201
......@@ -36,7 +36,7 @@ export default {
resizeEnable: true,
zoom: 20
})
AMap.plugin(['AMap.PlaceSearch'], function () {
AMap.plugin(['AMap.PlaceSearch'], function() {
//构造地点查询类
placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数
......@@ -52,8 +52,7 @@ export default {
},
searchAddress() {
let _this = this
placeSearch.search(this.input, function (status, result) {
console.log(result)
placeSearch.search(this.input, function(status, result) {
if (status === 'complete' && result.poiList.pois.length) {
let lnglat = result.poiList.pois[0].location
_this.getAddress(lnglat)
......@@ -67,7 +66,6 @@ export default {
} else {
position = lnglat
}
console.log(position)
marker = new AMap.Marker({
icon: new AMap.Icon({
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
......@@ -81,7 +79,6 @@ export default {
map.setFitView()
},
getAddress(e) {
console.log(e)
let self = this
let lnglat
if (e.type == 'click') {
......@@ -118,7 +115,7 @@ export default {
this.mapInit()
}
}
</script>
</script>
<style scoped lang="scss">
.map-box {
......@@ -142,4 +139,4 @@ export default {
line-height: 20px;
bottom: -30px;
}
</style>
\ No newline at end of file
</style>
......@@ -20,7 +20,7 @@ export default {
return {
provinceList: provinceList(),
AllData: [],
cityList: [{ adcode: '', name: '请先选择省' }],
cityList: [{ adcode: '', name: '全部' }],
provinceForm: {
provinceName: '', // 省值
cityName: '', // 市值
......@@ -54,15 +54,18 @@ export default {
})
AMap.plugin(['AMap.DistrictSearch'], () => {
var opts = {
subdistrict: 2, //返回下一级行政区
subdistrict: 3, //返回下一级行政区
level: 'city', //查询的范围
showbiz: true //查询行政级别为 市
}
var districtSearch = new AMap.DistrictSearch(opts)
districtSearch.search('中国', (status, result) => {
this.AllData = result.districtList[0].districtList
this.AllData.unshift({
adcode: '',
name: '全部'
})
})
console.log(this.AllData)
})
console.log(this.AllData)
if (provinceName) {
......@@ -75,6 +78,8 @@ export default {
if (itm.name.indexOf(cityName) != -1) {
this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name
// console.log(itm.name)
// this.$set(this.provinceForm, 'cityName', itm.name)
}
})
}
......
......@@ -281,8 +281,18 @@ export default {
this.accountAddForm.lng = lnglat.lng
var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市
var provincecode = this.$refs.mapForm.geocoderAddress.adcode
var province = fullAddress.province
var city = fullAddress.city
const municipalities = ['北京市', '天津市', '上海市', '重庆市']
var municipality = municipalities.find(item => item == province)
if (municipality) {
city = city.slice(0, 2) + '城区'
if (municipality === '重庆市') {
provincecode = provincecode.slice(0, 4)
provincecode == 5001 ? (city = city.slice(0, 2) + '城区') : (city = city.slice(0, 2) + '郊县')
}
}
// 判断省市是否匹配
if (this.accountAddForm.provinceName) {
if (this.accountAddForm.provinceName !== province || this.accountAddForm.cityName !== city) {
......
......@@ -25,7 +25,7 @@
<el-time-picker size="small" value-format="HH:mm:ss" is-range v-model="infoForm.bussinessTime" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围"></el-time-picker>
</el-form-item>
<el-form-item size="small" label="驻店电话" style="position: relative">
<el-input v-model="infoForm.residentPhone" placeholder="此电话会在小程序上显示,请填写真实有效的电话或手机号"></el-input>
<el-input v-model="infoForm.residentPhone" class="phone-input" maxlength="11" placeholder="此电话会在小程序上显示,请填写真实有效的电话或手机号"></el-input>
<div @click="showTelDia" class="show-address">显示位置</div>
</el-form-item>
<el-form-item size="small" label="主营品牌" style="height: 500px">
......@@ -49,6 +49,7 @@
</template>
<script>
import util from '@/utils/util'
import mapView from '@/components/mapView/index'
import SelectBrand from './selectBrand.vue'
import TelPosition from './telPosition.vue'
......@@ -165,8 +166,19 @@ export default {
this.infoForm.lng = lnglat.lng
var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市
var provincecode = this.$refs.mapForm.geocoderAddress.adcode
var province = fullAddress.province
var city = fullAddress.city
const municipalities = ['北京市', '天津市', '上海市', '重庆市']
var municipality = municipalities.find(item => item == province)
if (municipality) {
city = city.slice(0, 2) + '城区'
if (municipality === '重庆市') {
provincecode = provincecode.slice(0, 4)
console.log(provincecode)
provincecode == 5001 ? (city = city.slice(0, 2) + '城区') : (city = city.slice(0, 2) + '郊县')
}
}
// 判断省市是否匹配
if (this.infoForm.provinceName) {
if (this.infoForm.provinceName !== province || this.infoForm.cityName !== city) {
......@@ -199,6 +211,15 @@ export default {
},
handleSave() {
const params = this.infoForm
if (this.infoForm.residentPhone && !util.checkPhone(this.infoForm.residentPhone)) {
this.$message.error('请输入正确的驻店电话')
document.querySelector('#app').scrollTop = 0
setTimeout(() => {
var isError = document.getElementsByClassName('phone-input')
isError[0].querySelector('input').focus()
}, 100)
return
}
params.merchantBrandMain = ''
// 获取省市信息
const { provinceName, provinceCode, cityName, cityCode } = this.$refs.provinceForm.provinceForm
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!