작은 프로그램 공유

3720 단어
/**
   *  
   */
  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
  }
 


 
/**
* 사용자가 오른쪽 상단을 클릭하여 공유
*/
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
}

좋은 웹페이지 즐겨찾기