H5跳转小程序

微信文档: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接口注入权限验证配置并申请所需开放标签
    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, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
            appId: appId, // 必填,公众号的唯一标识
            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中调用
 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']

小程序内嵌H5跳转回当前小程序

//引入js文件
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
//跳转
            wx.miniProgram.navigateTo({url: '/pages/arch/pages/architecture?Id='+id})

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容