wxacode.getUnlimited批量生成二维码
批量生成二维码
router.get('/getUnlimited', function* () {
const page = 'pages/discountCoupon/discountCoupon'
const token = yield axios.get('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appid&secret=secret')
const access_token = token.data.access_token;
for (let i = 0; i < list.length; i++) {
setTimeout(() => {
const codeOptions = {
method: 'POST',
url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' + access_token,
headers: { 'Content-Type': 'json' },
responseType: 'arraybuffer',
data: {
page: page,
width: 230,
scene: list[i].path,
}
}
axios(codeOptions).then(res => {
fs.writeFileSync(`./${list[i].name}.png`, res.data)
})
}, 500);
}
})
服务调用即可