- 小程序无法获取地理位置
以前可以,现在不行了,不知道什么原因。
08-17 - 开发云环境找不到?
我的云环境是免费的,开发工具找不到云环境:clound-zygj,提示要新建,我的小程序仍可以使用,说明我的云环境及数据还存在。我的appid是:wxe103f48acd33ecd7
2022-01-11 - 多条记录同时提交时,当事务处理出错时,添加记录无法回滚?
try { const transaction = await db.startTransaction() var tjarray=[]; var updatearray=[]; var p1=true; var p2=true; var cz=[] for(var i=0;i<data.length;i++){ let id=data[i]._id; cz[i]=await transaction.collection('cl_kc').doc(id).get() tjarray[i]=await transaction.collection('cl_buy').add({data:{bh:'Z0002',czy:'Z0004'}}) if (cz[i]){ updatearray[i] = await transaction.collection('cl_kc').doc(id).update({ data: { 'sl': 67 } }) } if (tjarray[i]._id==null){ p1 = false throw{msg:'dfsf'} } if (!updatearray[i].stats.updated) { p2 = false; throw { msg: updatearray[i].stats } } } if (p1&&p2){ await transaction.commit() console.log(`transaction succeeded`) return { success: true } }else{ await transaction.rollback(-100); } } catch (e) { console.error(`transaction error`, e) return { success: false, error: e }
2020-06-01 - 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-24 - 自定义组件 事件改变 组件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 - 云开发 数据库 如何 存储 日期字段?
小程序端的这个字段如何设置, data:{ time: new Date() } 上传后查询库的时候发现是字符类型的,不是date的
2020-02-26 - 云文件下载问题?
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-25