个人案例
- 请问页面元素排列不规则,如何用wx:for渲染(二维数组)?
效果图 [图片] <block wx:for-items="{{item.memberlist}}" wx:key="item"> <image class="member_avatar" src="{{item[0].memberInfo[0].avatarUrl || '/images/default_img.png'}}"> </image> </block> 这里加了item[0]就渲染不出来了。 [图片]
2020-12-24 - 多个input输入内容后,push()到数组,结果重复?
data: { ask: [], }, // 答案D answerDInput: function (e) { let value = e.detail.value let asks = [] let askItem = { D: value, isCheck: false } asks.push(askItem) this.data.ask.push(...asks) this.setData({ ask: this.data.ask }) console.log(asks) console.log(this.data.ask) }, [图片]
2020-11-28 - 云开发添加数据报错errMsg: [FailedOperation.Insert] bulk w?
新建的集合 [图片] (Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 00e5fcc8-2dfd-11eb-b2eb-5254002d4a45, cloud function service error code -504002, error message Error: errCode: -502001 database request fail | errMsg: [FailedOperation.Insert] bulk write error: [{[{E11000 duplicate key error collection: tnt-9faylinha.LostOrder index: location dup key: { : 3887078034246690233 }}]}, {<nil>}]; ) wxml _updateLost: function (cloudPath, cloudPathVideo) { wx.cloud.callFunction({ name: 'add_Goods', data: { req_type: 'Lost', lostType: this.data.lostType, lostDesc: this.data.currentContent, lostName: this.data.lostName, radiocheck: this.data.radiocheck, lostIDcard: this.data.lostIDcard, lostTime: this.data.lostTime, lostLocation: this.data.lostLocation, latitude: Number(this.data.latitudes), longitude: Number(this.data.longitudes), lostFenceID: this.data.lostFenceID, lostFenceName: this.data.lostFenceName, contact: this.data.currentContactWay, images: cloudPath, video: cloudPathVideo, createAt: formatTime(new Date()), } }).then(res => { console.log("添加失物招领信息成功:", res.result) wx.hideLoading() wx.redirectTo({ url: '/pages/lostChannel/lostChannel', }) }).catch( err => { console.log(err) }) }, 云函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() const req_type = event.req_type switch (req_type) { case "Lost": return addLost(); default: { return } } function addLost() { return db.collection('LostOrder').add({ data: { lostType: event.lostType, lostDesc: event.lostDesc, lostName: event.lostName, radiocheck: event.radiocheck, lostIDcard: event.lostIDcard, lostTime: event.lostTime, lostLocation: event.lostLocation, location: db.Geo.Point(event.longitude, event.latitude), lostFenceID: event.lostFenceID, lostFenceName: event.lostFenceName, contact: event.contact, images: event.images, video: event.video, createAt: event.createAt, userId: wxContext.OPENID, status: 0 } }) } }
2020-11-24 - 不规则图案前端如何渲染?
请问这种样式如何渲染? [图片]
2020-11-13 - 如何判断表单是否被修改?
请问,在编辑已发布的内容时,如何判断表单是否被修改?如果修改了只修改了一个内容该如何提交数据库。
2020-09-04 - 云开发聚合查询match(_.expr($.and([])),求简化方法?
我想把status != 4,且 0 ≤ memberList.length + 1 ≤ "$groupType.groupNum"的数据筛选出来 求简化方法? .match(_.expr($.and([ $.or([ $.eq(['$status', 1]), $.eq(['$status', 2]), $.eq(['$status', 3]), $.and([ $.eq(['$status', 4]), $.and([ $.gt([$.size('$memberList'), 0]), $.lt([$.size('$memberList'), $.subtract(['$groupType.groupNum', 1])]), ]), ]) ]), $.and([ $.gte([$.size('$memberList'), 0]), $.lt([$.size('$memberList'), $.subtract(['$groupType.groupNum', 1])]), ]) ])))
2020-08-27 - 云开发聚合查询match(_.expr())?
我想把status != 4,且 0 ≤ memberList.length + 1 ≤ "$groupType.groupNum"的数据筛选出来, 我的方法并没有把(memberList.length 大于等于 0) 且 (memberList.length + 1 小于等于 "$groupType.groupNum")的值筛选出来。 求解决方法 .match( _.expr( $.or([ $.neq(["$status", 4]), //去除团长取消订单时(status=4),没有人参与团购。 $.and([ $.gte([$.size("$memberList"), 0]), $.lte([$.size("$memberList") + 1, "$groupType.groupNum"]), ]), ]) ) ) .end() [图片]
2020-08-25 - 微信支付成功后,回调函数内wx.redirectTo没有关闭之前页面?
微信支付成功后,回调函数内wx.redirectTo不起作用,没有关闭之前页面,还是有返回按钮可以返回上一页。 支付失败回调,wx.redirectTo起作用了。 [图片] [图片] callPay: function (orderID, leaderOrderID) { var that = this wx.cloud.callFunction({ name: 'payment', data: { req_type: "CallPay", body: that.data.shopName, //商品描述 outTradeNo: orderID, //商户订单号 subMchId: that.data.subMchId, //子商户号 totalFee: that.data.total, //总金额,单位为分 shopID: that.data.shopID, //店铺ID shopName: that.data.shopName, //店铺名 }, success: res => { console.log(res) const payment = res.result.payment wx.requestPayment({ ...payment, success(res) { console.log('支付成功', res) wx.hideLoading() wx.redirectTo({ url: '/pages/smallShop/orderDetail/orderStatus/orderStatus?orderID=' + leaderOrderID + '&payType=' + 'success' + '&userType=' + that.data.userType, }) }, fail(err) { wx.hideLoading() wx.redirectTo({ url: '/pages/smallShop/orderDetail/orderStatus/orderStatus?orderID=' + leaderOrderID + '&payType=' + 'fail' + '&userType=' + that.data.userType, }) } }) }, fail: error => { console.log(error) wx.hideLoading() }, }) },
2020-08-23 - 云函数聚合查询.match().group()返回空数组?
有的时候可以查询出结果,有的时候查询不到。 用where()查询就不会出现返回空数组的问题。 [图片] [图片] 按sortName(商品类别)分组 return dbRes.match({ shopID: event.shopId }) .group({ _id: { sortName: '$sortItem.sortName' }, list: $.push({ _id: '$_id', goodsName: '$goodsName', goodsDesc: '$goodsDesc', goodsPrice: '$goodsPrice', imgUrl: '$imgUrl' }) }) .end().then(res => { console.log(res); return res })
2020-08-15 - 云开发“拼团”功能,数据查询?
我设计的拼团功能数据结构,团长(Leader)和团员(Member)都生成了独立的订单号(在同一个集合里‘groupOrder’)。 团员在下单时会关联了团长的订单(ID)。 我现在想把每个团长及团员的订单筛选出来放到一个新数组里面。 [{ 团长A: '', 团员[{ 团员A: '', }, { 团员B: '', }] }, { 团长B: '', 团员[{ 团员A: '', }, { 团员C: '', }] }] 云函数,查询‘Leader._id’,并通过‘addFields()函数’新建了一个数组‘memberOrder’,再通过查询到的‘Leader._id’,继续查询符合条件的‘member’订单,并把查询结果push到新数组‘memberOrder’,但返回结果null exports.main = async (event, context) => { const wxContext = cloud.getWXContext() const req_type = event.req_type switch (req_type) { case "Member": return memberCheck(); default: { return } } function memberCheck() { const memberOrder = [] return dbRes.match({ shopID: event.shopID, orderType: 'Leader' }).addFields({ memberOrder: memberOrder }).end() .then( res => { console.log(res); const leaderOrder = res.data for (let i = 0; i < leaderOrder.length; i++) { const orderID = leaderOrder[i]._id; return db.collection('groupOrder').where({ orderID: orderID }).get() .then( res => { const member = res.data for (let j = 0; j < member.length; j++) { const tempObj = member[j]; memberOrder.push(tempObj) } return res }) } return res }).catch( err => { console.log(err); }) } }
2020-08-10