unserver-unify
Version:
182 lines (174 loc) • 5.91 kB
JavaScript
;
angular.module('bamboo').controller('AboutUsController', function(ApiService, InfoService, $scope, $state, loginService, Lightbox) {
var _self = this;
var school = ApiService.school;
this.defaultNewsPhoto = 'assets/images/news_no-image1.jpg';
this.defaultCertPhoto = 'assets/images/certificate.jpg';
this.defaultUseCasePhoto = 'assets/images/usecase.jpg';
this.defaultPersonPhoto = 'assets/images/logo_cmpany.png';
this.imgBaseUrl = ApiService.SHOST + '/advinfo/';
this.SchoolIconUrl = ApiService.PSURL + '/school/' + ApiService.gid + '/' + loginService.school.icon;
this.SchoolPhotoUrl = ApiService.PSURL + '/school/' + ApiService.gid + '/' + loginService.school.photo;
this.schoolUrl = ApiService.PSURL + "/school/" + ApiService.gid + "/";
console.log(_self.PSBaseUrl);
$scope.school = loginService.school;
console.info($scope.school);
console.info(_self.SchoolIconUrl);
console.log($state.current.name);
switch ($state.current.name) {
case 'index.aboutus.aboutus':
getAboutInfo();
break;
case 'index.aboutus.certificate':
getInfoByType("getcerts", 'CertList', 'CertListCount');
break;
case 'index.aboutus.mission':
getMissionInfo();
break;
case 'index.aboutus.whyus':
getWhyusInfo();
break;
case 'index.aboutus.programinfos':
getInfoByType("getProgramInfos", 'ProgramInfosList', 'ProgramInfosCount');
break;
case 'index.aboutus.partner':
getInfoByType("getpartners", 'PartnerList', 'PartnerListCount');
break;
case 'index.aboutus.albums':
getInfoByType("getalbums", 'AlbumList', 'AlbumListCount');
break;
case 'index.aboutus.usecase':
getInfoByType("getusecases", 'UseCaseList', 'UseCaseListCount');
break;
case 'index.aboutus.awards':
getInfoByType("getawards", 'AwardsList', 'AwardsListCount');
break;
}
this.showState = function(state) {
switch (state) {
case 'aboutus':
getAboutInfo();
break;
case 'certificate':
getInfoByType("getcerts", 'CertList', 'CertListCount');
break;
case 'mission':
getMissionInfo();
break;
case 'mission':
getWhyusInfo();
break;
case 'albums':
getInfoByType("getalbums", 'AlbumList', 'AlbumListCount');
break;
case 'programinfos':
getInfoByType("getProgramInfos", 'ProgramInfosList', 'ProgramInfosCount');
break;
case 'partner':
getInfoByType("getpartners", 'PartnerList', 'PartnerListCount');
break;
case 'usecase':
getInfoByType("getusecases", 'UseCaseList', 'UseCaseListCount');
break;
case 'awards':
getInfoByType("getawards", 'AwardsList', 'AwardsListCount');
break;
}
}
// common get info funtion
function getInfoByType(_action, list, count) {
var info = {
start: 0,
limit: 99,
type: 'school',
action: _action
};
console.log(info);
InfoService.api(info, function(result) {
console.log(result);
$scope[list] = result.items;
$scope[count] = result.counter;
AddUiSrefForList($scope[list]);
});
}
function AddUiSrefForList(list) {
angular.forEach(list, function(val, idx) {
val.to = '.detail';
val.toParams = {
id: val._id
};
});
}
//getMissionInfo();
ApiService.getSchoolInfo().then(function(school) {
console.info(school);
getMissionInfo(school.missiondoc);
getInfoCounters();
locationInfo(school.locationInfoDoc);
});
function getMissionInfo(doc) {
ApiService.get("/schooldoc/" + doc).then(function(result) {
if (result.data.success) {
_self.mission = result.data.data.detail;
_self.missionCN = result.data.data.chinese;
}
})
}
ApiService.getSchoolInfo().then(function(school) {
console.info(school);
getWhyusInfo(school.whyUsDoc);
});
function getWhyusInfo(doc) {
ApiService.get("/schooldoc/" + doc).then(function(result) {
console.log(result.data);
if (result.data.success) {
_self.whyus = result.data.data.detail;
_self.whyusCN = result.data.data.chinese;
}
})
}
function getInfoCounters() {
var info = {
action: 'getinfocounters',
}
ApiService.post("/site", info).then(function(result) {
console.log(result);
if (result.data.success) {
_self.infoCounter = result.data.data;
}
});
}
function getAboutInfo() {
if (ApiService.school.aboutdoc) {
ApiService.get("/schooldoc/" + ApiService.school.aboutdoc).then(function(result) {
console.log(result);
if (result.data.success) {
_self.about = result.data.data.detail;
_self.aboutCN = result.data.data.chinese;
}
})
}
}
this.openLightboxModal = function(index) {
var arr = [];
arr.push({ url: '//edusharesg.oss-ap-southeast-1.aliyuncs.com/advinfo/1stfloor_04085.png',
thumbUrl: '//edusharesg.oss-ap-southeast-1.aliyuncs.com/advinfo/1stfloor_04085.png',
caption: 'First Floor'
});
arr.push({ url: '//edusharesg.oss-ap-southeast-1.aliyuncs.com/advinfo/3rd floor_24901.png',
thumbUrl: '//edusharesg.oss-ap-southeast-1.aliyuncs.com/advinfo/3rd floor_24901.png',
caption: 'Third Floor'
});
Lightbox.openModal(arr, index);
};
function locationInfo(doc) {
if(doc){
ApiService.get("/schooldoc/"+doc).then(function(result){
console.log(result);
if(result.data.success){
_self.locationInfo = result.data.data.content;
}
})
}
}
});