myMessageCtrl.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. angular.module('push')
  2. .controller('MyMessageCtrl', function ($scope, $rootScope, $ionicTabsDelegate, $ionicScrollDelegate,
  3. MyCollectionService, AccountService, accountModel, UserService, $timeout, ConstantService) {
  4. //TODO
  5. if ($scope.app) {
  6. $scope.setStatusBar(0);
  7. }
  8. $scope.myMessageList = [];
  9. $scope.nodata = false;
  10. $scope.showend = false;
  11. $scope.urlname = '';
  12. $scope.param = {};
  13. var page_no = 1;
  14. var page_total = 0;
  15. $scope.can_loadmore = function () {
  16. return page_no < page_total;
  17. };
  18. //获取消息类型列表
  19. $scope.$on('$ionicView.loaded', function () {
  20. page_no = 1;
  21. $scope.showLoadingToast();
  22. MyCollectionService.getSystemMessage(page_no).then(function (response) {
  23. console.log(response);
  24. $scope.myMessageList = response.data;
  25. $scope.nodata = !$scope.myMessageList.length;
  26. // angular.forEach($scope.myMessageList,function (value) {
  27. // $scope.urlname=value.msgTypeModel.url;
  28. // $scope.parames=JSON.parse(value.parastr);
  29. // });
  30. angular.forEach($scope.myMessageList, function (val) {
  31. if (val.msgTypeModel) {
  32. switch (val.msgTypeModel.mtype) {
  33. case 2647 :
  34. val.title = '有人对 ' + val.infoname + ' 录入了信息';
  35. break;
  36. case 2646 :
  37. val.title = '有人走访了 ' + val.infoname;
  38. break;
  39. case 2645 :
  40. val.title = val.applytypename + " " + val.resultmark;
  41. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  42. break;
  43. case 2614 :
  44. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  45. val.params.comefrom = 'mymessage';
  46. val.params.label = val.params.label ? val.params.label : '[]';
  47. val.title = '有人评论了 ' + val.params.title;
  48. break;
  49. case 2615 :
  50. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  51. val.params.comefrom = 'mymessage';
  52. val.params.label = val.params.label ? val.params.label : '[]';
  53. val.title = '有人点赞了 ' + val.params.title;
  54. break;
  55. case 2640 :
  56. val.title = '有人申请权限,请审核';
  57. break;
  58. case 2641 :
  59. val.title = '您申请的权限已被处理,请查看!';
  60. break;
  61. case 2617 :
  62. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  63. val.title = val.msgTypeModel.content;
  64. break;
  65. case 2662 :
  66. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  67. val.params.comefrom = 'mymessage';
  68. val.params.opentowho = JSON.stringify(val.params.opentowho);
  69. val.title = val.resultmark;
  70. break;
  71. default:
  72. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  73. val.title = val.resultmark;
  74. }
  75. }
  76. });
  77. console.log($scope.myMessageList);
  78. page_total = response.page.totalPage;
  79. $scope.hideLoadingToast();
  80. }, function () {
  81. $scope.hideLoadingToast();
  82. })
  83. });
  84. //加载更多消息
  85. $scope.loadMore = function () {
  86. page_no += 1;
  87. MyCollectionService.getSystemMessage(page_no).then(function (response) {
  88. console.log(response);
  89. page_total = response.page.totalPage;
  90. var tempreslib = new Array();
  91. tempreslib = angular.fromJson(response.data);
  92. console.log(tempreslib);
  93. $scope.showend = tempreslib.length < response.page.pageSize;
  94. angular.forEach(tempreslib, function (val) {
  95. // console.log(val.postscript);
  96. switch (val.msgTypeModel.mtype) {
  97. case 2647 :
  98. val.title = '有人对 ' + val.infoname + ' 录入了信息';
  99. break;
  100. case 2646 :
  101. val.title = '有人走访了 ' + val.infoname;
  102. break;
  103. case 2645 :
  104. val.title = val.applytypename + " " + val.authenstatusname;
  105. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  106. break;
  107. case 2614 :
  108. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  109. val.params.comefrom = 'mymessage';
  110. val.params.label = val.params.label ? val.params.label : '[]';
  111. val.title = '有人评论了 ' + val.params.title;
  112. break;
  113. case 2615 :
  114. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  115. val.params.comefrom = 'mymessage';
  116. val.params.label = val.params.label ? val.params.label : '[]';
  117. val.title = '有人点赞了 ' + val.params.title;
  118. break;
  119. case 2640 :
  120. val.title = '有人申请权限,请审核';
  121. break;
  122. case 2641 :
  123. val.title = '您申请的权限已被处理,请查看!';
  124. break;
  125. case 2617 :
  126. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  127. val.title = val.msgTypeModel.content;
  128. break;
  129. case 2662 :
  130. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  131. val.params.comefrom = 'mymessage';
  132. val.params.opentowho = JSON.stringify(val.params.opentowho);
  133. val.title = val.resultmark;
  134. break;
  135. default:
  136. val.params = val.postscript ? JSON.parse(val.postscript) : {};
  137. val.title = val.resultmark;
  138. }
  139. })
  140. //加载数据,更新当前页数
  141. $timeout(function () {
  142. if (tempreslib.length > 0) {
  143. $scope.myMessageList = $scope.myMessageList.concat(tempreslib);
  144. }
  145. }, 50);
  146. }, function () {
  147. $scope.hideLoadingToast();
  148. }).finally(function () {
  149. $scope.$broadcast('scroll.infiniteScrollComplete');
  150. });
  151. };
  152. //删除我的消息
  153. $scope.deal = function (item, nid) {
  154. console.log(item);
  155. $scope.myMessageList.splice(item, 1);
  156. MyCollectionService.getMessageDelete(nid).then(function () {
  157. //console.log(response);
  158. $scope.loadMore();//重新拉数据
  159. $scope.hideLoadingToast();
  160. }, function () {
  161. $scope.hideLoadingToast();
  162. })
  163. };
  164. //页面调转
  165. $scope.goResourceDetail = function (resid, url, parastr) {
  166. // var url=$scope.urlname;
  167. console.log(url);
  168. if (url == "resourceCommonInfoDetailsRepeatPage") {
  169. $scope.go('resourceCommonInfoDetailsRepeatPage', {resid: resid});
  170. } else if (url == "resourceCommonInfoDetailsPage") {
  171. $scope.go('resourceCommonInfoDetailsPage', parastr);
  172. } else if (url == "resourceCommonDetailsPage") {
  173. $scope.go('resourceCommonDetailsPage', parastr);
  174. } else {
  175. $scope.go(url);
  176. }
  177. };
  178. // 进入消息详情
  179. $scope.goMessageDetail = function (index) {
  180. var message = $scope.myMessageList[index];
  181. switch ($scope.myMessageList[index].msgTypeModel.mtype) {
  182. case 2647:
  183. break;
  184. case 2645:
  185. $scope.go('identifyStatus', {
  186. code: $scope.myMessageList[index].params.code,
  187. id: $scope.myMessageList[index].targetid,
  188. pageTitle: $scope.myMessageList[index].applytypename,
  189. type: $scope.myMessageList[index].result,
  190. });
  191. break;
  192. case 2614:
  193. $scope.go($scope.myMessageList[index].msgTypeModel.url, {
  194. comfrom: $scope.myMessageList[index].params.comfrom,
  195. node: $scope.myMessageList[index].params.node,
  196. orgtype: $scope.myMessageList[index].params.orgtype,
  197. pagecode: $scope.myMessageList[index].params.pagecode,
  198. // resid: $scope.myMessageList[index].params.recourceid,
  199. templettype: $scope.myMessageList[index].params.templettype,
  200. recourcecomefrom: $scope.myMessageList[index].params.node,
  201. recourcetype: $scope.myMessageList[index].params.recourcetype,
  202. title: $scope.myMessageList[index].params.title,
  203. recourceid: $scope.myMessageList[index].params.recourceid,
  204. actions: $scope.myMessageList[index].params.actions,
  205. comefrom: $scope.myMessageList[index].params.comefrom,
  206. label: $scope.myMessageList[index].params.label,
  207. // node: $scope.myMessageList[index].params.node,
  208. opentype: $scope.myMessageList[index].params.opentype,
  209. resid: $scope.myMessageList[index].params.resid,
  210. restype: $scope.myMessageList[index].params.restype,
  211. taskid: $scope.myMessageList[index].params.taskid,
  212. taskstatus: $scope.myMessageList[index].params.taskstatus,
  213. activityid: $scope.myMessageList[index].params.activityid
  214. });
  215. break;
  216. case 2615:
  217. $scope.go($scope.myMessageList[index].msgTypeModel.url, {
  218. comfrom: $scope.myMessageList[index].params.comfrom,
  219. node: $scope.myMessageList[index].params.node,
  220. orgtype: $scope.myMessageList[index].params.orgtype,
  221. pagecode: $scope.myMessageList[index].params.pagecode,
  222. resid: $scope.myMessageList[index].params.recourceid,
  223. templettype: $scope.myMessageList[index].params.templettype,
  224. recourcecomefrom: $scope.myMessageList[index].params.node,
  225. recourcetype: $scope.myMessageList[index].params.recourcetype,
  226. title: $scope.myMessageList[index].params.title,
  227. recourceid: $scope.myMessageList[index].params.recourceid,
  228. actions: $scope.myMessageList[index].params.actions,
  229. comefrom: $scope.myMessageList[index].params.comefrom,
  230. label: $scope.myMessageList[index].params.label,
  231. // node: $scope.myMessageList[index].params.node,
  232. opentype: $scope.myMessageList[index].params.opentype,
  233. // resid: $scope.myMessageList[index].params.resid,
  234. restype: $scope.myMessageList[index].params.restype,
  235. taskid: $scope.myMessageList[index].params.taskid,
  236. taskstatus: $scope.myMessageList[index].params.taskstatus,
  237. activityid: $scope.myMessageList[index].params.activityid
  238. });
  239. break;
  240. case 2640:
  241. $scope.go('authorityApply', {
  242. content: $scope.myMessageList[index].applyinfo,
  243. messageId: $scope.myMessageList[index].id,
  244. type: $scope.myMessageList[index].type
  245. });
  246. break;
  247. case 2641:
  248. $scope.go('authorityApply', {
  249. content: $scope.myMessageList[index].applyinfo,
  250. messageId: $scope.myMessageList[index].id,
  251. type: $scope.myMessageList[index].type
  252. });
  253. break;
  254. case 2662:
  255. UserService.isMessage = 1;
  256. var messageParams = message.postscript ? JSON.parse(message.postscript) : {};
  257. $scope.go('taskDetail', {
  258. resid: messageParams.resid,
  259. node: messageParams.node,
  260. title: messageParams.title,
  261. restype: messageParams.restype,
  262. comefrom: 'mymessage',
  263. //ifjoin: params.otherObj.ifjoin,
  264. actions: messageParams.actions,
  265. taskstatus: messageParams.taskstatus,
  266. taskid: messageParams.taskid,
  267. //opentowho: params.otherObj.opentowho,
  268. });
  269. break;
  270. case 2617 :
  271. $scope.go($scope.myMessageList[index].msgTypeModel.url, {
  272. Id: $scope.myMessageList[index].creator
  273. });
  274. break;
  275. case 2681 :break;
  276. case 2682 :break;
  277. case 2683 :break;
  278. case 2684 :break;
  279. case 2685 :break;
  280. case 2686 :break;
  281. default:
  282. $scope.go($scope.myMessageList[index].msgTypeModel.url, $scope.myMessageList[index].params);
  283. }
  284. }
  285. $scope.gobackTohome = function () {
  286. $scope.go('tab.activityIndex');
  287. }
  288. });