|
@@ -4,35 +4,37 @@
|
|
//$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());
|
|
- userService.isTest().then(function(result){
|
|
|
|
- Wechat.auth(scope, state, function (response) {
|
|
|
|
- // alert("response:"+JSON.stringify(response));
|
|
|
|
- // var response={code:1231};
|
|
|
|
- if(response.code){
|
|
|
|
- msg.loading('登录中...');
|
|
|
|
- userService.wechat_login(response.code).then(function(result){
|
|
|
|
- msg.hide();
|
|
|
|
- // alert("wechat_login success: " + JSON.stringify(result));
|
|
|
|
- if(result.data.data.user){
|
|
|
|
- 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:result.data.data.openid})
|
|
|
|
- }
|
|
|
|
- },function(error){
|
|
|
|
- console.log("loginbywx Failed: " + JSON.stringify(error));
|
|
|
|
- $state.go("loginAccount");
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }, function (error) {
|
|
|
|
- console.log("Failed: " + JSON.stringify(error));
|
|
|
|
- })
|
|
|
|
- }, function (error) {
|
|
|
|
- $state.go("loginAccount",{wechat:'orrk51inhmfmQRXA8VvGEQfow3Es'});
|
|
|
|
- })
|
|
|
|
|
|
+ userService.isTest().then(function(res){
|
|
|
|
+ if(res.data.data){
|
|
|
|
+ Wechat.auth(scope, state, function (response) {
|
|
|
|
+ // alert("response:"+JSON.stringify(response));
|
|
|
|
+ // var response={code:1231};
|
|
|
|
+ if(response.code){
|
|
|
|
+ msg.loading('登录中...');
|
|
|
|
+ userService.wechat_login(response.code).then(function(result){
|
|
|
|
+ msg.hide();
|
|
|
|
+ // alert("wechat_login success: " + JSON.stringify(result));
|
|
|
|
+ if(result.data.data.user){
|
|
|
|
+ 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:result.data.data.openid})
|
|
|
|
+ }
|
|
|
|
+ },function(error){
|
|
|
|
+ console.log("loginbywx Failed: " + JSON.stringify(error));
|
|
|
|
+ $state.go("loginAccount");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }, function (error) {
|
|
|
|
+ console.log("Failed: " + JSON.stringify(error));
|
|
|
|
+ })
|
|
|
|
+ }else{
|
|
|
|
+ $state.go("loginAccount",{wechat:'orrk51inhmfmQRXA8VvGEQfow3Es'});
|
|
|
|
+ }
|
|
|
|
+ } )
|
|
|
|
|
|
}
|
|
}
|
|
}]);
|
|
}]);
|