taskDetailCtrl.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. /**
  2. * Created by pushkeji on 2018/10/11.
  3. */
  4. angular.module('push')
  5. .controller('taskDetailCtrl',
  6. ['$scope', 'taskModuleService', '$timeout', '$q', 'UserService', '$stateParams', 'ResourceLibraryService', '$ionicSlideBoxDelegate', 'CommentService', 'ConfigService', 'ScienceCircleService', 'CommonService', '$ionicScrollDelegate', 'ConstantService', '$ionicActionSheet', 'UtilService', 'ShareService', '$ionicHistory', 'UserService', '$ionicPopup', 'dataToolsService',
  7. function ($scope, taskModuleService, $timeout, $q, UserService, $stateParams, ResourceLibraryService, $ionicSlideBoxDelegate, CommentService, ConfigService, ScienceCircleService, CommonService, $ionicScrollDelegate, ConstantService, $ionicActionSheet, UtilService, ShareService, $ionicHistory, UserService, $ionicPopup, dataToolsService) {
  8. console.log($stateParams);
  9. // $scope.comfromMytask=$stateParams.comefrom=='myTask';
  10. // $scope.showDockingButton=false;
  11. var personPageNum = 1;
  12. var personPagesize = 15;
  13. $scope.abutLength = false;
  14. $scope.index = $stateParams.index;
  15. $scope.ispublic = $stateParams.ispublic;
  16. $scope.isPublisher = false;
  17. $scope.node = UserService.node;
  18. $scope.status = $stateParams.status;
  19. $scope.resid = $stateParams.resid;
  20. $scope.resourceDetail = {};
  21. $scope.totalParticipants = 0;
  22. $scope.showDemandRewardButton = false;
  23. $scope.hasApplyAward = false;
  24. $scope.docking = false;
  25. $scope.techingreward = 0;
  26. $scope.endDemand = true;
  27. $scope.showTechnicalContract = false;
  28. // $scope.showApplyButton=$stateParams.ifjoin=='true';
  29. $scope.hasCollect = false;
  30. $scope.showConsultBox = true;
  31. $scope.notReceived = Number($stateParams.taskstatus) == 5300;
  32. $scope.action = {
  33. // action0:false,//我要申请 5322
  34. // action1:false,//对接录入 5322
  35. // action2:false,//评价 5323
  36. // action3:false,//申请奖励 5324
  37. // action4:false,//任务完成 5325
  38. }
  39. $scope.pubulisherData = {};
  40. $scope.buttonNum = 0;
  41. if ($scope.status == 'technicalreward') {
  42. $scope.buttonNum++;
  43. if (!$scope.showDemandRewardButton) {
  44. $scope.showDemandRewardButton = true;
  45. $scope.buttonNum++;
  46. }
  47. if (!$scope.docking) {
  48. $scope.docking = true;
  49. $scope.buttonNum++;
  50. }
  51. }
  52. //该用户是否签订过技术合同
  53. var getTechnical = function () {
  54. ResourceLibraryService.getTechnical(UserService.id, $scope.resid).then(function (res) {
  55. if (res.code == 3350) {
  56. if (res.data.length > 0) {
  57. //签订过技术合同就不显示
  58. $scope.showTechnicalContract = false;
  59. $scope.techingreward = 1;
  60. $scope.buttonNum++;
  61. } else {
  62. //没签订过技术合同就显示
  63. $scope.showTechnicalContract = true;
  64. $scope.techingreward = 0;
  65. }
  66. }
  67. })
  68. }
  69. getTechnical();
  70. //桐庐对接记录申请奖励
  71. var getDemandReward = function () {
  72. if ($stateParams.node == "330122000") {
  73. ResourceLibraryService.getResourceByID($scope.resid).then(function (res) {
  74. console.log(res)
  75. console.log(UserService.id)
  76. if (res.code == 3350) {
  77. if (res.data.creator == UserService.id) {
  78. //显示申请技术需求奖励按钮
  79. if (!$scope.showDemandRewardButton) {
  80. $scope.showDemandRewardButton = true;
  81. $scope.buttonNum++;
  82. }
  83. }
  84. }
  85. })
  86. }
  87. }
  88. getDemandReward();
  89. //当前用户是否申请过奖励
  90. var getDemandRewardByUser = function () {
  91. if ($scope.endDemand) {
  92. $scope.buttonNum++;
  93. }
  94. if ($stateParams.node == "330122000") {
  95. ResourceLibraryService.getDemandRewardByUser($scope.resid, UserService.id).then(function (res) {
  96. if (res.code == 3350) {
  97. if (res.data) {
  98. $scope.hasApplyAward = true;
  99. } else {
  100. $scope.hasApplyAward = false;
  101. $scope.buttonNum++;
  102. }
  103. }
  104. })
  105. }
  106. }
  107. getDemandRewardByUser();
  108. $scope.seeTechnicalContract = function (resourceDetail) {
  109. ResourceLibraryService.getTechnical(UserService.id, resourceDetail.resid).then(function (res) {
  110. if (res.code == 3350) {
  111. if (res.data.length > 0) {
  112. $scope.go('signDemandContractDetail', { contract: res.data[0] });
  113. }
  114. }
  115. })
  116. }
  117. $scope.getDemandRewardDetail = function (resourceDetail) {
  118. if (UserService.id == resourceDetail.creator) {
  119. dataToolsService.judgeUserBroker(UserService.id).then(function (res) {
  120. if (res.code == 3350) {
  121. if (res.data) {
  122. //是技术经纪人
  123. $scope.go("demandRewardDetail", { resid: resourceDetail.id, comefrom: "taskDetail" });
  124. } else {
  125. //不是技术经纪人
  126. $ionicPopup.confirm({
  127. title: '认证',
  128. template: '需先认证为技术经纪人,方可申请技术需求类奖励',
  129. okText: '去认证',
  130. cancelText: '取消'
  131. }).then(function (result) {
  132. if (result) {
  133. if ($scope.node == "330122000") {
  134. $scope.go('identifyFormForTongLu', {
  135. pageTitle: '技术经纪人认证',
  136. code: 4801,
  137. action: 'check'
  138. });
  139. } else {
  140. $scope.go('identifyForm', {
  141. pageTitle: '技术经纪人认证',
  142. code: 4801,
  143. action: 'check'
  144. });
  145. }
  146. }
  147. })
  148. }
  149. }
  150. })
  151. } else {
  152. if ($scope.app) {
  153. UtilService.showMess("仅发布者可以申请需求奖励!");
  154. } else {
  155. CommonService.showMessage("仅发布者可以申请需求奖励!", $scope);
  156. }
  157. }
  158. }
  159. $scope.goBackPage = function () {
  160. $scope.go('tab.activityIndex');
  161. /*if ($ionicHistory.backView()) {
  162. $ionicHistory.backView().go();
  163. } else {
  164. $ionicHistory.goBack();
  165. }*/
  166. // if($stateParams.comefrom=='tab.activityIndex'){
  167. // $scope.go('tab.activityIndex');
  168. // }else{
  169. // $scope.go('taskHoll');
  170. // }
  171. /*if (UserService.isRewardFlag == 1 && UserService.isTaskHollFlag == 1) {
  172. $scope.go('taskHoll');
  173. UserService.isRewardFlag = 0;
  174. UserService.isTaskHollFlag = 0;
  175. } else {
  176. if (UserService.isMessage == 1) {
  177. $scope.go('mymessage');
  178. UserService.isMessage = 0;
  179. } else {
  180. if (UserService.isNotThisUserFlag == 1) {
  181. $scope.go('tab.activityIndex');
  182. UserService.isNotThisUserFlag = 0;
  183. } else {
  184. if ($stateParams.comefrom == "taskHoll" && UserService.isTaskHollFlag == 1) {
  185. $scope.go('taskHoll');
  186. UserService.isTaskHollFlag = 0;
  187. } else {
  188. if ($ionicHistory.backView()) {
  189. $ionicHistory.backView().go();
  190. } else {
  191. $ionicHistory.goBack();
  192. }
  193. }
  194. }
  195. }
  196. }*/
  197. }
  198. /*if ($stateParams.comefrom) {
  199. if ($stateParams.comefrom == "publisher") {
  200. $scope.go($stateParams.comefrom, {Id: UserService.id});
  201. } else {
  202. $scope.go($stateParams.comefrom);
  203. }
  204. } else {
  205. $scope.go('taskHoll');
  206. }*/
  207. var tempArr = $stateParams.actions ? $stateParams.actions.split(',') : [];
  208. console.log(tempArr);
  209. if (tempArr.length > 0) {
  210. for (var i = 0; i < tempArr.length; i++) {
  211. switch (tempArr[i]) {
  212. case '5321':
  213. //进行中的任务
  214. if ($stateParams.taskstatus == 5301) {
  215. taskModuleService.getTaskReceiver($stateParams.taskid).then(function (response) {
  216. for (var i = 0; i < response.data.length; i++) {
  217. if (UserService.id != response.data[i]) {
  218. $scope.action.action0 = true;
  219. $scope.buttonNum++;
  220. break;
  221. }
  222. }
  223. })
  224. }
  225. $scope.action.action0 = true;
  226. $scope.buttonNum++;
  227. break;
  228. case '5322':
  229. taskModuleService.getTaskReceiver($stateParams.taskid).then(function (response) {
  230. for (var i = 0; i < response.data.length; i++) {
  231. if (UserService.id == response.data[i]) {
  232. $scope.action.action1 = true;
  233. $scope.buttonNum++;
  234. break;
  235. }
  236. }
  237. })
  238. break;
  239. // case '5323':$scope.action.action2=true;$scope.buttonNum++;break;//评价功能添加的时候,取消注释
  240. case '5324':
  241. taskModuleService.getTaskReceiver($stateParams.taskid).then(function (response) {
  242. for (var i = 0; i < response.data.length; i++) {
  243. if (UserService.id == response.data[i]) {
  244. $scope.action.action3 = true;
  245. $scope.buttonNum++;
  246. break;
  247. }
  248. }
  249. })
  250. break;
  251. case '5325':
  252. $scope.action.action4 = true;
  253. $scope.buttonNum++;
  254. break;
  255. }
  256. }
  257. console.log($scope.action);
  258. }
  259. $scope.goToSignDemandContract = function (resourceDetail) {
  260. $scope.go('signDemandContract', {
  261. pageTitle: "签订技术合同",
  262. code: 4801,
  263. type: 5100,
  264. action: 'submit',
  265. resid: resourceDetail.id
  266. });
  267. }
  268. $scope.technicalreward = function (resourceDetail) {
  269. console.log(resourceDetail)
  270. taskModuleService.checkTaskDetailPermission(2, UserService.id).then(function (res) {
  271. if (res.code == 3350) {
  272. if (!res.data) {//true可见,false不可见
  273. $ionicPopup.confirm({
  274. title: '确认',
  275. template: '需先认证为技术经纪人,方可申请技术经纪人技术合作类奖励',
  276. okText: '去认证',
  277. cancelText: '取消'
  278. }).then(function (result) {
  279. if (result) {
  280. if (UserService.node == '330122000') {
  281. $scope.go('identifyFormForTongLu', {
  282. pageTitle: '技术经纪人认证',
  283. code: 4801,
  284. type: 5100,
  285. id: UserService.userid
  286. });
  287. } else {
  288. $scope.go('identifyForm', {
  289. pageTitle: '技术经纪人认证',
  290. code: 4801,
  291. type: 5100,
  292. id: UserService.userid
  293. });
  294. }
  295. }
  296. })
  297. } else {
  298. // resourceDetail.restype=4801
  299. $scope.go('technicalawardapplication', {
  300. pageTitle: "技术经纪人产学研奖励",
  301. code: 4801,
  302. type: 5100,
  303. action: 'submit',
  304. resid: resourceDetail.id,
  305. restype: 4801,
  306. list: resourceDetail
  307. });
  308. }
  309. }
  310. });
  311. }
  312. // 标签点击事件
  313. $scope.showResourceAboutTheLabel = function (item) {
  314. ResourceLibraryService.getResourceBySameLabel(item.labelName).then(function (res) {
  315. if (res.code == 3350) {
  316. $scope.go('resourceLabelList', { resourceList: res.data, labelName: item.labelName });
  317. }
  318. })
  319. }
  320. $scope.goToTaskAction = function (list, action) {
  321. UserService.isTaskFlag = 1;
  322. console.log(list);
  323. console.log(action);
  324. if (!ConfigService.islogin) {
  325. if (localStorage.wxFlag == "true") {
  326. if (localStorage.isUserFocusXW == 0) {
  327. var title = localStorage.appidStr;
  328. $ionicPopup.alert({
  329. title: '提示',
  330. template: '请先关注微信公众号"' + title + '"!'
  331. });
  332. return;
  333. } else {
  334. if (localStorage.isUserBindWx == 0) {
  335. var wxFlag = JSON.parse(localStorage.params);
  336. if (wxFlag.weChatModel) {
  337. $scope.go('bindPhone', {
  338. params: localStorage.params,
  339. comfrom: 'maincontroller',
  340. url: window.location.href.split('#/')[1]
  341. });
  342. } else {
  343. $scope.go('login');
  344. return;
  345. }
  346. } else {
  347. $scope.go('login');
  348. return;
  349. }
  350. }
  351. } else {
  352. $scope.go('login');
  353. return;
  354. }
  355. return;
  356. }
  357. if (action == 5321) {
  358. senddata = {
  359. data: {
  360. resourceid: $stateParams.resid,
  361. action: 5321,
  362. creator: UserService.id
  363. },
  364. node: UserService.node
  365. }
  366. $scope.showLoadingToast();
  367. console.log(senddata);
  368. taskModuleService.saveOrupdatetaskAction(senddata).then(function (res) {
  369. console.log(res);
  370. if (res.code == 3350) {
  371. // $scope.go('taskHoll');
  372. // $scope.showDockingButton=true;
  373. // $scope.showApplyButton=false;
  374. if ($scope.app) {
  375. UtilService.showMess("任务申请成功!");
  376. } else {
  377. CommonService.showMessage("任务申请成功!", $scope);
  378. }
  379. // getTaskDetail();
  380. // getAllParticipant();
  381. // getTaskDetail().then(function(data){
  382. // getAllParticipant();
  383. // })
  384. $stateParams.actions = '5322,5324';
  385. $scope.go('taskDetail', $stateParams, { reload: true });
  386. }
  387. $scope.hideLoadingToast();
  388. })
  389. } else if (action == 5323) {
  390. $scope.go('taskEvaluate', {
  391. taskRes: JSON.stringify(list)
  392. })
  393. } else if (action == 5322) {
  394. // 对接录入
  395. $scope.go('dockingInput', {
  396. comfrom: 'dockingInput',
  397. taskTitle: list.title,
  398. taskid: $stateParams.taskid,
  399. tasktitle: list.title,
  400. companyName: list.affiliatedCompany ? list.affiliatedCompany.name : "",
  401. companyid: list.baseInfoModel ? list.baseInfoModel.oid : 0,
  402. })
  403. } else if (action == 5324) {
  404. $scope.go('visitModularForm', {
  405. companyid: list.baseInfoModel.oid,
  406. pageTitle: '新建录入',
  407. pagecode: 1000027,
  408. pageid: 15,
  409. restype: 0,
  410. node: $stateParams.node,
  411. title: list.affiliatedCompany.name,
  412. })
  413. } else if (action == 5325) {
  414. if ($scope.endDemand) {
  415. $scope.endDemand = false;
  416. $scope.buttonNum--;
  417. }
  418. //弹框
  419. $ionicPopup.confirm({
  420. title: '确认',
  421. template: '是否确认结束需求'
  422. }).then(function (result) {
  423. if (result) {
  424. senddata = {
  425. data: {
  426. resourceid: $stateParams.resid,
  427. action: 5325,
  428. creator: UserService.id
  429. },
  430. node: UserService.node
  431. }
  432. $scope.showLoadingToast();
  433. console.log(senddata);
  434. taskModuleService.saveOrupdatetaskAction(senddata).then(function (res) {
  435. console.log(res);
  436. $stateParams.actions = '5322,5324';
  437. $stateParams.ifjoin = false;
  438. $scope.go('taskDetail', $stateParams, { reload: true });
  439. $scope.hideLoadingToast();
  440. })
  441. } else {
  442. $scope.goback();
  443. }
  444. })
  445. }
  446. }
  447. var customActionParams = {
  448. clicktype: 0,
  449. moduleid: 0,
  450. targetid: 0,
  451. userid: UserService.id
  452. }
  453. console.log($scope.showApplyButton);
  454. // 获得任务详情
  455. var getTaskDetail = function () {
  456. var deferred = $q.defer();
  457. $scope.showLoadingToast();
  458. console.log($stateParams);
  459. ResourceLibraryService.getPrivateResourceDetail($stateParams.resid, $stateParams.restype, $stateParams.node).then(function (res) {
  460. console.log('这又是个什么东东', res);
  461. if (res.code == 3350) {
  462. if (res.data.creator == UserService.id) {
  463. if (!$scope.isPublisher) {
  464. $scope.isPublisher = true;
  465. $scope.buttonNum++;
  466. }
  467. if (!$scope.docking) {
  468. $scope.docking = true;
  469. $scope.buttonNum++;
  470. }
  471. } else {
  472. $scope.isPublisher = false;
  473. }
  474. if ($stateParams.taskstatus == 5302) {
  475. taskModuleService.getTaskReceiver($stateParams.taskid).then(function (response) {
  476. for (var i = 0; i < response.data.length; i++) {
  477. if (UserService.id == response.data[i]) {
  478. $scope.taskFinish = true;
  479. $scope.buttonNum++;
  480. break;
  481. }
  482. }
  483. })
  484. }
  485. $scope.hideLoadingToast();
  486. $scope.allLabel = res.otherObj;
  487. $scope.hasCollect = res.data.collect;
  488. $scope.hasFocus = res.data.focus;
  489. $scope.resourceDetail = res.data;
  490. $scope.resourceDetail.restype = $stateParams.restype
  491. $scope.resourceDetail.resid = res.data.id;
  492. $scope.resourceDetail.createid = res.data.creator;
  493. $scope.showConsultBox = $scope.resourceDetail.createid != UserService.id;
  494. $scope.resourceDetail.title = res.data.baseInfoModel.title;//任务名称
  495. $scope.pubulisherData.contactName = res.data.userModel.username;//联系人
  496. $scope.pubulisherData.contactPhone = res.data.userModel.mobile;//联系电话
  497. $scope.resourceDetail.publisherScore = res.data.userModel.scoretotal;//联系人评分
  498. $scope.pubulisherData.createtime = res.data.createtime;//发布时间
  499. $scope.pubulisherData.publisherLogo = res.data.userModel.photo;//发布者头像
  500. $scope.pubulisherData.userid = res.data.userModel.userid;//发布者id
  501. $scope.resourceDetail.affiliatedCompany = {};
  502. angular.forEach(res.data.infoSectionList[0].unitlist, function (val) {
  503. val.tcname == 'oid' ? ($scope.resourceDetail.affiliatedCompany.name = val.content, $scope.resourceDetail.affiliatedCompany.showCode = val.showCode) : //所属单位
  504. val.tcname == 'capitalScale' ? $scope.resourceDetail.capitalScale = val.content == '0.0' ? '面议' : val.content ://投入预算
  505. val.tcname == 'cooperationmodel' ? $scope.resourceDetail.cooperationmodel = val.content ://合作模式
  506. val.tcname == 'content' ? $scope.resourceDetail.content = val.content ://简介
  507. val.tcname == 'tasktype' ? $scope.resourceDetail.tasktype = val.content ://任务类型
  508. val.tcname == 'images' ? $scope.resourceDetail.images = JSON.parse(val.content) : '';//任务类型
  509. /*val.tcname == 'contactor' ? $scope.resourceDetail.contactor = val.content : '';//任务类型
  510. val.tcname == 'tel' ? $scope.resourceDetail.tel = val.content : '';//任务类型*/
  511. })
  512. console.log($scope.resourceDetail);
  513. document.title = res.data.baseInfoModel.title;
  514. document.getElementById('shareSourc').setAttribute('src', ConfigService.imgurl + res.data.baseInfoModel.logo);
  515. deferred.resolve("ok");
  516. }
  517. })
  518. return deferred.promise;
  519. }
  520. // $scope.resourceDetail={
  521. // affiliatedCompany:{
  522. // name: "",
  523. // showCode: 2603
  524. // },
  525. // capitalScale: "0.0",
  526. // contactName: "普适科技-吴晓婷",
  527. // contactPhone: "15295115835",
  528. // content: "科晶电子任务1520科晶电子任务1520科晶电子任务1520科晶电子任务1520介绍",
  529. // cooperationmodel: "技术咨询",
  530. // createtime: "2018-10-24 15:21:43",
  531. // publisherLogo: "group3/M00/0A/CA/wKjILFmNIS2ADzOvAABQ0oV3mpA301.jpg",
  532. // publisherScore: 3.55,
  533. // tasktype: "人才需求",
  534. // title: "科晶电子任务1520"
  535. // }
  536. // 获得参与用户列表
  537. var getAllParticipant = function () {
  538. taskModuleService.searchAllParticipants($stateParams.resid, personPageNum, personPagesize).then(function (res) {
  539. console.log(res);
  540. if (res.code == 3350) {
  541. $scope.totalParticipants = res.page.totalCount;//参与用户数量
  542. $scope.participantsList = Object.assign([], res.data);
  543. // for(var i=0;i<$scope.participantsList.length;i++){
  544. // if($scope.participantsList[i].userid==$scope.resourceDetail.userModel.userid){
  545. // $scope.participantsList.splice(i,1);
  546. // $scope.totalParticipants--;
  547. // break;
  548. // }
  549. // }
  550. taskModuleService.searchDockingRecord($stateParams.resid, UserService.id, UserService.id).then(function (response) {
  551. if (response.code == 3350) {
  552. if (response.data.length > 0 && !$scope.abutLength) {
  553. $scope.abutLength = true;
  554. $scope.buttonNum++;
  555. }
  556. }
  557. })
  558. angular.forEach($scope.participantsList, function (val) {
  559. val.dockingRecord = [];
  560. taskModuleService.searchDockingRecord($stateParams.resid, UserService.id, val.userid).then(function (response) {
  561. console.log(response);
  562. if (response.data == false) {
  563. val.hasAuth = false;
  564. } else {
  565. /*if (response.data.length > 0 && !$scope.abutLength) {
  566. $scope.abutLength = true;
  567. $scope.buttonNum++;
  568. }*/
  569. $scope.node = UserService.node;
  570. ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) {
  571. //ture:机构领导人,可以看到(hasAuth:true, unfoldDropdown:false)
  572. if (res.data == true) {
  573. val.hasAuth = true;
  574. val.unfoldDropdown = false;
  575. } else {
  576. //当前用户是任务发布者,可以看到对接记录
  577. if ($scope.pubulisherData.userid == UserService.id) {
  578. val.hasAuth = true;
  579. val.unfoldDropdown = false;
  580. //当前用户是该条对接记录的发布者(创建者)
  581. } else if (val.userid == UserService.id) {
  582. val.hasAuth = true;
  583. val.unfoldDropdown = false;
  584. } else {
  585. val.hasAuth = false;
  586. }
  587. }
  588. val.dockingRecord = response.data;
  589. val.allImages = JSON.parse(val.images);
  590. angular.forEach(val.dockingRecord, function (vv) {
  591. vv.allImages = JSON.parse(vv.images);
  592. })
  593. })
  594. }
  595. })
  596. })
  597. // 发布者的对接记录
  598. $scope.pubulisherData.typecode = Number(res.message) > 0 ? res.message : 0;
  599. taskModuleService.searchDockingRecord($stateParams.resid, UserService.id, $scope.pubulisherData.userid).then(function (response) {
  600. console.log(response);
  601. if (response.data == false) {
  602. $scope.pubulisherData.hasAuth = false;
  603. } else {
  604. $scope.pubulisherData.hasAuth = true;
  605. $scope.pubulisherData.dockingRecord = response.data;
  606. $scope.pubulisherData.unfoldDropdown = false;
  607. console.log($scope.pubulisherData);
  608. angular.forEach($scope.pubulisherData.dockingRecord, function (val) {
  609. val.allImages = JSON.parse(val.images);
  610. })
  611. }
  612. })
  613. console.log($scope.participantsList);
  614. }
  615. })
  616. }
  617. getTaskDetail().then(function (data) {
  618. getAllParticipant();
  619. })
  620. // 展开对接列表
  621. $scope.showDkDropdown = function (index) {
  622. $scope.participantsList[index].unfoldDropdown = !$scope.participantsList[index].unfoldDropdown;
  623. }
  624. $scope.bigImage = false; //初始默认大图是隐藏的
  625. $scope.hideBigImage = function () {
  626. $timeout(function () {
  627. if ($scope.app) {
  628. $scope.setStatusBar(0);
  629. }
  630. $scope.bigImage = false;
  631. }, 400);
  632. };
  633. $scope.shouBigImage = function (imgList, index) {
  634. if ($scope.app) {
  635. $scope.setStatusBar(1);
  636. }
  637. console.log('aaa')
  638. $scope.imgUrlList = imgList;
  639. console.log($scope.imgUrlList[index]);
  640. // var str=$scope.imgUrlList[index].sourceName.split('.');
  641. // if(str&&str.length>0&&str[1]!='jpg'&&str[1]!='gif'&&str[1]!='bmp'&&str[1]!='png'&&str[1]!='jpeg')
  642. // if($scope.imgUrlList[index]){
  643. // window.open(ConfigService.imgurl+$scope.imgUrlList[index].sourceName);
  644. // return;
  645. // }
  646. $scope.bigImage = true; //显示大图
  647. $(function () {
  648. $('div.pinch-zoom').each(function () {
  649. new RTP.PinchZoom($(this), {});
  650. });
  651. });
  652. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  653. //图片总数量
  654. setTimeout(function () {
  655. // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
  656. // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
  657. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
  658. //获取图片
  659. var imgObj = document.getElementsByClassName('bigimage');
  660. var n;
  661. for (n = 0; n < imgObj.length; n++) {
  662. // 获取图片的原始高度和宽度
  663. var oldWid = imgObj[n].naturalWidth;
  664. var oldHei = imgObj[n].naturalHeight;
  665. var screen = document.body.offsetWidth;
  666. var screenH = window.innerHeight;
  667. // console.log(oldWid/oldHei);
  668. // console.log(screen );
  669. var rate = oldWid / oldHei;
  670. if (oldWid >= screen && oldHei >= screenH) {
  671. var tw = screen;
  672. var th = tw / rate;
  673. if (th < screenH) {
  674. imgObj[n].style.width = tw + 'px';
  675. imgObj[n].style.height = th + 'px';
  676. imgObj[n].style.marginTop = (screenH - th) / 2 + 'px';
  677. } else {
  678. imgObj[n].style.width = screenH * rate + 'px';
  679. imgObj[n].style.height = screenH + 'px';
  680. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  681. }
  682. } else if (oldWid >= screen && oldHei <= screenH) {
  683. imgObj[n].style.width = screen + 'px';
  684. imgObj[n].style.height = screen / rate + 'px';
  685. imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px';
  686. } else if (oldWid <= screen && oldHei >= screenH) {
  687. // var hh=screenH;
  688. // var ww=screenH*rate;
  689. imgObj[n].style.width = screenH * rate + 'px';
  690. imgObj[n].style.height = screenH + 'px';
  691. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  692. } else {
  693. imgObj[n].style.width = oldWid + 'px';
  694. imgObj[n].style.height = oldHei + 'px';
  695. imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px';
  696. imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px';
  697. }
  698. }
  699. }, 500);
  700. }
  701. // 申请任务
  702. $scope.applyForTask = function () {
  703. }
  704. // 对接录入
  705. // $scope.goToTaskAction=function(){
  706. // $scope.go('dockingInput',{
  707. // comfrom:'dockingInput',
  708. // taskTitle:$stateParams.title,
  709. // taskid:$stateParams.resid,
  710. // companyName:$scope.resourceDetail.affiliatedCompany.name,
  711. // companyid:0,
  712. // })
  713. // }
  714. // 结束任务
  715. $scope.stopTask = function () {
  716. }
  717. // 收藏
  718. $scope.customAction = function (clicktype, moduleid, targetid) {
  719. customActionParams = {
  720. clicktype: clicktype,
  721. moduleid: moduleid,
  722. targetid: targetid,
  723. userid: UserService.id
  724. }
  725. console.log(customActionParams);
  726. CommentService.postClickFavour(customActionParams).then(function (res) {
  727. if (res.code == 3350) {
  728. if (clicktype == 2619 || clicktype == 2620) {
  729. $scope.hasCollect = !$scope.hasCollect;
  730. }
  731. if (clicktype == 2617 || clicktype == 2618) {
  732. $scope.hasFocus = !$scope.hasFocus;
  733. }
  734. }
  735. })
  736. }
  737. //分享
  738. $scope.shareflg = false;
  739. $scope.openShare = function () {
  740. if ($scope.app) {
  741. $scope.shareflg = true;
  742. } else {
  743. $scope.shareMessage();
  744. }
  745. };
  746. $scope.closeShareBox = function () {
  747. $scope.shareflg = false;
  748. };
  749. //TODO
  750. $scope.showShareWechat = false;
  751. $scope.closeShare = function () {
  752. $scope.showShareWechat = false;
  753. };
  754. var sharelink = "https://blog.csdn.net/molong421/article/details/51586194";
  755. //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
  756. $scope.shareMessage = function (type) {
  757. console.log($scope.resourceDetail);
  758. $scope.shareflg = false;
  759. var linkUrl = ConfigService.webserver + '#/taskDetail/' + $stateParams.resid + '/' + $stateParams.restype + '/' + $stateParams.node + '/' + $stateParams.title + '/' + $stateParams.comefrom + '/' + $stateParams.ifjoin + '/' + $stateParams.actions + '/' + $stateParams.taskstatus + '/' + $stateParams.taskid + '/' + $stateParams.opentowho;
  760. var imagurl = $scope.resourceDetail.baseInfoModel.logo ? (ConfigService.imgurl + $scope.resourceDetail.baseInfoModel.logo) : "https://cordova.apache.org/static/img/cordova_bot.png";
  761. var message = {
  762. title: $scope.resourceDetail.baseInfoModel.title,
  763. description: $scope.resourceDetail.baseInfoModel.title.substring(0, 19),
  764. url: linkUrl,
  765. imageurl: imagurl
  766. };
  767. console.log(linkUrl);
  768. if ($scope.app) {
  769. $scope.showLoadingToast();
  770. // var message = {
  771. // title: $scope.resourceDetail.title,
  772. // description: $scope.resourceDetail.title.substring(0,19),
  773. // url: sharelink,
  774. // imageurl: imagurl
  775. // };
  776. switch (type) {
  777. case 0:
  778. case 1:
  779. ShareService.shareToQQ(type, message).then(function () {
  780. $scope.hideLoadingToast();
  781. if ($scope.app) {
  782. UtilService.showMess("QQ分享成功");
  783. } else {
  784. CommonService.showMessage("QQ分享成功", $scope);
  785. }
  786. }, function (error) {
  787. $scope.hideLoadingToast();
  788. if ($scope.app) {
  789. UtilService.showMess(error);
  790. } else {
  791. CommonService.showMessage(error, $scope);
  792. }
  793. });
  794. break;
  795. case 2:
  796. ShareService.shareToWechat(type, message).then(function () {
  797. // UtilService.showMess("微信分享成功");
  798. $scope.hideLoadingToast();
  799. if ($scope.app) {
  800. UtilService.showMess("微信分享成功");
  801. } else {
  802. CommonService.showMessage("微信分享成功", $scope);
  803. }
  804. }, function (error) {
  805. // UtilService.showMess(error);
  806. $scope.hideLoadingToast();
  807. if ($scope.app) {
  808. UtilService.showMess(error);
  809. } else {
  810. CommonService.showMessage(error, $scope);
  811. }
  812. });
  813. break;
  814. case 3:
  815. ShareService.shareToWechat(type, message).then(function () {
  816. // UtilService.showMess("微信分享成功");
  817. $scope.hideLoadingToast();
  818. if ($scope.app) {
  819. UtilService.showMess("微信分享成功");
  820. } else {
  821. CommonService.showMessage("微信分享成功", $scope);
  822. }
  823. }, function (error) {
  824. // UtilService.showMess(error);
  825. $scope.hideLoadingToast();
  826. if ($scope.app) {
  827. UtilService.showMess(error);
  828. } else {
  829. CommonService.showMessage(error, $scope);
  830. }
  831. });
  832. break;
  833. case 4:
  834. ShareService.shareToWeibo(message).then(function () {
  835. // UtilService.showMess("新浪微博分享成功");
  836. $scope.hideLoadingToast();
  837. if ($scope.app) {
  838. UtilService.showMess("新浪微博分享成功");
  839. } else {
  840. CommonService.showMessage("新浪微博分享成功", $scope);
  841. }
  842. }, function (error) {
  843. // UtilService.showMess(error);
  844. $scope.hideLoadingToast();
  845. if ($scope.app) {
  846. UtilService.showMess(error);
  847. } else {
  848. CommonService.showMessage(error, $scope);
  849. }
  850. });
  851. break;
  852. default:
  853. break;
  854. }
  855. $timeout(function () {
  856. $scope.hideLoadingToast();
  857. }, 10000);
  858. } else {
  859. $scope.showShareWechat = true;
  860. var content = document.getElementById('qrcode-dialog1');
  861. content.innerHTML = '';
  862. console.log($scope.resourceDetail.baseInfoModel.title);
  863. var qrcode = new QRCode(content, {
  864. text: $scope.resourceDetail.baseInfoModel.title,
  865. // title: $scope.resourceDetail.baseInfoModel.title,
  866. // description: $scope.resourceDetail.baseInfoModel.title.substring(0,19),
  867. // url: linkUrl,
  868. // imageurl: imagurl,
  869. width: 200,
  870. height: 200
  871. })
  872. qrcode.makeCode(linkUrl);
  873. }
  874. };
  875. $scope.sendMessage = function (userid) {
  876. console.log(userid);
  877. // if(userid==UserService.id){
  878. // if($scope.app){
  879. // UtilService.showMess("不能咨询本人哦!");
  880. // }else{
  881. // CommonService.showMessage("不能咨询本人哦!",$scope);
  882. // }
  883. // return;
  884. // }
  885. ScienceCircleService.createConversation(6202, userid, 20001).then(function (response) {
  886. console.log(response);
  887. if (response.result > 0) {
  888. $scope.go('singleChatMode', {
  889. "topicid": response.topic.topicid,
  890. "topicname": response.topic.topicname,
  891. "username": $scope.pubulisherData.contactName,
  892. "reciverid": response.topic.reciverid,
  893. "isfocus": $scope.isfocus
  894. });
  895. } else {
  896. if ($scope.app) {
  897. UtilService.showMess("网络不给力,请重试");
  898. } else {
  899. CommonService.showMessage("网络不给力,请重试", $scope);
  900. }
  901. }
  902. }, function () {
  903. if ($scope.app) {
  904. UtilService.showMess("网络不给力,请重试");
  905. } else {
  906. CommonService.showMessage("网络不给力,请重试", $scope);
  907. }
  908. })
  909. };
  910. //跳转到评论发布者的主页
  911. $scope.goPublisher = function (id) {
  912. UserService.isNotThisUserFlag = 1;
  913. console.log(id);
  914. if (id != 0) {
  915. $scope.go('publisher', { Id: id });
  916. }
  917. };
  918. /****评论*****/
  919. $scope.comment = { content: "" };
  920. var recourceid = $stateParams.resid;
  921. var recourcetype = $stateParams.restype;
  922. // 评论/评论回复的传参
  923. $scope.infoComment =
  924. {
  925. infoid: recourceid,//资源id
  926. infotype: recourcetype,// 资源类别
  927. parentid: 0,// 评论回复时,记录父评论的id
  928. parentuserid: 0,// 评论回复时,记录父评论的创建者
  929. content: "",// 评论/回复内容
  930. //TODO
  931. creator: UserService.id,// 创建者
  932. updater: UserService.id,// 更新者
  933. // creator:1,// 创建者
  934. // updater:1// 更新者
  935. contenttype: '资源详情页'
  936. };
  937. // 获取评论列表的传参
  938. $scope.paramsForInfoCommentList =
  939. {
  940. mode: 1,// 显示样式:1热门 2全部
  941. infoid: recourceid,// 资源id
  942. infotype: recourcetype,// 资源类型
  943. sortkey: 0,// 排序字段
  944. sorttype: "ASC",// 排序方式
  945. moduleid: ConstantService.TABLE_CODE_30002,// 评论表对应的code
  946. //TODO
  947. userid: UserService.id// 登录者id
  948. // userid:1// 登录者id
  949. };
  950. //获取热门评论列表
  951. var getInfoCommentList = function () {
  952. CommentService.getInfoCommentList($scope.paramsForInfoCommentList).then(function (response) {
  953. console.log(response);
  954. // 评论列表
  955. $scope.comments = response.data;
  956. }, function () {
  957. })
  958. };
  959. getInfoCommentList();
  960. //发布普通评论
  961. $scope.publishComment = function (type, comment) {
  962. var content = $scope.comment.content;
  963. if (content.length == 0) {
  964. if ($scope.app) {
  965. UtilService.showMess("请输入评论内容!");
  966. } else {
  967. CommonService.showMessage("请输入评论内容!", $scope);
  968. }
  969. return;
  970. }
  971. $scope.showComment = true;
  972. $scope.infoComment.content = content;
  973. // 评论
  974. if (type == 1) {
  975. $scope.infoComment.parentid = 0;// 评论回复时,记录父评论的id
  976. $scope.infoComment.parentuserid = 0;// 评论回复时,记录父评论的创建者
  977. }
  978. // 评论回复
  979. else if (type == 2) {
  980. $scope.infoComment.parentid = comment.id;// 评论回复时,记录父评论的id
  981. $scope.infoComment.parentuserid = comment.creator;// 评论回复时,记录父评论的创建者
  982. }
  983. //提交评论信息
  984. $scope.showLoadingToast();
  985. console.log($scope.infoComment);
  986. $scope.infoComment.contenttype = '任务详情页';
  987. CommentService.publishSimpleComment($scope.infoComment).then(function () {
  988. if ($scope.app) {
  989. UtilService.showMess("评论成功");
  990. } else {
  991. CommonService.showMessage("评论成功", $scope);
  992. }
  993. $scope.infoComment.content = "";
  994. getInfoCommentList();
  995. /*if ($scope.comments.length >= 3) {
  996. $timeout(function () {
  997. $scope.getInfoCommentList();
  998. }, 650);
  999. }*/
  1000. $scope.hideLoadingToast();
  1001. }, function () {
  1002. $scope.hideLoadingToast();
  1003. });
  1004. };
  1005. //发表详细评论
  1006. $scope.releaseComment = function () {
  1007. $scope.go('releaseComment', {
  1008. infoid: recourceid,
  1009. infotype: recourcetype,
  1010. comlen: $scope.commentlist.length,
  1011. recourcecomefrom: recourcecomefrom
  1012. })
  1013. };
  1014. //点击抢沙发
  1015. $scope.hadSoft = function () {
  1016. $scope.showComment = false;
  1017. $(".my_comment").focus();
  1018. };
  1019. $scope.showComment = true;
  1020. $scope.focus_write = function () {
  1021. scrollToBottom();//滚动至底部
  1022. $scope.showComment = false;
  1023. $(".my_comment").focus();
  1024. };
  1025. $scope.hiddenComment = function () {
  1026. $scope.showComment = true;
  1027. };
  1028. //跳转到评论详情页comment
  1029. $scope.goComment = function (comment) {
  1030. $scope.go("Reply", {
  1031. comment: comment,
  1032. infotype: comment.infotype,
  1033. infoid: comment.infoid,
  1034. comfrom: '任务详情页'
  1035. })
  1036. };
  1037. // 滚动至底部
  1038. var scrollToBottom = function () {
  1039. $timeout(function () {
  1040. $ionicScrollDelegate.$getByHandle("calenderContent").scrollBottom();
  1041. }, 0);
  1042. };
  1043. //进入评论列表页
  1044. $scope.goCommentList = function () {
  1045. $timeout(function () {
  1046. $scope.go('comment', {
  1047. mode: 2,
  1048. infoid: $scope.resourceDetail.id,
  1049. infotype: $scope.resourceDetail.restype,
  1050. comfrom: 'task'
  1051. });
  1052. }, 350);
  1053. };
  1054. // 弹出简单评论框
  1055. $scope.showComment = true;
  1056. $scope.focus_write = function () {
  1057. $scope.showComment = false;
  1058. };
  1059. // 隐藏简单评论框
  1060. $scope.hiddenComment = function () {
  1061. $scope.showComment = true;
  1062. };
  1063. // 简单评论框内容变更,判断 发表 按钮颜色
  1064. $scope.commentValue = function () {
  1065. var search_history = angular.element(document.getElementsByClassName("my_comment"));
  1066. if (UtilService.isDefined($scope.comment.content) && $scope.comment.content.length > 1000) {
  1067. if ($scope.app) {
  1068. UtilService.showMess("您的评论已超过1000字!");
  1069. } else {
  1070. CommonService.showMessage("您的评论已超过1000字!", $scope);
  1071. }
  1072. $scope.comment.content = $scope.comment.content.substr(0, 1000);
  1073. }
  1074. if (UtilService.isDefined($scope.comment.content) && $scope.comment.content != 0) {
  1075. $scope.commentNotnull = {
  1076. "background-color": "#2a90d7",
  1077. "text-decoration": "underline"
  1078. };
  1079. } else {
  1080. $scope.commentNotnull = {
  1081. "background-color": "#ccc"
  1082. };
  1083. }
  1084. };
  1085. // 点赞、收藏、分享的传参
  1086. $scope.clickRecord =
  1087. {
  1088. //TODO
  1089. targetid: $stateParams.recourceid,
  1090. // targetid: 124,
  1091. moduleid: ConstantService.TABLE_CODE_30001,
  1092. userid: UserService.id,
  1093. // userid:1,
  1094. clicktype: 1,
  1095. content: '资源详情页'
  1096. };
  1097. // 控制重复点击
  1098. var flag = 1;
  1099. // 操作:点赞、关注、收藏
  1100. $scope.praiseAction = function (clicktype, recourceid, moduleid, ind) {
  1101. if (flag == 0) {
  1102. return;
  1103. }
  1104. flag = 0;
  1105. console.log(ind)
  1106. console.log(moduleid)
  1107. console.log($scope.resourceDetail.creator);
  1108. // 点赞 or 收藏 资源
  1109. // 取消点赞 or 取消收藏 资源
  1110. if (clicktype == 2615 || clicktype == 2619
  1111. || clicktype == 2616 || clicktype == 2620) {
  1112. $scope.clickRecord.targetid = recourceid;
  1113. $scope.clickRecord.moduleid = moduleid;
  1114. } else if (clicktype == 2617 || clicktype == 2618) {
  1115. // 关注 用户
  1116. // 取消关注 用户
  1117. $scope.clickRecord.targetid = $scope.resourceDetail.creator;
  1118. $scope.clickRecord.moduleid = 30043;
  1119. }
  1120. $scope.clickRecord.clicktype = clicktype;
  1121. $scope.clickRecord.content = '任务详情页';
  1122. console.log($scope.clickRecord);
  1123. CommentService.postClickFavour($scope.clickRecord).then(function (response) {
  1124. console.log(response);
  1125. if (response.code == 3350 && (clicktype == 2615 || clicktype == 2616)) {
  1126. $scope.comments[ind].favour = !$scope.comments[ind].favour;
  1127. clicktype == 2615 ? $scope.comments[ind].favourcount++ : $scope.comments[ind].favourcount--;
  1128. }
  1129. // 恢复可用
  1130. flag = 1;
  1131. }, function () {
  1132. // 恢复可用
  1133. flag = 1;
  1134. })
  1135. };
  1136. /********任务评价**********/
  1137. taskModuleService.searchTaskRateList($stateParams.resid, 1, 5).then(function (res) {
  1138. console.log(res);
  1139. })
  1140. /********任务编辑**********/
  1141. $scope.openActionSheet = function () {
  1142. var buttonlist = [
  1143. { text: '编辑' },
  1144. { text: '删除' }
  1145. ];
  1146. $ionicActionSheet.show({
  1147. buttons: buttonlist,
  1148. cancelText: '取消',
  1149. buttonClicked: function (index) {
  1150. if (index == 0) {
  1151. $scope.resourceDetail.opentowho = $scope.opentowho;
  1152. $scope.go('taskRelease', { comfrom: 'taskRelease', data: $scope.resourceDetail })
  1153. }
  1154. if (index == 1) {
  1155. var taskTitle = $scope.resourceDetail.title;
  1156. var companyId = $scope.resourceDetail.baseInfoModel.oid;
  1157. taskModuleService.deleteTask(taskTitle, companyId);
  1158. $scope.go('taskHoll');
  1159. }
  1160. }
  1161. })
  1162. }
  1163. /****************邀请人员******************/
  1164. $scope.opentowho = $scope.opentowho ? JSON.parse($stateParams.opentowho) : '';
  1165. console.log($scope.opentowho);
  1166. }
  1167. ])
  1168. ;