Commit 5feaebdf by 前端

Merge branch 'kuangyq_dev_2.1.0' into 'v2.1.0'

Kuangyq dev 2.1.0

See merge request !34
2 parents 7cd6aae2 45f2847f
...@@ -2,25 +2,25 @@ ...@@ -2,25 +2,25 @@
<div> <div>
<el-form ref="provinceForm" :model="provinceForm" label-width="80px" inline="true" class="province"> <el-form ref="provinceForm" :model="provinceForm" label-width="80px" inline="true" class="province">
<el-select v-model="provinceForm.provinceName" placeholder="选择省份" @change="selectProvince" class="select-padding"> <el-select v-model="provinceForm.provinceName" placeholder="选择省份" @change="selectProvince" class="select-padding">
<el-option v-for="item in AllData" :key="item.provinceCode" :label="item.provinceName" :value="item.provinceName" @click.native="selectProvince(item)"></el-option> <el-option v-for="item in AllData" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectProvince(item)"></el-option>
</el-select> </el-select>
<el-select v-model="provinceForm.cityName" placeholder="选择您所在的市" style="width: 250px" @change="selectCity" class="select-padding"> <el-select v-model="provinceForm.cityName" placeholder="选择您所在的市" style="width: 250px" @change="selectCity" class="select-padding">
<el-option v-for="item in cityList" :key="item.cityCode" :label="item.cityName" :value="item.cityName" @click.native="selectCity(item)"></el-option> <el-option v-for="item in cityList" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectCity(item)"></el-option>
</el-select> </el-select>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
let map
import { provinceList } from './index' import { provinceList } from './index'
export default { export default {
name: 'Province', name: 'Province',
// props: ['provinceName', 'cityName'],
data() { data() {
return { return {
provinceList: provinceList(), provinceList: provinceList(),
AllData: [], AllData: [],
cityList: [{ cityCode: '', cityName: '请先选择省' }], cityList: [{ adcode: '', name: '请先选择省' }],
provinceForm: { provinceForm: {
provinceName: '', // 省值 provinceName: '', // 省值
cityName: '', // 市值 cityName: '', // 市值
...@@ -29,55 +29,55 @@ export default { ...@@ -29,55 +29,55 @@ export default {
} }
} }
}, },
// inject: ['provinceEditAccount'], mounted() {},
mounted() {
// 初始化
// this.getProvinceList()
// console.log(this.provinceEditAccount, '====')
// console.log(JSON.stringify(this.provinceEditAccount.cityName))
// if (this.provinceEditAccount) {
// this.init(this.provinceEditAccount.provinceName, this.provinceEditAccount.cityName)
// console.log(this.provinceEditAccount.provinceName, this.provinceEditAccount.cityName)
// }
},
methods: { methods: {
init(province, city) { init(province, city) {
this.provinceForm = { this.provinceForm = {
provinceName: province, provinceName: province,
cityName: city cityName: city
} }
this.getProvinceList(province, city) this.mapInit(province, city)
},
// 选择省
selectProvince(val) {
this.provinceForm.cityName = ''
this.cityList = val.districtList
this.$emit('getProvince', val.name, val.adcode)
},
// 选择市
selectCity(val) {
this.$emit('getCity', val.name, val.adcode)
}, },
async getProvinceList(provinceName, cityName) { mapInit(provinceName, cityName) {
const { provinceInfoList: provinceList } = await this.provinceList map = new AMap.Map('district', {
this.AllData = provinceList resizeEnable: true
// this.$set(this, 'AllData', provinceList) })
// if (this.provinceEditAccount) { AMap.plugin(['AMap.DistrictSearch'], () => {
// this.init(this.provinceEditAccount.provinceName, this.provinceEditAccount.cityName) var opts = {
// } subdistrict: 2, //返回下一级行政区
level: 'city', //查询的范围
showbiz: true //查询行政级别为 市
}
var districtSearch = new AMap.DistrictSearch(opts)
districtSearch.search('中国', (status, result) => {
this.AllData = result.districtList[0].districtList
})
})
if (provinceName) { if (provinceName) {
this.AllData.map(item => { this.AllData.map(item => {
if (item.provinceName.indexOf(provinceName) != -1) { if (item.name.indexOf(provinceName) != -1) {
this.cityList = item.cityInfoList this.provinceForm.provinceName = item.name
this.provinceForm.provinceCode = item.provinceCode this.cityList = item.districtList
this.provinceForm.provinceCode = item.adcode
this.cityList.map(itm => { this.cityList.map(itm => {
if (cityName == itm.cityName) { if (itm.name.indexOf(cityName) != -1) {
this.provinceForm.cityCode = itm.cityCode this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name
} }
}) })
} }
}) })
} }
},
// 选择省
selectProvince(val) {
this.provinceForm.cityName = ''
this.cityList = val.cityInfoList
this.$emit('getProvince', val.provinceName, val.provinceCode)
},
// 选择市
selectCity(val) {
this.$emit('getCity', val.cityName, val.cityCode)
} }
} }
} }
......
...@@ -271,26 +271,20 @@ export default { ...@@ -271,26 +271,20 @@ 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
} }
this.accountAddForm.merchantAddress = this.$refs.mapForm.address this.accountAddForm.merchantAddress = this.$refs.mapForm.address
var address = this.accountAddForm.merchantAddress
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 fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市 // 获取省市
var provinceIdx = fullAddress.province var province = fullAddress.province
var cityIdx = fullAddress.city var city = fullAddress.city
var province = provinceIdx.slice(0, 2)
var city = cityIdx.slice(0, 2)
// 判断省市是否匹配 // 判断省市是否匹配
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 = ''
...@@ -321,7 +315,8 @@ export default { ...@@ -321,7 +315,8 @@ export default {
getCity(cityName, cityCode) { getCity(cityName, cityCode) {
this.accountAddForm.cityName = cityName this.accountAddForm.cityName = cityName
this.accountAddForm.cityCode = cityCode this.accountAddForm.cityCode = cityCode
this.accountAddForm.merchantAddress = '' this.$set(this.accountAddForm, 'merchantAddress', '')
this.$forceUpdate()
}, },
delImg(index) { delImg(index) {
this.accountAddForm.merchantFiles.splice(index, 1) this.accountAddForm.merchantFiles.splice(index, 1)
...@@ -377,7 +372,8 @@ export default { ...@@ -377,7 +372,8 @@ export default {
mounted() { mounted() {
this.getUserInfo() this.getUserInfo()
this.$refs.provinceForm.getProvinceList() // this.$refs.provinceForm.getProvinceList()
this.$refs.provinceForm.mapInit()
} }
} }
</script> </script>
......
...@@ -159,20 +159,15 @@ export default { ...@@ -159,20 +159,15 @@ export default {
return return
} }
this.infoForm.merchantAddress = this.$refs.mapForm.address this.infoForm.merchantAddress = this.$refs.mapForm.address
var address = this.infoForm.merchantAddress
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 fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
// 获取省市 // 获取省市
var provinceIdx = fullAddress.province var province = fullAddress.province
var cityIdx = fullAddress.city var city = fullAddress.city
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!