微信小程序生成带参数的小程序码-node
const axios = require("axios") const fs = require("fs") const appId = 'appid' const secret = 'appsecret'
let data = {
scene: "参数",
page: "小程序页面"
}
picUrl = `./upload/${data.scene}.png` axios({ method:'get', url:`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${secret}` }) .then((res1)=> { if(res1.data){ if(res1.data.access_token){ axios.post(`https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${res1.data.access_token}`,
data,
{responseType:'stream'}) .then((response)=> { response.data.pipe(fs.createWriteStream(`goods.png`)) }) } } })
.catch((error)=> {
console.log("err:"+error);
});