修改在动态详情点赞返回和点赞状态不一致的BUG

This commit is contained in:
yuanke 2016-07-11 16:46:07 +08:00
parent 627135ec12
commit 70ed5790b8
3 changed files with 93 additions and 26 deletions

View File

@ -1,34 +1,35 @@
<div class="post-container" style="padding-bottom: 50px;"> <div class="post-container" style="padding-bottom: 50px;">
<div loading-spinner></div> <div loading-spinner></div>
<div class="blue-title">课程列表</div> <div class="blue-title">课程列表</div>
<div>
<div ng-repeat="syllabus in syllabuses">
<div class="course-diff-row"><span class="c-blue f13 ml10">我创建的课程</span></div> <div class="course-diff-row"><span class="c-blue f13 ml10">我创建的课程</span></div>
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div> <div ng-show = "syllabus.can_setting" ng-repeat="syllabus in syllabuses">
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3"> <div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}"> <ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /> <li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
<span class="fl ml10 class-list-name hidden">{{course.name}}</span> <img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
<span class="fr c-grey4">&gt;</span> <span class="fl ml10 class-list-name hidden">{{course.name}}</span>
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span> <span class="fr c-grey4">&gt;</span>
</li> <span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
</ul> </li>
</ul>
</div>
</div> </div>
<div>
<div ng-repeat="syllabus in syllabuses">
<div class="course-diff-row border-top mt10"><span class="c-blue f13 ml10">我参与的课程</span></div> <div class="course-diff-row border-top mt10"><span class="c-blue f13 ml10">我参与的课程</span></div>
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div> <div ng-show = "!syllabus.can_setting" ng-repeat="syllabus in syllabuses">
<ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3"> <div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3"><img src="/images/wechat/plus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div>
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}"> <ul ng-show="!syllabus.show_plus" class="class-list f13 c-grey3">
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /> <li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
<span class="fl ml10 class-list-name hidden">{{course.name}}</span> <img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
<span class="fr c-grey4">&gt;</span> <span class="fl ml10 class-list-name hidden">{{course.name}}</span>
<span class="students-amount f12 fr mt10">{{course.member_count}}人</span> <span class="fr c-grey4">&gt;</span>
</li> <span class="students-amount f12 fr mt10">{{course.member_count}}人</span>
</ul> </li>
</ul>
</div>
</div> </div>
<div class="bottom-tab-wrap mt10"> <div class="bottom-tab-wrap mt10">
<a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a> <a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a>
<a ng-click="joinClass()" class="weixin-tab link-blue2 border-top">加入班级</a> <a ng-click="joinClass()" class="weixin-tab link-blue2 border-top">加入班级</a>

View File

@ -137,6 +137,9 @@ app.controller('ActivityController',
//跳到详情页 //跳到详情页
$scope.goDetail = function(type, act_id,id){ $scope.goDetail = function(type, act_id,id){
rms.save("yoffset", window.document.body.scrollTop); 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); $location.path('/'+type+'/'+act_id);
} }

View File

@ -86,7 +86,7 @@ app.factory('rms', function(){
return {save: save, get: get}; 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){ var addCommonReply = function(id, type, data, cb){
if(!data.comment || data.comment.length<=0){ 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}; return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};