zoukankan      html  css  js  c++  java
  • 小程序分享

    /**
       * 用户点击右上角分享
       */
      onShareAppMessage: function(options) {
        let image = this.data.shareInfo.imagePath ? this.data.shareInfo.imagePath : '/assets/images/headPhoto.png' // 动态图片地址
        // 分享配置
        let shareObj = {
          title: "分享标题",
          path: '/pages/invite/invite?firstUserName=' + app.globalData.user.username + '&inviteName=' + this.data.user.terminalName, // 分享地址
          imageUrl: image, // 分享图片
          success: function(res) {
            if (res.errMsg == 'shareAppMessage:ok') {
              console.log('ok')
            }
          },
          fail: function() {
            if (res.errMsg == 'shareAppMessage:fail cancel') {
              console.log('cancel')
            } else if (res.errMsg == 'shareAppMessage:fail') {
              console.log('fail')
            }
          },
          complete: function() {}
        }
        return shareObj
      }
    分享按钮
    
    <button class="share-btn" data-id="shareBtn" open-type="share">
          <text class="title">分享邀请</text>
    </button>
    /**
    * 用户点击右上角分享
    */
    onShareAppMessage: function(options) {
    let image = this.data.shareInfo.imagePath ? this.data.shareInfo.imagePath : '/assets/images/headPhoto.png'
    console.log(image, app.globalData.user.username)
    let shareObj = {
    title: this.data.shareInfo.name,
    path: '/pages/invite/invite?firstUserName=' + app.globalData.user.username + '&inviteName=' + this.data.user.terminalName,
    imageUrl: image,
    success: function(res) {
    if (res.errMsg == 'shareAppMessage:ok') {
    console.log('ok')
    }
    },
    fail: function() {
    if (res.errMsg == 'shareAppMessage:fail cancel') {
    console.log('cancel')
    } else if (res.errMsg == 'shareAppMessage:fail') {
    console.log('fail')
    }
    },
    complete: function() {}
    }
    if (options.from == 'button') {
    //var dataid = options.target.dataset; //上方data-id=shareBtn设置的值
    // 此处可以修改 shareObj 中的内容
    //shareObj.path = '/pages/btnname/btnname?id=' + dataid.id;  
    }
    return shareObj
    }
  • 相关阅读:
    如何使用php实现首页和子页面之间的交互
    用php实现,打开哪个页面哪个页面就有默认的样式
    后台链接前台有关显示不显示
    上传文件的最大值,post传值的最大值得修改
    linux 操作系统的安装,本地登录及远程登录,vnc连接操作详细步骤
    滑动组件
    Numpy简介
    java对象序列化
    集合类操作需要注意的地方
    TreeMap详解
  • 原文地址:https://www.cnblogs.com/lezuw/p/12020608.html
Copyright © 2011-2022 走看看