Commit cd14503c by 王志慧

fixed

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