submit(){ const {radio,dateStartText,dateendText} =this.data console.log(radio) if(radio==‘‘){ Toast(‘请选择子设备‘) return; } // if(!dateStartText||!dateendText){ // Toast(‘请选择日期‘) // return; // } let arrData=wx.getStorageSync(‘subDeviceData‘) arrData=arrData.filter(item=>item.name) let dataType={} let dataArrsy=[] let timestamp = Date.parse(new Date()); timestamp = timestamp / 1000; arrData.forEach((item,index)=>{ console.log(item.deviceName) dataArrsy.push(dataType={ IotId:item.iotId, identifier:item.radio, time:timestamp, // endTime:this.data.dateendText, // pageSize:100, // productKey:item.productKey, deviceName:item.deviceName }) }) console.log(dataArrsy,‘dataArrsy‘) function sum(arr) {//数组的数字相加 return arr.reduce(function(prev, curr, idx, arr){ return prev + curr; }); } const httpList=[] const numLength=[] for(var i=0;i<arrData.length;i++){ httpList.push(this.getproxy(dataArrsy[i],dataArrsy[i].deviceName)) } Rx.Observable.forkJoin(httpList) .subscribe(resp => { resp.forEach((item,index)=>{ numLength.push(item.data.length) }) console.log(sum(numLength)==0,sum(numLength)) if(sum(numLength)==0){ wx.showToast({ title:‘暂无数据可以展示‘, // 提示的内容, icon: ‘none‘, // 图标, mask: true, // 显示透明蒙层,防止触摸穿透, success: res => { } }); return; } wx.setStorageSync(‘radio‘, radio) wx.setStorageSync(‘deviceProperties‘, resp) wx.setStorageSync(‘chooseService‘, resp) wx.navigateTo({ url: ‘/pages/index/listSWG/exhibition/charts‘, }) }) }, getproxy(data,deviceName){ return new Rx.Observable(observer=>{ http.request({ url: ‘p-net-deviceProperties-time‘, method: ‘POST‘, data, success: (res) => { if (res.code==‘ok‘) { console.log(res) res.deviceName=deviceName observer.next(res); observer.complete(); } else { Toast(res.data || res.message) wx.showToast({ title: res.data, // 提示的内容, icon: ‘none‘, // 图标, mask: true, // 显示透明蒙层,防止触摸穿透, success: res => { } }); observer.error(res); } } }) }) },