Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
txz 2016-04-05 15:12:50 +08:00
commit b2a892bd22
1 changed files with 19 additions and 11 deletions

View File

@ -2,13 +2,19 @@ var app = angular.module('wechat', ['ngRoute']);
var apiUrl = 'http://wechat.trustie.net/api/v1/'; var apiUrl = 'http://wechat.trustie.net/api/v1/';
//var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; //var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg";
var openid = ''; var openid = '';
var debug = true; //调试标志,如果在本地请置为true
if(debug){
openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg";
}
app.factory('auth', function($http,$routeParams){ app.factory('auth', function($http,$routeParams){
var _openid = ''; var _openid = openid;
var getOpenId = function(cb) { var getOpenId = function(cb) {
if (_openid.length > 0) { if (_openid.length > 0) {
cb(_openid); cb(_openid);
return;
} }
var code = $routeParams.code; var code = $routeParams.code;
$http({ $http({
@ -39,16 +45,7 @@ app.controller('ActivityController',function($scope, $http, auth){
$scope.activities = []; $scope.activities = [];
$scope.page = 1; $scope.page = 1;
auth.getOpenId(function(openid){ var loadActData = function(page){
if(!openid){
alert("获取openid出错");
} else {
openid = openid;
$scope.loadActData($scope.page);
}
});
$scope.loadActData = function(page){
$scope.page = page; $scope.page = page;
$http({ $http({
method: 'POST', method: 'POST',
@ -60,6 +57,17 @@ app.controller('ActivityController',function($scope, $http, auth){
}); });
} }
auth.getOpenId(function(openid){
if(!openid){
alert("获取openid出错");
} else {
openid = openid;
loadActData($scope.page);
}
});
$scope.loadActData = loadActData;
}); });
app.controller('IssueController', function($scope, $http, $routeParams, auth){ app.controller('IssueController', function($scope, $http, $routeParams, auth){