angular.module('push') .controller('notificationDetailCtrl', function ($scope, UserService, dataToolsService, ConfigService, $ionicPopup, $ionicSlideBoxDelegate, $timeout, ResourceLibraryService, $stateParams, $ionicActionSheet, $sce,LoginService) { $scope.notice = $stateParams.notice; $scope.noticecontent = $sce.trustAsHtml($scope.notice.content); $scope.picturelistsingle = []; console.log($scope.noticecontent) if (!$scope.notice) { var splitArr = window.location.href.split('/'); var unique = splitArr[splitArr.length - 1]; ResourceLibraryService.getESDataByUnique(unique).then(function (res) { if (res.code == 3350) { $scope.notice = res.data; $scope.noticecontent = $sce.trustAsHtml($scope.notice.content); ResourceLibraryService.getPictureList($scope.notice.unique, $scope.notice.creator).then(function (res) { if (res.code == 3350) { $scope.picturelist = res.data; angular.forEach(res.data, function (val, index) { if (val.doctype == 4902) { $scope.picturelistsingle[index] = val; } }) } }) } }) } //微信转发 //微信分享时自定义标题和描述 var wechatInit = function () { var url = encodeURIComponent(window.location.href.split("#")[0]); dataToolsService.getWechatConfig(UserService.node, url).then(function (res) { if (res.code == 3350) { $scope.wechattitle = $scope.notice.title; $scope.wechatlink = res.data[3] + "#/notificationDetail/" + $scope.notice.unique + ""; if($scope.notice.address){ $scope.wechatdesc = $scope.notice.address; }else{ $scope.wechatdesc = $scope.notice.summary; } for(var i = 0; i <$scope.picturelist.length;i++){ if($scope.picturelist[i].doctype == 4901){ $scope.imageUrl = $scope.picturelist[i].photoName; if($scope.imageUrl){ $scope.wechatimg = "http://pic.ubittc.com/" + $scope.imageUrl; }else{ $scope.wechatimg = './img/2018/notice.png'; } break; } } wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: res.data[4], // 必填,公众号的唯一标识 timestamp: res.data[0], // 必填,生成签名的时间戳 nonceStr: res.data[1], // 必填,生成签名的随机串 signature: res.data[2],// 必填,签名 jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填,需要使用的JS接口列表 }); wx.ready(function () { wx.onMenuShareTimeline({ title: $scope.wechattitle, // 分享标题 desc: $scope.wechatdesc, // 分享描述 link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: $scope.wechatimg, }); wx.onMenuShareAppMessage({ title: $scope.wechattitle, // 分享标题 desc: $scope.wechatdesc, // 分享描述 link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: $scope.wechatimg, }); }); wx.error(function (res) { // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。 console.log(JSON.stringify(res)); }); } }) }; wechatInit(); $scope.isCreator = false; if (UserService.id == $scope.notice.creator) { $scope.isCreator = true; } ResourceLibraryService.judgeManager(UserService.id, 0).then(function (res) { if (res.code == 3350) { $scope.canDoUpdate = res.data; } }) LoginService.getNodeInfo(UserService.node).then(function(res) { if (res.code == 3350) { $scope.platform = res.data.titlecode; } }); if ($scope.notice) { ResourceLibraryService.getPictureList($scope.notice.unique, $scope.notice.creator).then(function (res) { if (res.code == 3350) { $scope.picturelist = res.data; angular.forEach(res.data, function (val, index) { if (val.doctype == 4902) { $scope.picturelistsingle[index] = val; } }) } }) } //打开操作表:设置/编辑 $scope.openActionSheet = function () { var buttonlist = [ {text: '编辑'}, {text: '删除'} ]; $ionicActionSheet.show({ buttons: buttonlist, buttonClicked: function (index) { if (index == 0) { //编辑 $scope.go("newNotification", {notice: $scope.notice}); } if (index == 1) { //删除 $ionicPopup.confirm({ title: '确认', template: '确认删除?' }).then(function (result) { if (result) { ResourceLibraryService.deleteNotice($stateParams.notice.unique).then(function (res) { if (res.code == 3350) { $ionicPopup.alert({ title: '提示', template: '删除成功' }) } $scope.go("notification"); }) } }) } return true; } }); } //点击图片放大 $scope.bigImage = false; //初始默认大图是隐藏的 $scope.hideBigImage = function () { $timeout(function () { if ($scope.app) { $scope.setStatusBar(0); } $scope.bigImage = false; }, 400); }; $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl) window.open(ConfigService.imgurl + piclist[index].sourceName); return; }; }) ;