yangc 7 лет назад
Родитель
Сommit
f88b8d321f

+ 43 - 35
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_index_ctrl.js

@@ -4,40 +4,31 @@
  */
 define(['app/app', 'calendar'], function(app) {
     'use strict';
-    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', '$modal', 'DistributionRule', '$q', 'User', function($scope, toaster, VendorService, $rootScope, News, $filter, $modal, DistributionRule, $q, User) {
+    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', '$modal', 'DistributionRule', '$q', 'User', '$http', function($scope, toaster, VendorService, $rootScope, News, $filter, $modal, DistributionRule, $q, User, $http) {
         $rootScope.active = 'index';
         $scope.count = 0;
         $scope.userInfo = $rootScope.userInfo;
 
         $scope.toAccount = function(){
-            User.isDevOrProd(null, function(data){
-                $scope.isProd = data.data;
-                if ($scope.isProd == 'success') {
-                    var urlPrex = 'https://sso.ubtob.com';
-                } else {
-                    var urlPrex = 'http://192.168.253.12:32323';
+            //urlPrex = 'http://192.168.253.118:3001';
+            var url = $scope.urlPrex + '/sso/login/change/userspace?spaceUU='+$scope.userInfo.enterprise.uu;
+            var newTab=window.open('about:blank');
+            $.ajax({
+                url:url,
+                dataType:'jsonp',
+                processData: false,
+                type:'get',
+                crossDomain: true,
+                jsonp:'callback',
+                jsonpCallback:"successCallback",
+                success:function(data){
+                    console.log(data);
+                    // window.open(urlPrex + '/cloudcenter/enterprise');
+                    newTab.location.href = urlPrex + '/cloudcenter/enterprise';
+                },
+                error:function(data) {
+                    console.log(data);
                 }
-                //urlPrex = 'http://192.168.253.118:3001';
-                var url = urlPrex + '/sso/login/change/userspace?spaceUU='+$scope.userInfo.enterprise.uu;
-                var newTab=window.open('about:blank');
-                $.ajax({
-                    url:url,
-                    dataType:'jsonp',
-                    processData: false,
-                    type:'get',
-                    crossDomain: true,
-                    jsonp:'callback',
-                    jsonpCallback:"successCallback",
-                    success:function(data){
-                        console.log(data);
-                       // window.open(urlPrex + '/cloudcenter/enterprise');
-                        newTab.location.href = urlPrex + '/cloudcenter/enterprise';
-                    },
-                    error:function(data) {
-                        console.log(data);
-                    }
-                });
-            }, function(response) {
             });
         };
 
@@ -59,13 +50,30 @@ define(['app/app', 'calendar'], function(app) {
             toaster.pop('error', '获取商家的交易信息失败');
         });
 
-        VendorService.getNotDealApplyCount({businessCode: $scope.userInfo.enterprise.enBussinessCode}, function (data) {
-            console.log(data);
-            $scope.count = data.data;
-        },function (err) {
-            toaster.pop('error', '获取未处理审批数据失败');
-        })
-
+        if ($scope.isAdmin) {
+            User.isDevOrProd(null, function (data) {
+                // $scope.isProd = data.data;
+                $scope.urlPrex = data.data == 'success' ? 'https://sso.ubtob.com' : 'http://192.168.253.12:32323';
+                $http({
+                    method: 'get',
+                    dataType: 'json',
+                    url: $scope.urlPrex + '/api/userspace/apply/count',
+                    params: {spaceUU: $scope.userInfo.enterprise.uu}
+                }).success(function (data) {
+                    $scope.count = data.content[311];
+                }).error(function (response) {
+                    toaster.pop('error', '获取未处理审批数据失败');
+                });
+                // VendorService.getNotDealApplyCount({spaceUU: $scope.userInfo.enterprise.uu}, function (data) {
+                //     console.log(data);
+                //     $scope.count = data.content[311];
+                // },function (err) {
+                //     toaster.pop('error', '获取未处理审批数据失败');
+                // })
+            }, function (response) {
+                toaster.pop('error', '获取运行环境失败');
+            });
+        }
         var num = $filter('number')(0.1, 6);
         // console.log(num);