微信小程序生成带参数的小程序码-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);
});
 

 

 

 

posted @ 2018-09-01 11:13  JJRains  阅读(1078)  评论(0编辑  收藏  举报