Mike 8 years ago
parent
commit
35dbd8e7e1

+ 1 - 1
yanshi/config.xml

xqd
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<widget id="com.ionicframework.myapp576034" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="com.ionicframework.myapp576034" version="0.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
   <name>移动数据应用系统</name>
   <description>
         An Ionic Framework and Cordova project.

BIN
yanshi/resources/android/icon/drawable-hdpi-icon.png


BIN
yanshi/resources/android/icon/drawable-ldpi-icon.png


BIN
yanshi/resources/android/icon/drawable-ldpi-icon.png.png


BIN
yanshi/resources/android/icon/drawable-mdpi-icon.png


BIN
yanshi/resources/android/icon/drawable-xhdpi-icon.png


BIN
yanshi/resources/android/icon/drawable-xxhdpi-icon.png


BIN
yanshi/resources/android/icon/drawable-xxxhdpi-icon.png


BIN
yanshi/resources/icon.png


+ 76 - 136
yanshi/www/js/controllers.js

xqd xqd xqd xqd
@@ -30,24 +30,31 @@ starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$i
 }])
 //主页面控制器
 starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$state','$ionicPopup','config',function($scope,$http,$timeout,$ionicLoading,$state,$ionicPopup,config){
-	$http({
-    		method:'get',
-    		url:config.server+'/list',
-    	}).success(function(newItem){
-    		$scope.excals = newItem
-    	})
-    
-	$scope.doRefresh = function(){
+	$scope.doRefresh = function(sec){
+		if($scope.isChecked.checked){
+			mytimer = $timeout(function() {
+				$scope.doRefresh(sec);
+			}, sec*1000);
+			localStorage.refreshtime=sec;
+		}else{
+      		$timeout.cancel(mytimer);
+			localStorage.refreshtime=0;
+		} 
+		console.log(mytimer); 
+		$scope.refresh();
+	}
+
+	$scope.refresh = function(){
 		$ionicLoading.show({
-            template: '加载中...',
-        });
-    	$http({
+          template: '加载中...',
+    	});
+		$http({
     		method:'get',
     		url:config.server+'/list',
     	}).success(function(newItem){
 	        $timeout(function(){
-	        	$ionicLoading.hide();
 	        	$scope.excals = newItem
+	        	$ionicLoading.hide();
 	        });
     	}).error(function(){
     		$timeout(function(){
@@ -66,142 +73,72 @@ starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$sta
         .finally(function() {
               $scope.$broadcast('scroll.refreshComplete');
         });
-		
 	}
+	var mytimer;
+	$scope.$on('$ionicView.beforeEnter', function () {
+	    $scope.refreshtime = 5;
+		$scope.isChecked = { checked: localStorage.refreshtime!=0?true:false };
+	    if(localStorage.refreshtime!=0){ 
+	    	$scope.refreshtime = localStorage.refreshtime;
+	      	$timeout.cancel(mytimer);
+			$scope.doRefresh(localStorage.refreshtime);
+	    }else{
+			$scope.refresh();
+	    }
+	});
+	$scope.$on('$ionicView.beforeLeave', function () { 
+		console.log(mytimer); 
+	    $timeout.cancel(mytimer);
+	});
 	$scope.getName = function(name){
 		$state.go('show',{item:name});
 	}
+	$scope.blur = function(sec){
+		if($scope.isChecked.checked){
+			localStorage.refreshtime=sec;
+		}else{
+			localStorage.refreshtime=0;
+		} 
+	}
 }])
 	
 //数据展示控制器
 starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$stateParams','$http','$ionicLoading','$ionicPopup','config',function($scope,$ionicHistory,$state,$timeout,$stateParams,$http,$ionicLoading,$ionicPopup,config){
+    var newtimer;
     $scope.$on('$ionicView.beforeEnter', function () {
-    	$http({
-    		method:'get',
-    		url:config.server+'/list',
-    	}).success(function(newItem){
-    		$scope.excels = newItem
-    	})
     	name = $stateParams.item;
     	$scope.name = name;
-    	$ionicLoading.show({
-            template: '加载中...',
-        });
-    	$http({
-			method:'get',
-			url:config.server+'/data/'+name
-		}).success(function(req){
-			$timeout(function() {
-		        $ionicLoading.hide();
-		        //主页参数
-		        $scope.table1 = req.t.t1;
-		        $scope.table2 = req.t.t2;
-		        $scope.table3 = req.t.t3;
-		        $scope.table4 = req.t.t4;
-		        
-		        //tn曲线图参数
-				$scope.item1= req.speed;
-				$scope.data2 = [req.torque,req.v,req.p,req.a,req.efficiency];
-				//五轴图参数
-				$scope.item2 = req.nj;
-				$scope.data3 = [req.glys,req.ssgl,req.xl,req.zs,req.dl];
-				//效率云图
-				$scope.item3= req.n_speed;
-				$scope.data4 = [req.n_torque,req.n_v,req.n_p,req.n_a,req.n_efficiency];
-				console.log(req.n_speed);
-				console.log($scope.data4);
-				
-// 				var Stat = G2.Stat;
-// 	    		var vvvdata = [];
-// //	    for(var i = 0; i <= 20; i ++) {
-// //	        for(var j = 0; j <= 20; j ++) {
-// //	          var x = i*25.6;
-// //	          var y = j*19.2;
-// //	          var z = 700-(x+0.5*y)+Math.random()*(400); 
-// //	          console.log(x);
-// //	          console.log(y);
-// //	          console.log(z);
-// //	          
-// //	        }
-// //	    }
-// 				var data1 = $scope.a;
-// 				var data2 = $scope.b;
-// 				var data3 = $scope.c;
-				
-// 				for(var i=0;i<=212;i++){
-// 					var x = data1[i];
-// 					var y = data2[i];
-// 					var z = data3[i];
-// 					vvvdata.push({
-// 			            l:x,
-// 			            g: y,
-// 			            Altitude:z
-// 			        });
-// 					    console.log(x+'x')
-// 						console.log(y+'y')
-// 						console.log(z+'z')
-// 				}
-				
-	    
-//       var chart = new G2.Chart({
-//         id: 'c1',
-//         forceFit: true,
-//         height: 1000
-//       });
-//       //为了将数据与图片上的位置完全吻合,我们需要将横轴和纵轴的范围设定为数据对应范围,并将范围优化处理关闭
-//       var defs = {
-//         'l': {
-//           type: 'linear',
-//           min: 2735,
-//           max: 2900,
-//           nice: false//优化处理关闭
-//         },
-//         'g': {
-//           type: 'linear',
-//           min: 0,
-//           max: 2,
-//           nice: false
-//         },
-//         'Altitude': {
-//           tickCount:5
-//         }
-//       };
-
-//       chart.source(vvvdata,defs);
-//       chart.contour().position(Stat.smooth.loess.triangular('l*g*Altitude',0.01)).color('Altitude','hue').size(3);
-//       chart.render();
-// 		document.getElementById('newchats').style.display='none';
-				
-			});
-		}).error(function(){
-			$timeout(function(){
-				$ionicLoading.hide();
-				var alertPopup = $ionicPopup.alert({
-	            title: '连接超时',
-	            buttons: [
-			       {
-			         text: '<b>确定</b>',
-			         type: 'button-calm',
-			       },
-			     ]
-		        });
-			})
-		})	
-		
-		
+       	$scope.doSelected(name);
     });
+    $scope.$on('$ionicView.beforeLeave', function () {
+	    $timeout.cancel(newtimer);
+	});
 
-    $scope.change = function(selectedName){
-    	$scope.name = selectedName;
+    $scope.change = function(name){
+      	$timeout.cancel(mytimer);
+    	$scope.name = name;
+       	$scope.doSelected(name);
+	}
+	$scope.doSelected = function(name){
+		if(localStorage.refreshtime!=0){
+			newtimer = $timeout(function() {
+       			$scope.doSelected(name);
+			}, localStorage.refreshtime*1000);
+		}else{
+      		$timeout.cancel(mytimer);
+		}
+		$scope.selectedName(name);
+	}
+    
+	$scope.selectedName = function(name){
 		$ionicLoading.show({
             template: '加载中...',
         });
     	$http({
 			method:'get',
-			url:config.server+'/data/'+selectedName
+			url:config.server+'/data/'+name
 		}).success(function(req){	
-		    $ionicLoading.hide();
-			$timeout(function() {
+			// $timeout(function() {
 				 //主页参数
 		        $scope.table1 = req.t.t1;
 		        $scope.table2 = req.t.t2;
@@ -213,9 +150,15 @@ starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$st
 				//五轴图参数
 				$scope.item2 = req.nj;
 				$scope.data3 = [req.glys,req.ssgl,req.xl,req.zs,req.dl];
-			});
+				//效率云图
+				$scope.item3= req.n_speed;
+				$scope.data4 = [req.n_torque,req.n_v,req.n_p,req.n_a,req.n_efficiency];
+				// console.log(req.n_speed);
+				// console.log($scope.data4);
+			// });
+		    $ionicLoading.hide();
 		}).error(function(){
-			$timeout(function(){
+			// $timeout(function(){
 				$ionicLoading.hide();
 				var alertPopup = $ionicPopup.alert({
 	            title: '连接超时',
@@ -226,12 +169,9 @@ starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$st
 			       },
 			     ]
 		        });
-			})
-		})
+			// })
+		});
 	}
