var starter = angular.module('starter.controllers', []) //登录页面控制器 starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$ionicPopup',function($scope,$state,$ionicLoading,$timeout,$ionicPopup){ $scope.vm = { mobile:'', password:'' }; $scope.login = function(){ if($scope.vm.username == 'admin' && $scope.vm.password == 'admin'){ $ionicLoading.show({ template: '
' }); $timeout(function(){ $ionicLoading.hide(); $state.go('home') },1500); }else{ var alertPopup = $ionicPopup.alert({ title: '账号密码不正确', template: '唯一账号密码:admin!!!' }); $timeout(function() { ionicMaterialInk.displayEffect(); }, 0); } } }]) //主页面控制器 starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$state',function($scope,$http,$timeout,$ionicLoading,$state){ $http({ method:'get', url:'http://172.31.40.29/list', }).success(function(newItem){ $scope.excals = newItem }) $scope.doRefresh = function(){ $ionicLoading.show({ tcontent: 'Loading', animation: 'fade-in', showBackdrop: true, maxWidth: 200, showDelay: 0 }); $http({ method:'get', url:'http://172.31.40.29/list', }).success(function(newItem){ $timeout(function(){ $ionicLoading.hide(); $scope.excals = newItem }); }) .finally(function() { $scope.$broadcast('scroll.refreshComplete'); }); } $scope.getName = function(item){ name = this.$$watchers[0].last; $state.go('show',{item:name}) } }]) //数据展示控制器 starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$http',function($scope,$ionicHistory,$state,$http){ $scope.tabs = [{"title":"主页","url":"line.html"}, {"title":"TN曲线","url":"tn.html"}, {"title":"五轴图","url":"zhou.html"}, {"title":"效率云图","url":"strom.html"}]; $scope.name = name; $scope.go = function(result){ $state.go(result) }; $scope.isActiveTab = function(tabUrl){ return tabUrl == $scope.currentTab; }; $scope.onClickTab = function(tab){ $scope.currentTab = tab.url; if(tab.title==="TN曲线"){ $http({ method:'get', url:'http://172.31.40.29/data/'+name }).success(function(req){ $scope.item= req.speed; $scope.data = [req.torque,req.v,req.p,req.a,req.efficiency] }) } }; //TN曲线图 $scope.legend = ["扭矩", "电压",'输入功率','电流','效率']; $scope.item = ['200rpm','400rpm','600rpm','800rpm','1000rpm','1200rpm','1400rpm','1600rpm','1800rpm','2000rpm','2200rpm','2400rpm']; $scope.num = [0,1,2,3,4]; $scope.data = [ [1,1,1,1,1,1,1,1,1,1,1,1], //扭矩 [196,196,196,196,196,196,196,196,196,196,196,196,], //电压 [500,500,500,500,500,500,500,500,500,500,500,500,], //输入功率 [4,4,4,4,4,4,4,4,4,4,4,4], //电流 [68,68,68,68,68,68,68,68,68,68,68,68,]//效率 ]; }]) starter.directive('line', function() { return { scope: { id: "@", legend: "=", item: "=", num:"=", data: "=" }, restrict: 'E', template: '', replace: true, link: function($scope, element, attrs, controller) { var colors = ['#a62ca6', '#8e0515', '#45baf3','#ff2420','#1a9a1a']; var option = { color:colors, // 提示框,鼠标悬浮交互时的信息提示 tooltip: { show: true, trigger: 'axis' }, grid:{ left:'23%' }, //图例 legend: { data: $scope.legend , textStyle:{ fontSize:22 } }, // toolbox: { // feature: { // dataView: {show: true, readOnly: false}, // restore: {show: true}, // saveAsImage: {show: true} // } // }, // 横轴坐标轴 xAxis: [ { type: 'category', // boundaryGap:false, axisLabel:{ textStyle:{ fontSize:20 } }, data: $scope.item } ], // 纵轴坐标轴 yAxis: [ { type: 'value', // name: '扭\n矩\n(N*m)', min: 0, max: 4, position: 'left', offset:205, axisLine: { lineStyle: { color: colors[0], width:2 } }, axisLabel:{ margin:20, textStyle:{ fontSize:18 } } }, { type: 'value', // name: '电\n压\n(V)', min: 193, max: 202, position: 'left', offset: 150, axisLine: { lineStyle: { color: colors[1], width:2 } }, axisLabel:{ margin:15, textStyle:{ fontSize:18 } }, }, { type: 'value', // name: '输\n入\n功\n率\n(W)', min: 0, max: 1300, position: 'left', offset:90, axisLine: { lineStyle: { color: colors[2], width:2 } }, axisLabel:{ textStyle:{ fontSize:18 } }, }, { type: 'value', // name: '电\n流\n(A)', min: 1, max: 6, position: 'left', offset:45, axisLine: { lineStyle: { color: colors[3], width:2 } }, axisLabel:{ margin:20, textStyle:{ fontSize:18 } }, }, { type: 'value', // name: '效\n率\n(%)', min: 10, max: 80, position: 'left', offset:0, axisLine: { lineStyle: { color: colors[4], width:2 } }, axisLabel:{ margin:15, textStyle:{ fontSize:18 } }, } ], // 数据内容数组 series: function(){ var serie=[]; for(var i=0;i<$scope.legend.length;i++){ var item = { name : $scope.legend[i], type: 'line', yAxisIndex:$scope.num[i], data: $scope.data[i] }; serie.push(item); } return serie; }() }; var myChart = echarts.init(document.getElementById($scope.id),'macarons'); myChart.setOption(option); } }; })