- 正式版无法调用云函数?
我想先获取用户的open_id,然后判断数据库中,是否含有open_id,有则不操作,没有则添加到数据库。 开发版和体验版都没有问题,就是正式版,新用户无法把open_id添加到数据库。 这是我的代码 let that = this; // 调用云函数,判断是否注册 wx.cloud.callFunction({ name: 'login', data: {}, success: res => { console.log('open_id', res.result.openid) //查询open_id是否在数据库中 const db = wx.cloud.database() db.collection('user'). where({ open_id: res.result.openid }). get({ success: function (res) { // 判断是否注册,如未注册,自动注册赠送票数 if (res.data.length == 0) { console.log('正常调用云函数') wx.cloud.callFunction({ name: 'databaseadd', data: {}, success: res => { console.log('查询到数据为', res.result) }, err: res => {} }) } else { console.log('已是老会员') var yesvotes = res.data[0].votes console.log('已是老会员', yesvotes) that.setData({ yesvotes: yesvotes, //获取数据数组 }); } }, fail: err => { console.log(err); } }) }, fail: err => { console.log(err); return err } }) 云函数是这样写的 // 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init() const db = cloud.database() const_ = db.command // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() return db.collection('user').add({ data: { open_id: wxContext.OPENID, votes: 100 }, success: res => { console.log('[数据库] [新增记录] 成功,记录 _id: ', res._id) }, }) } 权限加了,这个应该和权限没关系吧 [图片]
2020-05-01 - 云函数调用msgSecCheck,“我爱你”三个字报87014错误?
云函数调用msgSecCheck,“我爱你”三个字报87014错误。其他的正常。 [图片][图片]
2020-04-15 - IOS手机图片安全检测imgSecChe,报Error: errCode: -1 错误?
真机调试报这个错误,提示max size,我上传的图片很小的。Android手机没问题,现在发现iPhone6有问题。 APPID:wxa0c17091265340da Error: errCode: -1 | errMsg: cloud.callFunction:fail Error: data exceed max size (callId: 1586489164793-0.5581622445325081) (trace: 11:26:4 start->11:26:11 system error (Error: data exceed max size), retry->11:26:17 system error (Error: data exceed max size), retry->11:26:21 system error (Error: data exceed max size), abort); at cloud.callFunction api; at new u (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:233907) at d (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:234414) at f (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:234509) at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:399226) at t (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:65617) at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:65739) at e (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:68192) at e.exports (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:27005) at y. (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:32408) at Number.r (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:32107) [图片] 刚才有开始报404012错误了 [图片] [图片] 云函数的写法,请求的写法 const cloud = require('wx-server-sdk') cloud.init() // 云函数入口函数 exports.main = async(event, context) => { const { value } = event; try { const res = await cloud.openapi.security.imgSecCheck({ media: { header: { 'Content-Type': 'application/octet-stream' }, contentType: 'image/png', value: Buffer.from(value) } }) return res; } catch (err) { return err; } } 请求 //检查图片 imgcheck: function () { var that = this; wx.compressImage({ src: this.data.imgbg, // 图片路径 quality: 10, // 压缩质量 success(res) { console.log('图片' + res.tempFilePath) wx.getFileInfo({ filePath: res.tempFilePath, success(resinfo) { console.log('图片压缩后的尺寸' + resinfo.size) if (resinfo.size < 600 * 1024) { wx.getFileSystemManager().readFile({ filePath: res.tempFilePath, success: buffer => { console.log('getImageInfo' + JSON.stringify(buffer)) console.log('getImageInfo' + buffer) console.log('getImageInfo' + buffer.data) wx.cloud.callFunction({ name: 'imgcheck', data: { value: buffer.data }, success: res => { console.log('图片检测成功') console.log(JSON.stringify(res)) console.log(res.result.errCode) if (res.result.errCode == '87014') { wx.hideLoading() wx.showModal({ title: '提醒', content: '此图片暂不可用', showCancel: false }) } else { that.updateimg(); console.log('图片正常') } }, fail: err => { console.log(err) }, complete: () => { } }) }, fail: err => { console.log(err) } }) } else { wx.hideLoading() wx.showModal({ content: '图片过大,请选小点的(๑❛ᴗ❛๑)', showCancel: false }) } } }) }, }) },
2020-04-10 - 图片安全检测openapi.security.imgSecChe,云函数在iPhone6手机报错?
iPhone6手机在检测图片时,报这个错误,请问是怎么回事呀。 其他手机都可以的,图片检测时大小超过1M应该报的是40001,这个是什么情况呢。 [图片]
2020-03-31 - 导入官方代码片段报代码包解压到文件夹失败?
https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html 这个里面的,点击在开发者工具中预览效果,报这个错误 [图片] 其他的都是好的,应该是这个代码片段的问题
2019-09-30 - 导入官方代码片段报这个错误,代码包解压到文件夹失败?
https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html 这个里面的,点击在开发者工具中预览效果,报这个错误 [图片] 有没有人知道要怎么解决呀?
2019-09-30 - for循环生成的button怎么修改里面的文字?
我用for循环生成了很多个button, 我想点击单个button后,修改该button的文字。 请问这个要怎么做呢? [图片] [图片] 我给每个button,绑定了不一样的id, 要怎么根据id,来修改这个button的class、内部文字呢?
2019-09-25 - Dialog弹窗组件确定、取消的按钮问题?
用的是官方Dialog弹窗组件,链接https://developers.weixin.qq.com/miniprogram/dev/extended/weui/dialog.html 怎么给确定、取消这两个按钮绑定事件呀。 [图片] 官方文档是这样写的,buttons按钮组点击时触发的事件,detail为{index, item},item是按钮的配置项是什么意思呀? bindbuttontapeventhandler 否buttons按钮组点击时触发的事件,detail为{index, item},item是按钮的配置项我现在是这样写的 [代码]<[代码][代码]mp-dialog[代码] [代码]title[代码][代码]=[代码][代码]"test"[代码] [代码]show[代码][代码]=[代码][代码]"{{dialogShow}}"[代码] [代码]bindclose[代码][代码]=[代码][代码]"bindclose"[代码] [代码]bindbuttontap[代码][代码]=[代码][代码]"tapDialogButton"[代码] [代码]buttons[代码][代码]=[代码][代码]"{{buttons}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码][代码]>test content</[代码][代码]view[代码][代码]>[代码][代码]</[代码][代码]mp-dialog[代码][代码]>[代码][代码]tapDialogButton: function() {[代码][代码] [代码][代码]console.log([代码][代码]'点击确认按钮啦'[代码][代码], [代码][代码]''[代码][代码])[代码][代码]},[代码]无论点确定还是取消,都打印上面这个,谁知道这个要怎么改呀? 搜到了同样的问题,也没有答案:https://developers.weixin.qq.com/community/develop/doc/00086a1e0889187f2af8181015bc00
2019-09-23 - 云开发获取用户信息,如何把省份的拼音设置为汉字?
云开发获取用户信息,如何把省份的拼音设置为汉字? 现在获取的信息都是拼音,如何改成汉字呢?
2019-09-09