notificationDetailCtrl.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. angular.module('push')
  2. .controller('notificationDetailCtrl', function ($scope, UserService, dataToolsService, ConfigService, $ionicPopup, $ionicSlideBoxDelegate, $timeout, ResourceLibraryService, $stateParams, $ionicActionSheet, $sce,LoginService) {
  3. $scope.notice = $stateParams.notice;
  4. $scope.noticecontent = $sce.trustAsHtml($scope.notice.content);
  5. $scope.picturelistsingle = [];
  6. console.log($scope.noticecontent)
  7. if (!$scope.notice) {
  8. var splitArr = window.location.href.split('/');
  9. var unique = splitArr[splitArr.length - 1];
  10. ResourceLibraryService.getESDataByUnique(unique).then(function (res) {
  11. if (res.code == 3350) {
  12. $scope.notice = res.data;
  13. $scope.noticecontent = $sce.trustAsHtml($scope.notice.content);
  14. ResourceLibraryService.getPictureList($scope.notice.unique, $scope.notice.creator).then(function (res) {
  15. if (res.code == 3350) {
  16. $scope.picturelist = res.data;
  17. angular.forEach(res.data, function (val, index) {
  18. if (val.doctype == 4902) {
  19. $scope.picturelistsingle[index] = val;
  20. }
  21. })
  22. }
  23. })
  24. }
  25. })
  26. }
  27. //微信转发
  28. //微信分享时自定义标题和描述
  29. var wechatInit = function () {
  30. var url = encodeURIComponent(window.location.href.split("#")[0]);
  31. dataToolsService.getWechatConfig(UserService.node, url).then(function (res) {
  32. if (res.code == 3350) {
  33. $scope.wechattitle = $scope.notice.title;
  34. $scope.wechatlink = res.data[3] + "#/notificationDetail/" + $scope.notice.unique + "";
  35. if($scope.notice.address){
  36. $scope.wechatdesc = $scope.notice.address;
  37. }else{
  38. $scope.wechatdesc = $scope.notice.summary;
  39. }
  40. for(var i = 0; i <$scope.picturelist.length;i++){
  41. if($scope.picturelist[i].doctype == 4901){
  42. $scope.imageUrl = $scope.picturelist[i].photoName;
  43. if($scope.imageUrl){
  44. $scope.wechatimg = "http://pic.ubittc.com/" + $scope.imageUrl;
  45. }else{
  46. $scope.wechatimg = './img/2018/notice.png';
  47. }
  48. break;
  49. }
  50. }
  51. wx.config({
  52. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  53. appId: res.data[4], // 必填,公众号的唯一标识
  54. timestamp: res.data[0], // 必填,生成签名的时间戳
  55. nonceStr: res.data[1], // 必填,生成签名的随机串
  56. signature: res.data[2],// 必填,签名
  57. jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填,需要使用的JS接口列表
  58. });
  59. wx.ready(function () {
  60. wx.onMenuShareTimeline({
  61. title: $scope.wechattitle, // 分享标题
  62. desc: $scope.wechatdesc, // 分享描述
  63. link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  64. imgUrl: $scope.wechatimg,
  65. });
  66. wx.onMenuShareAppMessage({
  67. title: $scope.wechattitle, // 分享标题
  68. desc: $scope.wechatdesc, // 分享描述
  69. link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  70. imgUrl: $scope.wechatimg,
  71. });
  72. });
  73. wx.error(function (res) {
  74. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  75. console.log(JSON.stringify(res));
  76. });
  77. }
  78. })
  79. };
  80. wechatInit();
  81. $scope.isCreator = false;
  82. if (UserService.id == $scope.notice.creator) {
  83. $scope.isCreator = true;
  84. }
  85. ResourceLibraryService.judgeManager(UserService.id, 0).then(function (res) {
  86. if (res.code == 3350) {
  87. $scope.canDoUpdate = res.data;
  88. }
  89. })
  90. LoginService.getNodeInfo(UserService.node).then(function(res) {
  91. if (res.code == 3350) {
  92. $scope.platform = res.data.titlecode;
  93. }
  94. });
  95. if ($scope.notice) {
  96. ResourceLibraryService.getPictureList($scope.notice.unique, $scope.notice.creator).then(function (res) {
  97. if (res.code == 3350) {
  98. $scope.picturelist = res.data;
  99. angular.forEach(res.data, function (val, index) {
  100. if (val.doctype == 4902) {
  101. $scope.picturelistsingle[index] = val;
  102. }
  103. })
  104. }
  105. })
  106. }
  107. //打开操作表:设置/编辑
  108. $scope.openActionSheet = function () {
  109. var buttonlist = [
  110. {text: '编辑'},
  111. {text: '删除'}
  112. ];
  113. $ionicActionSheet.show({
  114. buttons: buttonlist,
  115. buttonClicked: function (index) {
  116. if (index == 0) {
  117. //编辑
  118. $scope.go("newNotification", {notice: $scope.notice});
  119. }
  120. if (index == 1) {
  121. //删除
  122. $ionicPopup.confirm({
  123. title: '确认',
  124. template: '确认删除?'
  125. }).then(function (result) {
  126. if (result) {
  127. ResourceLibraryService.deleteNotice($stateParams.notice.unique).then(function (res) {
  128. if (res.code == 3350) {
  129. $ionicPopup.alert({
  130. title: '提示',
  131. template: '删除成功'
  132. })
  133. }
  134. $scope.go("notification");
  135. })
  136. }
  137. })
  138. }
  139. return true;
  140. }
  141. });
  142. }
  143. //点击图片放大
  144. $scope.bigImage = false; //初始默认大图是隐藏的
  145. $scope.hideBigImage = function () {
  146. $timeout(function () {
  147. if ($scope.app) {
  148. $scope.setStatusBar(0);
  149. }
  150. $scope.bigImage = false;
  151. }, 400);
  152. };
  153. $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl)
  154. window.open(ConfigService.imgurl + piclist[index].sourceName);
  155. return;
  156. };
  157. })
  158. ;