Browse Source

compconnect

zhuxc 7 năm trước cách đây
mục cha
commit
843662f67e

+ 1 - 1
www/apps/accountMng/js/controllers.js

@@ -158,7 +158,7 @@ starter.controller('AccountManageCtrl', function ($scope, global, showPopup, Com
     };
 
     $scope.import = function () {
-        $window.location.href = "http://"+$location.host()+":"+$location.port()+"/apps/compmanage/index.html#/index";
+        $window.location.href = "http://" + $window.location.host + "/apps/compmanage/index.html#/index";
         // $location.url('http://192.168.1.5:8101/apps/compmanage/index.html#/index');
     };
 

+ 4 - 4
www/apps/authuser/js/factory.js

@@ -1,13 +1,13 @@
-starter.factory('User', function ($resource, $q, $filter, cfg, formatFilter, global) {
+starter.factory('User', function ($resource, $q, $filter, cfg, formatFilter, global,cfg) {
     global.erp_api = "http://192.168.1.36:13210/api/";
 
     return {
         user: function (actionname) {
-            return $resource(formatFilter('{0}Comp/{1}/0/', global.erp_api, actionname == undefined ? "" : actionname), {},
+            return $resource(formatFilter('{0}ext_erp/Comp/{1}/0/', cfg.api, actionname == undefined ? "" : actionname), {},
                 {
-                    save: {
+                    post: {
                         method: "POST",
-                        headers: {"cid": JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone}), "sn": ""}
+                        headers: {"cid": JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone}), "sn": "DEMO2017TW654327"}
                     }
                 })
         }

+ 8 - 1
www/apps/compmanage/js/controllers.js

@@ -4,6 +4,13 @@ starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDe
     var compmodal = showPopup.modalTemplate('templates/modal-selectcomp.html', 'slide-in-up', $scope);
 
     global.fetch_user().then(function (res) {
+        if (!global.sn)
+            Comp.sn.get({"comp_id": global.user.compno}, function (data) {
+                global.sn = data.sn;
+                console.warn("sn: " + global.sn);
+            }, function (err) {
+                console.error("获取服务器的SN失败: " + JSON.stringify(err))
+            });
         $scope.activecomp = {};
     });
 
@@ -30,7 +37,7 @@ starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDe
         $scope.activecomp = _.extend($scope.activecomp, {"cellphone": global.user.cellphone, "imid": global.user.im_usrid, "linkerpassword": global.user.password, "linkerusername": global.user.usrname, "region": 86});
         showPopup.showLoading(1, '正在提交', false);
         console.log($scope.activecomp);
-        Comp.comp("PostComp", $scope.serialnumber).save($scope.activecomp, function (res) {
+        Comp.comp("PostComp/0", $scope.serialnumber).save($scope.activecomp, function (res) {
             $ionicSlideBoxDelegate.next();
         }, function (err) {
             console.log(err);

+ 32 - 2
www/apps/compmanage/js/factory.js

@@ -1,9 +1,39 @@
 starter.factory('Comp', function ($resource, $q, $filter, cfg, formatFilter, global) {
-    global.erp_api = "http://192.168.1.70:13210/api/";
+    global.erp_api = "http://192.168.1.36:13210/api/";
 
     return {
+        sn: $resource(formatFilter('{0}erp/comp/', cfg.api)),
         comp: function (actionname) {
-            return $resource(formatFilter('{0}Comp/{1}', global.erp_api, actionname == undefined ? "" : actionname))
+            return $resource(formatFilter('{0}ext_erp/Comp/{1}/', cfg.api, actionname == undefined ? "" : actionname))
         }
     };
 })
+.config(function ($httpProvider) {
+    $httpProvider.interceptors.push(function ($q, cfg, global) {
+        return {
+            'request': function (config) {
+                if (config.url != null && (global.refresh || global.debug)) { //if the call is not for an asset file
+                    config.url += (config.url.indexOf("?") === -1 ? "?" : "&") + "v=" + Date.now();
+                    if (global.refresh)
+                        global.refresh = false;
+                }
+
+                if (config.url.startsWith(cfg.api) || config.url.indexOf(global.api) == 0) {//分页时自带了请求路径
+                    if (config.url.startsWith(cfg.api)) config.url = global.api + config.url;
+                    console.log(angular.lowercase(config.method) + " url: " + config.url);
+                    if (global.user.token) {
+                        config.headers['authorization'] = 'Token ' + global.user.token;
+                        console.log(' authorization:' + config.headers['authorization']);
+                    }
+                }
+                config.timeout = 60000;
+
+                if (config.url.indexOf("ext_erp") != -1) {//分页时自带了请求路径
+                    config.headers['cid'] = JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone});
+                    config.headers['sn'] = global.sn;
+                }
+                return config;
+            }
+        };
+    });
+})

+ 3 - 3
www/js/start/config.js

@@ -66,7 +66,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
         if (global.user && global.user.token) {
             usergot(global.user, deferred)
         } else if (ionic.Platform.platform() == 'win32' || ionic.Platform.platform() == 'linux') {
-            $http.post(formatFilter('{0}authcheck/', "http://192.168.1.5:7000/api/"), "imid=mlCQkcg7j&password=31003100", {
+            $http.post(formatFilter('{0}authcheck/', "http://srv.linkerplus.com/api/"), "imid=zPayHMi6s&password=123456", {
                 headers: {
                     'Content-Type': 'application/x-www-form-urlencoded'
                 }
@@ -96,7 +96,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
         if (data.cfg && (ionic.Platform.platform() == "ios" || ionic.Platform.platform() == 'android')) {
             global.api = data.cfg.api;
         } else {
-            global.api = "http://192.168.1.5:7000";
+            global.api = "http://srv.linkerplus.com";
         }
         deferred.resolve(data);
         console.warn(JSON.stringify(global.user));
@@ -245,7 +245,7 @@ starter.run(function ($ionicPlatform, $rootScope, $http, formatFilter, $q, $cord
                         global.refresh = false;
                 }
 
-                if (config.url.startsWith(cfg.api) || config.url.indexOf(global.api) == 0 || config.url.indexOf(global.erp_api) == 0) {//分页时自带了请求路径
+                if (config.url.startsWith(cfg.api) || config.url.indexOf(global.api) == 0) {//分页时自带了请求路径
                     if (config.url.startsWith(cfg.api)) config.url = global.api + config.url;
                     console.log(angular.lowercase(config.method) + " url: " + config.url);
                     if (global.user.token) {

+ 1 - 1
www/js/start/factory.js

@@ -221,7 +221,7 @@ starter.factory('Tool', function ($http, $q, $translate, $ionicHistory) {
             $cordovaImagePicker.getPictures(options).then(function (results) {
                 _.each(results, function (res) {
                     var deferred1 = $q.defer();
-                    window.resolveLocalFileSystemURL(res, function done(fileEntry) {
+                    window.resolveLocalFileSystemURL(res, function (fileEntry) {
                         fileEntry.file(function (fileObj) {
                             var reader = new FileReader();
                             reader.onloadend = function (e) {