因為這個jssdk被uni-app坑了好多天,作者說支援1.4版本,但是我用1.4的兩個分享的新方法一直不支援。
最後隻能放棄了,期待什麼時候能更新上。
基本的使用方法:
第一步 - 下載下傳使用方式
下載下傳位址:https://unpkg.com/[email protected]/out/index.js
項目引用:
項目下建立子產品,放在該子產品下。
main.js引用:
var jweixin = require('jweixin-module')
//擷取微信公衆号的配置
uni.request({
url: 'xxxxxxxxxxx',
dataType: 'text',
data: {
url: window.location.href.split('#')[0]
},
success: res => {
var s = JSON.parse(res.data);
console.log(s.data);
jweixin.config({
debug: false, // 開啟調試模式,調用的所有api的傳回值會在用戶端alert出來,若要檢視傳入的參數,可以在pc端打開,參數資訊會通過log打出,僅在pc端時才會列印。
appId: s.data.appId, // 必填,公衆号的唯一辨別
timestamp: s.data.timestamp, // 必填,生成簽名的時間戳
nonceStr: s.data.nonceStr, // 必填,生成簽名的随機串
signature: s.data.signature.toLowerCase(), // 必填,簽名,見附錄1
jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo","onMenuShareQZone"]
});
jweixin.ready(function () {
//擷取“分享到QQ”按鈕點選狀态及自定義分享内容接口(即将廢棄)
jweixin.onMenuShareQQ({
title: title, // 分享标題
desc: desc, // 分享描述
link: url, // 分享連結
imgUrl: imgurl, // 分享圖示
success: function () {
// 使用者确認分享後執行的回調函數
},
cancel: function () {
// 使用者取消分享後執行的回調函數
}
});
//擷取“分享給朋友”按鈕點選狀态及自定義分享内容接口(即将廢棄)
jweixin.onMenuShareAppMessage({
title: title, // 分享标題
desc: desc, // 分享描述
link: url, // 分享連結
imgUrl: imgurl, // 分享圖示
type: '', // 分享類型,music、video或link,不填預設為link
dataUrl: '', // 如果type是music或video,則要提供資料連結,預設為空
success: function () {
// 使用者确認分享後執行的回調函數
},
cancel: function () {
// 使用者取消分享後執行的回調函數
}
});
//擷取“分享到朋友圈”按鈕點選狀态及自定義分享内容接口(即将廢棄)
jweixin.onMenuShareTimeline({
title: title, // 分享标題
desc: desc, // 分享描述
link: url, // 分享連結
imgUrl: imgurl, // 分享圖示
type: '', // 分享類型,music、video或link,不填預設為link
dataUrl: '', // 如果type是music或video,則要提供資料連結,預設為空
success: function () {
// 使用者确認分享後執行的回調函數
},
cancel: function () {
// 使用者取消分享後執行的回調函數
}
});
//擷取“分享到騰訊微網誌”按鈕點選狀态及自定義分享内容接口
jweixin.onMenuShareWeibo({
title: title, // 分享标題
desc: desc, // 分享描述
link: url, // 分享連結
imgUrl: imgurl, // 分享圖示
type: '', // 分享類型,music、video或link,不填預設為link
dataUrl: '', // 如果type是music或video,則要提供資料連結,預設為空
success: function () {
// 使用者确認分享後執行的回調函數
},
cancel: function () {
// 使用者取消分享後執行的回調函數
}
});
//擷取“分享到QQ空間”按鈕點選狀态及自定義分享内容接口(即将廢棄)
jweixin.onMenuShareQZone({
title: title, // 分享标題
desc: desc, // 分享描述
link: url, // 分享連結
imgUrl: imgurl, // 分享圖示
type: '', // 分享類型,music、video或link,不填預設為link
dataUrl: '', // 如果type是music或video,則要提供資料連結,預設為空
success: function () {
// 使用者确認分享後執行的回調函數
},
cancel: function () {
// 使用者取消分享後執行的回調函數
}
});
});
},
fail: err => {
console.log('request fail', err);
}
});
轉載于:https://blog.csdn.net/qq_24347541/article/details/89710562