From 70ed5790b8b8ffdcb031471e4fab70043c123a40 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 11 Jul 2016 16:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=82=B9=E8=B5=9E=E8=BF=94=E5=9B=9E=E5=92=8C?= =?UTF-8?q?=E7=82=B9=E8=B5=9E=E7=8A=B6=E6=80=81=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_list.html | 47 ++++++------- .../wechat/controllers/activity.js | 3 + public/javascripts/wechat/others/factory.js | 69 ++++++++++++++++++- 3 files changed, 93 insertions(+), 26 deletions(-) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index 69a3db43c..dafce2cfc 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -1,34 +1,35 @@
课程列表
- -
+
我创建的课程
-
{{syllabus.title}}
-
    -
  • - - - > - {{course.member_count}}人 -
  • -
+
+
{{syllabus.title}}
+
    +
  • + + + > + {{course.member_count}}人 +
  • +
+
- -
+
我参与的课程
-
{{syllabus.title}}
-
    -
  • - - - > - {{course.member_count}}人 -
  • -
+
+
{{syllabus.title}}
+
    +
  • + + + > + {{course.member_count}}人 +
  • +
+
-
新建课程 加入班级 diff --git a/public/javascripts/wechat/controllers/activity.js b/public/javascripts/wechat/controllers/activity.js index b89c46300..16a8e71d0 100644 --- a/public/javascripts/wechat/controllers/activity.js +++ b/public/javascripts/wechat/controllers/activity.js @@ -137,6 +137,9 @@ app.controller('ActivityController', //跳到详情页 $scope.goDetail = function(type, act_id,id){ rms.save("yoffset", window.document.body.scrollTop); + rms.save("activities",$scope.activities); + rms.save("course_activities",$scope.course_activities); + rms.save("project_activities",$scope.project_activities); $location.path('/'+type+'/'+act_id); } diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 6acf25c59..64204dfca 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -86,7 +86,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){ +app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, auth, $routeParams,rms){ var addCommonReply = function(id, type, data, cb){ if(!data.comment || data.comment.length<=0){ @@ -174,8 +174,71 @@ app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $r } }); }; - args.scope.addPraise = addCommonPraise; - args.scope.decreasePraise = decreaseCommonPraise; + +// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致 + args.scope.addPraise = function(act){ + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == act.act_id){ + activities[i].praise_count += 1; + activities[i].has_praise = true; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == act.act_id){ + course_activities[i].praise_count += 1; + course_activities[i].has_praise = true; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == act.act_id){ + project_activities[i].praise_count += 1; + project_activities[i].has_praise = true; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + + addCommonPraise(act); + }; + + args.scope.decreasePraise = function(act){ + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == act.act_id){ + activities[i].praise_count -= 1; + activities[i].has_praise = false; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == act.act_id){ + course_activities[i].praise_count -= 1; + course_activities[i].has_praise = false; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == act.act_id){ + project_activities[i].praise_count -= 1; + project_activities[i].has_praise = false; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + + decreaseCommonPraise(act); + }; } return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};