Micro letter forwarding sharing applet (b)

About forwarding applet:

The easiest is to click on the top right of the menu applet "Forward" button to directly share, but this share is not too friendly practicality is not strong.

Of course, you can customize to share content, including the title, description, picture and share applet page path.

High point, the applet can be forwarded through the secondary when it opened to get some information.

A custom forwarding content:

onShareAppMessage (Obj):

1. monitor the upper right corner or small forward button (button open-type = "share") program "Forward" button clicks;
2. Customize forward to share content.
3. You can also listen for this information:
 
Sample code:
Copy the code
  / ** 
   * User Share Custom 
   * / 
  onShareAppMessage: function (RES) { 
    return { 
      title: 'Daz ice cream 50% off', 
      path: '? / Pages / index / index goods_id =' + wx.getStorageSync ( "goods_id"), 
      imageUrl: 'http://static.e-mallchina.com/pic/product/brand/detail/hgds.jpg'// custom image path, it may be a local file path, the file path or code package network image path. Support PNG and JPG. Display image aspect ratio of 5: 4. 
    } 
  }
Copy the code

Click on the top right menu in the "Forward" button, and share results are as follows:

Second, click on the page forward button to share:

<button> Component settings open-type="share"即可实现页面内分享,点击按钮即可跟点击右上角菜单中的转发按钮会有一样的效果。

<button open-type='share' type='warn' size="mini" plain="true" id='btnShare0'>推荐给好友</button>

Of course, with the Forward button in the upper right corner of the menu, like, if you set a custom forwarding content, click the Share button will also show custom content sharing.

Third, turn off sharing:

wx.hideShareMenu (Object Object) : hide the Forward button, turn off forwarding (forwarding does not affect the function of the buttons, but there is no shared the top right corner).
Copy the code
  / ** 
   * Life Cycle function - listen for page loads 
   * / 
  onLoad: function (Options) { 
    wx.hideShareMenu () 
  }, 
  / ** 
   * Life Cycle function - monitor page displays 
   * / 
  onShow: function () { 
    WX. hideShareMenu () 
  },
Copy the code

 

Four more forwarding information:

Forwarded applet is secondary when opened can get some information, such as identity groups.

General process:

1. withShareTicket calling wx.showShareMenu and arranged to true;
2. When the user program will be forwarded to either a group of small talk, when to forward this card in the group chat is open to other users, you can get to a shareTicket in App.onLaunch or App.onShow;
3. By calling wx.getShareInfo () interface to pass this shareTicket can get to forwarding information.

Sample code:

Copy the code
  Share // open the Page Setup group to share information 
  / ** 
   * Life Cycle function - listen for page loads 
   * / 
  onLoad: function (Options) { 
    wx.showShareMenu ({ 
      withShareTicket: to true 
    }) 
  }, 
  / ** 
   * Life Cycle function - - page display monitor 
   * / 
  onShow: function () { 
    wx.showShareMenu ({ 
      withShareTicket: to true 
    }) 
  }
Copy the code
Copy the code
//app.js get business cards to share information applet included with 
App ({ 
  OnLaunch: function (OPS) { 
    // applet in the group after being opened, the acquisition value scenarios and shareTicket 
    console.log ( "OPS:", OPS ) 
    IF (ops.scene == 1044) { 
      wx.getShareInfo ({ 
        shareTicket: ops.shareTicket, 
        Success: function (RES) { 
          the console.log ( "wx.getShareInfo :::", RES) 
        } 
      }) 
    } 
  } 
} )
Copy the code

After the share to the group, open the applet in the group, to obtain data similar to the following:

As shown above, is to get a group chat to share relevant information, but this information is encrypted, you need to get the phone number the same as the back-end to go before they can decrypt.

Wherein  encryptedData  decrypted json following structures, see the encrypted data decryption algorithm . OpenGId which uniquely identifies the current group:

{
"openGId": "OPENGID"
}
If you need to show the group name, you can use open data component .

Proven, this feature is only available to share the group chat will be effective, that can only distinguish between small program window is open or chat with friends in the group, so this function is relatively tasteless.

V. Other features:

There is an interface, the interface is to update the forward attributes: wx.updateShareMenu (Object Object) , usually with very little, you can go to the official web self-study interest.

 

 

Source address: https: //www.cnblogs.com/xyyt
 
 
 

