Commit cd14503c by 王志慧

fixed

1 parent 053e03cf
......@@ -18,8 +18,7 @@
</template>
<script>
let content = [],
contextMenu
let contextMenu
import AMapLoader from '@amap/amap-jsapi-loader' //按需引入依赖
export default {
data() {
......@@ -56,10 +55,7 @@ export default {
activeIndex: ''
}
},
beforeCreate() {
console.log(contextMenu)
contextMenu && contextMenu.close()
},
mounted() {
this.merchantId = this.$globalState.session.merchantId
this.queryData = this.$route.query
......@@ -94,6 +90,7 @@ export default {
resizeEnable: true,
cursor: 'move' //初始化地图级别
})
// contextMenu && contextMenu.close()
//构造地点查询类
that.placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数
......@@ -105,7 +102,7 @@ export default {
})
//获取所有的点标记
that.getParkingSpaceList()
that.getContextMenu( that.map)
that.getContextMenu(that.map)
})
.catch(e => {
console.log(e)
......@@ -198,7 +195,8 @@ export default {
}
},
initContent() {
let { AMap, } = this;
let { AMap } = this,
content = []
content.push("<div class='info context_menu'>")
content.push(" <p class='marker' id='marker'><span>+</span>新增车位标记</p>")
content.push('</div>')
......@@ -206,15 +204,15 @@ export default {
//通过content自定义右键菜单内容
contextMenu = new AMap.ContextMenu({ isCustom: true, content: content.join('') })
},
// isOpen:1=>打开,0=>关闭,manipulator:操作物
getContextMenu(manipulator,isOpen) {
let that = this;
isOpen=isOpen||!this.queryData.parkingAddressFlag
// isOpen:1=>打开,2=>关闭,manipulator:操作物
getContextMenu(manipulator, isOpen) {
let that = this
isOpen = isOpen || !this.queryData.parkingAddressFlag
this.initContent()
//地图绑定鼠标右击事件——弹出右键菜单
manipulator.on('rightclick', function (e) {
contextMenu.close()
if (isOpen) {
if (isOpen==1||isOpen) {
contextMenu.open(that.map, e.lnglat)
}
......@@ -307,7 +305,8 @@ export default {
merchantId
}
this.$apis.parkingSpace.addFlagparkingSpace(params).then(res => {
if (res) {
console.log(res)
if (res.code==0) {
marker = new AMap.Marker({
icon: require('@/assets/select.png'),
position: [lng, lat],
......@@ -322,8 +321,10 @@ export default {
this.initMarket(marker, 1)
infoWindow.close()
this.$message.success('车位标记成功')
this.getContextMenu(this.map,0)
}else{
this.$message.error(res.message)
}
this.getContextMenu(this.map, 2)
})
},
cancel(infoWindow) {
......@@ -342,7 +343,7 @@ export default {
marker.hide()
infoWindow.close()
this.$message.success('删除成功')
this.getContextMenu(this.map,1)
this.getContextMenu(this.map, 1)
}
})
},
......@@ -455,6 +456,7 @@ export default {
}
},
beforeDestroy() {
contextMenu && contextMenu.close()
this.map.destroy()
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!