lxnd 8 лет назад
Родитель
Сommit
d74313f7f4

+ 12 - 11
yanshi/www/index.html

xqd xqd
@@ -23,17 +23,7 @@
     <link href="css/ionic.app.css" rel="stylesheet">
     -->
 
-    <!-- ionic/angularjs js -->
-    <script src="lib/ionic/js/ionic.bundle.js"></script>
-		<script src="js/echarts.min.js"></script>
-    <!-- cordova script (this will be a 404 during development) -->
-    <script src="cordova.js"></script>
-
-    <!-- your app's js -->
-    <script src="js/app.js"></script>
-    <script src="js/config.js"></script>
-    <script src="js/controllers.js"></script>
-    <script src="js/services.js"></script>
+ 
   </head>
   <body ng-app="starter">
     <!--
@@ -48,3 +38,14 @@
     <ion-nav-view></ion-nav-view>
   </body>
 </html>
+   <!-- ionic/angularjs js -->
+<script src="lib/ionic/js/ionic.bundle.js"></script>
+<script src="js/echarts.min.js"></script>
+<!-- cordova script (this will be a 404 during development) -->
+<script src="cordova.js"></script>
+
+<!-- your app's js -->
+<script src="js/app.js"></script>
+<script src="js/config.js"></script>
+<script src="js/controllers.js"></script>
+<script src="js/service/nameService.js"></script>

+ 6 - 38
yanshi/www/js/app.js

xqd
@@ -53,48 +53,16 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
   			controller:'homeCtrl'
   		}
   	}
-  	
   })
-   .state('line',{
-  	url:'/line',
-  	views:{
-  		'':{
-  			templateUrl:'templates/show/line.html',
-  			controller:'lineCtrl'
-  		}
-  	}
-  })
-  .state('tn',{
-  	url:'/tn',
-  	views:{
-  		'':{
-  			templateUrl:'templates/show/tn.html',
-  			controller:'tnCtrl'
-  		}
-  	}
-  })
- 
-  
-  .state('zhou',{
-  	url:'/zhou',
-  	views:{
-  		'':{
-  			templateUrl:'templates/show/zhou.html',
-  			controller:'zhouCtrl'
-  		}
-  	}
-  })
-	.state('strom',{
-  	url:'/strom',
-  	views:{
-  		'':{
-  			templateUrl:'templates/show/strom.html',
-  			controller:'stromCtrl'
-  		}
-  	}
+  .state('show',{
+  	url:'/show',
+  	params:{item:null},
+  	templateUrl:'templates/show.html',
+  	controller:'showCtrl'
   })
 
 
+
  
 
   // if none of the above states are matched, use this as the fallback

+ 67 - 89
yanshi/www/js/controllers.js

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -1,5 +1,5 @@
 var starter = angular.module('starter.controllers', [])
-
+//登录页面控制器
 starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$ionicPopup',function($scope,$state,$ionicLoading,$timeout,$ionicPopup){
 	$scope.vm = {
 		mobile:'',
@@ -16,12 +16,6 @@ starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$i
         },1500);
 			
 		}else{
-//			$scope.showAlert = function(){
-//				var alertPopup = $ionicPopup.alert({
-//					title:'账号密码不正确',
-//					template:'唯一账号密码---admin'
-//				})
-//			}
 			var alertPopup = $ionicPopup.alert({
             title: '账号密码不正确',
             template: '唯一账号密码:admin!!!'
@@ -31,18 +25,17 @@ starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$i
             ionicMaterialInk.displayEffect();
         }, 0);
 		}
-	}
-	
-	
+	}	
 }])
-
-starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading',function($scope,$http,$timeout,$ionicLoading){
+//主页面控制器
+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',
@@ -51,72 +44,70 @@ starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading',funct
 		    maxWidth: 200,
 		    showDelay: 0 
         });
-        $timeout(function(){
-        	$ionicLoading.hide();
         	$http({
         		method:'get',
         		url:'http://172.31.40.29/list',
         	}).success(function(newItem){
-        		$scope.excals = newItem
+	        $timeout(function(){
+	        	$ionicLoading.hide();
+	        		$scope.excals = newItem
+	        });
         	})
             .finally(function() {
-                $scope.$broadcast('scroll.refreshComplete');
+	              $scope.$broadcast('scroll.refreshComplete');
             });
-        },1000);
 		
 	}
