123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- angular.module('push')
- .controller('ReplyCtrl', function ($scope, $stateParams, UserService, $timeout,replyService,ConfigService,UtilService, $ionicLoading, CommentService, ConstantService,CommonService) {
- //TODO
- if($scope.app){
- $scope.setStatusBar(0);
- }
- //提交的回复
- $scope.replay = [
- {
- say:""
- }
- ];
- $scope.replay.isCommentZan=false;
- //回复的对象(那条评论)
- var comment = $scope.discuss = $stateParams.comment;
- var siteName = $stateParams.siteName;
- var id = comment.id;
- //回复的父id(也就是评论的id)
- var parentId = comment.id;
- //回复的那条评论的用户id
- var parentUserId = comment.creator;
- //拿到之前内页的信息id和type
- var infoType = $scope.moduleId = $stateParams.infotype;
- var infoId = $scope.id = $stateParams.infoid;
- // 点赞
- $scope.TRACE_TYPE_2615 = ConstantService.TRACE_TYPE_2615;
- // 取消点赞
- $scope.TRACE_TYPE_2616 = ConstantService.TRACE_TYPE_2616;
- // 评论表 info_comment
- $scope.TABLE_CODE_30002 = ConstantService.TABLE_CODE_30002;
- // 评论/评论回复的传参
- $scope.infoComment=
- {
- infoid: infoId,//资源id
- infotype:ConstantService.TABLE_CODE_30002,// 资源类别
- parentid:parentId,// 评论回复时,记录父评论的id
- parentuserid:parentUserId,// 评论回复时,记录父评论的创建者
- content:"",// 评论/回复内容
- //TODO
- creator:UserService.id,// 创建者
- updater:UserService.id// 更新者
- // creator:1,// 创建者
- // updater:1// 更新者
- };
- // 点赞、收藏、分享的传参
- $scope.clickRecord=
- {
- //TODO
- targetid: parentId,
- // targetid: 124,
- // moduleid: ConstantService.TABLE_CODE_30002,
- userid:UserService.id,
- // userid:1,
- clicktype:1
- };
- // 获取评论回复列表的传参
- $scope.paramsForInfoReplyCommentList=
- {
- id: id // 评论id
- };
- //进详情加载评论列表
- var getInfoReplyCommentModelList = function () {
- CommentService.getInfoReplyCommentModelList($scope.paramsForInfoReplyCommentList).then(function (response) {
- console.log(response);
- // 评论列表
- $scope.replys = response.data;
- }, function () {
- });
- };
- getInfoReplyCommentModelList();
- //评论详情页回复提交
- $scope.appreplay = function () {
- $scope.showComment=true;
- var islogin = ConfigService.islogin;
- if (!islogin) {
- UtilService.showMess("请登录");
- } else {
- var content = $scope.replay.say;
- //提交评论信息
- replyService.appreply(infoId,infoType,content,parentId,parentUserId,siteName).then(function () {
- //回复成功后重新获取回复列表
- replyService.replyList(id).then(function (response) {
- $scope.replys = response.comment;
- }, function () {
- });
- //重置评论内容为空
- $scope.replay.say = "";
- }, function () {
- });
- }
- };
- // 控制重复点击
- var flag = 1;
- // 操作:点赞
- // 操作:取消点赞
- $scope.commentPraiseAction=function (comment, ind, clicktype, recourceid, moduleid) {
- if(flag == 0){
- return;
- }
- flag = 0;
- $scope.clickRecord.targetid = recourceid;
- $scope.clickRecord.clicktype = clicktype;
- $scope.clickRecord.moduleid = moduleid;
- CommentService.postClickFavour($scope.clickRecord).then(function (response) {
- console.log(response);
- if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
- // 点赞
- if(clicktype == $scope.TRACE_TYPE_2615) {
- if (!comment.favour) {
- $scope.discuss.favourcount = $scope.discuss.favourcount + 1;
- $scope.discuss.isCommentZan=true;
- }
- }else
- // 取消点赞
- if(clicktype == $scope.TRACE_TYPE_2616) {
- if (comment.favour) {
- $scope.discuss.favourcount = $scope.discuss.favourcount - 1;
- $scope.discuss.isCommentZan=false;
- }
- }
- $scope.discuss.favour=!$scope.discuss.favour;
- }
- // 恢复可用
- flag = 1;
- }, function () {
- // 恢复可用
- flag = 1;
- UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
- });
- };
- //发布普通评论
- $scope.publishComment = function (type, comment) {
- $scope.showComment = true;
- var content = $scope.replay.say;
- $scope.infoComment.content = content;
- // 评论
- if(type == 1){
- $scope.infoComment.parentid = 0;// 评论回复时,记录父评论的id
- $scope.infoComment.parentuserid = 0;// 评论回复时,记录父评论的创建者
- }
- // 评论回复
- else if(type == 2){
- $scope.infoComment.parentid = comment.id;// 评论回复时,记录父评论的id
- $scope.infoComment.parentuserid = comment.creator;// 评论回复时,记录父评论的创建者
- $scope.infoComment.infotype = ConstantService.TABLE_CODE_30002;// 评论回复默认code:30002
- }
- //提交评论信息
- $scope.showLoadingToast();
- $scope.infoComment.contenttype=$stateParams.comfrom;
- CommentService.publishSimpleComment($scope.infoComment).then(function () {
- //TODO
- if($scope.app){
- UtilService.showMess("回复成功");
- }else{
- CommonService.showMessage("回复成功",$scope);
- }
- $timeout(function () {
- $scope.replay.say = "";
- getInfoReplyCommentModelList();
- }, 450);
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- });
- };
- $scope.showComment=true;
- $scope.focus_write=function () {
- $scope.showComment=false;
- };
- $scope.hiddenComment=function () {
- $scope.showComment=true;
- };
- $scope.commentValue=function () {
- if (UtilService.isDefined($scope.replay.say) && $scope.replay.say.length >1000) {
- UtilService.showMess("您的回复已超过1000字!");
- $scope.replay.say = $scope.replay.say.substr(0, 1000);
- }
- if (UtilService.isDefined($scope.replay.say) && $scope.replay.say.length != 0){
- $scope.commentNotnull = {
- "background-color": "#2a90d7",
- "text-decoration": "underline"
- }
- }else {
- $scope.commentNotnull = {
- "background-color": "#ccc"
- };
- }
- };
- $timeout(function () {
- $ionicLoading.hide();
- }, 1000);
- });
|