|
@@ -3,33 +3,33 @@
|
|
function ($scope,userService,$ionicNavBarDelegate, storage, $state, msg, $http, util) {
|
|
function ($scope,userService,$ionicNavBarDelegate, storage, $state, msg, $http, util) {
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
//$ionicNavBarDelegate.showBackButton(false);
|
|
$scope.wechat_login = function(){
|
|
$scope.wechat_login = function(){
|
|
- //var scope = "snsapi_userinfo", state = "_" + (+new Date());
|
|
|
|
- // 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));
|
|
|
|
- // })
|
|
|
|
- $state.go("loginAccount",{wechat:'orrk51inhmfmQRXA8VvGEQfow3Es'});
|
|
|
|
|
|
+ var scope = "snsapi_userinfo", state = "_" + (+new Date());
|
|
|
|
+ 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));
|
|
|
|
+ })
|
|
|
|
+ // $state.go("loginAccount",{wechat:'orrk51inhmfmQRXA8VvGEQfow3Es'});
|
|
|
|
|
|
}
|
|
}
|
|
}]);
|
|
}]);
|