wx.getShareInfo总是失败,返回错误42
发布于 6 年前 作者 tiantao 18849 次浏览 来自 问答

//app.js

App({

globalData: {

shareTicket: ‘’,

openGid: ‘’

},

onLaunch: function (options) {

},

onShow: function (options) {

let that = this

if (options && options.scene == 1044) {

that.globalData.shareTicket = options.shareTicket

}

console.log(‘onShow—options=—>’ + JSON.stringify(options))

},

getShareTiket: function (cb) {

let that = this

// 展示本地存储能力

if (that.globalData.shareTicket) {

wx.getShareInfo({

shareTicket: that.globalData.shareTicket,

success: function (res) {

console.log(‘getShareTiket—shareTicket–>’ + JSON.stringify(res))

let js_encryptedData = res.encryptedData

let js_iv = res.iv

wx.login({

success: function (res) {

let js_code = res.code

console.log(‘code–>’ + js_code)

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))

}

})

}

})

},

fail:function(res){

console.log(res)

},

complete:function(res){

console.log(res)

}

})

} else {

console.log(‘不存在shareTicket’)

}

}

})

1 回复

使用你的代码片段,是可以获取的啊

回到顶部