unserver-unify
Version:
75 lines (71 loc) • 2.55 kB
JavaScript
;
angular.module('bamboo.news').controller('NewsCtrl', function($location, $scope, ApiService, $stateParams, Lightbox, youtubeEmbedUtils, previewFileHelper, $uibModal, deviceDetector) {
var _self = this;
this.id = $stateParams.id;
this.contentModel = {};
this.publicUrl = ApiService.SHOST + "/public/images/";
this.attachmentsURL = ApiService.SHOST + "/public/" + ApiService.RES + "/schoolnews/" + _self.id + "/";
this.contentModelPicUrl = ApiService.SHOST + "/public/" + ApiService.RES + "/schoolnews/";
var videopath = ApiService.SHOST + "/public/" + ApiService.RES + "/schoolnews/" + _self.id + "/";
this.defaultNewsPhoto = 'assets/images/news_no-image1.jpg';
getInfo();
function getInfo() {
ApiService.get("/newses/" + _self.id).then(function(result) {
console.log(_self.id)
if (result.data.success) {
_self.contentModel = result.data.data || {};
console.log(_self.contentModel);
_self.imageUrl = _self.contentModel.photo ? _self.contentModelPicUrl + _self.contentModel._id + '/' + _self.contentModel.photo : _self.defaultNewsPhoto;
if (_self.contentModel.videoLink) {
_self.videoLink = _self.contentModel.videoLink;
}
if (_self.contentModel.video) {
_self.videoUrl = videopath + _self.contentModel.video;
}
}
});
}
$scope.openHtmlModal = function() {
openHtmlModalDlg(_self.contentModel.name, _self.contentModel.detail);
}
function openHtmlModalDlg(title, content) {
$uibModal.open({
templateUrl: "components/dialog/html-dlg.html",
size: 'lg',
controller: 'HTML_DlgCtrl',
resolve: {
title: function() {
return title;
},
content: function() {
return content;
}
}
}).result.then(function() {});
}
$scope.openLightboxModal = function(url) {
Lightbox.openModal([{
url: url
}], 0);
};
this.hotest = [];
this.latest = [];
function getsidenews() {
var info = {
action: 'getsidenews',
}
if (ApiService.school.excludedepartmentFlag) {
info.action = "getgroupsidenews";
}
ApiService.post("/news", info).then(function(result) {
if (result.data.success) {
console.log(result.data.data);
_self.hotest = result.data.data.hotest;
_self.latest = result.data.data.latest;
}
});
}
if (!deviceDetector.isMobile()) {
getsidenews();
}
});