diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb
index 87ede1365..190502a3c 100644
--- a/app/controllers/wechats_controller.rb
+++ b/app/controllers/wechats_controller.rb
@@ -383,7 +383,15 @@ class WechatsController < ActionController::Base
render 'wechats/user_activities', layout: nil
end
+
+
def user_activities
+
+ @appid = Wechat.config.appid
+ ## sign
+
+ @sign_params = wechat.jsapi_ticket.signature(current_url)
+
session[:wechat_code] = params[:code] if params[:code]
@path = '/'+(params[:state] || '')
open_id = get_openid_from_code(params[:code]) rescue
@@ -431,6 +439,9 @@ class WechatsController < ActionController::Base
uw = UserWechat.where(openid: openid).first
end
+ def current_url
+ "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
+ end
end
diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb
index f5cfb8250..ac3b845ff 100644
--- a/app/views/wechats/user_activities.html.erb
+++ b/app/views/wechats/user_activities.html.erb
@@ -12,6 +12,7 @@
<%= stylesheet_link_tag '/stylesheets/weui/weixin.css' %>
+
diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js
index ca69e308c..0467dee5d 100644
--- a/public/javascripts/wechat/controllers/invite_code.js
+++ b/public/javascripts/wechat/controllers/invite_code.js
@@ -3,9 +3,23 @@
*/
-app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){
+app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth','wx', function($scope, $http, $routeParams, config, auth, wx){
var vm = $scope;
+ wx.ready(function(){
+ wx.onMenuShareTimeline({
+ title: '定制的标题', // 分享标题
+ link: 'http://wechat.trustie.net/', // 分享链接
+ imgUrl: 'http://wechat.trustie.net/images/logo2.png', // 分享图标
+ success: function () {
+ console.log("share successed.");
+ },
+ cancel: function () {
+ console.log("share canceled.");
+ }
+ });
+ });
+
vm.course = {};
var courseid = $routeParams.id;
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
diff --git a/public/javascripts/wechat/controllers/login.js b/public/javascripts/wechat/controllers/login.js
index f31dd629f..f8e87a93f 100644
--- a/public/javascripts/wechat/controllers/login.js
+++ b/public/javascripts/wechat/controllers/login.js
@@ -1,5 +1,11 @@
-app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams', 'alertService', 'config','auth','session',
- function ($scope, $http, $location, $routeParams, alertService, config, auth,session) {
+app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams', 'alertService', 'config','auth','session','wx',
+ function ($scope, $http, $location, $routeParams, alertService, config, auth,session, wx) {
+
+ // 登录页不用显示菜音
+ wx.ready(function(){
+ wx.hideOptionMenu();
+ })
+
if(auth.get_bind().then(function(){
$location.path("/activities");
}));
@@ -33,8 +39,7 @@ app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams
vm.loginFailed = (response.data.status != 0);
if (!$scope.loginFailed) { //绑定成功
vm.alertService.showMessage('提示', response.data.message, function(){
-// $location.path("/activities");
- window.WeixinJSBridge.call('closeWindow');
+ wx.closeWindow();
});
} else {
vm.alertService.showMessage('出错了', response.data.message);
diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js
index 89e2b700f..6e110a6ea 100644
--- a/public/javascripts/wechat/others/factory.js
+++ b/public/javascripts/wechat/others/factory.js
@@ -30,6 +30,10 @@ app.factory('alertService', function(){
}
});
+app.factory('wx', ['$window', function($window){
+ var wechat = $window.wx;
+ return wechat;
+}]);
app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){
//是否已经绑定