About forwarding applet:

The easiest is to click on the top right of the menu applet "Forward" button to directly share, but this share is not too friendly practicality is not strong.

Of course, you can customize to share content, including the title, description, picture and share applet page path.

High point, the applet can be forwarded through the secondary when it opened to get some information.

A custom forwarding content:

onShareAppMessage (Obj):

1. monitor the upper right corner or small forward button (button open-type = "share") program "Forward" button clicks;
2. Customize forward to share content.
3. You can also listen for this information:
 
Sample code:
Copy the code
  / ** 
   * User Share Custom 
   * / 
  onShareAppMessage: function (RES) { 
    return { 
      title: 'Daz ice cream 50% off', 
      path: '? / Pages / index / index goods_id =' + wx.getStorageSync ( "goods_id"), 
      imageUrl: 'http://static.e-mallchina.com/pic/product/brand/detail/hgds.jpg'// custom image path, it may be a local file path, the file path or code package network image path. Support PNG and JPG. Display image aspect ratio of 5: 4. 
    } 
  }
Copy the code

Click on the top right menu in the "Forward" button, and share results are as follows:

Second, click on the page forward button to share:

<button> Component settings open-type="share"即可实现页面内分享,点击按钮即可跟点击右上角菜单中的转发按钮会有一样的效果。

<button open-type='share' type='warn' size="mini" plain="true" id='btnShare0'>推荐给好友</button>

Of course, with the Forward button in the upper right corner of the menu, like, if you set a custom forwarding content, click the Share button will also show custom content sharing.

Third, turn off sharing:

wx.hideShareMenu (Object Object) : hide the Forward button, turn off forwarding (forwarding does not affect the function of the buttons, but there is no shared the top right corner).
Copy the code
  / ** 
   * Life Cycle function - listen for page loads 
   * / 
  onLoad: function (Options) { 
    wx.hideShareMenu () 
  }, 
  / ** 
   * Life Cycle function - monitor page displays 
   * / 
  onShow: function () { 
    WX. hideShareMenu () 
  },
Copy the code

 

Four more forwarding information:

Forwarded applet is secondary when opened can get some information, such as identity groups.

General process:

1. withShareTicket calling wx.showShareMenu and arranged to true;
2. When the user program will be forwarded to either a group of small talk, when to forward this card in the group chat is open to other users, you can get to a shareTicket in App.onLaunch or App.onShow;
3. By calling wx.getShareInfo () interface to pass this shareTicket can get to forwarding information.

Sample code:

Copy the code
  Share // open the Page Setup group to share information 
  / ** 
   * Life Cycle function - listen for page loads 
   * / 
  onLoad: function (Options) { 
    wx.showShareMenu ({ 
      withShareTicket: to true 
    }) 
  }, 
  / ** 
   * Life Cycle function - - page display monitor 
   * / 
  onShow: function () { 
    wx.showShareMenu ({ 
      withShareTicket: to true 
    }) 
  }
Copy the code
Copy the code
//app.js get business cards to share information applet included with 
App ({ 
  OnLaunch: function (OPS) { 
    // applet in the group after being opened, the acquisition value scenarios and shareTicket 
    console.log ( "OPS:", OPS ) 
    IF (ops.scene == 1044) { 
      wx.getShareInfo ({ 
        shareTicket: ops.shareTicket, 
        Success: function (RES) { 
          the console.log ( "wx.getShareInfo :::", RES) 
        } 
      }) 
    } 
  } 
} )
Copy the code

After the share to the group, open the applet in the group, to obtain data similar to the following:

As shown above, is to get a group chat to share relevant information, but this information is encrypted, you need to get the phone number the same as the back-end to go before they can decrypt.

Wherein  encryptedData  decrypted json following structures, see the encrypted data decryption algorithm . OpenGId which uniquely identifies the current group:

{
"openGId": "OPENGID"
}
If you need to show the group name, you can use open data component .

Proven, this feature is only available to share the group chat will be effective, that can only distinguish between small program window is open or chat with friends in the group, so this function is relatively tasteless.

V. Other features:

There is an interface, the interface is to update the forward attributes: wx.updateShareMenu (Object Object) , usually with very little, you can go to the official web self-study interest.

 

 

Guess you like

Origin www.cnblogs.com/zmdComeOn/p/12466168.html