From f1783c06a211b5cd0c58ad9a8ca46b52f90a1c61 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 14:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E4=BC=A0?= =?UTF-8?q?=E5=8F=82openid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 39 +++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5e6234501..6061b665e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,14 +3,14 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/'; var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - //apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + _openid = "1"; } var getOpenId = function() { @@ -43,7 +43,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ }; var openid = function(){ return _openid; - } + }; return {getOpenId: getOpenId, openid: openid}; }); @@ -56,7 +56,7 @@ app.factory('rms', function(){ var get = function(key){ return _saveStorage[key]; - } + }; return {save: save, get: get}; }); @@ -64,7 +64,7 @@ app.factory('rms', function(){ app.controller('ActivityController',function($scope, $http, auth, rms){ $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; - } + }; console.log("ActivityController load"); $scope.activities = rms.get("activities") || []; @@ -75,13 +75,13 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ $http({ method: 'POST', url: apiUrl+ "activities", - data: {openid: auth.openid(), page: page}, + data: {openid: auth.openid(), page: page} }).then(function successCallback(response) { $scope.activities = $scope.activities.concat(response.data.data); rms.save('activities', $scope.activities); }, function errorCallback(response) { }); - } + }; auth.getOpenId().then( function successCallback(response){ loadActData($scope.page); @@ -96,11 +96,11 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ //$http - } + }; $scope.decreasePraise = function(act){ act.activity_praise_count -= 1; act.has_praise = false; - } + }; $scope.loadActData = loadActData; @@ -133,23 +133,16 @@ app.factory('common', function($http, auth){ }); }; - - - var loadCommonData = function(id, type){ return $http({ method: 'GET', - url: apiUrl+ type + "/" + id + url: apiUrl+ type + "/" + id+"?openid="+auth.openid() }) }; return {addCommonReply: addCommonReply, loadCommonData: loadCommonData}; - - }); - - app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; @@ -204,7 +197,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a $scope.news = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -226,7 +219,7 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut $scope.discussion = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -248,7 +241,7 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth, $scope.message = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -258,7 +251,7 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth, $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; }); app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ @@ -270,7 +263,7 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com $scope.blog = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -280,7 +273,7 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; }); app.filter('safeHtml', function ($sce) {