-    
-    	
-
 	$scope.tabs = [
 	{"title":"主页","url":"line.html"},
 	{"title":"TN曲线","url":"tn.html"},

+ 13 - 3
yanshi/www/templates/home.html

xqd
@@ -1,9 +1,19 @@
 <ion-view>
 	<ion-content scroll="false">
         <div style="text-align: center;font-size: 20px;font-family: '微软雅黑';font-weight: bold;opacity: 0.6;margin-top: 5%;">测试数据表格汇总</div>
-		<button ng-click="doRefresh()" class="button button-calm button-small" style="font-weight: bold;font-size: 14px;font-family: '微软雅黑';margin: 5% 0 5% 5%;">刷新任务</button>
-    <ion-scroll direction="y" class="pList-scroll"> 
-    	<ion-refresher pulling-text="下拉刷新" on-refresh="doRefresh()"></ion-refresher>
+<br>
+<div class="list" style="margin: 0">
+  <label class="item item-input">
+    <span class="input-label">刷新间隔(秒):</span>
+    <input type="text" placeholder="秒" ng-model="refreshtime" ng-blur="blur(refreshtime)">
+  </label>
+  <ion-checkbox ng-model="isChecked.checked"
+            ng-change="doRefresh(refreshtime)">
+    自动刷新
+  </ion-checkbox>
+</div>
+    <ion-scroll direction="y" style="height: 500px"> 
+
          <ion-list>
          	<ion-item style="border-bottom: 1px solid gray;" ng-repeat = "excal in excals" ng-click="getName(excal)">
          		{{excal}}