123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- angular.module('push')
- .controller('MyMessageCtrl', function ($scope, $rootScope, $ionicTabsDelegate, $ionicScrollDelegate,
- MyCollectionService, AccountService, accountModel, UserService, $timeout, ConstantService) {
- //TODO
- if ($scope.app) {
- $scope.setStatusBar(0);
- }
- $scope.myMessageList = [];
- $scope.nodata = false;
- $scope.showend = false;
- $scope.urlname = '';
- $scope.param = {};
- var page_no = 1;
- var page_total = 0;
- $scope.can_loadmore = function () {
- return page_no < page_total;
- };
- //获取消息类型列表
- $scope.$on('$ionicView.loaded', function () {
- page_no = 1;
- $scope.showLoadingToast();
- MyCollectionService.getSystemMessage(page_no).then(function (response) {
- console.log(response);
- $scope.myMessageList = response.data;
- $scope.nodata = !$scope.myMessageList.length;
- // angular.forEach($scope.myMessageList,function (value) {
- // $scope.urlname=value.msgTypeModel.url;
- // $scope.parames=JSON.parse(value.parastr);
- // });
- angular.forEach($scope.myMessageList, function (val) {
- if (val.msgTypeModel) {
- switch (val.msgTypeModel.mtype) {
- case 2647 :
- val.title = '有人对 ' + val.infoname + ' 录入了信息';
- break;
- case 2646 :
- val.title = '有人走访了 ' + val.infoname;
- break;
- case 2645 :
- val.title = val.applytypename + " " + val.resultmark;
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- break;
- case 2614 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.label = val.params.label ? val.params.label : '[]';
- val.title = '有人评论了 ' + val.params.title;
- break;
- case 2615 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.label = val.params.label ? val.params.label : '[]';
- val.title = '有人点赞了 ' + val.params.title;
- break;
- case 2640 :
- val.title = '有人申请权限,请审核';
- break;
- case 2641 :
- val.title = '您申请的权限已被处理,请查看!';
- break;
- case 2617 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.title = val.msgTypeModel.content;
- break;
- case 2662 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.opentowho = JSON.stringify(val.params.opentowho);
- val.title = val.resultmark;
- break;
- default:
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.title = val.resultmark;
- }
- }
- });
- console.log($scope.myMessageList);
- page_total = response.page.totalPage;
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- })
- });
- //加载更多消息
- $scope.loadMore = function () {
- page_no += 1;
- MyCollectionService.getSystemMessage(page_no).then(function (response) {
- console.log(response);
- page_total = response.page.totalPage;
- var tempreslib = new Array();
- tempreslib = angular.fromJson(response.data);
- console.log(tempreslib);
- $scope.showend = tempreslib.length < response.page.pageSize;
- angular.forEach(tempreslib, function (val) {
- // console.log(val.postscript);
- switch (val.msgTypeModel.mtype) {
- case 2647 :
- val.title = '有人对 ' + val.infoname + ' 录入了信息';
- break;
- case 2646 :
- val.title = '有人走访了 ' + val.infoname;
- break;
- case 2645 :
- val.title = val.applytypename + " " + val.authenstatusname;
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- break;
- case 2614 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.label = val.params.label ? val.params.label : '[]';
- val.title = '有人评论了 ' + val.params.title;
- break;
- case 2615 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.label = val.params.label ? val.params.label : '[]';
- val.title = '有人点赞了 ' + val.params.title;
- break;
- case 2640 :
- val.title = '有人申请权限,请审核';
- break;
- case 2641 :
- val.title = '您申请的权限已被处理,请查看!';
- break;
- case 2617 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.title = val.msgTypeModel.content;
- break;
- case 2662 :
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.params.comefrom = 'mymessage';
- val.params.opentowho = JSON.stringify(val.params.opentowho);
- val.title = val.resultmark;
- break;
- default:
- val.params = val.postscript ? JSON.parse(val.postscript) : {};
- val.title = val.resultmark;
- }
- })
- //加载数据,更新当前页数
- $timeout(function () {
- if (tempreslib.length > 0) {
- $scope.myMessageList = $scope.myMessageList.concat(tempreslib);
- }
- }, 50);
- }, function () {
- $scope.hideLoadingToast();
- }).finally(function () {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- });
- };
- //删除我的消息
- $scope.deal = function (item, nid) {
- console.log(item);
- $scope.myMessageList.splice(item, 1);
- MyCollectionService.getMessageDelete(nid).then(function () {
- //console.log(response);
- $scope.loadMore();//重新拉数据
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- })
- };
- //页面调转
- $scope.goResourceDetail = function (resid, url, parastr) {
- // var url=$scope.urlname;
- console.log(url);
- if (url == "resourceCommonInfoDetailsRepeatPage") {
- $scope.go('resourceCommonInfoDetailsRepeatPage', {resid: resid});
- } else if (url == "resourceCommonInfoDetailsPage") {
- $scope.go('resourceCommonInfoDetailsPage', parastr);
- } else if (url == "resourceCommonDetailsPage") {
- $scope.go('resourceCommonDetailsPage', parastr);
- } else {
- $scope.go(url);
- }
- };
- // 进入消息详情
- $scope.goMessageDetail = function (index) {
- var message = $scope.myMessageList[index];
- switch ($scope.myMessageList[index].msgTypeModel.mtype) {
- case 2647:
- break;
- case 2645:
- $scope.go('identifyStatus', {
- code: $scope.myMessageList[index].params.code,
- id: $scope.myMessageList[index].targetid,
- pageTitle: $scope.myMessageList[index].applytypename,
- type: $scope.myMessageList[index].result,
- });
- break;
- case 2614:
- $scope.go($scope.myMessageList[index].msgTypeModel.url, {
- comfrom: $scope.myMessageList[index].params.comfrom,
- node: $scope.myMessageList[index].params.node,
- orgtype: $scope.myMessageList[index].params.orgtype,
- pagecode: $scope.myMessageList[index].params.pagecode,
- // resid: $scope.myMessageList[index].params.recourceid,
- templettype: $scope.myMessageList[index].params.templettype,
- recourcecomefrom: $scope.myMessageList[index].params.node,
- recourcetype: $scope.myMessageList[index].params.recourcetype,
- title: $scope.myMessageList[index].params.title,
- recourceid: $scope.myMessageList[index].params.recourceid,
- actions: $scope.myMessageList[index].params.actions,
- comefrom: $scope.myMessageList[index].params.comefrom,
- label: $scope.myMessageList[index].params.label,
- // node: $scope.myMessageList[index].params.node,
- opentype: $scope.myMessageList[index].params.opentype,
- resid: $scope.myMessageList[index].params.resid,
- restype: $scope.myMessageList[index].params.restype,
- taskid: $scope.myMessageList[index].params.taskid,
- taskstatus: $scope.myMessageList[index].params.taskstatus,
- activityid: $scope.myMessageList[index].params.activityid
- });
- break;
- case 2615:
- $scope.go($scope.myMessageList[index].msgTypeModel.url, {
- comfrom: $scope.myMessageList[index].params.comfrom,
- node: $scope.myMessageList[index].params.node,
- orgtype: $scope.myMessageList[index].params.orgtype,
- pagecode: $scope.myMessageList[index].params.pagecode,
- resid: $scope.myMessageList[index].params.recourceid,
- templettype: $scope.myMessageList[index].params.templettype,
- recourcecomefrom: $scope.myMessageList[index].params.node,
- recourcetype: $scope.myMessageList[index].params.recourcetype,
- title: $scope.myMessageList[index].params.title,
- recourceid: $scope.myMessageList[index].params.recourceid,
- actions: $scope.myMessageList[index].params.actions,
- comefrom: $scope.myMessageList[index].params.comefrom,
- label: $scope.myMessageList[index].params.label,
- // node: $scope.myMessageList[index].params.node,
- opentype: $scope.myMessageList[index].params.opentype,
- // resid: $scope.myMessageList[index].params.resid,
- restype: $scope.myMessageList[index].params.restype,
- taskid: $scope.myMessageList[index].params.taskid,
- taskstatus: $scope.myMessageList[index].params.taskstatus,
- activityid: $scope.myMessageList[index].params.activityid
- });
- break;
- case 2640:
- $scope.go('authorityApply', {
- content: $scope.myMessageList[index].applyinfo,
- messageId: $scope.myMessageList[index].id,
- type: $scope.myMessageList[index].type
- });
- break;
- case 2641:
- $scope.go('authorityApply', {
- content: $scope.myMessageList[index].applyinfo,
- messageId: $scope.myMessageList[index].id,
- type: $scope.myMessageList[index].type
- });
- break;
- case 2662:
- UserService.isMessage = 1;
- var messageParams = message.postscript ? JSON.parse(message.postscript) : {};
- $scope.go('taskDetail', {
- resid: messageParams.resid,
- node: messageParams.node,
- title: messageParams.title,
- restype: messageParams.restype,
- comefrom: 'mymessage',
- //ifjoin: params.otherObj.ifjoin,
- actions: messageParams.actions,
- taskstatus: messageParams.taskstatus,
- taskid: messageParams.taskid,
- //opentowho: params.otherObj.opentowho,
- });
- break;
- case 2617 :
- $scope.go($scope.myMessageList[index].msgTypeModel.url, {
- Id: $scope.myMessageList[index].creator
- });
- break;
- case 2681 :break;
- case 2682 :break;
- case 2683 :break;
- case 2684 :break;
- case 2685 :break;
- case 2686 :break;
- default:
- $scope.go($scope.myMessageList[index].msgTypeModel.url, $scope.myMessageList[index].params);
- }
- }
- $scope.gobackTohome = function () {
- $scope.go('tab.activityIndex');
- }
- });
|