123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- angular.module('push')
- .controller('relativeDetailsCtrl', function ($scope, ResourceLibraryService, $stateParams, SearchResultService, UtilService,
- ShareService, CommentService, $sce, $timeout, UserService) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- //1:需求,2:成果,6:企业,8:人才
- var recourceid = $stateParams.recourceid;
- var recourcetype = $stateParams.recourcetype;
- var recourcecomefrom = $stateParams.recourcecomefrom;
- var categorylabel = $stateParams.categorylabel;
- $scope.userid = UserService.id;
- $scope.comment = {content: ""};
- //获取相关资源
- $scope.getRelativeResource = function () {
- CommentService.getRelativeResource(0, $scope.resource.title, categorylabel, "", recourceid, "").then(function (response) {
- // console.log(response);
- $scope.relativelist = response.resourcelibrary;
- $scope.relativerecord = response.connectioninfoEntity;
- }, function () {
- })
- };
- var sharelink = "";
- //获取资源库列表
- var getPublicResourceList = function () {
- ResourceLibraryService.getResourceDetail(recourceid, recourcetype, recourcecomefrom).then(function (response) {
- // console.log(response);
- $scope.resource = response.res;
- $scope.getRelativeResource();
- $scope.contenthtml = $sce.trustAsHtml($scope.resource.content);
- if (angular.isDefined($scope.resource.cperlist) && $scope.resource.cperlist.length > 0) {
- $scope.modelstr = $scope.resource.cperlist.join(",");
- } else {
- $scope.modelstr = "";
- }
- sharelink = response.sharelink;
- }, function () {
- })
- };
- getPublicResourceList();
- var getHotCommentList = function () {
- CommentService.getHotCommentList(recourceid, recourcetype).then(function (response) {
- // console.log(response);
- $scope.commentlist = response.res.comment;
- $scope.MoreComment = response.MoreComment;
- }, function () {
- })
- };
- getHotCommentList();
- $scope.shareflg = false;
- $scope.openShare = function () {
- $scope.shareflg = true;
- };
- $scope.closeShare = function () {
- $scope.shareflg = false;
- };
- //关注用户 --已经关注是1,未关注是2
- $scope.focusUser = function () {
- var status = $scope.resource.Focus ? 1 : 2;
- SearchResultService.doFocus(status, $scope.resource.creator).then(function (response) {
- // console.log(response);
- if (response.status == true) {
- if ($scope.resource.Focus) {
- $scope.resource.Focus = false;
- UtilService.showMess("取消关注成功");
- } else {
- $scope.resource.Focus = true;
- UtilService.showMess("关注成功");
- }
- } else {
- UtilService.showMess("网络不给力,请重试");
- }
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- });
- };
- //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
- $scope.shareMessage = function (type) {
- $scope.shareflg = false;
- $scope.showLoadingToast();
- CommentService.createShareRecord(sharelink, recourceid, recourcecomefrom, recourcetype).then(function (response) {
- // console.log(response);
- var imagurl = "http://test.ubitech.cn/000000000/themes/avatar_save/1490753632823.jpg";
- var tempcontent = $scope.resource.content.substring(0, 19);
- var message = {
- title: $scope.resource.title,
- description: tempcontent,
- url: response.shareurl,
- imageurl: imagurl
- };
- switch (type) {
- case 0:
- case 1:
- ShareService.shareToQQ(type, message).then(function () {
- UtilService.showMess("QQ分享成功");
- getCurrencyFromShare(response.clickid);
- $scope.hideLoadingToast();
- }, function (error) {
- UtilService.showMess(error);
- $scope.hideLoadingToast();
- });
- break;
- case 2:
- case 3:
- ShareService.shareToWechat(0, message).then(function () {
- UtilService.showMess("微信分享成功");
- getCurrencyFromShare(response.clickid);
- $scope.hideLoadingToast();
- }, function (error) {
- UtilService.showMess(error);
- $scope.hideLoadingToast();
- });
- break;
- case 4:
- ShareService.shareToWeibo(message).then(function () {
- UtilService.showMess("新浪微博分享成功");
- getCurrencyFromShare(response.clickid);
- $scope.hideLoadingToast();
- }, function (error) {
- UtilService.showMess(error);
- $scope.hideLoadingToast();
- });
- break;
- default:
- break;
- }
- $timeout(function () {
- $scope.hideLoadingToast();
- }, 10000);
- }, function () {
- $scope.hideLoadingToast();
- })
- };
- var getCurrencyFromShare = function (clickid) {
- CommentService.getCurrencyFromShare(clickid);
- };
- $scope.showbutton = true;
- //详情页评论
- $scope.showComment = true;
- $scope.publishComment = function () {
- $scope.showComment = true;
- var content = $scope.comment.content;
- //提交评论信息
- $scope.showLoadingToast();
- CommentService.publishComment(0, recourceid, recourcetype, "", "", content, recourcecomefrom).then(function () {
- UtilService.showMess("评论成功");
- $scope.comment.content = "";
- getHotCommentList();
- if ($scope.commentlist.length >= 3) {
- $timeout(function () {
- $scope.goCommentList();
- }, 650);
- }
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- });
- };
- //发表详细评论
- $scope.releaseComment = function () {
- $scope.go('releaseComment', {
- infoid: recourceid,
- infotype: recourcetype,
- comlen: $scope.commentlist.length,
- recourcecomefrom: recourcecomefrom
- })
- };
- //进入评论列表页
- $scope.goCommentList = function () {
- $timeout(function () {
- $scope.go('toolDiscuss', {
- infoid: recourceid,
- infotype: recourcetype,
- recourcecomefrom: recourcecomefrom,
- isedit: $scope.roler.isedit
- });
- }, 350);
- };
- //进入资源详情
- $scope.goRelativeResource = function (relative) {
- if (relative.type == 81) {
- $scope.go('cloudDockingdetail', {infoid: relative.id, creator: relative.creator});
- } else {
- $scope.go('resourceDetails', {
- recourceid: relative.unique,
- recourcetype: relative.type,
- recourcecomefrom: relative.source,
- categorylabel: categorylabel
- });
- }
- };
- //进入相关资源列表
- $scope.goResourceMatch = function (relative) {
- $scope.go('resourceMatch', {type: relative.type, title: $scope.resource.title, categorylabel: categorylabel});
- };
- //资源点赞
- $scope.dianZan = function () {
- CommentService.clickFavour(recourceid, recourcetype, $scope.resource.source, recourcecomefrom).then(function (response) {
- // console.log(response);
- if (response.favourState == 1) {
- $scope.resource.favourcount++;
- $scope.resource.Like = true;
- } else {
- $scope.resource.favourcount--;
- $scope.resource.Like = false;
- }
- // UtilService.showMess(response.clickStatus);
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- })
- };
- //评论点赞
- $scope.content_zan = function (comment, index) {
- CommentService.commentLike(comment.id, recourcetype).then(function (response) {
- // console.log(response);
- if (response.favourState == 1) {
- $scope.commentlist[index].favourcount++;
- $scope.commentlist[index].Like = true;
- } else {
- $scope.commentlist[index].favourcount--;
- $scope.commentlist[index].Like = false;
- }
- // UtilService.showMess(response.clickStatus);
- }, function () {
- })
- };
- //收藏
- $scope.collectResource = function () {
- CommentService.collectResource(recourceid, recourcetype, $scope.resource.source, 1).then(function (response) {
- // console.log(response);
- if (response.clickStatus == "收藏成功") {
- $scope.resource.Enshrine = true;
- } else {
- $scope.resource.Enshrine = false;
- }
- UtilService.showMess(response.clickStatus);
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- })
- };
- //进入评论详情页
- $scope.goCommentDetail = function (comment) {
- $scope.go('resourceCommentReply', {
- comment: angular.toJson(comment),
- infoid: recourceid,
- infotype: recourcetype,
- recourcecomefrom: recourcecomefrom,
- isedit: $scope.roler.isedit
- });
- };
- //点击强沙发
- $scope.hadSoft = function () {
- $scope.showComment = false;
- };
- $scope.showComment = true;
- $scope.focus_write = function () {
- $scope.showComment = false;
- $(".my_comment").focus();
- };
- $scope.hiddenComment = function () {
- $scope.showComment = true;
- };
- //弹出评论框
- $scope.commentValue = function () {
- var search_history = angular.element(document.getElementsByClassName("my_comment"));
- if ($scope.comment.content.length > 1000) {
- UtilService.showMess("您的评论已超过1000字!");
- $scope.comment.content = $scope.comment.content.substr(0, 1000);
- }
- if (search_history.val.length != 0) {
- $scope.commentNotnull = {
- "background-color": "#2a90d7",
- "text-decoration": "underline"
- };
- }
- };
- //删除自己刚刚发布或者以后的评论
- $scope.delectToolDis = function (commentid) {
- $scope.showLoadingToast();
- CommentService.deleteComment(commentid).then(function () {
- UtilService.showMess("删除成功");
- getHotCommentList();
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- });
- };
- //拨打电话
- $scope.openTel = function (tel) {
- window.open("tel:" + tel);
- };
- });
|