服务器上调试openid成功

chenlw_dev
guange 9 years ago
parent bb5a527f9e
commit 619b07b5c2

@ -2,7 +2,7 @@ button:
- -
type: "view" type: "view"
name: "最新动态" name: "最新动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
- -
type: "click" type: "click"
name: "意见返馈" name: "意见返馈"

@ -4,7 +4,7 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/';
var openid = ''; var openid = '';
var debug = false; //调试标志,如果在本地请置为true var debug = false; //调试标志,如果在本地请置为true
if(debug){ if(debug===true){
openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg";
} }
@ -22,7 +22,8 @@ app.factory('auth', function($http,$routeParams){
data: {code: code}, data: {code: code},
method: 'POST' method: 'POST'
}).then(function successCallback(response) { }).then(function successCallback(response) {
_openid = data.openid; _openid = response.data.openid;
openid = _openid;
cb(_openid); cb(_openid);
}, function errorCallback(response) { }, function errorCallback(response) {
cb(null); cb(null);
@ -57,11 +58,10 @@ app.controller('ActivityController',function($scope, $http, auth){
}); });
} }
auth.getOpenId(function(openid){ auth.getOpenId(function(oid){
if(!openid){ if(!oid){
alert("获取openid出错"); alert("获取openid出错");
} else { } else {
openid = openid;
loadActData($scope.page); loadActData($scope.page);
} }
}); });
@ -136,4 +136,4 @@ app.config(['$routeProvider',function ($routeProvider) {
.otherwise({ .otherwise({
redirectTo: '/activities' redirectTo: '/activities'
}); });
}]); }]);

Loading…
Cancel
Save