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:
/ ** * 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. } }
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:
/ ** * Life Cycle function - listen for page loads * / onLoad: function (Options) { wx.hideShareMenu () }, / ** * Life Cycle function - monitor page displays * / onShow: function () { WX. hideShareMenu () },
Four more forwarding information:
Forwarded applet is secondary when opened can get some information, such as identity groups.
General process:
Sample 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 }) }
//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) } }) } } } )
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" }
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.
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:
/ ** * 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. } }
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:
/ ** * Life Cycle function - listen for page loads * / onLoad: function (Options) { wx.hideShareMenu () }, / ** * Life Cycle function - monitor page displays * / onShow: function () { WX. hideShareMenu () },
Four more forwarding information:
Forwarded applet is secondary when opened can get some information, such as identity groups.
General process:
Sample 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 }) }
//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) } }) } } } )
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" }
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.