statistic_frm.html 10.1 KB
<!DOCTYPE html>
<html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
      <meta name="referrer" content="no-referrer">
      <title>统计分析_frm</title>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/api.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/aui.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/style.css"/>
      <style>
          html,
          body{
            background: #F4F6F9;
          }
      </style>
  </head>
  <body>
    <div id="app">
      <template>
        <div id="chart_area">
          <div class="store01001-info-title2">{{ measureTitle }}</div>
          <div class="store01001-chart-panel">
            <div style="padding-left:10px;padding-right:10px;padding-bottom:10px;">
              <div style="padding-top: 10px;" tapmode @click="showPopup">
                <span>{{ curMeasure }} &nbsp;</span><i></i>
              </div>
              <div style="height:1px;background:rgba(240,245,255,1);margin-top: 13.5px;margin-bottom:5px;"></div>
              <div class="tab-view-list" id="echarts_view" style="height:11.5rem;">
              </div>
              <div style="height:10px;"></div>
            </div>
          </div>
        </div>  
          <!-- <div style="height:30px;width:auto"></div> -->
      </template>
    </div>
  </body>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/api.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/vue.min.js"></script>
  <!-- <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/common.js"></script> -->
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/element.js"></script>
  <!-- <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/ctrl.js"></script> -->
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/fastclick.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/aui-popup-wjb.js" ></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/echarts.min.js"></script>  
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/common.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/ctrl.js"></script>
  <script type="text/javascript">
    var vm,
        popup,
        that;

    apiready = function(){
      api.parseTapmode();
      $(function() {
        FastClick.attach(document.body);
      }); 

      //---------初始化vue
      vm = new Vue({
        el: '#app',
        data: {
          deviceImei: api.pageParam.imei,

          chartArr: [{text:'温度',value:'r_temp',unit: '℃'},{text:'湿度',value:'r_humidity',unit: '%'}],
          userId: api.getPrefs({sync: true,key: 'userID'}),
          token: api.getPrefs({sync: true,key: 'userToken'}), 
          measureTitle: '历史测量信息趋势变化',                   
          curMeasure: '温度',
          date: parseTime((new Date()).getTime()-1000*60*60*24*1,'{y}-{m}-{d}'),
          chooseMeasure: {buttonIndex: 1, buttonTitle: '温度', buttonValue: 'r_temp', buttonUnit: '℃'},
        },
        mounted() {
          //window.chooseProduct = this.chooseProduct;
        },
        created() {
          that = this
          api.addEventListener({
            name: 'chanegSearchDate'
          }, function(ret, err){
            console.log(JSON.stringify(ret));
            that.date = ret.value.selected_time
            that.chooseMeasureType(that.chooseMeasure)
          });
          setTimeout(() => {
            this.chooseMeasureType(this.chooseMeasure)  
          }, 1000);
        },
        methods: {
          showPopup() {
            popup = new auiPopup();
            popup.init({
                frameBounces:true,//当前页面是否弹动,(主要针对安卓端)
                location: 'bottom-right',//位置,top(默认:顶部中间),top-left top-right,bottom,bottom-left,bottom-right
                buttons:  this.chartArr,
            },function(ret){
                if(ret){
                  that.chooseMeasure = ret
                  that.chooseMeasureType(ret)
                  that.curMeasure = ret.buttonTitle
                }
            })              
          },
          async chooseMeasureType(ret) {  //
            const params = {
              imei: this.deviceImei,
              token: this.token,
              chartType: ret.buttonValue,
              date: this.date
            }
            console.log(JSON.stringify(ret));
            let lineColor = '#5B7FF8'
            if (ret.buttonTitle === '温度') {
              lineColor = '#5B7FF8'
            }else {
              lineColor = '#70C248'
            }
            
            var echartDom = document.getElementById("echarts_view");
            let dailyRes = await get_normal_daily_chart(params)
            if (dailyRes.success == 1) {
              var myChart = echarts.init(echartDom);
              var option = {
                title: {
                    left: 'center',
                    text: ret.buttonTitle+'趋势变化图',
                },
                grid: {
                  //  top: 50,
                    x: 45,
                    x2: 20,
                    y: 50,
                },
                tooltip: {
                    trigger: 'axis',
                    position: 'top',
                    formatter: function (params) {
                          params = params[0];
                          return params.axisValue+'<br />'+params.marker+params.seriesName+'值 '+params.data+ ret.buttonUnit;
                      },
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: dailyRes.data.xdata.map(function(item){
                      return item.substring(11,16)
                    }),
                    axisLine: {
                        lineStyle: {
                            color: '#B0C8FF'
                        }
                    },
                    axisLabel: {
                      textStyle: {
                        color: function (value, index) {
                            return '#818295';
                        }
                      },
                      rotate:330
                    }
                },
                yAxis: {
                    type: 'value',
                    boundaryGap: [0, '100%'],
                    //y轴颜色
                    axisLine: {
                        lineStyle: {
                            color: '#fff'
                        }
                    },
                    axisLabel: {
                        formatter: '{value}'+ ret.buttonUnit,
                        textStyle: {
                          color: function (value, index) {
                              return value >= 0 ? '#818295' : 'red';
                          }
                        },
                        interval: 0,//让所有坐标值全部显示
                        rotate:30,//让坐标值旋转一定的角度
                    },
                    splitLine:{
                      show:true  ,
                      lineStyle:{
                        color:'#F0F5FF',
                        width: 1
                      }
                    }
                },
                dataZoom: [
                  {
                    type: 'slider',
                    fillerColor: '#B0C8FF',
                    backgroundColor: '#F0F5FF',
                    start: 0,
                    end: 100,
                    handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                    handleSize: '90%',
                    handleStyle: {
                        color: '#5B7FF8',
                    },
                    dataBackground:{
                        lineStyle:{
                            color:'#B0C8FF'
                        },
                        areaStyle:{
                            color:'#F0F5FF',
                            opacity:1,
                        }
                    },
                    bottom:'0%'
                  },{
                      type: 'inside',//这个 dataZoom 组件是 inside 型 dataZoom 组件(能在坐标系内进行拖动,以及用滚轮(或移动触屏上的两指滑动)进行缩放)
                      xAxisIndex: 0,//控制x轴
                  }
                ],
                series: [{
                    data: dailyRes.data.ydata[ret.buttonValue],
                    name: ret.buttonTitle,
                    type:'line',
                    showSymbol: true,
                    hoverAnimation: false,
                    symbol: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z',
                    symbolSize: 8,
                    // 折线颜色
                    itemStyle: {
                      normal: {
                          color: lineColor,
                          lineStyle: {
                              color: lineColor
                          }
                      }
                    },
                }]
              };
              if (option && typeof option === "object") {
                myChart.setOption(option, true);
              }
            }
          },
        }
      })
    }
  </script>
</html>