resourceCommonInfoDetailsRepeatPageCtrl.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. angular.module('push')
  2. .controller('resourceCommonInfoDetailsRepeatPageCtrl', function ($scope, $timeout, $ionicPopup,$rootScope, $stateParams, $ionicScrollDelegate,$ionicActionSheet,
  3. dataToolsService, CommentService, UserService, UtilService, roleService, ConstantService,
  4. TechnicalBrokerPublishTrainService, ShareService,$ionicSlideBoxDelegate, AccountService,ConfigService,$q,$ionicModal,CommonService) {
  5. $scope.searchtype=4;
  6. // $stateParams.label?$scope.allLabel=JSON.parse($stateParams.label):'';
  7. $scope.defaultLan = UserService.defaultLan;
  8. // 按标签查询页面
  9. var labelResourceListModal=function(){
  10. $ionicModal.fromTemplateUrl('./modules/common/views/labelResourceListModal.html', {
  11. scope: $scope,
  12. animation: 'slide-in-left'
  13. }).then(function (modal) {
  14. $scope.labelResourceListModal = modal;
  15. });
  16. }
  17. labelResourceListModal();
  18. $scope.keyfilter={
  19. key:''
  20. }
  21. // 搜索关键字标红
  22. $scope.badge = function (title) {
  23. var re = eval("/" + $scope.keyfilter.key + "/g");
  24. title = title.replace(re, '<span style="color:red">' + $scope.keyfilter.key + '</span>');
  25. return $sce.trustAsHtml(title)
  26. };
  27. $scope.isShowSearchButton = true;
  28. $scope.showSearchButtonLeft=function(){
  29. $scope.isShowSearchButton = false;
  30. $timeout(function(){
  31. $(".showSearchInput").focus();
  32. },300)
  33. }
  34. $scope.clearSearch=function(){
  35. $scope.isShowSearchButton = true;
  36. $scope.keyfilter.key = "";
  37. }
  38. //进入记录详情
  39. $scope.goDockingdetails = function (rec) {
  40. $scope.islogin = ConfigService.islogin;
  41. if(!$scope.islogin){
  42. if (localStorage.wxFlag == "true") {
  43. if (localStorage.isUserFocusXW == 0) {
  44. var title = localStorage.appidStr;
  45. $ionicPopup.alert({
  46. title: '提示',
  47. template: '请先关注微信公众号"' + title + '"!'
  48. });
  49. return;
  50. } else {
  51. if (localStorage.isUserBindWx == 0) {
  52. var wxFlag = JSON.parse(localStorage.params);
  53. if (wxFlag.weChatModel) {
  54. $scope.go('bindPhone', {
  55. params: localStorage.params,
  56. comfrom: 'maincontroller',
  57. url: window.location.href.split('#/')[1]
  58. });
  59. } else {
  60. $scope.go('login');
  61. return;
  62. }
  63. } else {
  64. $scope.go('login');
  65. return;
  66. }
  67. }
  68. } else {
  69. $scope.go('login');
  70. return;
  71. }
  72. }else{
  73. $scope.labelResourceListModal.hide();
  74. $scope.go('resourceCommonInfoDetailsPage', {resid: rec.id, isAllVisitor: 1,node:UserService.node});
  75. }
  76. };
  77. //TODO
  78. $scope.comfrom=$stateParams.comfrom;
  79. // $stateParams.label?$scope.label=JSON.parse($stateParams.label):'';
  80. var funid=$scope.comfrom=='typein'?2:1;
  81. // 传入参数
  82. //81:对接宝
  83. var recourceid = $stateParams.resid;
  84. var recourcetype = $scope.type = ConstantService.CATEGORY_MODULE_81;
  85. // console.log($stateParams);
  86. var recourcecomefrom = $stateParams.node;
  87. var connid = $stateParams.resid;
  88. var isCache = $stateParams.isCache;
  89. //登录者id
  90. $scope.userId = UserService.id;
  91. $scope.imagelist=[];
  92. $rootScope.imgUrlList=[];
  93. /*var recourceid = 27;
  94. var recourcetype = $scope.type = ConstantService.CATEGORY_MODULE_81;
  95. var recourcecomefrom = "320412000";
  96. var connid = 27;
  97. $scope.userId = 653;*/
  98. //加载等待页
  99. $scope.isloadingPageFloor=false;
  100. //加载失败页
  101. $scope.isloadingPageFail=false;
  102. $scope.isAllVisitor=$stateParams.isAllVisitor;//1:云走访,0是我的走访
  103. // 提交的评论
  104. $scope.comment = {content: ""};
  105. // 点赞
  106. $scope.TRACE_TYPE_2615 = ConstantService.TRACE_TYPE_2615;
  107. // 取消点赞
  108. $scope.TRACE_TYPE_2616 = ConstantService.TRACE_TYPE_2616;
  109. // 关注
  110. $scope.TRACE_TYPE_2617 = ConstantService.TRACE_TYPE_2617;
  111. // 取消关注
  112. $scope.TRACE_TYPE_2618 = ConstantService.TRACE_TYPE_2618;
  113. // 收藏
  114. $scope.TRACE_TYPE_2619 = ConstantService.TRACE_TYPE_2619;
  115. // 取消收藏
  116. $scope.TRACE_TYPE_2620 = ConstantService.TRACE_TYPE_2620;
  117. // 分享
  118. $scope.TRACE_TYPE_2628 = ConstantService.TRACE_TYPE_2628;
  119. // 无权限显示内容
  120. $scope.TRACE_TYPE_STRING_2600 = ConstantService.TRACE_TYPE_STRING_2600;
  121. // 私密显示内容
  122. $scope.TRACE_TYPE_STRING_2603 = ConstantService.TRACE_TYPE_STRING_2603;
  123. // 基本信息表 resourcelibrary
  124. $scope.TABLE_CODE_30001 = ConstantService.TABLE_CODE_30001;
  125. // 评论表 info_comment
  126. $scope.TABLE_CODE_30002 = ConstantService.TABLE_CODE_30002;
  127. // 对接信息表 connectioninfo 走访
  128. $scope.TABLE_CODE_30003 = ConstantService.TABLE_CODE_30003;
  129. // 用户基本信息 sys_users
  130. $scope.TABLE_CODE_30043 = ConstantService.TABLE_CODE_30043;
  131. //获取走访历史履历
  132. var getHistoryInterviewList = function (orgid, userid,recourcecomefrom,funid) {
  133. TechnicalBrokerPublishTrainService.getHistoryInterviewList("", userid, orgid, 1, funid,recourcecomefrom).then(function (response) {
  134. if(UtilService.isDefined(response.data)){
  135. // 获取走访录入界面的传参
  136. $scope.rolePageModel=
  137. {
  138. //TODO
  139. id: response.data.templettype,// 模版id
  140. orgtype: 0// 走访对应的机构类型
  141. };
  142. // console.log("================历史走访履历==============");
  143. // 基本信息
  144. $scope.historyInterviewList = response.data;
  145. }
  146. }, function () {
  147. });
  148. };
  149. //获取走访详情
  150. var getBasicInfo=function(){
  151. var deferred = $q.defer();
  152. dataToolsService.getConnectioninfoDetailByConnid(connid,1000002,0,recourcecomefrom).then(function (response){
  153. if(response.data){
  154. $scope.isloadingPageFloor=false;
  155. $scope.isloadingPageFail=false;
  156. angular.forEach(response.data.infoSectionList,function(val){
  157. if(val.title){
  158. angular.forEach(val.unitlist,function(value){
  159. if(value.addimg){
  160. value.imageList=[];
  161. value.imageList=JSON.parse(value.content);
  162. }
  163. })
  164. if($stateParams.node=='320412000'||$stateParams.node=='900000001'){
  165. if($scope.comfrom=='typein'&&(($stateParams.templettype!=3&&val.title!='基本信息')||$stateParams.templettype==3)){
  166. $scope.scrollTitle.push(val);
  167. }else if($scope.comfrom!='typein'){
  168. $scope.scrollTitle.push(val);
  169. }
  170. }else{
  171. $scope.scrollTitle.push(val);
  172. }
  173. }
  174. })
  175. $ionicSlideBoxDelegate.update();
  176. }
  177. // $scope.$watch("$scope.connInfoDetail.infoSectionList",function(){
  178. // $ionicSlideBoxDelegate.update();
  179. // });
  180. deferred.resolve(response.data);
  181. })
  182. return deferred.promise;
  183. }
  184. var getPublicResourceList = function () {
  185. $scope.isloadingPageFloor=true;
  186. $scope.scrollTitle=[];
  187. //$scope.showLoadingToast();
  188. // console.log($stateParams);
  189. // 获取基本信息
  190. getBasicInfo().then(function(data){
  191. // dataToolsService.getConnectioninfoDetailByConnid(connid,1000002,0,recourcecomefrom).then(function (response) {
  192. // if(UtilService.isDefined(response.data)){
  193. // // console.log("=============获取走访详情=================");
  194. // console.log(response);
  195. // // 基本信息
  196. // $scope.connInfoDetail=response.data;
  197. // document.title=$scope.connInfoDetail.baseInfoModel.title;
  198. // document.getElementById('shareSourc').setAttribute('src',ConfigService.imgurl+$scope.connInfoDetail.baseInfoModel.logo);
  199. // console.log($scope.connInfoDetail);
  200. // connid=response.data.id;
  201. // $scope.scrollTitle=[];
  202. // angular.forEach(response.data.infoSectionList,function(val){
  203. // if(val.title){
  204. // angular.forEach(val.unitlist,function(value){
  205. // if(value.addimg){
  206. // value.imageList=[];
  207. // value.imageList=JSON.parse(value.content);
  208. // }
  209. // })
  210. // if($stateParams.node=='320412000'||$stateParams.node=='900000001'){
  211. // if($scope.comfrom=='typein'&&(($stateParams.templettype!=3&&val.title!='基本信息')||$stateParams.templettype==3)){
  212. // $scope.scrollTitle.push(val);
  213. // }else if($scope.comfrom!='typein'){
  214. // $scope.scrollTitle.push(val);
  215. // }
  216. // }else{
  217. // $scope.scrollTitle.push(val);
  218. // }
  219. // }
  220. // })
  221. // $ionicSlideBoxDelegate.update();
  222. // $scope.$watch("$scope.connInfoDetail.infoSectionList",function(){
  223. // $ionicSlideBoxDelegate.update();
  224. // });
  225. // var orgid=$scope.connInfoDetail.baseInfoModel.oid;
  226. // var recourcecomefrom = $stateParams.node;
  227. // // angular.forEach($scope.connInfoDetail.infoSectionList,function (value) {
  228. // // angular.forEach(value.unitlist,function (content) {
  229. // // if(content.addimg==1){
  230. // // $scope.imagelist=JSON.stringify(content.content).toString();
  231. // // var imgWrap = JSON.parse($scope.imagelist);
  232. // // var v1=eval(imgWrap);
  233. // // $rootScope.imgUrlList=$rootScope.imgUrlList.concat(v1);
  234. // // }
  235. // // });
  236. // // });
  237. //
  238. // console.log($scope.connInfoDetail.infoSectionList);
  239. // // console.log($rootScope.imgUrlList);
  240. // $timeout(function () {
  241. // $(".main-select").eq(0).addClass("arrange_borderBottom")
  242. // }, 50);
  243. // // 获取走访详情后,判断
  244. // $timeout(function () {
  245. // //1:云走访,传递用户id=0,0是我的走访,传递登录用户
  246. // var userid = UserService.id;
  247. // if($scope.isAllVisitor == 1){
  248. // userid = 0;
  249. // }
  250. // getHistoryInterviewList(orgid, userid,recourcecomefrom,funid);
  251. // }, 100);
  252. // }
  253. // $timeout(function () {
  254. // $scope.isloadingPageFloor=false;
  255. // $scope.isloadingPageFail=false;
  256. // },50);
  257. // //$scope.hideLoadingToast();
  258. // }, function () {
  259. // $scope.isloadingPageFloor=false;
  260. // //$scope.hideLoadingToast();
  261. // if($scope.app){
  262. // UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  263. // }else{
  264. // CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR,$scope);
  265. // }
  266. // $scope.isloadingPageFail=true;
  267. // });
  268. // 获取其他信息
  269. dataToolsService.getConnectionOtherInfoDetail(connid,1000002,0,recourcecomefrom).then(function (response) {
  270. if(UtilService.isDefined(response.data)){
  271. // console.log("=============获取走访详情=================");
  272. console.log(response);
  273. $scope.connInfoDetail={};
  274. // 基本信息
  275. if(data.id){
  276. if(response.data.id){
  277. $scope.connInfoDetail=response.data;
  278. $scope.connInfoDetail.infoSectionList=Object.assign($scope.connInfoDetail.infoSectionList,data.infoSectionList);
  279. }else{
  280. $scope.connInfoDetail=data;
  281. }
  282. }
  283. document.title=$scope.connInfoDetail.baseInfoModel.title;
  284. document.getElementById('shareSourc').setAttribute('src',ConfigService.imgurl+$scope.connInfoDetail.baseInfoModel.logo);
  285. console.log($scope.connInfoDetail);
  286. connid=$scope.connInfoDetail.id;
  287. angular.forEach(response.data.infoSectionList,function(val){
  288. if(val.title){
  289. angular.forEach(val.unitlist,function(value){
  290. if(value.addimg){
  291. value.imageList=[];
  292. value.imageList=JSON.parse(value.content);
  293. }
  294. })
  295. if($stateParams.node=='320412000'||$stateParams.node=='900000001'){
  296. if($scope.comfrom=='typein'&&(($stateParams.templettype!=3&&val.title!='基本信息')||$stateParams.templettype==3)){
  297. $scope.scrollTitle.push(val);
  298. }else if($scope.comfrom!='typein'){
  299. $scope.scrollTitle.push(val);
  300. }
  301. }else{
  302. $scope.scrollTitle.push(val);
  303. }
  304. }
  305. })
  306. $ionicSlideBoxDelegate.update();
  307. $scope.$watch("$scope.connInfoDetail.infoSectionList",function(){
  308. $ionicSlideBoxDelegate.update();
  309. });
  310. var orgid=$scope.connInfoDetail.baseInfoModel.oid;
  311. var recourcecomefrom = $stateParams.node;
  312. // angular.forEach($scope.connInfoDetail.infoSectionList,function (value) {
  313. // angular.forEach(value.unitlist,function (content) {
  314. // if(content.addimg==1){
  315. // $scope.imagelist=JSON.stringify(content.content).toString();
  316. // var imgWrap = JSON.parse($scope.imagelist);
  317. // var v1=eval(imgWrap);
  318. // $rootScope.imgUrlList=$rootScope.imgUrlList.concat(v1);
  319. // }
  320. // });
  321. // });
  322. console.log($scope.connInfoDetail.infoSectionList);
  323. // console.log($rootScope.imgUrlList);
  324. $timeout(function () {
  325. $(".main-select").eq(0).addClass("arrange_borderBottom")
  326. }, 50);
  327. // 获取走访详情后,判断
  328. $timeout(function () {
  329. //1:云走访,传递用户id=0,0是我的走访,传递登录用户
  330. var userid = UserService.id;
  331. if($scope.isAllVisitor == 1){
  332. userid = 0;
  333. }
  334. getHistoryInterviewList(orgid, userid,recourcecomefrom,funid);
  335. }, 100);
  336. }
  337. $timeout(function () {
  338. $scope.isloadingPageFloor=false;
  339. $scope.isloadingPageFail=false;
  340. },50);
  341. //$scope.hideLoadingToast();
  342. }, function () {
  343. $scope.isloadingPageFloor=false;
  344. //$scope.hideLoadingToast();
  345. if($scope.app){
  346. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  347. }else{
  348. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR,$scope);
  349. }
  350. $scope.isloadingPageFail=true;
  351. });
  352. })
  353. };
  354. getPublicResourceList();
  355. // 走访历史列表
  356. $scope.historyInterviewList = [];
  357. //切换到对应页面
  358. var commonChaneSlide=function (num) {
  359. //切换到对应页面
  360. /*$scope.act = $scope.activity[num];*/
  361. /************2018****************/
  362. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
  363. $timeout(function () {
  364. $("#orgname").prop("disabled", true);
  365. },50);
  366. /* $scope.act = $scope.activity[num].className;*/
  367. var alltab=document.querySelectorAll(".main-select");
  368. var tablength = alltab.length;//标题个数
  369. var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
  370. var OffLeft = $(".main-select").eq(num).offset().left;//获取当前点击标题距离父容器左边框的距离
  371. var SelfWidth = $(".main-select").eq(num).width();//获取当前点击标题宽度
  372. var startTranform = $(".visitModule_header .scroll").offset().left+25;
  373. var movewidth = OffLeft - middlewidth + SelfWidth / 2;
  374. startTranform -= movewidth;
  375. if (startTranform <= 0) {
  376. if (num < tablength - 1) {
  377. $('.visitModule_header .scroll').css({
  378. 'transform': 'translate3d(' + startTranform + 'px,0,0)'
  379. });
  380. }
  381. } else if (num < 4) {
  382. $('.visitModule_header .scroll').css({
  383. 'transform': 'translate3d(0,0,0)'
  384. });
  385. }
  386. $(".main-select").eq(num).addClass("arrange_borderBottom").siblings().removeClass("arrange_borderBottom");
  387. $ionicSlideBoxDelegate.slide(num);
  388. };
  389. // 点击页头切换页面
  390. $scope.changeAct = function (num) {
  391. commonChaneSlide(num);
  392. };
  393. $scope.go_changed=function(index){
  394. commonChaneSlide(index);
  395. };
  396. $timeout(function () {
  397. $ionicSlideBoxDelegate.$getByHandle("messageBanner").update();
  398. $(".main-select").eq(0).addClass("arrange_borderBottom")
  399. }, 50);
  400. $scope.repeatLoad = function () {
  401. $scope.isloadingPageFail=false;
  402. getPublicResourceList();
  403. };
  404. //分享
  405. $scope.shareflg = false;
  406. $scope.openShare = function () {
  407. if($scope.app){
  408. $scope.shareflg = true;
  409. }else{
  410. $scope.shareMessage();
  411. }
  412. };
  413. $scope.closeShareBox = function () {
  414. $scope.shareflg = false;
  415. };
  416. //TODO
  417. $scope.showShareWechat=false;
  418. $scope.closeShare=function(){
  419. $scope.showShareWechat=false;
  420. };
  421. var sharelink = "https://blog.csdn.net/molong421/article/details/51586194";
  422. //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
  423. $scope.shareMessage = function (type) {
  424. console.log($scope.connInfoDetail);
  425. $scope.shareflg = false;
  426. var linkUrl=ConfigService.webserver+'#/resourceCommonInfoDetailsRepeatPage/'+$stateParams.resid+'/'+$stateParams.comfrom+'/'+$stateParams.templettype+'/'+$stateParams.node;
  427. var imagurl =$scope.connInfoDetail.baseInfoModel.logo?(ConfigService.imgurl+$scope.connInfoDetail.baseInfoModel.logo):"https://cordova.apache.org/static/img/cordova_bot.png";
  428. var message = {
  429. title: $scope.connInfoDetail.baseInfoModel.title,
  430. description: $scope.connInfoDetail.baseInfoModel.title.substring(0,19),
  431. url: linkUrl,
  432. imageurl: imagurl
  433. };
  434. console.log(linkUrl);
  435. if($scope.app){
  436. $scope.showLoadingToast();
  437. // var message = {
  438. // title: $scope.connInfoDetail.title,
  439. // description: $scope.connInfoDetail.title.substring(0,19),
  440. // url: sharelink,
  441. // imageurl: imagurl
  442. // };
  443. switch (type) {
  444. case 0:
  445. case 1:
  446. ShareService.shareToQQ(type, message).then(function () {
  447. $scope.hideLoadingToast();
  448. if($scope.app){
  449. UtilService.showMess("QQ分享成功");
  450. }else{
  451. CommonService.showMessage("QQ分享成功",$scope);
  452. }
  453. }, function (error) {
  454. $scope.hideLoadingToast();
  455. if($scope.app){
  456. UtilService.showMess(error);
  457. }else{
  458. CommonService.showMessage(error,$scope);
  459. }
  460. });
  461. break;
  462. case 2:
  463. ShareService.shareToWechat(type, message).then(function () {
  464. // UtilService.showMess("微信分享成功");
  465. $scope.hideLoadingToast();
  466. if($scope.app){
  467. UtilService.showMess("微信分享成功");
  468. }else{
  469. CommonService.showMessage("微信分享成功",$scope);
  470. }
  471. }, function (error) {
  472. // UtilService.showMess(error);
  473. $scope.hideLoadingToast();
  474. if($scope.app){
  475. UtilService.showMess(error);
  476. }else{
  477. CommonService.showMessage(error,$scope);
  478. }
  479. });
  480. break;
  481. case 3:
  482. ShareService.shareToWechat(type, message).then(function () {
  483. // UtilService.showMess("微信分享成功");
  484. $scope.hideLoadingToast();
  485. if($scope.app){
  486. UtilService.showMess("微信分享成功");
  487. }else{
  488. CommonService.showMessage("微信分享成功",$scope);
  489. }
  490. }, function (error) {
  491. // UtilService.showMess(error);
  492. $scope.hideLoadingToast();
  493. if($scope.app){
  494. UtilService.showMess(error);
  495. }else{
  496. CommonService.showMessage(error,$scope);
  497. }
  498. });
  499. break;
  500. case 4:
  501. ShareService.shareToWeibo(message).then(function () {
  502. // UtilService.showMess("新浪微博分享成功");
  503. $scope.hideLoadingToast();
  504. if($scope.app){
  505. UtilService.showMess("新浪微博分享成功");
  506. }else{
  507. CommonService.showMessage("新浪微博分享成功",$scope);
  508. }
  509. }, function (error) {
  510. // UtilService.showMess(error);
  511. $scope.hideLoadingToast();
  512. if($scope.app){
  513. UtilService.showMess(error);
  514. }else{
  515. CommonService.showMessage(error,$scope);
  516. }
  517. });
  518. break;
  519. default:
  520. break;
  521. }
  522. $timeout(function () {
  523. $scope.hideLoadingToast();
  524. }, 10000);
  525. }else{
  526. $scope.showShareWechat=true;
  527. var content=document.getElementById('qrcode-dialog');
  528. content.innerHTML='';
  529. console.log($scope.connInfoDetail.baseInfoModel.title);
  530. var qrcode=new QRCode(content,{
  531. text:$scope.connInfoDetail.baseInfoModel.title,
  532. // title: $scope.connInfoDetail.baseInfoModel.title,
  533. // description: $scope.connInfoDetail.baseInfoModel.title.substring(0,19),
  534. // url: linkUrl,
  535. // imageurl: imagurl,
  536. width:200,
  537. height:200
  538. })
  539. qrcode.makeCode(linkUrl);
  540. }
  541. };
  542. //发布普通评论
  543. $scope.publishComment = function (type, comment) {
  544. $scope.showComment = true;
  545. var content = $scope.comment.content;
  546. $scope.infoComment.content = content;
  547. // 评论
  548. if(type == 1){
  549. $scope.infoComment.parentid = 0;// 评论回复时,记录父评论的id
  550. $scope.infoComment.parentuserid = 0;// 评论回复时,记录父评论的创建者
  551. }
  552. // 评论回复
  553. else if(type == 2){
  554. $scope.infoComment.parentid = comment.id;// 评论回复时,记录父评论的id
  555. $scope.infoComment.parentuserid = comment.creator;// 评论回复时,记录父评论的创建者
  556. }
  557. //提交评论信息
  558. $scope.showLoadingToast();
  559. CommentService.publishSimpleComment($scope.infoComment).then(function () {
  560. UtilService.showMess("评论成功");
  561. $scope.infoComment.content = "";
  562. getInfoCommentList();
  563. /*if ($scope.comments.length >= 3) {
  564. $timeout(function () {
  565. $scope.getInfoCommentList();
  566. }, 650);
  567. }*/
  568. $scope.hideLoadingToast();
  569. }, function () {
  570. $scope.hideLoadingToast();
  571. });
  572. };
  573. //发表详细评论
  574. $scope.releaseComment = function () {
  575. $scope.go('releaseComment', {
  576. infoid: recourceid,
  577. infotype: recourcetype,
  578. comlen: $scope.commentlist.length,
  579. recourcecomefrom: recourcecomefrom
  580. })
  581. };
  582. //点击抢沙发
  583. $scope.hadSoft = function () {
  584. $scope.showComment = false;
  585. $(".my_comment").focus();
  586. };
  587. $scope.showComment = true;
  588. $scope.focus_write = function () {
  589. scrollToBottom();//滚动至底部
  590. $scope.showComment = false;
  591. $(".my_comment").focus();
  592. };
  593. $scope.hiddenComment = function () {
  594. $scope.showComment = true;
  595. };
  596. //跳转到评论详情页comment
  597. $scope.goComment = function (comment) {
  598. $scope.go("Reply", {comment: comment, infotype: comment.infotype, infoid: comment.infoid})
  599. };
  600. // 滚动至底部
  601. var scrollToBottom = function () {
  602. $timeout(function () {
  603. $ionicScrollDelegate.$getByHandle("calenderContent").scrollBottom();
  604. }, 0);
  605. };
  606. $scope.openCard=function (item) {
  607. $scope.connInfoDetail.resourceClasses[item].isShowCard=!$scope.connInfoDetail.resourceClasses[item].isShowCard;
  608. };
  609. //进入评论列表页
  610. $scope.goCommentList = function () {
  611. $timeout(function () {
  612. $scope.go('comment', {
  613. mode: 2,
  614. infoid: $scope.connInfoDetail.id,
  615. infotype: $scope.type
  616. });
  617. }, 350);
  618. };
  619. // 申请权限消耗普适积分
  620. var consumptionPushPoints = function (authorityid) {
  621. // 获取录入界面的传参
  622. $scope.requestModel = {
  623. data: [],
  624. userid: UserService.id
  625. };
  626. // 传参格式
  627. $scope.requestModel.data.push(authorityid);
  628. AccountService.consumptionPushPoints($scope.requestModel).then(function (response) {
  629. if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
  630. // console.log("==============申请权限消耗普适积分成功================");
  631. // console.log(response);
  632. // 消耗成功后刷新页面
  633. $scope.go('resourceCommonInfoDetailsPage',
  634. {
  635. resid: recourceid,
  636. isAllVisitor: 1,
  637. isCache:true // 是否要强制刷新
  638. });
  639. }else
  640. if (response.code == ConstantService.INTERFACE_STATUS_CODE_21102) {
  641. // 提示积分不足
  642. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_21102);
  643. }
  644. }, function () {
  645. // 购买失败
  646. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  647. });
  648. };
  649. //查看将消耗
  650. $scope.isCanApply=function () {
  651. $scope.pushvalue = 0;
  652. AccountService.getAuthorityInfo(authorityid).then(function (response) {
  653. if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
  654. // 消耗成功后刷新页面
  655. $scope.authorityinfo = response.data;
  656. $scope.pushvalue = $scope.authorityinfo.pushvalue;
  657. $ionicPopup.show({
  658. title:'申请查看将消耗',
  659. template: "<p class='applyWrapFloor'>" +
  660. "<i class='ion-ios-pricetags'></i>" +
  661. "<em>{{pushvalue}}</em>" +
  662. "<span>普适分</span></p>",
  663. scope: $scope,
  664. buttons: [
  665. {
  666. text: "取消",
  667. onTap: function () {
  668. console.log('取消')
  669. }
  670. },
  671. {
  672. text: '<span class="ionicAction_span">申请</span>',
  673. type: "button-positive",
  674. onTap: function () {
  675. console.log('申请');
  676. // 申请权限消耗普适积分
  677. consumptionPushPoints();
  678. }
  679. }
  680. ]
  681. });
  682. }
  683. }, function () {
  684. // 购买失败
  685. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  686. });
  687. };
  688. //是否可以申请权限
  689. $scope.isApplyAuthority=function (authorityid) {
  690. var tempdata = {
  691. title: $scope.connInfoDetail.title,
  692. recourceid: recourceid,
  693. recourcetype: recourcetype,
  694. recourcecomefrom: recourcecomefrom,
  695. authorityid: authorityid,
  696. type: ConstantService.TRACE_TYPE_2640
  697. };
  698. $scope.go("resourceApply", {authoritydata: angular.toJson(tempdata)});
  699. };
  700. // 获取评论列表的传参
  701. $scope.paramsForInfoCommentList=
  702. {
  703. mode: 1,// 显示样式:1热门 2全部
  704. infoid: recourceid,// 资源id
  705. infotype:recourcetype,// 资源类型
  706. sortkey:0,// 排序字段
  707. sorttype:"ASC",// 排序方式
  708. moduleid:ConstantService.TABLE_CODE_30002,// 评论表对应的code
  709. //TODO
  710. userid:UserService.id// 登录者id
  711. // userid:1// 登录者id
  712. };
  713. //详情页评论
  714. $scope.appComment = function () {
  715. $scope.showComment = true;
  716. var islogin = ConfigService.islogin;
  717. if (!islogin) {
  718. $ionicLoading.show({
  719. template: '请登录!',
  720. noBackdrop: true
  721. });
  722. $timeout(function () {
  723. $ionicLoading.hide();
  724. }, 1000);
  725. return;
  726. } else {
  727. var content = $scope.comment.say;
  728. //提交评论信息
  729. DetailsService.appComment(id, moduleId, content, siteName).then(function () {
  730. //评论成功后重新获取评论列表
  731. CommentService.getInfoCommentList($scope.paramsForInfoCommentList).then(function (response) {
  732. // console.log(response);
  733. // 评论列表
  734. $scope.comments = response.data;
  735. }, function () {
  736. })
  737. //重置评论内容为空
  738. $scope.comment.say = "";
  739. }, function () {
  740. });
  741. }
  742. };
  743. $scope.resource = {};
  744. // 点赞、收藏、分享的传参
  745. $scope.clickRecord=
  746. {
  747. //TODO
  748. targetid: $stateParams.recourceid,
  749. // targetid: 124,
  750. moduleid: ConstantService.TABLE_CODE_30003,
  751. userid:UserService.id,
  752. // userid:1,
  753. clicktype:1,
  754. content:'走访历史详情页'
  755. };
  756. // 评论/评论回复的传参
  757. $scope.infoComment=
  758. {
  759. infoid: recourceid,//资源id
  760. infotype:recourcetype,// 资源类别
  761. parentid:0,// 评论回复时,记录父评论的id
  762. parentuserid:0,// 评论回复时,记录父评论的创建者
  763. content:"",// 评论/回复内容
  764. //TODO
  765. creator:UserService.id,// 创建者
  766. updater:UserService.id,// 更新者
  767. // creator:1,// 创建者
  768. // updater:1// 更新者
  769. contenttype:'走访历史详情页'
  770. };
  771. //获取热门评论列表
  772. var getInfoCommentList = function () {
  773. CommentService.getInfoCommentList($scope.paramsForInfoCommentList).then(function (response) {
  774. // console.log(response);
  775. // 评论列表
  776. $scope.comments = response.data;
  777. }, function () {
  778. })
  779. };
  780. getInfoCommentList();
  781. // 弹出简单评论框
  782. $scope.showComment = true;
  783. $scope.focus_write = function () {
  784. $scope.showComment = false;
  785. };
  786. // 隐藏简单评论框
  787. $scope.hiddenComment = function () {
  788. $scope.showComment = true;
  789. };
  790. // 简单评论框内容变更,判断 发表 按钮颜色
  791. $scope.commentValue = function () {
  792. var search_history = angular.element(document.getElementsByClassName("my_comment"));
  793. if (UtilService.isDefined($scope.comment.content) && $scope.comment.content.length > 1000) {
  794. UtilService.showMess("您的评论已超过1000字!");
  795. $scope.comment.content = $scope.comment.content.substr(0, 1000);
  796. }
  797. if (UtilService.isDefined($scope.comment.content) && $scope.comment.content != 0) {
  798. $scope.commentNotnull = {
  799. "background-color": "#2a90d7",
  800. "text-decoration": "underline"
  801. };
  802. }else{
  803. $scope.commentNotnull = {
  804. "background-color": "#ccc"
  805. };
  806. }
  807. };
  808. var search_history = angular.element(document.getElementsByClassName("my_comment"));
  809. //查看信息的详情时跳转
  810. $scope.goLibrary=function () {
  811. $scope.go('');
  812. };
  813. $scope.opencardWrap=function (currentIndex) {
  814. $scope.connInfoDetail.connectioninfoModelList[currentIndex].isShowVisitContent=!$scope.connInfoDetail.connectioninfoModelList[currentIndex].isShowVisitContent;
  815. };
  816. $scope.openCard=function () {
  817. $scope.connInfoDetail.connectioninfoModelList.isShowCard=!$scope.connInfoDetail.connectioninfoModelList.isShowCard;
  818. };
  819. // 控制重复点击
  820. var flag = 1;
  821. // 操作:点赞、关注、收藏
  822. $scope.praiseAction=function (clicktype, recourceid, moduleid, ind) {
  823. if(flag == 0){
  824. return;
  825. }
  826. flag = 0;
  827. // 点赞 or 收藏 资源
  828. // 取消点赞 or 取消收藏 资源
  829. if(clicktype == $scope.TRACE_TYPE_2615 || clicktype == $scope.TRACE_TYPE_2619
  830. || clicktype == $scope.TRACE_TYPE_2616 || clicktype == $scope.TRACE_TYPE_2620){
  831. $scope.clickRecord.targetid = recourceid;
  832. $scope.clickRecord.moduleid = moduleid;
  833. }else if(clicktype == $scope.TRACE_TYPE_2617 || clicktype == $scope.TRACE_TYPE_2618){
  834. // 关注 用户
  835. // 取消关注 用户
  836. $scope.clickRecord.targetid = $scope.connInfoDetail.creator;
  837. $scope.clickRecord.moduleid = $scope.TABLE_CODE_30043;
  838. }
  839. $scope.clickRecord.clicktype = clicktype;
  840. CommentService.postClickFavour($scope.clickRecord).then(function (response) {
  841. // console.log(response);
  842. if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
  843. // 点赞
  844. if(clicktype == $scope.TRACE_TYPE_2615) {
  845. // 信息
  846. if(moduleid == $scope.TABLE_CODE_30003) {
  847. $scope.connInfoDetail.favourcount = $scope.connInfoDetail.favourcount + 1;
  848. $scope.connInfoDetail.favour=!$scope.connInfoDetail.favour;
  849. }else
  850. // 评论
  851. if(moduleid == $scope.TABLE_CODE_30002) {
  852. $scope.comments[ind].favourcount = $scope.comments[ind].favourcount + 1;
  853. $scope.comments[ind].favour=!$scope.comments[ind].favour;
  854. }
  855. }else
  856. // 取消点赞
  857. if(clicktype == $scope.TRACE_TYPE_2616) {
  858. // 信息
  859. if(moduleid == $scope.TABLE_CODE_30003) {
  860. $scope.connInfoDetail.favourcount = $scope.connInfoDetail.favourcount - 1;
  861. $scope.connInfoDetail.favour=!$scope.connInfoDetail.favour;
  862. }else
  863. // 评论
  864. if(moduleid == $scope.TABLE_CODE_30002) {
  865. $scope.comments[ind].favourcount = $scope.comments[ind].favourcount - 1;
  866. $scope.comments[ind].favour=!$scope.comments[ind].favour;
  867. }
  868. }
  869. // 关注
  870. // 取消关注
  871. else if(clicktype == $scope.TRACE_TYPE_2617
  872. || clicktype == $scope.TRACE_TYPE_2618) {
  873. $scope.connInfoDetail.focus=!$scope.connInfoDetail.focus;
  874. }
  875. // 收藏
  876. // 取消收藏
  877. else if(clicktype == $scope.TRACE_TYPE_2619
  878. || clicktype == $scope.TRACE_TYPE_2620) {
  879. $scope.connInfoDetail.collect=!$scope.connInfoDetail.collect;
  880. }
  881. }
  882. // UtilService.showMess(response.clickStatus);
  883. // 若是评论点赞,则刷新评论列表
  884. if (moduleid == $scope.TABLE_CODE_30002) {
  885. $timeout(function () {
  886. getInfoCommentList();
  887. }, 650);
  888. }
  889. // 恢复可用
  890. flag = 1;
  891. }, function () {
  892. // 恢复可用
  893. flag = 1;
  894. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  895. })
  896. };
  897. // 滚动至底部
  898. var scrollToBottom = function () {
  899. $timeout(function () {
  900. $ionicScrollDelegate.$getByHandle("calenderContent").scrollBottom();
  901. }, 0);
  902. };
  903. //打开操作表:设置/编辑
  904. $scope.openActionSheet = function () {
  905. // isedit:是否可以编辑资源,isset:是否可以设置权限
  906. var buttonlist = [{text: '复制'}];
  907. if ($scope.connInfoDetail.hasset) {
  908. buttonlist.push({text: '设置'});
  909. buttonlist.push({text: '编辑'});
  910. }
  911. $ionicActionSheet.show({
  912. buttons: buttonlist,
  913. cancelText: '取消',
  914. buttonClicked: function (index) {
  915. if (index == 0) {
  916. //copy
  917. $scope.go('visitModularForm', {
  918. companyid: 0,
  919. pageid: $stateParams.templettype,
  920. orgtype: $stateParams.orgtype,
  921. isedit: 2,
  922. connid: $scope.connInfoDetail.id,
  923. pagecode:$stateParams.pagecode,
  924. node:$stateParams.node,
  925. pageTitle:$stateParams.comfrom=='typein'?'复制并新建录入':'复制并新建走访'
  926. });
  927. // $scope.go('visitModularForm', {
  928. // companyid: 0,
  929. // pageid: $scope.connInfoDetail.templettype,
  930. // orgtype: 1,
  931. // isedit: 2,// isedit:对应的是0新增/1编辑/2复制并编辑
  932. // connid: $scope.connInfoDetail.id,
  933. // pagecode:$stateParams.pagecode,
  934. // node:$stateParams.node,
  935. // pageTitle:'新建走访'
  936. // });
  937. }
  938. else if (index == 1) {
  939. // console.log($scope.connInfoDetail.typecodemap);
  940. $scope.go("selectFieldsToSet", {typecodemap: $scope.connInfoDetail.typecodemap, resid: recourceid, typecode: ConstantService.TABLE_CODE_300031});
  941. }
  942. else if (index = 2) {
  943. // console.log('编辑');
  944. $scope.go('visitModularForm', {
  945. companyid: 0,
  946. pageid: $stateParams.templettype,
  947. orgtype: $stateParams.orgtype,
  948. isedit: 1,
  949. connid: $scope.connInfoDetail.id,
  950. pagecode:$stateParams.pagecode,
  951. node:$stateParams.node,
  952. pageTitle:$stateParams.comfrom=='typein'?'编辑录入':'编辑走访'
  953. });
  954. return true;
  955. }
  956. }
  957. });
  958. };
  959. //进入资源详情
  960. $scope.jumpResourceDetail = function (company) {
  961. console.log(company);
  962. // 再跳转到资源详情页
  963. $scope.go('resourceCommonDetailsPage', {
  964. recourceid: company.resourcelibrary.id,
  965. recourcetype: company.resourcelibrary.restype,
  966. recourcecomefrom: company.resourcelibrary.comefrom,
  967. creator: company.resourcelibrary.creator,
  968. templettype:$stateParams.templettype,
  969. orgtype:$stateParams.orgtype,
  970. comfrom:$scope.comfrom,
  971. title:company.name,
  972. // label:$stateParams.label
  973. });
  974. };
  975. // 点击走访历史进入走访详情页
  976. $scope.gotoResourceCommonInfoDetailsRepeatPage = function (resid) {
  977. $scope.go('resourceCommonInfoDetailsRepeatPage', {resid: resid});
  978. };
  979. // 点击头像或名字进入个人主页
  980. $scope.goPublisher = function (userid) {
  981. if (userid != 0) {
  982. $scope.go('publisher', {Id: userid});
  983. }
  984. };
  985. //点击图片放大
  986. $scope.bigImage = false; //初始默认大图是隐藏的
  987. $scope.hideBigImage = function () {
  988. $timeout(function () {
  989. if($scope.app){
  990. $scope.setStatusBar(0);
  991. }
  992. $scope.bigImage = false;
  993. }, 400);
  994. };
  995. $scope.hideBigImage=function(){
  996. $scope.bigImage = false;
  997. }
  998. $scope.shouBigImage = function (outerIndex,innerIndex,index) { //传递一个参数(图片的URl)
  999. if($scope.app){
  1000. $scope.setStatusBar(1);
  1001. }
  1002. $scope.bigImage = true;
  1003. $scope.imgUrlList=$scope.scrollTitle[outerIndex].unitlist[innerIndex].imageList;
  1004. // console.log($scope.imgUrlList);//显示大图
  1005. // console.log(index);
  1006. $(function () {
  1007. $('div.pinch-zoom').each(function () {
  1008. new RTP.PinchZoom($(this), {});
  1009. });
  1010. });
  1011. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  1012. //图片总数量
  1013. setTimeout(function () {
  1014. // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
  1015. // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
  1016. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
  1017. //获取图片
  1018. var imgObj = document.getElementsByClassName('bigimage');
  1019. console.log(imgObj);
  1020. var n;
  1021. for (n = 0; n < imgObj.length; n++) {
  1022. // 获取图片的原始高度和宽度
  1023. var oldWid = imgObj[n].naturalWidth;
  1024. var oldHei = imgObj[n].naturalHeight;
  1025. console.log(oldWid);
  1026. console.log(oldHei);
  1027. var screen = document.body.offsetWidth;
  1028. var screenH = window.innerHeight;
  1029. // console.log(oldWid/oldHei);
  1030. // console.log(screen );
  1031. var rate=oldWid/oldHei;
  1032. if(oldWid>=screen&&oldHei>=screenH){
  1033. var tw=screen;
  1034. var th=tw/rate;
  1035. if(th<screenH){
  1036. imgObj[n].style.width = tw + 'px';
  1037. imgObj[n].style.height = th + 'px';
  1038. imgObj[n].style.marginTop=(screenH-th)/2+ 'px';
  1039. }else{
  1040. imgObj[n].style.width = screenH*rate + 'px';
  1041. imgObj[n].style.height = screenH + 'px';
  1042. imgObj[n].style.marginLeft=(screen-screenH*rate)/2+ 'px';
  1043. }
  1044. }else if(oldWid>=screen&&oldHei<=screenH){
  1045. imgObj[n].style.width = screen + 'px';
  1046. imgObj[n].style.height = screen/rate + 'px';
  1047. imgObj[n].style.marginTop=(screenH-screen/rate)/2+ 'px';
  1048. }else if(oldWid<=screen&&oldHei>=screenH){
  1049. // var hh=screenH;
  1050. // var ww=screenH*rate;
  1051. imgObj[n].style.width = screenH*rate + 'px';
  1052. imgObj[n].style.height = screenH + 'px';
  1053. imgObj[n].style.marginLeft=(screen-screenH*rate)/2+ 'px';
  1054. }else{
  1055. imgObj[n].style.width = oldWid + 'px';
  1056. imgObj[n].style.height = oldHei + 'px';
  1057. imgObj[n].style.marginLeft=(screen-oldWid)/2+ 'px';
  1058. imgObj[n].style.marginTop=(screenH-oldHei)/2+ 'px';
  1059. }
  1060. }
  1061. }, 500);
  1062. };
  1063. });