H5跳轉(zhuǎn)小程序

微信文檔: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})

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容