From 151661830fab88a7e6cc0f50c243ccd171d73ec0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 3 May 2016 11:03:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/wechat_service.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index 2fb222d4f..1abf5e888 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -10,23 +10,23 @@ class WechatService data:{ first: { value:first, - color:"#173177" + color:"#707070" }, keyword1:{ value:key1, - color:"#173177" + color:"#707070" }, keyword2:{ value:key2, - color:"#173177" + color:"#707070" }, keyword3:{ value:key3, - color:"#173177" + color:"#707070" }, remark:{ value:remark, - color:"#173177" + color:"#707070" } } } @@ -88,19 +88,19 @@ class WechatService data:{ first: { value:first, - color:"#173177" + color:"#707070" }, keyword1:{ value:key1, - color:"#173177" + color:"#707070" }, keyword2:{ value:key2, - color:"#173177" + color:"#707070" }, remark:{ value:remark, - color:"#173177" + color:"#707070" } } } From de8b303b93fe9117801fb3b2859f4f83e6d5393d Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 3 May 2016 15:37:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=97=B6=E6=98=BE=E7=A4=BA=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 1 + public/assets/wechat/app.html | 5 --- public/javascripts/wechat/app.js | 62 ++++++++++++++++++++-------- public/stylesheets/weui/weixin.css | 2 +- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index f87af796f..f0f8e9c92 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -1,6 +1,7 @@
+
diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 187439468..6fcaa76f5 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -14,11 +14,6 @@
-
-
- 加载中... -
-
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index a15e94014..3dcc0e6c1 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,6 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ + //apiUrl = 'http://localhost:3000/api/v1/'; apiUrl = 'https://www.trustie.net/api/v1/'; } @@ -399,6 +400,25 @@ app.directive('textAutoHeight', function($timeout){ } }); +app.directive('loadingSpinner', function ($http) { + return { + restrict: 'A', + replace: true, + template: '
加载中...
', + link: function (scope, element, attrs) { + + scope.$watch('activeCalls', function (newVal, oldVal) { + if (newVal == 0) { + $(element).hide(); + } + else { + $(element).show(); + } + }); + } + }; +}); + app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) { $routeProvider .when('/activities', { @@ -436,22 +456,30 @@ app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProv .otherwise({ redirectTo: '/activities' }); - //$httpProvider.interceptors.push('timestampMarker'); -}]); -//loading -app.factory('timestampMarker', ["$rootScope", function ($rootScope) { - var timestampMarker = { - request: function (config) { - $rootScope.loading = true; - config.requestTimestamp = new Date().getTime(); - return config; - }, - response: function (response) { - // $rootScope.loading = false; - response.config.responseTimestamp = new Date().getTime(); - return response; - } - }; - return timestampMarker; + //监听异步请求 + $httpProvider.interceptors.push(function ($q, $rootScope) { + if ($rootScope.activeCalls == undefined) { + $rootScope.activeCalls = 0; + } + + return { + request: function (config) { + $rootScope.activeCalls += 1; + return config; + }, + requestError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + }, + response: function (response) { + $rootScope.activeCalls -= 1; + return response; + }, + responseError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + } + }; + }); }]); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 21fde54bb..fffa7a214 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -76,4 +76,4 @@ a.underline {text-decoration:underline;} .loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} .loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} .loading-box img {margin-top: 3px; text-align: center;} -.loading-box span {display: block;} +.loading-box span {display: block; font-size:12px;}