- 菜鸟require 引入失败?
目录结构 [图片] 请大神们不吝赐教,我在require的时候,request-promise的提示都弹出来了,这证明系统检测到了这个module,可是最后编译的时候还是报错。我基础库和npm模块引用设置都是没问题的。我对require不是很熟,看了文档也看不到自己问题所在。请帮忙看看,谢谢! [图片] [图片] =================《》===================
2020-03-31 - 如何在用户微信支付后给自己(商户)推送消息?
大佬们早上好,如今订阅消息,只能每次都点击接收后才能收到消息。可如果我的身份是商户,我怎么才能每次在用户微信支付(触发某个事件)后就收到消息?谢谢!
2020-03-28 - 订阅消息商品名称长度只有20这怎么够啊?(连续问号)不是很懂腾讯的脑回路。(连续句号)
纯吐槽,如题。。。[图片]
2020-03-15 - 既然不用授权就能获取openid,那么授权后获取的头像昵称对于我们有什么用呢?
问题如题目,觉得用open-type getUserInfo 获取头像和昵称用处不大,但看文档又似乎是一个比较重要的东西。请问为什么呢。谢谢!
2020-03-11 - 请问云开怎样以对象为单位进行更新?
破案了, 感谢老张哥! 把list里的 _openid 和 _id 删掉后直接如下就可以把整个对象更新了!哈哈 update({ data:list }) 大佬们早上好,如下所示,我已经在JS中将对象中的数据进行了修改,可我并不想把对象里的属性一一对应地update数据库。 请问如何直接更新这个对象(据我所知,_openid在云开发语句中是非法的,这也是不能直接update我这个对象的障碍)?谢谢! [图片] var list = 数据集的对象 list.name = 'kobe' list.num = 24 test.where({ _id: '7edfcb21-7cff-4931-9cf0-8f95a4e2ecbb' }).update({ data: { ???: list } }) 恭喜发财,一本万利
2020-03-06 - 大佬好!将数组元素按条件一维转(push)二维,如何能有更优解?
大佬们好,如代码所示,想要按条件将一维数组按条件转换成二维数组,请问以下代码有没有更好的(更简洁的)解决方法? 首先谢谢 @Admin 2020哥的回答,我找到更好的方法了。嘿嘿。。。。 好点的解决方法 var nameList = ['<5', '<10', '>10'] var detailList = [] var emptyList = [] var list = [1, 3, 5, 7, 4, 9, 10, 11, 12, 13] var lt5 = list.filter(item=>{return item<5}) var lt10 = list.filter(item=>{return item<10}) var mt10 = list.filter(item=>{return item>10}) emptyList.push(lt5,lt10,mt10) for(var i in nameList){ detailList.push({name:nameList[i],detailArr:emptyList[i]}) } console.log(detailList) 问题 var nameList = ['<5', '<10', '>10'] var detailList = [] var emptyList = [] var list = [1, 3, 5, 7, 4, 9, 10, 11, 12, 13] for (var i in nameList) { detailList.push({ name: nameList[i], detailArr: [] }) emptyList.push([]) } for(var i in list){ if(list[i]<5){ emptyList[0].push(list[i]) } if(list[i]<10){ emptyList[1].push(list[i]) } if(list[i]>10){ emptyList[2].push(list[i]) } } for(var i in detailList){ detailList[i].detailArr = emptyList[i] } console.log('detailList',detailList) ----------------------------------------------------- [{name: "<5", detailArr: [1,3,4]}, {name: "<10", detailArr: [1,3,5,7,4,9]}, {name: ">10", detailArr: [11,12,13]}]
2020-03-02 - wx.cloud.uploadFile里计算的上传时间,怎么让方法外的变量延迟接收?
大佬们好,如代码所示,我想要将图片上传的时间计算出来后让方法外的变量接收,然后让我进行下一步逻辑。 但是莫得法子(试过setTimeout,但是不行),请指示!谢谢! var upBegin = new Date() for (let i = 0; i < TFP.length; i++) { console.log(i) wx.cloud.uploadFile({ cloudPath: 'warehouse/北京天安门1000000方厂房/WHImg' + i + '.png', filePath: TFP[i] }).then(res=>{ this.imgList.push(res.fileID) var upOver = new Date() this.differ = upOver - upBegin // 在这里计算图上上传需要的时间 console.log('inside',this.differ) }) } // 怎么等到differ计算出来后,云方法外的变量才接收? console.log('outside',this.differ)
2020-02-20 - 大佬们,云开发geopoint类型数据怎么更新?
大神请指教,如代码,更改了一晚,看了很多文档,实在不知道怎么样才能更新geopoint类型的数据了。谢谢! WHInfo.where({ _id:'a87a37b0-6680-4a7c-b2a4-e0d2ac34cd34', WHLAL:db.Geo.Point(112.97811,22.96833) }) .update({ data:{ WHLAL:db.Geo.Point(133,22) } })
2020-02-15 - 自定义tabbar page样式溢出?
自定义了一个tabbar,通过hidden来控制隐藏与否,可是组件1(compo)的page样式会溢出到组件2(compo2),并且修改组件2的page样式也依然被组件1的page样式覆盖。请大神看看为什么?谢谢!(用了styleIsolation:'isoloated' 没有效果) [图片] compo compo ------------------ page{ background-color: yellow; } compo2 compo2 ------------------ page{ background-color: red; } page的WXML <view hidden="{{mIndex==1?false:true}}"><compo /></view> <view hidden="{{mIndex==2?false:true}}"><compo2 /></view> <view hidden="{{mIndex==3?false:true}}"><compo3 /></view> <view class="box"> <view class="para {{mIndex==1?'active':'default'}}" bindtap="btn">恭</view> <view class="para {{mIndex==2?'active':'default'}}" bindtap="btn2">喜</view> <view class="para {{mIndex==3?'active':'default'}}" bindtap="btn3">发</view> </view> ------------------------------------------------------------------------------ Page({ data: { mIndex: 1 }, btn() { console.log('btn') this.setData({ mIndex: 1 }) }, btn2() { console.log('btn2') this.setData({ mIndex: 2 }) }, btn3() { console.log('btn3') this.setData({ mIndex: 3 }) }, }) ------------------------------------------------------------------------------ .box{ position: fixed; display: flex; bottom: 0; height: 100rpx; width: 100%; border-top: 1rpx solid black; z-index: 1; background: white; } .para{ text-align: center; flex:1; line-height: 100rpx; } .active{ color: red; } .default{ color: black; }
2020-02-03 - 新年好!我的公共方法,只能被两次引用中的一个引用,这是为什么呢?谢谢!
抱歉我的代码就是这么长,我的疑问在如下代码的注释里,请大神们耐心看一下哈!感谢! const db = wx.cloud.database() const userOrder = db.collection('userOrder') const _ = db.command const $ = _.aggregate Page({ data: { timeMode: 'twoDay', statusIndex: 0 }, onLoad() { var that = this userOrder .watch({ onChange: function (e) { let list = e.docs console.log('onLoad',list) let twoDayList = that.twoDayList(list) console.log('onLoad',twoDayList) that.handleData(twoDayList) that.handleData(twoDayList) that.setData({ list: list, // newOrderList:twoDayList.reverse(), chsDate: that.YYYYMMDD(new Date()) }) }, onError: function (err) { console.error('the watch closed because of error', err) } }) }, //为什么twoDayList只可以被引用一次? twoDay() { let list = this.data.list let two = this.twoDayList(list) // 是否twoDay的list根本就没有被引用到? console.log('twoDay',two) let twoDayList = [] for (let i in list) { if (new Date(list[i].TS) >= this.yesterdayFirstSec() && new Date(list[i].TS) <= this.todayLastSec()) { twoDayList.push(list[i]) } } this.handleData(twoDayList) console.log(twoDayList) this.setData({ newOrderList:twoDayList.reverse(), timeMode: 'twoDay' }) }, newOrder() { this.setData({ statusIndex: 0 }) }, finish() { var arr = this.data.arr var finishList = [] for (var i in arr) { if (arr[i].handled == true) finishList.push(arr[i]) } this.setData({ statusIndex: 1 }) }, orderFinish(e) { var arr = this.data.arr var index = e.currentTarget.dataset.index var id = arr[index]._id var TS = arr[index].TS userOrder.where({ _id: id, TS: TS }).update({ data: { handled: true, handleTime: new Date() } }) arr[index].handled = true arr[index].handleTime = this.time(new Date()) this.setData({ arr: arr }) }, chsDate(e) { var list = this.data.list var chsDate = e.detail.value var chsDateList = [] // console.log(list) //在这里新数组是有必要的 for (var i in list) { if (this.YYYYMMDD(list[i].TS) == chsDate) { chsDateList.push(list[i]) } } this.handleData(chsDateList) this.setData({ timeMode: 'chsDate', chsDate: chsDate, newOrderList:chsDateList.reverse() // chsDateList: chsDateList.reverse() }) }, // ------------------------------------公共方法----------------------------------- testPublic(mList){ var arr = [] arr.push(mList[0]) return arr }, twoDayList(mList){ let mTwoDayList = [] for (let i in mList) { if (new Date(mList[i].TS) >= this.yesterdayFirstSec() && new Date(mList[i].TS) <= this.todayLastSec()) { mTwoDayList.push(mList[i]) } } return mTwoDayList }, handleData(mList) { for (var i = 0; i < mList.length; i++) { mList[i].OID = this.OID(mList[i].TS, mList[i]._openid) mList[i].TS = this.time(mList[i].TS) mList[i].rank = i + 1 mList[i].nickName = this.handleName(mList[i].nickName) if (mList[i].gender == 1) { mList[i].gender = '先生' } else { mList[i].gender = '女士' } } return mList }, OID(mDate, mID) { var mId var date = new Date(mDate) / 1 * 1 var four = mID.substring(mID.length - 4) var result = date + four return result }, time(mDate) { var date = new Date(mDate) var M = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1) var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() var now = M + '-' + D + ' ' + h + ':' + m return now }, nowDate(mDate) { var date = new Date(mDate) var date2 = new Date() var Y = date.getFullYear(); var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); var D = date.getDate() var checkDate = Y + '' + M + '' + D var Y2 = date2.getFullYear(); var M2 = (date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1); var D2 = date2.getDate() var checkDate2 = Y2 + '' + M2 + '' + D2 return checkDate == checkDate2 }, todayLastSec() { var date = new Date() var Y = date.getFullYear() var M = date.getMonth() var D = date.getDate() var result = new Date(Y, M, D, '23', '59', '59') return result }, yesterdayFirstSec() { var date = new Date() var Y = date.getFullYear() var M = date.getMonth() var D = date.getDate(); var result = new Date(Y, M, D - 1, '00', '00', '01') return result }, YYYYMMDD(mDate) { var date = new Date(mDate) var Y = date.getFullYear(); var M = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() var result = Y + '-' + M + '-' + D return result }, handleName(mName) { var result = mName.replace(/[^a-zA-Z\u4e00-\u9fa5\d\s]+/g, '') var REChina = /^[\u4E00-\u9FA5\s]{0,}$/ // 中文 var REEng = /^[A-Za-z\s]+$/ // 英文 var REMath = /^[0-9\s]*$/ // 数字 if (REChina.test(result)) { return result.substring(0, 18) } else if (REEng.test(result)) { return result.substring(0, 30) } else if (REMath.test(result)) { return result.substring(0, 30) } else { return result.substring(0, 18) } } })
2020-01-24