diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index ee999d98f..1dcd147d4 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -10,23 +10,23 @@ class WechatService data:{ first: { value:first, - color:"#CCCCCC" + color:"#707070" }, keyword1:{ value:key1, - color:"#CCCCCC" + color:"#707070" }, keyword2:{ value:key2, - color:"#CCCCCC" + color:"#707070" }, keyword3:{ value:key3, - color:"#CCCCCC" + color:"#707070" }, remark:{ value:remark, - color:"#CCCCCC" + color:"#707070" } } } @@ -88,19 +88,19 @@ class WechatService data:{ first: { value:first, - color:"#CCCCCC" + color:"#707070" }, keyword1:{ value:key1, - color:"#CCCCCC" + color:"#707070" }, keyword2:{ value:key2, - color:"#CCCCCC" + color:"#707070" }, remark:{ value:remark, - color:"#CCCCCC" + color:"#707070" } } } 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 7caa318b6..63e88490f 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 e5444c384..16fa8cf03 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/'; } @@ -435,6 +436,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', { @@ -472,22 +492,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 22c568a2e..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; font-size:13px;} +.loading-box span {display: block; font-size:12px;}