小程序
小游戏
企业微信
微信支付
扫描小程序码分享
errCode: 40169 errMsg: "openapi.wxacode.getUnlimited:fail invalid length for scene, or the data is not json string rid: 62764ad3-09f60c12-58046222"
为甚会调用失败呢?
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
为啥不会调用失败呢
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
return fileObj;
} catch (err) {
return err
}
//页面调用云函数代码
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options.id);
const tmp_id = options.id;
wx.cloud.callFunction({
name: 'getQrcode',
data: {
page: 'pages/preview/preview',
scence: `id=${tmp_id}`,
})
.then(res => {
console.log(res.result);
if (res.result.status == 0) {
_this.setData({
qr_url: res.result.tempFileURL
}else{
wx.showToast({
icon: 'none',
title: '调用失败',
}).catch(err => {
console.error(err);
},
// 生成小程序码
const wxacodeResult = await cloud.openapi.wxacode.getUnlimited({
scene: event.scene,
page: event.page,
width: 280 //二维码的宽度,单位 px,最小 280px,最大 1280px
// return wxacodeResult;
if (wxacodeResult.errCode != 0) {
// 生成二维码失败,返回错误信息
return wxacodeResult;
// 上传到云存储
const uploadResult = await cloud.uploadFile({
cloudPath: 'qr/' + qr_name_hash + '.jpg',
fileContent: wxacodeResult.buffer,
});
// return uploadResult;
if (!uploadResult.fileID) {
//上传失败,返回错误信息
return uploadResult;
// 获取图片临时路径
getURLReault = await cloud.getTempFileURL({
fileList: [uploadResult.fileID]
fileObj = getURLReault.fileList[0];
fileObj.fromCache = false;
// 上传成功,获取文件临时url,返回临时路径的查询结果
scene长度超出32位限制了吧,或者有不允许的特殊字符存在,要使用 encodeURIComponent,扫码接收到参数的时候使用decodeURIComponent解码
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
为啥不会调用失败呢
return fileObj;
} catch (err) {
return err
}
}
//页面调用云函数代码
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options.id);
const tmp_id = options.id;
wx.cloud.callFunction({
name: 'getQrcode',
data: {
page: 'pages/preview/preview',
scence: `id=${tmp_id}`,
}
})
.then(res => {
console.log(res.result);
if (res.result.status == 0) {
_this.setData({
qr_url: res.result.tempFileURL
})
}else{
wx.showToast({
icon: 'none',
title: '调用失败',
})
}
}).catch(err => {
console.error(err);
wx.showToast({
icon: 'none',
title: '调用失败',
})
})
},
// 生成小程序码
const wxacodeResult = await cloud.openapi.wxacode.getUnlimited({
scene: event.scene,
page: event.page,
width: 280 //二维码的宽度,单位 px,最小 280px,最大 1280px
})
// return wxacodeResult;
if (wxacodeResult.errCode != 0) {
// 生成二维码失败,返回错误信息
return wxacodeResult;
}
// 上传到云存储
const uploadResult = await cloud.uploadFile({
cloudPath: 'qr/' + qr_name_hash + '.jpg',
fileContent: wxacodeResult.buffer,
});
// return uploadResult;
if (!uploadResult.fileID) {
//上传失败,返回错误信息
return uploadResult;
}
// 获取图片临时路径
getURLReault = await cloud.getTempFileURL({
fileList: [uploadResult.fileID]
});
fileObj = getURLReault.fileList[0];
fileObj.fromCache = false;
// 上传成功,获取文件临时url,返回临时路径的查询结果
return fileObj;
} catch (err) {
return err
}
}
scene长度超出32位限制了吧,或者有不允许的特殊字符存在,要使用 encodeURIComponent,扫码接收到参数的时候使用decodeURIComponent解码