魔幻的2020,你得到了什么,失去了什么?

简而言之,我得到了一身肥肉,失去了时间,健康,金钱,balabala,,,,
该有的都没有,不该有的全都有。

言归正传,我的2020最大的收获在微信身上,见识到了很多有趣又使用的功能

1,小程序分享朋友圈
文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
除了以前的 onShareAppMessage 方法,现在多了一个 onShareTimeline 方法,参数与 onShareAppMessage 一样,虽然说分享出来的东西还不能操作,不过能起到推广作用已经很难得了
 

2,公众号网页唤起app与小程序

文档地址:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html

来点码,参数与功能介绍请参考文档

// 唤起小程序
<wx-open-launch-weapp
  id="launch-btn"
  username="gh_xxxxxxxx"
  path="pages/home/index.html?user=123&action=abc"
>
  <template>
    <style>.btn { padding: 12px }</style>
    <button class="btn">打开小程序</button>
  </template>
</wx-open-launch-weapp>
<script>
  var btn = document.getElementById('launch-btn');
  btn.addEventListener('launch', function (e) {
    console.log('success');
  });
  btn.addEventListener('error', function (e) {
    console.log('fail', e.detail);
  });
</script>


***********************不太华丽的分割线*************************



// 唤起app
<wx-open-launch-app
  id="launch-btn"
  appid="your-appid"
  extinfo="your-extinfo"
>
  <template>
    <style>.btn { padding: 12px }</style>
    <button class="btn">App内查看</button>
  </template>
</wx-open-launch-app>
<script>
  var btn = document.getElementById('launch-btn');
  btn.addEventListener('launch', function (e) {
    console.log('success');
  });
  btn.addEventListener('error', function (e) {
    console.log('fail', e.detail);
  });
</script>

这里说个坑,<button>的样式不好整,可能页面上什么都不显示,但是如果你点击相应的位置,会发现是可以点击的,用微信的网页调试工具,就可以发现dom是在的,只是样式没出来。

我的解决方案是在外层包裹一个div,同时设置样式,我这里固定了宽高。此外自定义样式一定要写在它 插槽的 <style> 里

如果是vue的话,还需要处理一些关于标签的坑,具体可以参考这个博客:https://blog.csdn.net/weixin_45532305/article/details/109491862

    <div class="launch-btn">
      <wx-open-launch-weapp
        id="weappBtn"
        username="xxxxxxx"
        path="pages/find/find.html"
        @ready="btnReady"
        @launch="btnLaunch"
        @error="btnError"
      >
        <!-- <template> -->
        <script type="text/wxtag-template">
          <style>
            .btn {
              width: 100px;
              height: 50px;
              line-height: 50px;
              text-align: center;
              color: #444;
              font-size: 14px;
              display: inline-block;
              background: #fff100;
              border-radius: 100px;
              border: 0;
              padding: 0 10px;
              pointer-events: none;
            }
          </style>
          <button class="btn" >打开小程序</button>
        </script>
        <!-- </template> -->
      </wx-open-launch-weapp>

      <wx-open-launch-app
        id="appBtn"
        class="launch-btn"
        appid="xxxxxxx"
        @ready="btnReady2"
        @launch="btnLaunch2"
        @error="btnError2"
        extinfo=""
      >
      <script type="text/wxtag-template">
          <style>
            .btn {
              width: 100px;
              height: 50px;
              line-height: 50px;
              text-align: center;
              color: #444;
              font-size: 14px;
              display: inline-block;
              background: #fff100;
              border-radius: 100px;
              border: 0;
              padding: 0 10px;
              pointer-events: none;
            }
          </style>
          <button class="btn" >打开app</button>
        </script>
      </wx-open-launch-app>
    </div>


.launch-btn{
    
    width: 100px;
    height: 50px;
  }

另外需要补充一点,唤起app的时候,iOS很完美,安卓会卡主,原因未知。

3,微信使我半夜依然要爬起来工作,工作使我快(nan)乐(shou)!
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值