unserver-unify
Version:
139 lines (136 loc) • 3.94 kB
JavaScript
;
angular.module('bamboo.setting').controller('UserProfileCtrl', function($scope,$uibModal, loginService, ApiService, CommonService, $stateParams,UserService) {
var self = this;
$scope._SHOST = ApiService.SHOST;
this.nid = $stateParams.id || '';
this.cs=$stateParams.cs;
var _cs=ApiService.getCheckSum($stateParams.id);
if(this.cs!=_cs){
return CommonService.showError('Invalid Access!');
}
var _userloginname = $stateParams.id;
var teacherinfoId;
this.publicUrl = ApiService.SHOST + "/public/images/";
this.defaultPersonPhotoUrl = this.publicUrl + "user_icon&48.png";
this.avatarpath = ApiService.PSURL + "/avatar/";
$scope._RES = ApiService.RES;
this.user = {};
//this.showNurseProfile = isNurseProfile(loginService.school);
console.log(loginService.user);
ApiService.get('/sprofile/' + self.nid, !loginService.loggedDomain).then(function(result) {
//console.log(result);
if (result.data.success) {
self.user = result.data.data;
console.log(self.user);
getfollowing();
}
});
this.sendmessage = function() {
CommonService.sendmsgdlg({
"userid": self.user.id,
"name": self.user.fullname,
});
}
this.following = function() {
var info={
action:'addfollowing',
uid:self.user.id,
}
console.log(info);
CommonService.POST('/user',info,function(result){
console.log(result);
getfollowing();
})
}
this.unFollow = function() {
var info={
action:'delfollowing',
uid:self.user.id,
}
CommonService.POST('/user',info,function(result){
console.log(result);
getfollowing();
});
}
function getfollowing () {
var info={
action:'getflowings',
// uid:self.user.id,
}
console.log(info);
CommonService.POST('/user',info,function(result){
console.log(result);
if(result&&result.indexOf(self.user.id)>-1){
console.log("existed");
self.followed=true;
} else {
self.followed=false;
}
})
}
this.sendsms = function() {
console.log();
return $uibModal.open({
templateUrl: "components/dialog/sendmessage-dlg.html",
controller: "SendSMSDlgCtrl",
controllerAs: 'ctrl',
resolve: {
sendTo: function() {
return self.user.mobile;
}
}
}).result;
}
this.review = function() {
$uibModal.open({
templateUrl: "components/dialog/rating-dlg.html",
controller: "RatingDlgCtrl",
controllerAs: 'ctrl',
resolve: {
title: function() {
return _userloginname;
},
types: function() {
return ["Knowledge", "Attraction", "Content"];
}
}
}).result.then(function(result) {
console.log(result);
var info = {
action: "addteacherassessment",
value: result.averageRating,
object: result,
id: teacherinfoId,
}
ApiService.post('/rating', info).then(function(result) {
if (result.data.success) {
self.showassessment = false;
}
});
});
}
this.init = function(){
UserService.getTeacherInfoByLoginname(_userloginname, function(data) {
self.teacherinfo = data;
teacherinfoId = self.teacherinfo._id;
if (loginService.school.teacherRatingFlag&&loginService.isLogged) {
checkassessmentexit();
}
});
}
self.init();
function checkassessmentexit() {
var info = {
action: "checkteacherassessmentexist",
id: teacherinfoId,
};
ApiService.post('/rating', info).then(function(result) {
console.log(result);
if (result.data.success) {
if (!result.data.data||result.data.data < 1) {
self.showassessment = true;
}
}
});
}
});