From 619b07b5c2432c0e4581744e6d0fa1399bf23768 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 16:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8A=E8=B0=83?= =?UTF-8?q?=E8=AF=95openid=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- public/javascripts/wechat/app.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index 99c0cf583..224ad23dd 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" 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" name: "意见返馈" diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index b9e0e1958..7e5983652 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -4,7 +4,7 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/'; var openid = ''; var debug = false; //调试标志,如果在本地请置为true -if(debug){ +if(debug===true){ openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; } @@ -22,7 +22,8 @@ app.factory('auth', function($http,$routeParams){ data: {code: code}, method: 'POST' }).then(function successCallback(response) { - _openid = data.openid; + _openid = response.data.openid; + openid = _openid; cb(_openid); }, function errorCallback(response) { cb(null); @@ -57,11 +58,10 @@ app.controller('ActivityController',function($scope, $http, auth){ }); } - auth.getOpenId(function(openid){ - if(!openid){ + auth.getOpenId(function(oid){ + if(!oid){ alert("获取openid出错"); } else { - openid = openid; loadActData($scope.page); } }); @@ -136,4 +136,4 @@ app.config(['$routeProvider',function ($routeProvider) { .otherwise({ redirectTo: '/activities' }); -}]); \ No newline at end of file +}]);