提交 07eb495f 编写于 作者: Q qiang

fix: 解决iOS微信内置浏览器打开位置相关页面后无法后退的问题 fixed #1789

上级 4ab48920
......@@ -27,15 +27,14 @@ export default {
SystemHeader
},
data () {
const key = __uniConfig.qqMapKey
return {
src: '',
src: `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp`,
data: null
}
},
mounted () {
var key = __uniConfig.qqMapKey
this.src = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp`
window.addEventListener('message', (event) => {
function handler (event) {
var loc = event.data
if (loc && loc.module === 'locationPicker') {
this.data = {
......@@ -45,12 +44,17 @@ export default {
longitude: loc.latlng.lng
}
}
}, false)
}
this.__messageHandle = handler.bind(this)
window.addEventListener('message', this.__messageHandle, false)
},
beforeDestroy () {
window.removeEventListener('message', this.__messageHandle, false)
},
methods: {
_choose () {
if (this.data) {
UniViewJSBridge.publishHandler('onChooseLocation', this.data)
UniViewJSBridge.publishHandler('onChooseLocation', Object.assign({}, this.data))
getApp().$router.back()
}
},
......
......@@ -47,16 +47,10 @@ export default {
scale,
name,
address,
src: '',
src: latitude && longitude ? `${poimarkerSrc}?type=0&marker=coord:${latitude},${longitude};title:${name};addr:${address};&key=${key}&referer=${referer}` : '',
isPoimarkerSrc: false
}
},
mounted () {
if (this.latitude && this.longitude) {
this.src =
`${poimarkerSrc}?type=0&marker=coord:${this.latitude},${this.longitude};title:${this.name};addr:${this.address};&key=${key}&referer=${referer}`
}
},
methods: {
_back () {
if (this.$refs.map.src.indexOf(poimarkerSrc) !== 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册