/ 解析ShareTiket
getShareTiket: function (shareTicket) {
let that = this
// 展示本地存儲(chǔ)能力
if (shareTicket) {
wx.getShareInfo({
shareTicket: shareTicket,
success: function (res) {
console.log('getShareTiket---shareTicket-->' + JSON.stringify(res));
wx.request({
url: 'xxxxxxxx',
method: 'POST',
data: {
code: js_code,
appId: 'xxxxx',
encryptedData: js_encryptedData,
iv: js_iv
},
success: function (res) {
that.globalData.openGid = res.data.openGId
console.log('getShareTiket---openGid' + that.globalData.openGid)
typeof cb == "function" && cb(that.globalData)
},
fail: function (err) {
console.log('getShareTiket---err' + JSON.stringify(err))
}
})
}
})
} else {
console.log('不存在shareTicket')
}
},
|
通常開發(fā)者希望轉(zhuǎn)發(fā)出去的小程序被二次打開的時(shí)候能夠獲取到一些信息,例如群的標(biāo)識(shí)。現(xiàn)在通過調(diào)用 wx.showShareMenu 并且設(shè)置 withShareTicket 為 true ,當(dāng)用戶將小程序轉(zhuǎn)發(fā)到任一群聊之后,此轉(zhuǎn)發(fā)卡片在群聊中被其他用戶打開時(shí),可以在 App.onLaunch 或 App.onShow 獲取到一個(gè) shareTicket。通過調(diào)用 wx.getShareInfo 接口傳入此 shareTicket 可以獲取到轉(zhuǎn)發(fā)信息。
wx.showShareMenu({
withShareTicket: true
});
|