知識
不管是網站,軟件還是小程序,都要直接或間接能為您產生價值,我們在追求其視覺表現(xiàn)的同時,更側重于功能的便捷,營銷的便利,運營的高效,讓網站成為營銷工具,讓軟件能切實提升企業(yè)內部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
uniapp自定義微信公眾號分享設置
發(fā)表時間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):139
import wxshare from './wxshare.js'
//設置分享參數(shù)@data:從后端接口獲取分享相關數(shù)據(根據自己實際情況從后端接口獲取)
function setWxShare(data) {
wxshare.config({
debug: false,//是否打開調試
appId: data.appId, // 公眾號的唯一標識
timestamp: data.timestamp, // 生成簽名的時間戳
nonceStr: data.nonceStr, // ,生成簽名的隨機串
signature: data.signature, // 簽名
jsApiList: data.jsApiList
});
wxshare.ready(function() {
//分享給朋友
wxshare.updateAppMessageShareData({
title: data.share_title, // 分享標題
desc: data.share_desc, // 分享描述
link: `${window.location.href}`, // 當前頁面鏈接
imgUrl: data.share_pic, // 分享圖標
success: function() {//分享成功回調
},
cancel: function() {//取消分享回調
}
});
//分享到朋友圈
wxshare.updateTimelineShareData({
title: data.share_title, // 分享標題
link: `${window.location.href}`, // 分享鏈接
desc: data.share_desc, // 分享描述
imgUrl: data.share_pic, // 分享圖標
success: function() {
},
cancel: function() {
}
});
})
}
在onLoad或onShow調用setWxShare方法即可
wxshare.js:
https://unpkg.com/jweixin-module@1.4.1/out/index.js