-}])
-
-//starter.factory('getData',['$http','$q',function($http,$q){
-//	return function(){
-//		var defer = $q.defer();
-//		$http.get('../lib/ionic/test2.json')
-//		.success(function(data,status,headers,congfig){
-//			defer.resolve(data)
-//		}).error(function(data,status,headers,congfig){
-//			defer.reject(data);
-//		});
-//		return defer.promise
-//	}
-//}])
+	
 
-//展示首页控制器
-starter.controller('lineCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
-	$scope.go = function(target){
-		$ionicHistory.clearHistory();
-		$state.go(target)
+		$scope.getName = function(item){
+			name = this.$$watchers[0].last;
+			$state.go('show',{item:name})
 	}
 }])
-
-
-//TN曲线控制器
-starter.controller('tnCtrl',["$scope",'$ionicHistory','$state','$http',function($scope,$ionicHistory,$state,$http){
-	$scope.go = function(target){
-		$ionicHistory.clearHistory();
-		$state.go(target)
-	}
-	$scope.legend = ["扭矩", "电压",'输入功率','电流','效率'];  
-	
-//	$http.get('../lib/ionic/test2.json')
-//	.success(function(newItems){
-//		$scope.item = newItems.items;
-//		console.log($scope.item)
-//	})
 	
 	
-	
-    $scope.item = ['200rpm','400rpm','600rpm','800rpm','1000rpm','1200rpm','1400rpm','1600rpm','1800rpm','2000rpm','2200rpm']; 
-    console.log($scope.item)
-    $scope.num = [0,1,2,3,4];
-    $scope.data = [  
-        [0.2,0.8,1.6,2.7,1.3,3.0,2.5,1.1,3.1,0.5,1.4,2.8,1.1], //扭矩  
-        [0, 1, 4, 7, 12, 15, 16, 15, 15, 10, 6, 5], //电压 
-        [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],    //输入功率  
-        [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],   //电流
-        [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]//效率
-    ];  
-}]);  
-  
+
+//数据展示控制器
+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 {  
@@ -141,13 +132,13 @@ starter.directive('line', function() {
                 },  
                 grid:{
 
-                	left:'28%'
+                	left:'23%'
                 },
                    	//图例  
                 legend: {  
                     data: $scope.legend ,
                     textStyle:{
-                    	fontSize:20
+                    	fontSize:22
                     }
                 }, 
 //              toolbox: {
@@ -161,12 +152,10 @@ starter.directive('line', function() {
                 xAxis: [
 			        {
 			            type: 'category',
-			            axisTick: {
-			                alignWithLabel: true
-			            },
+//			            boundaryGap:false,
 			            axisLabel:{
 		            		textStyle:{
-		            		fontSize:18
+		            		fontSize:20
 		            	}
 		            },
 			            data: $scope.item
@@ -191,7 +180,7 @@ starter.directive('line', function() {
 		            axisLabel:{
 		            	margin:20,
 		            	textStyle:{
-		            		fontSize:17
+		            		fontSize:18
 		            	}
 		            }
 		        },
@@ -211,7 +200,7 @@ starter.directive('line', function() {
 		             axisLabel:{
 		             	margin:15,
 		            	textStyle:{
-		            		fontSize:17
+		            		fontSize:18
 		            	}
 		            },
 		        },
@@ -230,7 +219,7 @@ starter.directive('line', function() {
 		            },
 		             axisLabel:{
 		            	textStyle:{
-		            		fontSize:17
+		            		fontSize:18
 		            	}
 		            },
 		        },
@@ -250,7 +239,7 @@ starter.directive('line', function() {
 		       		  axisLabel:{
 		       		  	margin:20,
 		            	textStyle:{
-		            		fontSize:17
+		            		fontSize:18
 		            	}
 		            },
 		        },
@@ -270,7 +259,7 @@ starter.directive('line', function() {
 		              axisLabel:{
 		              	margin:15,
 		            	textStyle:{
-		            		fontSize:17
+		            		fontSize:18
 		            	}
 		            },
 		        }
@@ -296,17 +285,6 @@ starter.directive('line', function() {
         }  
     };  
 })
-//五轴图控制器
-starter.controller('zhouCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
-	$scope.go = function(target){
-		$ionicHistory.clearHistory();
-		$state.go(target)
-	}
-}])
-//效率云图控制器
-starter.controller('stromCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
-	$scope.go = function(target){
-		$ionicHistory.clearHistory();
-		$state.go(target)
-	}
-}])
+
+
+

+ 16 - 0
yanshi/www/js/service/nameService.js

xqd
@@ -0,0 +1,16 @@
+(function(starter){
+	 starter.factory('nameService',['$http','data','util',function($http,data,util){
+		return {
+			getName:function(name){
+				return $http({
+					url:'http://172.31.40.29/data',
+					method:'get',
+					data:name
+				})
+			}	
+		};
+	}]);
+})(angular.module('starter.services'));
+ 
+
+

+ 0 - 13
yanshi/www/js/services.js

xqd
@@ -1,13 +0,0 @@
-angular.module('starter.services', [])
-
-//starter.factory("lineService",["$q","$http",function($q,$http){
-//	return{
-//		get_excal:function(excals){
-//			return $http({
-//				url:'http://172.31.40.29/list',
-//				method:"get"
-//			})
-//		}
-//	}
-//}])
-

+ 0 - 6
yanshi/www/lib/ionic/test.json

xqd
@@ -1,6 +0,0 @@
-
-	[
-		"测试2","测试三"
-	]
-
-	

+ 1 - 1
yanshi/www/templates/home.html

xqd
@@ -5,7 +5,7 @@
     <ion-scroll direction="y" class="pList-scroll"> 
     	<ion-refresher pulling-text="下拉刷新" on-refresh="doRefresh()"></ion-refresher>
          <ion-list>
-         	<ion-item style="border-bottom: 1px solid gray;" ng-repeat = "excal in excals" href="#/line">
+         	<ion-item style="border-bottom: 1px solid gray;" ng-repeat = "excal in excals" ng-click="getName(excal)">
          		{{excal}}
          	</ion-item>
          </ion-list>

+ 1 - 1
yanshi/www/templates/login.html

xqd
@@ -1,4 +1,4 @@
-<ion-view >
+<ion-view>
   <ion-content overflow-scroll="true" style="overflow: hidden;" >
     <div style="font-weight: bold;font-family: '微软雅黑';font-size:28px;text-align: center;margin: 20% 0 10px ;opacity: 0.6;">高速永磁电机测试</div>
     <div style="font-weight: bold;font-family: '微软雅黑';font-size:28px;text-align: center;opacity: 0.6;">移动数据系统</div>

+ 35 - 0
yanshi/www/templates/show.html

xqd
@@ -0,0 +1,35 @@
+<ion-view>
+	<div class="bar bar-header">
+	  <button class="icon ion-chevron-left" style="font-size: 16px;border: none;background: white;" ng-click="go('home')">返回</button>
+	  <h1 class="title">{{name}}</h1>
+	</div>
+	<ion-content overflow-scroll="true" style="overflow: hidden;" class="has-header">
+			<div ng-include="currentTab"></div>
+		<div class="tabs">
+		  <a ng-repeat="tab in tabs" class="tab-item" 
+		  	ng-class="{active:isActiveTab(tab.url)}"
+		  	ng-click="onClickTab(tab)">{{tab.title}}
+		  </a>
+		</div>
+	</ion-content>
+	<script id="line.html" type="text/ng-template">
+		<div>主页</div>
+	</script>	
+	<script id="tn.html" type="text/ng-template">
+		<div>
+			<line id="main" legend="legend" item="item" data="data" num="num"></line> 
+		</div>
+	</script>
+	<script id="zhou.html" type="text/ng-template">
+		<div>
+			五轴图
+		</div>
+	</script>
+	<script id="strom.html" type="text/ng-template">
+		<div>效率云图</div>
+	</script>
+</ion-view>
+
+
+	
+	

+ 0 - 24
yanshi/www/templates/show/line.html

xqd
@@ -1,24 +0,0 @@
-<ion-view>
-	<ion-header-bar class="bar-stable">
-		<a class="button icon-left ion-chevron-left button-clear button-dark" ng-click=go('home')>返回</a>
-		<h1 class="title" style="text-align: center;">主页</h1>
-	</ion-header-bar>
-	<ion-content class="has-header">
-	主页
-	  
-	</ion-content>
-	<div class="tabs">
-	  <a class="tab-item" href="#/line">
-	    主页
-	  </a>
-	  <a class="tab-item" href="#/tn">
-	   TN曲线
-	  </a>
-	  <a class="tab-item" href="#/zhou">
-	    五轴图
-	  </a>
-	  <a class="tab-item" href="#/strom">
-	    效率云图
-	  </a>
-	</div>
-</ion-view>

+ 0 - 26
yanshi/www/templates/show/strom.html

xqd
@@ -1,26 +0,0 @@
-<ion-view>
-	<ion-header-bar class="bar-stable">
-		<a class="button icon-left ion-chevron-left button-clear button-dark" ng-click=go('home')>返回</a>
-		<h1 class="title" style="text-align: center;">效率云图</h1>
-	</ion-header-bar>
-	<ion-content overflow-scroll="true" style="overflow: hidden;" class="has-header" >
-	<div  style="line-height: 44px;width: 100%;background-color: #11C1F3;text-align: center;font-size: 20px;color: white;">
-		效率云图
-	</div>
-	  
-	</ion-content>
-	<div class="tabs">
-	  <a class="tab-item" href="#/line">
-	    主页
-	  </a>
-	  <a class="tab-item" href="#/tn">
-	   TN曲线
-	  </a>
-	  <a class="tab-item" href="#/zhou">
-	    五轴图
-	  </a>
-	  <a class="tab-item" href="#/strom">
-	    效率云图
-	  </a>
-	</div>
-</ion-view>

+ 0 - 29
yanshi/www/templates/show/tn.html

xqd
@@ -1,29 +0,0 @@
-<ion-view>
-	<ion-header-bar class="bar-stable">
-		<a class="button icon-left ion-chevron-left button-clear button-dark" ng-click=go('home')>返回</a>
-		<h1 class="title" style="text-align: center;">TN曲线</h1>
-	</ion-header-bar>
-	<ion-content overflow-scroll="true" style="overflow: hidden;" class="has-header" >
-	<div  style="line-height: 44px;width: 100%;background-color: #11C1F3;text-align: center;font-size: 20px;color: white;">
-		TN曲线
-	</div>
-	<div>
-		<line id="main" legend="legend" item="item" data="data" num="num"></line> 
-	</div>
-	
-	</ion-content>
-	<div class="tabs">
-	  <a class="tab-item" href="#/line">
-	    主页
-	  </a>
-	  <a class="tab-item" href="#/tn">
-	   TN曲线
-	  </a>
-	  <a class="tab-item" href="#/zhou">
-	    五轴图
-	  </a>
-	  <a class="tab-item" href="#/strom">
-	    效率云图
-	  </a>
-	</div>
-</ion-view>

+ 0 - 25
yanshi/www/templates/show/zhou.html

xqd
@@ -1,25 +0,0 @@
-<ion-view>
-	<ion-header-bar class="bar-stable">
-		<a class="button icon-left ion-chevron-left button-clear button-dark" ng-click=go('home')>返回</a>
-		<h1 class="title" style="text-align: center;">五轴图</h1>
-	</ion-header-bar>
-	<ion-content overflow-scroll="true" style="overflow: hidden;" class="has-header" >
-	<div  style="line-height: 44px;width: 100%;background-color: #11C1F3;text-align: center;font-size: 20px;color: white;">
-		五轴图
-	</div>
-	</ion-content>
-	<div class="tabs">
-	  <a class="tab-item" href="#/line">
-	    主页
-	  </a>
-	  <a class="tab-item" href="#/tn">
-	   TN曲线
-	  </a>
-	  <a class="tab-item" href="#/zhou">
-	    五轴图
-	  </a>
-	  <a class="tab-item" href="#/strom">
-	    效率云图
-	  </a>
-	</div>
-</ion-view>