问题描述
在使用公众号jssdk过程中,用户需求点击公众号菜单微信内置地图打开指定地点。
暂用实现过程为 用户打开空白页面 空白页面wx.config wx.openLocation打开内置地图
问题出现的环境背景及自己尝试过哪些方法
点击内置地图左上角的返回按钮时,会返回空白页面(不刷新)
有没有办法点击返回按钮时,直接退回到公众号(关闭页面)?
尝试使用过回调控制返回按钮事件,微信公众号并不支持
相关代码
<html>
<script th:src="@{/js/axios.min.js}"></script>
<script th:src="@{/js/jweixin-1.4.0.js}"></script>
<script>
var wxconfig = {
debug:false,
appId:'',
timestamp: '',
nonceStr:'',
signature: '',
jsApiList:['checkJsApi','openLocation','closeWindow']
};
let form = new FormData();
form.append('url',location.href.split('#')[0]);
axios.post('/johncena', form) //后端会返回wxconfig所需要的数据
.then(function(response){
wxconfig.appId = response.data.appId;
wxconfig.timestamp = response.data.timestamp;
wxconfig.nonceStr = response.data.nonceStr;
wxconfig.signature = response.data.signature;
wx.config( //wxconfig
wxconfig
);
wx.checkJsApi({
jsApiList: ['openLocation'],
success: function (res) {
if (res.checkResult.openLocation === false) {
alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
}
}
});
wx.ready(function(){
wx.openLocation({
latitude: 30.251991,
longitude: 120.135012,
name: ''
address: ''
scale: 28,
infoUrl: ''
});
});
})
.catch(function (error) {
window.console.log(error);
});
</script>
</html>
有没有大佬出来回答一下啊Orz