Commit 165232c6 by 匡雅琴

省市修改

1 parent 0eb46201
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
resizeEnable: true, resizeEnable: true,
zoom: 20 zoom: 20
}) })
AMap.plugin(['AMap.PlaceSearch'], function () { AMap.plugin(['AMap.PlaceSearch'], function() {
//构造地点查询类 //构造地点查询类
placeSearch = new AMap.PlaceSearch({ placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数 pageSize: 8, // 单页显示结果条数
...@@ -52,8 +52,7 @@ export default { ...@@ -52,8 +52,7 @@ export default {
}, },
searchAddress() { searchAddress() {
let _this = this let _this = this
placeSearch.search(this.input, function (status, result) { placeSearch.search(this.input, function(status, result) {
console.log(result)
if (status === 'complete' && result.poiList.pois.length) { if (status === 'complete' && result.poiList.pois.length) {
let lnglat = result.poiList.pois[0].location let lnglat = result.poiList.pois[0].location
_this.getAddress(lnglat) _this.getAddress(lnglat)
...@@ -67,7 +66,6 @@ export default { ...@@ -67,7 +66,6 @@ export default {
} else { } else {
position = lnglat position = lnglat
} }
console.log(position)
marker = new AMap.Marker({ marker = new AMap.Marker({
icon: new AMap.Icon({ icon: new AMap.Icon({
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
...@@ -81,7 +79,6 @@ export default { ...@@ -81,7 +79,6 @@ export default {
map.setFitView() map.setFitView()
}, },
getAddress(e) { getAddress(e) {
console.log(e)
let self = this let self = this
let lnglat let lnglat
if (e.type == 'click') { if (e.type == 'click') {
......
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
return { return {
provinceList: provinceList(), provinceList: provinceList(),
AllData: [], AllData: [],
cityList: [{ adcode: '', name: '请先选择省' }], cityList: [{ adcode: '', name: '全部' }],
provinceForm: { provinceForm: {
provinceName: '', // 省值 provinceName: '', // 省值
cityName: '', // 市值 cityName: '', // 市值
...@@ -54,15 +54,18 @@ export default { ...@@ -54,15 +54,18 @@ export default {
}) })
AMap.plugin(['AMap.DistrictSearch'], () => { AMap.plugin(['AMap.DistrictSearch'], () => {
var opts = { var opts = {
subdistrict: 2, //返回下一级行政区 subdistrict: 3, //返回下一级行政区
level: 'city', //查询的范围 level: 'city', //查询的范围
showbiz: true //查询行政级别为 市 showbiz: true //查询行政级别为 市
} }
var districtSearch = new AMap.DistrictSearch(opts) var districtSearch = new AMap.DistrictSearch(opts)
districtSearch.search('中国', (status, result) => { districtSearch.search('中国', (status, result) => {
this.AllData = result.districtList[0].districtList this.AllData = result.districtList[0].districtList
this.AllData.unshift({
adcode: '',
name: '全部'
})
}) })
console.log(this.AllData)
}) })
console.log(this.AllData) console.log(this.AllData)
if (provinceName) { if (provinceName) {
...@@ -75,6 +78,8 @@ export default { ...@@ -75,6 +78,8 @@ export default {
if (itm.name.indexOf(cityName) != -1) { if (itm.name.indexOf(cityName) != -1) {
this.provinceForm.cityCode = itm.adcode this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name this.provinceForm.cityName = itm.name
// console.log(itm.name)
// this.$set(this.provinceForm, 'cityName', itm.name)
} }
}) })
} }
......
...@@ -281,8 +281,18 @@ export default { ...@@ -281,8 +281,18 @@ export default {
this.accountAddForm.lng = lnglat.lng this.accountAddForm.lng = lnglat.lng
var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市 // 获取省市
var provincecode = this.$refs.mapForm.geocoderAddress.adcode
var province = fullAddress.province var province = fullAddress.province
var city = fullAddress.city 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) {
if (this.accountAddForm.provinceName !== province || this.accountAddForm.cityName !== city) { if (this.accountAddForm.provinceName !== province || this.accountAddForm.cityName !== city) {
......
...@@ -25,7 +25,7 @@ ...@@ -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-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>
<el-form-item size="small" label="驻店电话" style="position: relative"> <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> <div @click="showTelDia" class="show-address">显示位置</div>
</el-form-item> </el-form-item>
<el-form-item size="small" label="主营品牌" style="height: 500px"> <el-form-item size="small" label="主营品牌" style="height: 500px">
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
</template> </template>
<script> <script>
import util from '@/utils/util'
import mapView from '@/components/mapView/index' import mapView from '@/components/mapView/index'
import SelectBrand from './selectBrand.vue' import SelectBrand from './selectBrand.vue'
import TelPosition from './telPosition.vue' import TelPosition from './telPosition.vue'
...@@ -165,8 +166,19 @@ export default { ...@@ -165,8 +166,19 @@ export default {
this.infoForm.lng = lnglat.lng this.infoForm.lng = lnglat.lng
var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent var fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市 // 获取省市
var provincecode = this.$refs.mapForm.geocoderAddress.adcode
var province = fullAddress.province var province = fullAddress.province
var city = fullAddress.city 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) {
if (this.infoForm.provinceName !== province || this.infoForm.cityName !== city) { if (this.infoForm.provinceName !== province || this.infoForm.cityName !== city) {
...@@ -199,6 +211,15 @@ export default { ...@@ -199,6 +211,15 @@ export default {
}, },
handleSave() { handleSave() {
const params = this.infoForm 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 = '' params.merchantBrandMain = ''
// 获取省市信息 // 获取省市信息
const { provinceName, provinceCode, cityName, cityCode } = this.$refs.provinceForm.provinceForm 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!