controllers.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. var starter = angular.module('starter.controllers', [])
  2. starter.controller('loginCtrl',["$scope",'$state','$ionicLoading','$timeout','$ionicPopup',function($scope,$state,$ionicLoading,$timeout,$ionicPopup){
  3. $scope.vm = {
  4. mobile:'',
  5. password:''
  6. };
  7. $scope.login = function(){
  8. if($scope.vm.username == 'admin' && $scope.vm.password == 'admin'){
  9. $ionicLoading.show({
  10. template: '<div class="loader"><svg class="circular"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>'
  11. });
  12. $timeout(function(){
  13. $ionicLoading.hide();
  14. $state.go('home')
  15. },1500);
  16. }else{
  17. // $scope.showAlert = function(){
  18. // var alertPopup = $ionicPopup.alert({
  19. // title:'账号密码不正确',
  20. // template:'唯一账号密码---admin'
  21. // })
  22. // }
  23. var alertPopup = $ionicPopup.alert({
  24. title: '账号密码不正确',
  25. template: '唯一账号密码:admin!!!'
  26. });
  27. $timeout(function() {
  28. ionicMaterialInk.displayEffect();
  29. }, 0);
  30. }
  31. }
  32. }])
  33. starter.controller('homeCtrl',["$scope",'$http','$timeout',function($scope,$http,$timeout){
  34. $scope.excals = [
  35. {'list':'测试一'},
  36. {'list':'测试二'},
  37. {'list':'测试三'}
  38. ];
  39. $scope.doRefresh = function(){
  40. $http.get('../lib/ionic/test.json')
  41. .success(function(newItems) {
  42. $scope.excals = newItems;
  43. })
  44. .finally(function() {
  45. $scope.$broadcast('scroll.refreshComplete');
  46. });
  47. }
  48. }])
  49. //展示首页控制器
  50. starter.controller('lineCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
  51. $scope.go = function(target){
  52. $ionicHistory.clearHistory();
  53. $state.go(target)
  54. }
  55. }])
  56. //TN曲线控制器
  57. starter.controller('tnCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
  58. $scope.go = function(target){
  59. $ionicHistory.clearHistory();
  60. $state.go(target)
  61. }
  62. $scope.legend = ["扭矩", "电压",'输入功率','电流','效率'];
  63. $scope.item = ['200rpm','400rpm','600rpm','800rpm','1000rpm','1200rpm','1400rpm','1600rpm','1800rpm','2000rpm','2200rpm','2400rpm'];
  64. $scope.num = [0,1,2,3,4];
  65. $scope.data = [
  66. [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], //扭矩
  67. [0, 1, 4, 7, 12, 15, 16, 15, 15, 10, 6, 5], //电压
  68. [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2], //输入功率
  69. [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2], //电流
  70. [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]//效率
  71. ];
  72. }]);
  73. starter.directive('line', function() {
  74. return {
  75. scope: {
  76. id: "@",
  77. legend: "=",
  78. item: "=",
  79. num:"=",
  80. data: "="
  81. },
  82. restrict: 'E',
  83. template: '<div style="height:400px;"></div>',
  84. replace: true,
  85. link: function($scope, element, attrs, controller) {
  86. var colors = ['#a62ca6', '#8e0515', '#45baf3','#ff2420','#1a9a1a'];
  87. var option = {
  88. color:colors,
  89. // 提示框,鼠标悬浮交互时的信息提示
  90. tooltip: {
  91. show: true,
  92. trigger: 'axis'
  93. },
  94. grid:{
  95. left:'30%'
  96. },
  97. // 图例
  98. legend: {
  99. data: $scope.legend
  100. },
  101. // toolbox: {
  102. // feature: {
  103. // dataView: {show: true, readOnly: false},
  104. // restore: {show: true},
  105. // saveAsImage: {show: true}
  106. // }
  107. // },
  108. // 横轴坐标轴
  109. xAxis: [
  110. {
  111. type: 'category',
  112. axisTick: {
  113. alignWithLabel: true
  114. },
  115. data: $scope.item
  116. }
  117. ],
  118. // 纵轴坐标轴
  119. yAxis: [
  120. {
  121. type: 'value',
  122. name: '扭矩',
  123. min: 0,
  124. max: 3,
  125. position: 'left',
  126. offset:90,
  127. axisLine: {
  128. lineStyle: {
  129. color: colors[0]
  130. }
  131. },
  132. },
  133. {
  134. type: 'value',
  135. name: '电压',
  136. min: 0,
  137. max: 220,
  138. position: 'left',
  139. offset: 60,
  140. axisLine: {
  141. lineStyle: {
  142. color: colors[1]
  143. }
  144. },
  145. },
  146. {
  147. type: 'value',
  148. name: '输入功率',
  149. min: 0,
  150. max: 1500,
  151. position: 'left',
  152. offset:23,
  153. axisLine: {
  154. lineStyle: {
  155. color: colors[2]
  156. }
  157. },
  158. },
  159. {
  160. type: 'value',
  161. name: '电流',
  162. min: 0,
  163. max: 6,
  164. position: 'left',
  165. offset:5,
  166. axisLine: {
  167. lineStyle: {
  168. color: colors[3]
  169. }
  170. },
  171. },
  172. {
  173. type: 'value',
  174. name: '效率',
  175. min: 0,
  176. max: 80,
  177. position: 'left',
  178. offset:-20,
  179. axisLine: {
  180. lineStyle: {
  181. color: colors[4]
  182. }
  183. },
  184. }
  185. ],
  186. // 数据内容数组
  187. series: function(){
  188. var serie=[];
  189. for(var i=0;i<$scope.legend.length;i++){
  190. var item = {
  191. name : $scope.legend[i],
  192. type: 'line',
  193. yAxisIndex:$scope.num[i],
  194. data: $scope.data[i]
  195. };
  196. serie.push(item);
  197. }
  198. return serie;
  199. }()
  200. };
  201. var myChart = echarts.init(document.getElementById($scope.id),'macarons');
  202. myChart.setOption(option);
  203. }
  204. };
  205. })
  206. //五轴图控制器
  207. starter.controller('zhouCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
  208. $scope.go = function(target){
  209. $ionicHistory.clearHistory();
  210. $state.go(target)
  211. }
  212. }])
  213. //效率云图控制器
  214. starter.controller('stromCtrl',["$scope",'$ionicHistory','$state',function($scope,$ionicHistory,$state){
  215. $scope.go = function(target){
  216. $ionicHistory.clearHistory();
  217. $state.go(target)
  218. }
  219. }])