I had previously encountered the WeChat sharing function in the project, and I sorted it out myself. The specific code is as follows:
The sharing feature is different from the sharing feature of the app, but the sharing feature is limited. You cannot display the titles, icons, and descriptions you want to display. All WeChat sharing interfaces are required.
Var title = "{info. data. intro }}";
Var desc = "{info. data. intro }}";
Var appId = "{info. data. string. appi }}";
Var timestamp = "{info. data. string. timestamp }}";
Var signature = "{info. data. string. signature }}";
Var id = "{info. data. id }}";
Wx. config ({
Debug: false,
AppId: appId,
Timestamp: timestamp,
NonceStr: 'wm3wzytpz0wzccnw ',
Signature: signature,
JsApiList :[
'Checkjsapi ',
'Onmenusharetimeline ',
'Onmenushareappmessage ',
'Onmenushareqq ',
'Onmenushareqzone'
]
});
// Trigger a click event
Wx. ready (function (){
$ ('. Sh-header-share'). trigger ("click ");
});
$ (". Sh-header-share"). on ("click", upload action );
Function compute action (){
Var link = window. location. href;
Var img = "{% if info. data. banner [0] is defined %} {info. data. banner [0] }{% endif % }";
// Share with your friends
Wx. onMenuShareTimeline ({
Title: title, // share the title
Link: link, // sharing link
ImgUrl: img, // share icon
Success: function (){
// The callback function executed after the user confirms the sharing
GetGold (id );
},
Cancel: function (){
// The callback function executed after the user cancels the sharing
Alert ("share canceled ");
}
});
// Share with friends
Wx. onMenuShareAppMessage ({
Title: title, // share the title
Desc: desc, // share the description
Link: link, // sharing link
ImgUrl: img, // share icon
Type: '', // share type, such as music, video, or link. If this parameter is not specified, the default value is link.
DataUrl: '', // if the type is music or video, provide a data link. The default value is null.
Success: function (){
// The callback function executed after the user confirms the sharing
GetGold (id );
},
Cancel: function (){
// The callback function executed after the user cancels the sharing
Alert ("share canceled ");
}
});
// Share it with QQ
Wx. onMenuShareQQ ({
Title: title, // share the title
Desc: desc, // share the description
Link: link, // sharing link
ImgUrl: img, // share icon
Success: function (){
// The callback function executed after the user confirms the sharing
},
Cancel: function (){
// The callback function executed after the user cancels the sharing
// Alert ("share canceled ");
}
});
// Share to QQ space
Wx. onMenuShareQZone ({
Title: title, // share the title
Desc: desc, // share the description
Link: link, // sharing link
ImgUrl: img, // share icon
Success: function (){
// The callback function executed after the user confirms the sharing
},
Cancel: function (){
// The callback function executed after the user cancels the sharing
// Alert ("share canceled ");
}
});
}
</Script>