Commit 26f17404 by cwq0219

商户编辑

1 parent 52566eab
......@@ -34,12 +34,14 @@
v-for="(i, index) in List"
:key="index+''"
>
<span style="line-height: 50px;">{{i.label}}:
<span style="line-height: 50px;">
<span class="label-justify">{{i.label}}:</span>
<div
v-if="i.isMap"
class='amap-page-container'
>
<span v-show="hasLocation" class="error mapTips">{{i.value}}</span>
<span :class="[hasLocation ? 'error map-txt' : 'error', isEdit ? 'mapTips-edit': 'mapTips']">{{i.value}}</span>
<gl-button v-if="isEdit && i.label == 'POI位置点'" class="mapTips-button" @click="markAddr(isMarkAddr = true)">标记位置点</gl-button>
<el-amap
vid='amapDemo'
:center='center'
......@@ -58,10 +60,10 @@
>
<gl-input
v-else-if="isEdit && editOptions.includes(i.name)"
v-model="i.value"
:placeholder=i.label
v-model="merchantInfo[i.name]"
:placeholder="i.label"
></gl-input>
<span v-else>{{i.value}}</span>
<span v-else>{{merchantInfo[i.name]}}</span>
</span>
</gl-col>
</gl-col>
......@@ -161,6 +163,8 @@ export default {
activeName: 'first',
merchantInfo: {},
isEdit: false,
tempAddr: '',
isMarkAddr: false,
editOptions: ['address', 'merchantChannelName', 'contactor', 'contactPhone', 'phone', 'email'],
List: [
{
......@@ -215,24 +219,30 @@ export default {
center: [113.939723, 22.525351],
events: {
'click': (e) => {
amapManager._map.remove(marker)
marker = []
this.center = [+e.lnglat.lng, +e.lnglat.lat]
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: 'all'
})
geocoder.getAddress(this.center, (status, result) => {
if (status === 'complete' && result.info === 'OK') {
console.dir(result)
const mar = new AMap.Marker({
position: this.center,
title: result.regeocode.formattedAddress
})
marker.push(mar)
amapManager._map.add(marker)
}
})
if (this.isMarkAddr) {
amapManager._map.remove(marker)
this.getAddress(e.lnglat.lng, e.lnglat.lat)
// amapManager._map.remove(marker)
// marker = []
// this.center = [+e.lnglat.lng, +e.lnglat.lat]
// var geocoder = new AMap.Geocoder({
// radius: 1000,
// extensions: 'all'
// })
// geocoder.getAddress(this.center, (status, result) => {
// if (status === 'complete' && result.info === 'OK') {
// console.dir(result)
// const mar = new AMap.Marker({
// position: this.center,
// title: result.regeocode.formattedAddress
// })
// marker.push(mar)
// amapManager._map.add(marker)
// console.log(this.hasLocation)
// this.List[10].value = result.regeocode.formattedAddress
// }
// })
}
}
},
// 员工状态:0可用,1不可用
......@@ -363,11 +373,16 @@ export default {
},
// 编辑,取消
handleEdit(isCancel) {
this.isMarkAddr = false
// 保存
if (!isCancel && this.isEdit) {
this.merchantInfo.lng = this.center[0]
this.merchantInfo.lat = this.center[1]
console.log('调保存接口--')
console.log(this.merchantInfo)
this.isEdit = !this.isEdit
} else {
this.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
this.isEdit = !this.isEdit
}
},
......@@ -394,6 +409,8 @@ export default {
params.method = bizMethods.Detail
request.req(params).then(res => {
this.merchantInfo = res
// this.merchantInfo.lng = '113.939723'
// this.merchantInfo.lat = '22.525351'
this.assignBasicInfo()
this.IdChange[0] = 0
this.basicLoading = false
......@@ -407,14 +424,9 @@ export default {
for (var i in this.List) {
if (this.List[i].isMap) {
if (this.merchantInfo.lng && this.merchantInfo.lat) {
this.center = [+this.merchantInfo.lng, +this.merchantInfo.lat]
const o = amapManager.getMap()
const marker = new AMap.Marker({
position: this.center
})
marker.setMap(o)
this.getAddress(this.merchantInfo.lng, this.merchantInfo.lat)
} else {
this.hasLocation = true
this.hasLocation = false
}
} else if (this.List[i].isImg) {
this.List[i].value = this.merchantInfo.merchantPortrait
......@@ -423,6 +435,33 @@ export default {
}
}
},
// 根据经纬度获取地址名
getAddress(lng, lat) {
marker = []
this.center = [+lng, +lat]
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: 'all'
})
geocoder.getAddress(this.center, (status, result) => {
if (status === 'complete' && result.info === 'OK') {
// console.dir(result)
const mar = new AMap.Marker({
position: this.center,
title: result.regeocode.formattedAddress
})
marker.push(mar)
amapManager._map.add(marker)
this.tempAddr = result.regeocode.formattedAddress
this.markAddr()
}
})
},
markAddr() {
this.hasLocation = true
this.List[10].value = this.tempAddr
// console.log(this.center)
},
// 员工信息
getStaffInfo() {
const params = { merchantId: this.merchantId }
......@@ -481,7 +520,21 @@ export default {
}
.amap-page-container .mapTips {
position: absolute;
top: -28px;
top: -34px;
left: 85px;
}
.amap-page-container .map-txt {
color: #000;
font-size: 14px;
}
.amap-page-container .mapTips-edit {
position: absolute;
top: -34px;
left: 205px;
}
.amap-page-container .mapTips-button {
position: absolute;
top: -46px;
left: 85px;
}
.amap-demo {
......@@ -511,6 +564,11 @@ export default {
line-height: 36px;
/* padding-left: 20px */
}
.label-justify {
display:inline-block;
width:85px;
text-align-last: justify;
}
.detail-logo {
width: 40px;
height: 40px;
......@@ -520,7 +578,7 @@ export default {
background-color: #fafafa;
}
.detail .el-input {
width: 80%;
width: 50%;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!