新手,都是网上看看,不过你的方法有效,谢谢
java 调用 api 返回错误?String generalUrl="https://api.weixin.qq.com/tcb/databaseadd?access_token="+tocken; try { URL url = new URL(generalUrl); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Charset", "UTF-8"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("accept","application/json"); ccs="{\"env\": \"clound-zygj\",\"query\": \"db.collection(\"zg_gzb\").add({data: [{\"employeenumber\":\"Z01117\"}]})\"}"; System.out.println(ccs); byte[] writebytes = ccs.getBytes(); conn.setRequestProperty("Content-Length", String.valueOf(writebytes.length)); OutputStream outwritestream = conn.getOutputStream(); outwritestream.write(writebytes); outwritestream.flush(); outwritestream.close(); if (200 == conn.getResponseCode()){ is = conn.getInputStream(); br = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line; while ((line = br.readLine()) != null){ result.append(line); } }else{ System.out.println("ResponseCode is an error code:" + conn.getResponseCode()); } }catch (MalformedURLException e){ e.printStackTrace(); }catch (IOException e){ e.printStackTrace(); }catch (Exception e){ e.printStackTrace(); }finally { try{ if(br != null){ br.close(); } if(is != null){ is.close(); } }catch (IOException ioe){ ioe.printStackTrace(); } conn.disconnect(); } System.out.println(result.toString()); {"errcode":47001,"errmsg":"data format error hint: [5eLBH.wgE-hUGbXa]"},语句在开发控制平台测试没有问题。不知哪一步错误?
2020-04-24ready: function () { this.refresh(); console.log('ready') }, 这个启动后执行refresh,在调用getDate
自定义组件 事件改变 组件data 组件 不渲染?var wait=false; var rqzh = require('../../utils/util.js'); const app = getApp() var dzid = []; Component({ properties: { hidden: { type: Boolean, value: true }, heightd:{ type:Number, value:0 } }, ready: function () { this.refresh(); console.log('ready') }, data: { dataList:[], bottom:false }, methods: { getData: function () { const that = this; if (!wait){ wx.cloud.callFunction({ name: "editdata", data: { type: 'get', db: 'ssnew', skip: that.data.dataList.length, limit: 20, condition: {} }, success(res) { if (res.result.data.length > 0) { var picture = []; var m = 0; var arr = []; for (var i = 0; i < res.result.data.length; i++) { arr[i] = { "id": res.result.data[i]._id, "title": res.result.data[i].title, "text": res.result.data[i].text, "user": res.result.data[i].user, "systime": rqzh.format_date(new Date(res.result.data[i].systime)), "dianzan": res.result.data[i].dianzan, "view": res.result.data[i].view, "picture": res.result.data[i].picture[0] } if (res.result.data[i].picture.length != 0) { picture[m] = res.result.data[i].picture[0] m++ } } that.data.dataList.push(arr) that.setData({ dataList: that.data.dataList }) wx.cloud.getTempFileURL({ fileList: picture, success: res => { for (var i = 0; i < res.fileList.length; i++) { for (var a = 0; a < arr.length; a++) { if (that.data.dataList[a].picture == res.fileList[i].fileID) { that.data.dataList[a].picture = res.fileList[i].tempFileURL } } } console.log('sss', that.data.dataList) that.setData({ dataList: that.data.dataList }) wait=false }, fail(res) { console.log('下载图片失败', res) wait = false } }) } else { wx.showToast({ title: '没有更多数据了……', icon: 'none' }) setTimeout(function () { wx.hideToast() }, 2000) wait = false that.setData({ bottom: true }) } }, fail(res) { console.log("加载数据出错", res) } }) }, refresh: function (e) { var self = this; self.setData({ bottom: false }) self.getData(); } } }) 这是组件代码 <ssnew_list hiddend="false" heightd="500" id="ssnew_list"></ssnew_list> 这是页面代码,加载后不出现数据列表 这个是控制台显示,已经有数据 [图片]
2020-03-14我这种方法哪里错了?
云函数 await 调用?return await cloud.uploadFile({ cloudPath: dataCVS, fileContent: buffer, //excel二进制文件 }).then(res=>{ let filelist=[] filelist.push(res.fileID) // return filelist await cloud.getTempFileURL({ fileList: filelist, }).then(rec=>{ return rec }) }) 不知怎么处理 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 93f28b09-6067-11ea-8374-525400697544, cloud function service error code -504002, error message Unexpected identifier; at cloud.callFunction api; at new u (VM227 WAService.js:2) at d (VM227 WAService.js:2) at f (VM227 WAService.js:2) at Function.success (VM227 WAService.js:2) at VM227 WAService.js:2 at x (VM227 WAService.js:2) at i.<anonymous> (VM227 WAService.js:2) at i.emit (VM227 WAService.js:2) at Ea (VM227 WAService.js:2) at VM227 WAService.js:2
2020-03-07可以了,谢谢
Promise.all取不到页面DATA数据值或者方法?var sctu[xh],html; sss:function(){ this.editorCtx.getContents({ success(res) { html = res.html; var i=0 var ss = res.html.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) { url[i]=capture i++ }) console.log(url) var PromiseAllArr = [];//*********************用来存多个Promise for (var i = 0; i < url.length; i++) { console.log(i) PromiseAllArr.push( new Promise(function (resolve, reject) { let that = this; let xh=i; wx.cloud.uploadFile({ cloudPath: "ssnew/" +rqzh.timeName(new Date()) +"-"+xh + ".jpg", filePath: url[xh], success(res) { console.log(html) html=html.replace(url[xh],res.fileID) sctu[xh] = res.fileID console.log(xh+"上传成功") // if (that.data.sctu.length==url.length){ // that.data.html = mm // console.log(mm) // that.data_updata() // } return resolve(res); }, fail(res) { return reject(i+"个上传失败"); console.log(url[xh]) console.log('上传图片失败', res) } }) })) } Promise.all(PromiseAllArr).then(function (values) { let that=this; console.log(that.data.title) }).catch(reason => { console.log(reason) wx.cloud.deleteFile({ fileList: sctu, success(res){ console.log('删除已存文件') } }) }); } }) } TypeError: Cannot read property 'data' of undefined at ssnew.js? [sm]:181,我换成页面的函数,也提示找不到。
2020-02-29我的文件名字命的有问题,不应该有空格,现在可以了。不知云上为什么可以上传带空格的名字,就是不能下载。谢谢
云文件下载问题?addImg:function(){ let fsm = wx.getFileSystemManager(); fsm.writeFile({ filePath: wx.env.USER_DATA_PATH + '/tmp.txt', data: "数据" + rqzh.formatTime(new Date()) + "\n", encoding: 'base64', success: res => { console.log('文件生成',res) let filepath= wx.env.USER_DATA_PATH + '/tmp.txt' const cloudPath = "cjdata/" + rqzh.formatTime(new Date())+ ".ccjson" wx.cloud.uploadFile({ cloudPath: cloudPath, filePath: filepath, success: resa => { console.log('[上传文件] 成功:', resa.fileID) let fileid=resa.fileID wx.cloud.downloadFile({ "fileID": fileid, success: res => { console.log('文件下在',res) } }) }}) 云文件已经上传上了,但是下载不了,提示为 {statusCode: 500, header: {…}, cookies: Array(0), errMsg: "downloadFile:ok"}cookies: []errMsg: "downloadFile:ok"header: {}statusCode: 500__proto__: Object
2020-02-25wx.cloud.downloadFile 下载文件问题 addImg:function(){ let fsm = wx.getFileSystemManager(); fsm.writeFile({ filePath: wx.env.USER_DATA_PATH + '/tmp.txt', data: "数据" + rqzh.formatTime(new Date()) + "\n", encoding: 'base64', success: res => { console.log('文件生成',res) let filepath= wx.env.USER_DATA_PATH + '/tmp.txt' const cloudPath = "cjdata/" + rqzh.formatTime(new Date())+ ".ccjson" wx.cloud.uploadFile({ cloudPath: cloudPath, filePath: filepath, success: resa => { console.log('[上传文件] 成功:', resa.fileID) let fileid=resa.fileID wx.cloud.downloadFile({ "fileID": fileid, success: res => { console.log('文件下在',res) } }) }}) 运行提示{statusCode: 500, header: {…}, cookies: Array(0), errMsg: "downloadFile:ok"},取不到文件,
wx.cloud.downloadFile 下载文件问题- 当前 Bug 的表现(可附上截图) [图片] - 预期表现 在云开发控制台复制的fileID 不能使用wx.cloud.downloadFile 下载文件 错误信息: <Error: errCode: -403003 internal server error: empty download url | errMsg: internal server error: empty download url> console.error @ VM238:1 t.(anonymous function) @ WAService.js:1 (anonymous) @ WAService.js:1 a @ WAService.js:1 (anonymous) @ WAService.js:1 a @ WAService.js:1 t.invokeFailCompleteCallbacks @ WAService.js:1 (anonymous) @ WAService.js:1 Promise.catch (async) (anonymous) @ WAService.js:1 (anonymous) @ WAService.js:1 exportAPI.(anonymou6 (anonymous) @ WASes function) @ WAService.js:1 onShow @ index.js:15rvice.js:1 __callPageLifeTime__ @ WAService.js:1 (anonymous) @ WAService.js:1 It @ WAService.js:1 (anonymous) @ WAService.js:1 (anonymous) @ WAService.js:1 i.emit @ WAService.js:1 emit @ WAService.js:1 (anonymous) @ WAService.js:1 (anonymous) @ WAService.js:1 n @ appservice?t=1562118605670:1673 (anonymous) @ appservice?t=1562118605670:1673 (anonymous) @ appservice?t=1562118605670:1673 _ws.onmessage @ appservice?t=1562118605670:1673 - 复现路径 cloud://bazi-99zet.6261-bazi-99zet-1259416447/ad.jpg - 提供一个最简复现 Demo
2020-02-25