123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- angular.module('push')
- .controller('resourcePrivateDetailsCtrl', function ($scope, ResourceLibraryService, $stateParams, SearchResultService, UtilService, AuthorityService, $ionicModal,
- ShareService, CommentService, $sce, $timeout, UserService, $ionicActionSheet, $ionicSlideBoxDelegate) {
- //TODO
- if($scope.app){
- $scope.setStatusBar(0);
- }
- //1:需求,2:成果,6:企业,7:高校,8:人才
- var recourceid = $stateParams.recourceid;
- var recourcetype = $scope.type = $stateParams.recourcetype;
- // var recourceid = 1;
- // var recourcetype = 6;
- var recourcecomefrom = $stateParams.recourcecomefrom;
- var creator = $stateParams.creator;
- // var recourceid = "97024";
- // var recourcetype = $scope.type = "7";
- // var recourcecomefrom = "110100000";
- // var creator = 1359;
- var categorylabel = $stateParams.categorylabel;
- $scope.userid = UserService.id;
- $scope.viplevel = UserService.viplevel;
- $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.getPrivateResourceDetail(recourceid, recourcetype, recourcecomefrom).then(function (response) {
- console.log("==============================");
- console.log(response);
- // 基本信息
- $scope.resource = response.data;
- //TODO
- /*//产品 6
- $scope.productlist = response.detailMap.company_product_lk;
- //需求 6
- $scope.techrequirementlist = response.detailMap.company_techrequirement_lk;
- //产学研经历 6
- $scope.iurlist1 = response.detailMap.company_iur_lk_1;
- //科研项目 6
- $scope.iurlist2 = response.detailMap.company_iur_lk_2;
- //成果 8
- $scope.researchfindinglist = response.detailMap.researchfinding;
- //专利表 6 8 2
- $scope.intprolist = response.detailMap.intellectualproperty;
- //专利表 7
- $scope.intellectualpropertylist = response.res.intellectualpropertylist;
- // 成果 7
- $scope.technicalinfolist = response.res.technicalinfolist;
- //人员 7
- $scope.signuplist = response.res.expertlibrarylist;
- //特色专业 7
- $scope.specialtylist = response.res.specialtylist;
- //论文列表 7
- $scope.paperlist = response.res.paperlist;
- //已合作企业 7
- $scope.coopenterpriselist = response.res.coopenterpriselist;
- //意向企业 7
- $scope.intentionalerpriselist = response.res.intentionalerpriselist;
- //实验室 7
- $scope.univlablist = response.res.univlablist;
- //产学研中心 7
- $scope.iurlist3 = response.res.iurlist;
- //附件 7
- $scope.orglibrarydoclist = response.res.orglibrarydoclist;
- //历年申报项目 6
- $scope.calendarlist = response.res.calendarlist;
- //获取相关资源
- $scope.getRelativeResource();
- $scope.contenthtml = $sce.trustAsHtml($scope.resource.content);
- //分享链接
- sharelink = response.res.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 () {
- })
- };
- //TODO
- getHotCommentList();
- //提取当前用户是否有 查看/编辑 本记录权限
- var getVisitAuthority = function () {
- ResourceLibraryService.getVisitAuthority(1, recourceid, creator, recourcecomefrom, recourcetype).then(function (response) {
- // console.log(response);
- // isedit:是否可以编辑资源,isset:是否可以设置权限,bl:是否可以访问
- getPublicResourceList();
- $scope.roler = response;
- }, function () {
- })
- };
- //TODO
- getVisitAuthority();
- $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 {
- if (relative.groupid == "0") {
- $scope.go('resourceDetails', {
- recourceid: relative.unique,
- recourcetype: relative.type,
- recourcecomefrom: relative.source,
- categorylabel: categorylabel
- });
- } else {
- $scope.go('resourcePrivateDetails', {
- recourceid: relative.unique,
- recourcetype: relative.type,
- recourcecomefrom: relative.source,
- creator: relative.clickthrough
- });
- }
- }
- };
- //关联跳转
- $scope.goRelResource = function (resource) {
- if (!UtilService.isDefined(resource.resourceid)) {
- return;
- }
- $scope.go('resourcePrivateDetails', {
- recourceid: resource.resourceid,
- recourcetype: resource.resourcetype,
- recourcecomefrom: resource.resourcecomefrom,
- creator: resource.resourcecreator
- });
- };
- //进入相关资源列表
- $scope.goResourceMatch = function (relative) {
- $scope.go('resourceMatch', {type: relative.type, title: $scope.resource.title, categorylabel: categorylabel});
- };
- $scope.goResourceApply = function () {
- if ($scope.viplevel == 1) {
- AuthorityService.isHasEnoughCount(1).then(function (response) {
- if (response.isHasEnoughCount == 1) {
- var tempdata = {
- title: $scope.resource.title,
- recourceid: recourceid,
- recourcetype: recourcetype,
- recourcecomefrom: recourcecomefrom
- };
- $scope.go("resourceApply", {authoritydata: angular.toJson(tempdata)})
- } else {
- UtilService.showMess("本月申请次数已用完");
- }
- }, function () {
- });
- } else {
- var tempdata = {
- title: $scope.resource.title,
- recourceid: recourceid,
- recourcetype: recourcetype,
- recourcecomefrom: recourcecomefrom
- };
- $scope.go("resourceApply", {authoritydata: angular.toJson(tempdata)})
- }
- };
- //资源点赞
- $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.openActionSheet = function () {
- // isedit:是否可以编辑资源,isset:是否可以设置权限
- var buttonlist = [];
- if ($scope.roler.isset) {
- buttonlist.push({text: '设置'})
- }
- $ionicActionSheet.show({
- buttons: buttonlist,
- cancelText: '取消',
- buttonClicked: function (index) {
- if (index == 0) {
- var tempdata = {
- title: $scope.resource.title,
- recourceid: recourceid,
- recourcetype: recourcetype,
- recourcecomefrom: recourcecomefrom,
- creator: creator
- };
- $scope.go("authorityRecordSet", {authoritydata: angular.toJson(tempdata)});
- }
- /*else if (index = 1) {
- console.log('编辑');
- $scope.go("editResourcePrivateDetails", {resource: angular.toJson($scope.resource), type: recourcetype});
- }*/
- return true;
- }
- });
- };
- //点击图片放大
- $scope.bigImage = false; //初始默认大图是隐藏的
- $scope.hideBigImage = function () {
- $timeout(function () {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- $scope.bigImage = false;
- }, 400);
- };
- $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl)
- if($scope.app){
- $scope.setStatusBar(1);
- }
- // console.log(piclist);
- // console.log(index);
- $scope.commentpiclist = piclist;
- $scope.bigImage = true; //显示大图
- // console.log(index);
- $(function () {
- $('div.pinch-zoom').each(function () {
- new RTP.PinchZoom($(this), {});
- });
- });
- $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
- //图片总数量
- setTimeout(function () {
- // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
- // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
- $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
- //获取图片
- var imgObj = document.getElementsByClassName('bigimage');
- var n;
- for (n = 0; n < imgObj.length; n++) {
- // 获取图片的原始高度和宽度
- var oldWid = imgObj[n].naturalWidth;
- var oldHei = imgObj[n].naturalHeight;
- var screen = document.body.offsetWidth;
- var screenH = window.innerHeight;
- // console.log(oldWid/oldHei);
- // console.log(screen );
- var cc = screen / (oldWid / oldHei);
- imgObj[n].style.height = cc + 'px';
- if (cc < screenH) {
- imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
- // console.log("e:" + imgObj[n].style.marginTop);
- } else {
- imgObj[n].style.marginTop = 0 + 'px';
- // console.log((cc - screenH) + 'px')
- }
- }
- }, 0);
- };
- //查看原图
- $scope.viewOldImg = function (index) {
- // console.log($scope.commentpiclist[index]);
- // console.log("查看原图" + index);
- var url = UtilService.isDefined($scope.commentpiclist[index].source_name) ? $scope.commentpiclist[index].source_name : $scope.commentpiclist[index].photo_name;
- $(".bigimage").eq(index).attr("src", $scope.imgUrl + url);
- $timeout(function () {
- $scope.commentpiclist[index].loadsource = true;
- }, 20);
- };
- //请求SDK权限
- $scope.loadImg = function (pic) {
- if (UtilService.checkPlatform()) {
- window.imagePicker.verifyStorage(
- function (results) {
- if (results == "1") {
- downloadPicture(pic);
- }
- }, function (error) {
- }
- );
- } else {
- downloadPicture(pic);
- }
- };
- //图片下载
- var downloadPicture = function (pic) {
- $scope.showLoadingToast();
- var fileTransfer = new FileTransfer();
- var url = UtilService.isDefined(pic.source_name) ? pic.source_name : pic.photo_name;
- var imgname = url.substring(url.lastIndexOf('/') + 1);//图片名称
- var loadurl = $scope.imgUrl + url;//图片下载地址
- var fileURL = "";//下载后的地址
- if (UtilService.checkPlatform()) {
- fileURL = cordova.file.externalRootDirectory + "pushpicture/" + imgname;
- } else {
- fileURL = cordova.file.documentsDirectory + imgname;
- }
- // console.log(loadurl);
- // console.log(fileURL);
- fileTransfer.download(
- loadurl,
- fileURL,
- function (entry) {
- // console.log(entry);
- if (UtilService.checkPlatform()) {
- var tempstr = entry.toURL().replace("file://", "");
- UtilService.showMess("图片下载成功,地址:" + tempstr);
- } else {
- UtilService.showMess("图片下载成功");
- }
- $scope.hideLoadingToast();
- },
- function (error) {
- // console.log(error);
- $scope.hideLoadingToast();
- UtilService.showMess("网络不给力,请重试");
- },
- null, // or, pass false
- {
- //headers: {
- // "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
- //}
- }
- );
- };
- //拨打电话
- $scope.openTel = function (tel) {
- window.open("tel:" + tel);
- };
- //新增名片
- $scope.openCard1 = function () {
- $(".openCard1").toggleClass("upCardArrowEm");
- $(".openCardDiv1").toggle();
- };
- $scope.openCard2 = function () {
- $(".openCard2").toggleClass("upCardArrowEm");
- $(".openCardDiv2").toggle();
- };
- $scope.openCard3 = function () {
- $(".openCard3").toggleClass("upCardArrowEm");
- $(".openCardDiv3").toggle();
- };
- $scope.openCard4 = function () {
- $(".openCard4").toggleClass("upCardArrowEm");
- $(".openCardDiv4").toggle();
- };
- $scope.openCard5 = function () {
- $(".openCard5").toggleClass("upCardArrowEm");
- $(".openCardDiv5").toggle();
- };
- $scope.openCard6 = function () {
- $(".openCard6").toggleClass("upCardArrowEm");
- $(".openCardDiv6").toggle();
- };
- $scope.openCard7 = function () {
- $(".openCard7").toggleClass("upCardArrowEm");
- $(".openCardDiv7").toggle();
- };
- $scope.openCard8 = function () {
- $(".openCard8").toggleClass("upCardArrowEm");
- $(".openCardDiv8").toggle();
- };
- $scope.openCard9 = function () {
- $(".openCard9").toggleClass("upCardArrowEm");
- $(".openCardDiv9").toggle();
- };
- $scope.openCard10 = function () {
- $(".openCard10").toggleClass("upCardArrowEm");
- $(".openCardDiv10").toggle();
- };
- $scope.openCard11 = function () {
- $(".openCard11").toggleClass("upCardArrowEm");
- $(".openCardDiv11").toggle();
- };
- $scope.openCard12 = function () {
- $(".openCard12").toggleClass("upCardArrowEm");
- $(".openCardDiv12").toggle();
- };
- $scope.openCard13 = function () {
- $(".openCard13").toggleClass("upCardArrowEm");
- $(".openCardDiv13").toggle();
- };
- $scope.openCard14 = function () {
- $(".openCard14").toggleClass("upCardArrowEm");
- $(".openCardDiv14").toggle();
- };
- $scope.tttindex = 5;
- $scope.showMoreSignup = function () {
- $scope.tttindex = $scope.signuplist.length;
- };
- //关联跳转列表页
- $ionicModal.fromTemplateUrl('templates/moreresourcelist.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function (modal) {
- $scope.modal = modal;
- });
- //关闭关联列表
- $scope.hideModel = function () {
- $scope.modal.hide();
- $scope.moreresourcelist = [];
- };
- //打开关联列表
- $scope.showModel = function () {
- $scope.modal.show();
- };
- //关联跳转人才
- $scope.goPersonResource = function (resource) {
- if (UtilService.isDefined(resource.resourcelibrary)) {
- if(resource.resourcelibrary.length==1){
- var tempobj = resource.resourcelibrary[0];
- $scope.go('resourcePrivateDetails', {
- recourceid: tempobj.unique,
- recourcetype: tempobj.type,
- recourcecomefrom: tempobj.source,
- creator: tempobj.clickthrough
- });
- }
- if(resource.resourcelibrary.length>1){
- $scope.modal.hide();
- $scope.moreresourcelist = resource.resourcelibrary;
- }
- }
- };
- });
|