// 云函数入口文件
const cloud = require(‘wx-server-sdk’);
cloud.init();
const {
WXMINIUser
WXMINIQR
} = require(‘wx-js-utils’);
const appId = ‘’; // 小程序 appId
const secret = ‘’; // 小程序 secret
// 获取小程序码,A接口
let wXMINIUser = newWXMINIUser({
appId,
secret
});
// 一般需要先获取 access_token
// 云函数入口函数
exports.main = async (event, context) => {
let access_token = await wXMINIUser.getAccessToken();
let wXMINIQR = newWXMINIQR();
let qrResult = await wXMINIQR.getMiniQR({
scene: `?agent=${event.agent}&name=${event.name}&mobile=${event.mobile}
access_token,
path: ‘src/register/index’
is_hyaline: true
});
return await cloud.uploadFile({
cloudPath:‘qr.jpg’,
fileContent: qrResult
})
存储的二维码图片无法打开