场景:app唤起小程序进行微信支付
onLoad(options) {
let that = this
wx.showLoading({
title: '请稍候',
mask: true
})
this.setData({
writeOff_id: options.writeOff_id
})
wx.setStorageSync('writeOff_id', this.data.writeOff_id)
new Promise(((resolve) => {
wx.login({
success: res => {
var appId = '自己的appid'
var secret = ''
wx.request({
method: 'GET',
url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + secret + '&js_code=' + res.code + '&grant_type=authorization_code',
success: function (res) {
resolve(res.data.openid)
}
})
}
})
})).then(e => {
wx.request({
method: 'GET',