publisherCtrl.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. angular.module('push')
  2. .controller('PublisherCtrl', function ($scope, AccountService, $stateParams, SearchResultService, ConstantService, $ionicPopup,CommentService,
  3. UtilService, $ionicHistory, UserService, ConfigService, ScienceCircleService, CommonService, $ionicScrollDelegate) {
  4. //记录当前个人主页的用户id
  5. UserService.homeUserId = $stateParams.Id;
  6. //TODO
  7. console.log($stateParams);
  8. $scope.id = $stateParams.Id;
  9. $scope.userId = UserService.id;
  10. $scope.labelLists = [];
  11. $scope.stars = 0;
  12. $scope.category = '';
  13. // $scope.id = 670;
  14. // $scope.userId = 630;
  15. // 点赞、收藏、分享的传参
  16. $scope.clickRecord =
  17. {
  18. targetid: $stateParams.Id,
  19. moduleid: ConstantService.TABLE_CODE_30003,
  20. userid: UserService.id,
  21. clicktype: 1
  22. };
  23. AccountService.getHomeInfo($scope.id, $scope.userId).then(function (response) {
  24. console.log(response);
  25. var user = response.data;
  26. $scope.isfocus = user.isfocus;//当前登录用户是否关注了该主页用户 1:已经关注、2:未关注
  27. $scope.focusNmb = user.focuscount;//关注数
  28. $scope.fansNmb = user.fansNmb;//粉丝数
  29. $scope.name = user.username;//昵称
  30. $scope.orgName = user.orgName;//机构名
  31. $scope.intro = user.intro;//简介
  32. $scope.data = user.data;//资料
  33. $scope.orgType = user.orgType;//机构类型
  34. $scope.region = user.regionname;//所在地区
  35. $scope.linkman = user.linkman;//联系人
  36. $scope.contactnumber = user.contactnumber;//联系方式
  37. $scope.info = user;//用户信息
  38. $scope.labelLists = [];
  39. $scope.stars = 0;
  40. $scope.category = '';
  41. angular.forEach(response.otherObj, function (val) {
  42. switch (val.labelKey) {
  43. case 'scoreTotal':
  44. $scope.stars = Math.round(val.labelName);
  45. break;
  46. case 'industry':
  47. $scope.category = val.labelName;
  48. break;
  49. default :
  50. $scope.labelLists.push(val);
  51. }
  52. })
  53. console.log($scope.labelLists);
  54. }, function () {
  55. });
  56. $scope.range = function (n) {
  57. return new Array(n);
  58. }
  59. // 控制重复点击
  60. var flag = 1;
  61. // 关注对方
  62. $scope.A_Concerned = function () {
  63. if (flag == 0) {
  64. return;
  65. }
  66. flag = 0;
  67. // 关注动作
  68. if ($scope.isfocus == 2) {
  69. $scope.clickRecord.clicktype = ConstantService.TRACE_TYPE_2617;
  70. } else
  71. // 取消关注动作
  72. if ($scope.isfocus == 1) {
  73. $scope.clickRecord.clicktype = ConstantService.TRACE_TYPE_2618;
  74. }
  75. $scope.clickRecord.targetid = $scope.id;
  76. $scope.clickRecord.moduleid = ConstantService.TABLE_CODE_30043;
  77. CommentService.postClickFavour($scope.clickRecord).then(function (response) {
  78. // console.log(response);
  79. if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
  80. if ($scope.isfocus == 2) {
  81. $scope.isfocus = 1;
  82. // 关注成功
  83. if ($scope.app) {
  84. UtilService.showMess(ConstantService.TRACE_TYPE_STRING_2617);
  85. } else {
  86. CommonService.showMessage(ConstantService.TRACE_TYPE_STRING_2617, $scope);
  87. }
  88. } else
  89. // 取消关注
  90. if ($scope.isfocus == 1) {
  91. $scope.isfocus = 2;
  92. // 取消关注成功
  93. if ($scope.app) {
  94. UtilService.showMess(ConstantService.TRACE_TYPE_STRING_2618);
  95. } else {
  96. CommonService.showMessage(ConstantService.TRACE_TYPE_STRING_2618, $scope);
  97. }
  98. }
  99. }
  100. // 恢复可用
  101. flag = 1;
  102. }, function () {
  103. // 恢复可用
  104. flag = 1;
  105. if ($scope.app) {
  106. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  107. } else {
  108. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  109. }
  110. });
  111. };
  112. $scope.inbox={}
  113. // 发送消息
  114. $scope.sendMessage = function () {
  115. console.log($scope.id);
  116. // ScienceCircleService.createConversation(6202, $scope.id, 20001).then(function (response) {
  117. // console.log(response);
  118. // if (response.result > 0) {
  119. // $scope.go('singleChatMode', {
  120. // "topicid": response.topic.topicid,
  121. // "topicname": response.topic.topicname,
  122. // "username": $scope.name,
  123. // "reciverid": response.topic.reciverid,
  124. // "isfocus": $scope.isfocus
  125. // });
  126. // } else {
  127. // if ($scope.app) {
  128. // UtilService.showMess("网络不给力,请重试");
  129. // } else {
  130. // CommonService.showMessage("网络不给力,请重试", $scope);
  131. // }
  132. // }
  133. // }, function () {
  134. // if ($scope.app) {
  135. // UtilService.showMess("网络不给力,请重试");
  136. // } else {
  137. // CommonService.showMessage("网络不给力,请重试", $scope);
  138. // }
  139. // })
  140. $ionicPopup.show({
  141. title: '发送留言',
  142. template: `<input ng-model="inbox.content"
  143. placeholder="请输入内容"
  144. style="border: none;
  145. background: rgb(229 229 229 / 36%);
  146. height: 40px;
  147. ">`,
  148. scope: $scope,
  149. buttons: [{
  150. text: "取消",
  151. onTap: function () {
  152. // console.log('取消')
  153. }
  154. }, {
  155. text: '<span>发送</span>',
  156. type: "button-positive",
  157. onTap: function (e) {
  158. if($scope.inbox.content){
  159. let param={ "content": $scope.inbox.content,
  160. "receiveId":$scope.id ,
  161. "sendId": UserService.id}
  162. console.log(param)
  163. CommentService.postchatsend(param).then(function (res){
  164. if(res.code==3350){
  165. CommonService.prompt('发送成功');
  166. }else {
  167. $ionicPopup.alert({
  168. title: '提示',
  169. template: res.message
  170. });
  171. }
  172. }).catch(function () {
  173. $ionicPopup.alert({
  174. title: '提示',
  175. template: "服务器错误"
  176. });
  177. })
  178. }else {
  179. CommonService.prompt('请输入内容');
  180. e.preventDefault();
  181. }
  182. }
  183. }
  184. ]
  185. });
  186. };
  187. //删除动态
  188. $scope.item_delectSpan = function () {
  189. // console.log("删除");
  190. };
  191. //显示二维码
  192. $scope.showMyMessage = function () {
  193. $(".fixedTwo").css("display", "block");
  194. };
  195. //隐藏二维码
  196. $scope.hiddenTwoCode = function () {
  197. $(".fixedTwo").css("display", "none");
  198. };
  199. $scope.goNextPage = function () {
  200. /* $scope.islogin = ConfigService.islogin;
  201. if(!$scope.islogin){
  202. }else{
  203. $scope.go('editdata');
  204. }*/
  205. if ($scope.app) {
  206. UtilService.showMess("功能正在完善中,敬请期待!");
  207. } else {
  208. CommonService.showMessage("功能正在完善中,敬请期待!", $scope);
  209. }
  210. };
  211. $scope.gobackpage = function () {
  212. $scope.goback();
  213. /*if ($ionicHistory.backView()) {
  214. $ionicHistory.backView().go();
  215. } else {
  216. $ionicHistory.goBack(-4);
  217. }*/
  218. //个人主页是当前的登录用户
  219. /*if(info.userid == UserService.id){
  220. $scope.go('tab.account');
  221. }else{
  222. $ionicHistory.backView().go();
  223. }*/
  224. };
  225. //去完成任务
  226. $scope.gotoFanCenter = function (activityvalue) {
  227. $scope.go('fancenter', {act: activityvalue, userid: $scope.id});
  228. };
  229. var getMyRelease = function () {
  230. $scope.showLoadingToast();
  231. $scope.otherResource = [];
  232. $scope.len = -1;
  233. AccountService.releaseResource($scope.id).then(function (res) {
  234. // console.log(res);
  235. $scope.hideLoadingToast();
  236. if (res.code == 3350) {
  237. $scope.allList = res.data;
  238. console.log($scope.allList);
  239. angular.forEach($scope.allList, function (vv) {
  240. if (vv.list && vv.list.length > 0) {
  241. vv.shortList = vv.list.slice(0, 3);
  242. }
  243. if (vv.name == "走访的企业") {
  244. $scope.len = vv.list.length;
  245. }
  246. vv.showList = vv.shortList;
  247. })
  248. var temp = $scope.allList.filter(function (value) {
  249. return value.name == '发布的资源';
  250. });
  251. console.log($scope.allList);
  252. if (temp.length > 0) {
  253. angular.forEach(temp[0].typeList, function (val, index) {
  254. if (val.list != null && val.list != undefined && val.list.length > 0) {
  255. val.active = index == 0;
  256. $scope.otherResource.push(val);
  257. }
  258. })
  259. }
  260. }
  261. $scope.otherResourceList = $scope.otherResource[0];
  262. document.getElementById('click-button1').style.width = 100 * $scope.otherResource.length + 'px';
  263. })
  264. };
  265. getMyRelease();
  266. var currentIndex = 0;
  267. $scope.changeActiveTitle = function (index) {
  268. currentIndex = index;
  269. angular.forEach($scope.otherResource, function (val) {
  270. val.active = false;
  271. });
  272. $scope.otherResource[index].active = true;
  273. $scope.otherResourceList = $scope.otherResource[index];
  274. }
  275. // 进入资源详情
  276. $scope.goResourceDetail = function (resource, type) {
  277. //由用户首页的资源列表进入资源详情
  278. UserService.userHomeToResourceFlag = 1;
  279. console.log(resource);
  280. if (resource.unique !== undefined) {
  281. if (resource.type == 1) {
  282. if (!ConfigService.islogin) {
  283. if (localStorage.wxFlag == "true") {
  284. if (localStorage.isUserFocusXW == 0) {
  285. var title = localStorage.appidStr;
  286. $ionicPopup.alert({
  287. title: '提示',
  288. template: '请先关注微信公众号"' + title + '"!'
  289. });
  290. return;
  291. } else {
  292. if (localStorage.isUserBindWx == 0) {
  293. var wxFlag = JSON.parse(localStorage.params);
  294. if (wxFlag.weChatModel) {
  295. $scope.go('bindPhone', {
  296. params: localStorage.params,
  297. comfrom: 'maincontroller',
  298. url: window.location.href.split('#/')[1]
  299. });
  300. } else {
  301. $scope.go('login');
  302. return;
  303. }
  304. } else {
  305. $scope.go('login');
  306. return;
  307. }
  308. }
  309. } else {
  310. $scope.go('login');
  311. return;
  312. }
  313. } else if (type == 0) {
  314. $scope.go('taskDetail', {
  315. resid: resource.unique,
  316. node: resource.source,
  317. title: resource.title,
  318. restype: resource.type,
  319. comefrom: 'publisher',
  320. ifjoin: resource.otherObj.ifjoin,
  321. actions: resource.otherObj.actions,
  322. taskstatus: resource.otherObj.taskstatus,
  323. taskid: resource.otherObj.id,
  324. opentowho: resource.otherObj.opentowho
  325. });
  326. } else if (type == 1) {
  327. $scope.go('resourceCommonDetailsPage', {
  328. recourceid: resource.unique,
  329. recourcetype: resource.type,
  330. recourcecomefrom: resource.source,
  331. creator: resource.clickthrough,
  332. title: resource.title,
  333. orgtype: 0,
  334. pagecode: 0,
  335. label: JSON.stringify(resource.otherObj)
  336. });
  337. }
  338. } else {
  339. $scope.go('resourceCommonDetailsPage', {
  340. recourceid: resource.unique,
  341. recourcetype: resource.type,
  342. recourcecomefrom: resource.source,
  343. creator: resource.clickthrough,
  344. title: resource.title,
  345. orgtype: 0,
  346. pagecode: 0,
  347. label: JSON.stringify(resource.otherObj)
  348. });
  349. }
  350. }
  351. else if (resource.tablename !== undefined && resource.tablename == "activity_info") {
  352. //进入活动详情
  353. if (!ConfigService.islogin) {
  354. if (localStorage.wxFlag == "true") {
  355. if (localStorage.isUserFocusXW == 0) {
  356. var title = localStorage.appidStr;
  357. $ionicPopup.alert({
  358. title: '提示',
  359. template: '请先关注微信公众号"' + title + '"!'
  360. });
  361. return;
  362. } else {
  363. if (localStorage.isUserBindWx == 0) {
  364. var wxFlag = JSON.parse(localStorage.params);
  365. if (wxFlag.weChatModel) {
  366. $scope.go('bindPhone', {
  367. params: localStorage.params,
  368. comfrom: 'maincontroller',
  369. url: window.location.href.split('#/')[1]
  370. });
  371. } else {
  372. $scope.go('login');
  373. return;
  374. }
  375. } else {
  376. $scope.go('login');
  377. return;
  378. }
  379. }
  380. } else {
  381. $scope.go('login');
  382. return;
  383. }
  384. } else {
  385. $scope.go('activityDetail', {
  386. activityid: resource.id,
  387. });
  388. }
  389. } else {
  390. //进入走访列表
  391. if (!ConfigService.islogin) {
  392. if (localStorage.wxFlag == "true") {
  393. if (localStorage.isUserFocusXW == 0) {
  394. var title = localStorage.appidStr;
  395. $ionicPopup.alert({
  396. title: '提示',
  397. template: '请先关注微信公众号"' + title + '"!'
  398. });
  399. return;
  400. } else {
  401. if (localStorage.isUserBindWx == 0) {
  402. var wxFlag = JSON.parse(localStorage.params);
  403. if (wxFlag.weChatModel) {
  404. $scope.go('bindPhone', {
  405. params: localStorage.params,
  406. comfrom: 'maincontroller',
  407. url: window.location.href.split('#/')[1]
  408. });
  409. } else {
  410. $scope.go('login');
  411. return;
  412. }
  413. } else {
  414. $scope.go('login');
  415. return;
  416. }
  417. }
  418. } else {
  419. $scope.go('login');
  420. return;
  421. }
  422. } else {
  423. switch ($scope.act) {
  424. case "selfDetailList":
  425. $scope.isAllVisitor = 0;
  426. break;
  427. case "groupDetailList":
  428. $scope.isAllVisitor = 1;
  429. break;
  430. }
  431. $scope.go('resourceCommonInfoDetailsPage', {
  432. resid: resource.connid,
  433. isAllVisitor: $scope.isAllVisitor,
  434. pagecode: resource.pagecode,
  435. node: resource.node,
  436. orgtype: resource.orgtype,
  437. templettype: resource.templettype,
  438. label: JSON.stringify(resource.otherObj),
  439. });
  440. }
  441. }
  442. };
  443. $scope.showMoreResource = function (mainIndex, index) {
  444. $scope.allList[mainIndex].showList = $scope.allList[mainIndex].list
  445. }
  446. $scope.getPosition = function () {
  447. var position = $ionicScrollDelegate.getScrollPosition().top;
  448. console.log(position);
  449. $scope.showHeader = position > 180;
  450. }
  451. })
  452. ;