按钮分享(传参,确定取消分享按钮监听)

按钮分享(传参,确定取消分享按钮监听)
直接上代码:
wxml页面

<button id='btn'  open-type='share' plain='true'>分享按钮</button>

js页面代码

onShareAppMessage: function(res) {
    var time = Date.parse(new Date());
    console.log(time)
    console.log(this.data.openid)
    console.log(this.data.name)
    var openidd = this.data.openid;
    var username = this.data.name;
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target.id)
      console.log(res.from)
      //区分按钮分享
      if (res.target.id === "btn") {
        return {
          title: '按钮分享',
          path: `zh_vip/pages/my/glrk/helpQRcode?user_id=` + this.data.userid,//分享页面传参数
          success: function(res) {
            // 转发成功
            // 助力时间开始  (openid,当前时间,真实姓名)
            app.util.request({
              url: "entry/wxapp/GetstartTime",
              cachetime: "0",
              data: {
                openid: openidd,
                name: username,
                time: time
              },
              success(res) { }
            })
          },
          fail: function(res) {
            // 转发失败
          }
        }
      }
    }
    //系统右上角胶囊...分享
    return {
      title: '标题',
      path: `zh_vip/pages/my/glrk/helpQRcode?user_id=` + this.data.userid,,//分享页面传参数
      imageUrl: ``,
      success: function(res) {
        // 转发成功
        console.log("转发成功:" + JSON.stringify(res));
        // 助力时间开始  (openid,当前时间,真实姓名)
        app.util.request({//自己封装的接口请求方法
          url: "",
          cachetime: "0",
          data: {
            openid:this.data.openid,
            name: this.data.name,
            time:time
          },
          success(res) {
            // 助力时间开始  (openid,当前时间,真实姓名)
            app.util.request({//自己封装的接口请求方法
              url: "",
              cachetime: "0",
              data: {
                openid: this.data.openidd,
                name: this.data.username,
                time: time
              },
              success(res) { }
            })
          }
        })
      },
      fail: function(res) {
        // 转发失败
        console.log("转发失败:" + JSON.stringify(res));
      }
    }
  },
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值