socialforge/public/javascripts/wechat/controllers/review_class_member.js

90 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-08-02 15:50:15 +08:00
app.controller('ReviewClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
common.checkLogin();
2016-08-02 15:50:15 +08:00
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.current_review_member = rms.get('current_review_member');
vm.current_course = rms.get('current_course');
vm.alertService = alertService.create();
vm.tip_1 = "";
vm.tip_2 = "";
2016-08-02 15:50:15 +08:00
var course_id = $routeParams.id;
var user_id = $routeParams.user_id;
vm.status = 0;
2016-08-02 15:50:15 +08:00
if(!vm.current_course){
$http.get(config.apiUrl+ 'courses/'+course_id+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
if (response.data.status == 0){
vm.current_course = response.data.data;
console.log("courses");
console.log(response.data.data);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
if(!vm.current_course){
vm.tip_1 = "该班级不存在或已被删除";
}
2016-08-02 15:50:15 +08:00
}
);
}
if(!vm.current_review_member){
$http.post(config.apiUrl+'courses/review_member_info', {
token: auth.token(),
course_id: course_id,
user_id:user_id
}).then(function(response){
if(response.data.status==-1){
2016-08-02 15:50:15 +08:00
vm.alertService.showMessage('提示', response.data.message);
} else {
vm.current_review_member = response.data.data;
vm.status = response.data.status;
2016-08-02 15:50:15 +08:00
console.log("review_member_info");
console.log(response.data.data);
}
if(!vm.current_review_member){
vm.tip_2 = "该申请不存在";
}
2016-08-02 15:50:15 +08:00
});
}
vm.deal = function(result){
$http.post(config.apiUrl+'courses/deal_join_apply', {
token: auth.token(),
course_id: course_id,
user_id:user_id,
type:result
}).then(function(response) {
if (response.data.status == 0) {
vm.alertService.showMessage('提示', response.data.message, function () {
$location.path("/class").search({id: course_id,tag: 1});
2016-08-02 15:50:15 +08:00
});
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
});
};
vm.goClassMemberList = function(){
2016-08-10 16:08:30 +08:00
if(vm.current_course.is_member){
$location.path("/class").search({id: course_id,tag: 1});
}
else{
$location.path("/class_list");
}
};
2016-08-02 15:50:15 +08:00
}] );