|
@@ -1,5 +1,5 @@
|
|
(function (app) {
|
|
(function (app) {
|
|
- app.controller('loginCtrl', ["$scope", 'userService', "data", '$state', 'msg', function ($scope, userService, data, $state, msg) {
|
|
|
|
|
|
+ app.controller('loginCtrl', ["$scope", 'userService', "data", '$state', 'msg', '$http', function ($scope, userService, data, $state, msg, $http) {
|
|
$scope.vm = {
|
|
$scope.vm = {
|
|
mobile: '',
|
|
mobile: '',
|
|
password:''
|
|
password:''
|
|
@@ -10,6 +10,7 @@
|
|
msg.hide();
|
|
msg.hide();
|
|
data.setObject('user', result.data.user);
|
|
data.setObject('user', result.data.user);
|
|
data.set('token', result.data.token);
|
|
data.set('token', result.data.token);
|
|
|
|
+ $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.token;
|
|
if (result.data.user.type == 1) {//托运方
|
|
if (result.data.user.type == 1) {//托运方
|
|
$state.go('wl.car');
|
|
$state.go('wl.car');
|
|
}
|
|
}
|
|
@@ -22,7 +23,7 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}]);
|
|
}]);
|
|
- app.controller('registerCtrl', ["$scope", 'msg', 'util', 'userService', '$timeout', '$state', 'data', function ($scope, msg, util, userService, $timeout, $state, data) {
|
|
|
|
|
|
+ app.controller('registerCtrl', ["$scope", 'msg', 'util', 'userService', '$timeout', '$state', 'data', '$http', function ($scope, msg, util, userService, $timeout, $state, data, $http) {
|
|
$scope.vm = {
|
|
$scope.vm = {
|
|
mobile: '',
|
|
mobile: '',
|
|
password: '',
|
|
password: '',
|
|
@@ -71,6 +72,7 @@
|
|
}).then(function (result) {
|
|
}).then(function (result) {
|
|
data.setObject('user', { mobile: $scope.vm.mobile, type: $scope.vm.type });
|
|
data.setObject('user', { mobile: $scope.vm.mobile, type: $scope.vm.type });
|
|
data.set('token', result.data.token);
|
|
data.set('token', result.data.token);
|
|
|
|
+ $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.token;
|
|
msg.hide();
|
|
msg.hide();
|
|
if ($scope.vm.type == 1) {//托运方
|
|
if ($scope.vm.type == 1) {//托运方
|
|
$state.go('wl.car');
|
|
$state.go('wl.car');
|