unserver-unify
Version:
93 lines (87 loc) • 2.88 kB
JavaScript
;
angular.module('bamboo').controller('AboutUsDetailController', function(ApiService, $sce, InfoService, $scope, $state, $stateParams, Lightbox) {
var self = this;
self.id = $stateParams.id;
self.imgBaseUrl = ApiService.SHOST + '/advinfo/';
console.log($state.current.name);
var URL = "";
switch ($state.current.name) {
case "index.aboutus.certificate.detail":
URL = "certinfo";
break;
case "index.aboutus.partner.detail":
URL = "partner";
break;
case "index.aboutus.mission.detail":
URL = "mission";
break;
case "index.aboutus.usecase.detail":
URL = "usecase";
break;
case "index.aboutus.programinfos.detail":
URL = "programinfo";
break;
case "index.aboutus.awards.detail":
URL = "awardinfo";
break;
case "index.aboutus.albums.detail":
case "index.classes.class.albums.detail":
case "index.myspace.myclasses.class.albums.detail":
URL = "album";
break;
}
//partner
//certinfo
//awardinfo
//usecase
getInfo(URL);
function getInfo(URL) {
if (!URL) return;
ApiService.get("/" + URL + "/" + self.id).then(function(result) {
console.log(result);
if (result.data.success) {
self.item = result.data.data;
console.log(self.item);
self.imageUrl = self.item.photo ? self.imgBaseUrl + self.item.photo : self.defaultPhotoUrl;
if (URL == "album") {
if (self.item.photos) {
self.albums = self.item.photos.map(function(o) {
return {
url: self.imgBaseUrl + o.photo,
thumbUrl: self.imgBaseUrl + o.photo,
caption: o.name
}
});
console.log(self.albums);
}
if (self.item.videos) {
self.videos = self.item.videos.map(function(o) {
return {
url: self.getFileUrl(o.mp4),
thumbUrl: self.getFileTrustAsResourceUrl(o.mp4),
caption: o.name,
type: 'video'
}
});
console.log(self.albums);
console.log(self.videos);
}
}
}
});
}
this.getFileUrl = function(fileName) {
//return $sce.trustAsResourceUrl(self.imgBaseUrl + encodeURI(fileName));
return self.imgBaseUrl + encodeURI(fileName);
}
this.getFileTrustAsResourceUrl = function(fileName) {
return $sce.trustAsResourceUrl(self.imgBaseUrl + encodeURI(fileName));
//return self.imgBaseUrl + encodeURI(fileName);
}
$scope.openLightboxModal = function(index) {
Lightbox.openModal(self.albums, index);
};
$scope.openVideoLightboxModal = function(index) {
Lightbox.openModal(self.videos, index);
};
});