unserver-unify
Version:
138 lines (132 loc) • 4.55 kB
JavaScript
;
angular.module('bamboo').controller('CompanyAboutUsController', function(ApiService, InfoService, $scope, $state, loginService,$stateParams,$rootScope) {
var _self = this;
//var school = ApiService.school;
this.defaultNewsPhoto = 'assets/images/news_no-image1.jpg';
this.defaultAwardsPhoto = 'assets/images/awards.jpg';
this.defaultCertPhoto = 'assets/images/certificate.jpg';
this.defaultUsecasePhoto = 'assets/images/usecase.jpg';
this.imgBaseUrl = ApiService.SHOST + '/advinfo/';
this.SchoolPhotoUrl = ApiService.PSURL + '/school/' + ApiService.gid + '/' + loginService.school.photo;
console.log($stateParams);
this.id = $stateParams.cid;
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.company.detail.certificate':
getInfoByType("getcerts", 'CertList', 'CertListCount');
break;
case 'index.company.detail.partner':
getInfoByType("getpartners", 'PartnerList', 'PartnerListCount');
break;
case 'index.company.detail.usecase':
getInfoByType("getusecases", 'UseCaseList', 'UseCaseListCount');
break;
case 'index.company.detail.awards':
getInfoByType("getawards", 'AwardsList', 'AwardsListCount');
break;
}
this.showState = function(state) {
console.log(state);
switch (state) {
case 'certificate':
getInfoByType("getcerts", 'CertList', 'CertListCount');
break;
case 'partner':
getInfoByType("getpartners", 'PartnerList', 'PartnerListCount');
break;
case 'usecase':
getInfoByType("getusecases", 'UseCaseList', 'UseCaseListCount');
break;
case 'awards':
getInfoByType("getawards", 'AwardsList', 'AwardsListCount');
break;
default:
console.log(state);
}
}
// common get info funtion
function getInfoByType(_action, list, count) {
var info = {
start: 0,
limit: 99,
type: 'company',
comId:_self.id,
action: _action
};
console.log(info);
InfoService.api(info, function(result) {
console.log(result);
$scope[list] = result.items;
$scope[count] = result.counter;
AddUiSrefForList($scope[list]);
console.info($scope[list] );
});
}
function AddUiSrefForList(list) {
angular.forEach(list, function(val) {
val.to = '.detail';
val.toParams = {
id: val._id
};
});
}
//getMissionInfo();
/*function getMissionInfo() {
if (ApiService.school.missiondoc) {
ApiService.get("/schooldoc/" + ApiService.school.missiondoc).then(function(result) {
console.log(result);
if (result.data.success) {
_self.mission = result.data.data.detail;
_self.missionCN = result.data.data.chinese;
}
})
}
} */
/*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;
}
})
}
}*/
/*function getSchoolInfo() {
var info = {
action: "getcompany",
id: _self.id,
}
ApiService.post("/business", info).then(function(result) {
// console.log( '-Starting auth session result: ');
console.log(result);
if (result.data.success) {
_self.contentModel = result.data.data || {};
//$rootScope.restaurantName = self.contentModel.name;
//self.imageUrl = self.contentModel.photo ? self.photoPath + self.contentModel._id + '/' + self.contentModel.photo : null;
$scope.school = _self.contentModel;
_self.SchoolIconUrl = ApiService.SHOST + '/company/' + $scope.school._id +'/' +$scope.school.photo;
}
});
}*/
function showCompany() {
var info = {
action: "getcompany",
id: $stateParams.cid
};
console.log();
ApiService.post("/business", info).then(function(result) {
if (result.data.success) {
console.log(result.data);
_self.item = result.data.data || {};
$rootScope.CompanyName = _self.item.name;
}
});
}
showCompany();
});