zoukankan      html  css  js  c++  java
  • 微信小程序Rx 引入 调用合并的方法

    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);
    }
    }
    })
    })
    },
    

      

  • 相关阅读:
    C++解决单纯形表
    VS2010 MFC Excel(3)
    VS2010 MFC Excel(1)
    VS2010 MFC 读取Excel(2)
    读取数量不定的输入数据
    牛顿插值
    连接数据库
    雅克比迭代
    NOIP模拟 24
    NOIP模拟 23
  • 原文地址:https://www.cnblogs.com/alone2015/p/13728158.html
Copyright © 2011-2022 走看看