1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- app.controller('indexCtrl', ["$rootScope", "$scope", '$stateParams', '$http', 'api_bpm_domain', '$state', '$ionicPopup', '$timeout', '$location', 'ADDRESS', function($rootScope, $scope, $stateParams, $http, api_bpm_domain, $state, $ionicPopup, $timeout, $location, address) {
- console.log('indexCtrl is load');
- // $scope.getToken = function() {
- // // $location.path(address.serverIp + address.serverIpPort + address.api + '/login');
- // window.location.href = address.serverIp + address.serverIpPort + address.api + '/login';
- // };
- $scope.getToken = function() {
- $http({
- method: 'post',
- // url: 'http://115.156.150.70:9680/service/api/login',
- // url: 'http://192.168.3.49:9680/api/login',
- url: address.serverIp + address.serverIpPort + address.api + '/login',
- headers: { 'Content-Type': 'application/json' },
- data: {
- // 'username': loginForm.username,
- // 'password': loginForm.password
- 'username': '123456',
- 'password': '123456'
- }
- }).success(function(data, status, headers, config) {
- // 当相应准备就绪时调用
- console.log("success");
- // console.log(data.url);
- if (data.state == 201) {
- console.log(headers('access-token'));
- $rootScope.isToken = true;
- $rootScope['access-token'] = headers('access-token');
- // $rootScope.user = data.data.user;
- var sessionLogin = {
- 'user': data.data.user,
- 'token': headers('access-token')
- }
- //本地数据初始化
- sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
- $state.go('tab.myIncident');
- } else {
- $scope.showAlert({
- title: '账号密码不正确!',
- template: '请重新输入账号密码'
- });
- }
- }).error(function(data, status, headers, config) {
- console.log("error");
- return
- });
- }
- }]);
|