|
@@ -4,34 +4,39 @@
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
$scope.wechat_login = function(){
|
|
$scope.wechat_login = function(){
|
|
var scope = "snsapi_userinfo", state = "_" + (+new Date());
|
|
var scope = "snsapi_userinfo", state = "_" + (+new Date());
|
|
- Wechat.auth(scope, state, function (response) {
|
|
|
|
|
|
+ // Wechat.auth(scope, state, function (response) {
|
|
// alert("response:"+JSON.stringify(response));
|
|
// alert("response:"+JSON.stringify(response));
|
|
- // response.code;
|
|
|
|
|
|
+ //for test
|
|
|
|
+ var response={code:1231};
|
|
if(response.code){
|
|
if(response.code){
|
|
msg.loading('登录中...');
|
|
msg.loading('登录中...');
|
|
userService.wechat_login(response.code).then(function(result){
|
|
userService.wechat_login(response.code).then(function(result){
|
|
- alert("wechat_login success: " + JSON.stringify(result));
|
|
|
|
msg.hide();
|
|
msg.hide();
|
|
- storage.setObject('user', result.data.data.user);
|
|
|
|
- storage.set('token', result.data.data.token);
|
|
|
|
- $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.data.token;
|
|
|
|
- $scope.user=storage.getObject('user');
|
|
|
|
- $state.go('app.home');
|
|
|
|
|
|
+ // alert("wechat_login success: " + JSON.stringify(result));
|
|
|
|
+ if(result.data.data){
|
|
|
|
+ storage.setObject('user', result.data.data.user);
|
|
|
|
+ storage.set('token', result.data.data.token);
|
|
|
|
+ $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.data.token;
|
|
|
|
+ $scope.user=storage.getObject('user');
|
|
|
|
+ $state.go('app.home');
|
|
|
|
+ }else{
|
|
|
|
+ $state.go("loginAccount",{wechat:response.code})
|
|
|
|
+ }
|
|
},function(error){
|
|
},function(error){
|
|
// alert("wechat_login Failed: " + JSON.stringify(error));
|
|
// alert("wechat_login Failed: " + JSON.stringify(error));
|
|
$state.go("loginAccount",{wechat:response.code})
|
|
$state.go("loginAccount",{wechat:response.code})
|
|
//window.location.href="#/account/loginAccount?wechat=$scope.wecaht";
|
|
//window.location.href="#/account/loginAccount?wechat=$scope.wecaht";
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- }, function (error) {
|
|
|
|
- console("Failed: " + JSON.stringify(error));
|
|
|
|
- });
|
|
|
|
|
|
+ // }, function (error) {
|
|
|
|
+ // console("Failed: " + JSON.stringify(error));
|
|
|
|
+ // });
|
|
};
|
|
};
|
|
}]);
|
|
}]);
|
|
app.controller('loginCtrl', ["$scope", "userService","$stateParams","$ionicNavBarDelegate", "storage", "$state", "msg", "$http", "util","$timeout",
|
|
app.controller('loginCtrl', ["$scope", "userService","$stateParams","$ionicNavBarDelegate", "storage", "$state", "msg", "$http", "util","$timeout",
|
|
function ($scope, userService,$stateParams,$ionicNavBarDelegate, storage, $state, msg, $http, util, $timeout) {
|
|
function ($scope, userService,$stateParams,$ionicNavBarDelegate, storage, $state, msg, $http, util, $timeout) {
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
- $scope.wecaht = $stateParams.wechat;
|
|
|
|
|
|
+ $scope.wechat = $stateParams.wechat;
|
|
$scope.vm = {
|
|
$scope.vm = {
|
|
mobile: '',
|
|
mobile: '',
|
|
verify_code: '',
|
|
verify_code: '',
|