微信文檔:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html
//引入JS文件
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
//通過config接口注入權(quán)限驗證配置并申請所需開放標(biāo)簽
gowx() {
// let url = window.location.href
let url = window.location.href
axios
.get('http://wx.leyou-edu.com/Service/xxxx', {params: {url: url}})
.then(res => {
let appId = res.data.Value.appId;
let nonceStr = res.data.Value.nonceStr;
let signature = res.data.Value.signature;
let timestamp = res.data.Value.timestamp;
console.log(appId ,timestamp,nonceStr,signature)
wx.config({
debug: false, // 開啟調(diào)試模式,調(diào)用的所有api的返回值會在客戶端alert出來,若要查看傳入的參數(shù),可以在pc端打開,參數(shù)信息會通過log打出,僅在pc端時才會打印。
appId: appId, // 必填,公眾號的唯一標(biāo)識
timestamp: timestamp, // 必填,生成簽名的時間戳
nonceStr: nonceStr, // 必填,生成簽名的隨機串
signature: signature, // 必填,簽名
jsApiList: ['onMenuShareAppMessage'], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp']
});
wx.ready(function () {
console.log('sucess')
});
wx.error((err) => {
console.log(err, 'error'); // 如果報錯打印報錯信息
});
// resolve(response.data);
})
.catch(err => {
console.log(err)
});
},
//在mounted中調(diào)用
this.gowx()
//template
<div class="flex-cc" :class="[active==4 ? 'activetip': 'tip']">
<img src="@/assets/img/read@2x.png" alt="">
<wx-open-launch-weapp username="gh_ee42a68f0534" path="pages/home.html">
<script type="text/wxtag-template">
<style>.btn { font-size: 13px; color: #666666; }</style>
<span class="btn">閱讀建筑</span>
</script>
</wx-open-launch-weapp>
</div>
//main.js中配置
Vue.config.ignoredElements = ['wx-open-launch-weapp']
小程序內(nèi)嵌H5跳轉(zhuǎn)回當(dāng)前小程序
//引入js文件
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
//跳轉(zhuǎn)
wx.miniProgram.navigateTo({url: '/pages/arch/pages/architecture?Id='+id})