const timestamp = Math.floor(Date.now() / 1000)
const nonceStr = randomString()
const { apiSignature } = await getApiTicket({
noncestr: nonceStr,
timeStamp: timestamp,
url: location.href.split('#')[0],
cardId
})
console.log('addCard', cardId)
const cardExt = {
timestamp,
nonce_str: nonceStr,
signature: apiSignature,
outer_str: JSON.stringify({
...outer,
deviceId,
openStyleType,
subActivityWay
})
}
console.log('addCard', cardExt)
return new Promise((resolve, reject) => {
wx.addCard({
cardList: [{
cardId,
cardExt: JSON.stringify(cardExt)
}],
success: function (res) {
resolve(res.cardList)
console.log('addCard', res)
}
})
})
wx.addCard不能发放商户后台的代金券
那么wx.openCard是不是也不能打开商户后台发放的代金券了
后台也可以生成二维码给用户扫码发放;https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter3_2.shtml
wx.openCard({
cardList: [{
cardId: '',
code: ''
}]// 需要打开的卡券列表
});
API发券,需要指定openid
是不是因为商户号创建的代金券,通过公众号发放,必须要指定openId呢?