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

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-08-02 15:50:15 +08:00
app.controller('JoinProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx,common){
common.checkLogin();
2016-08-02 15:50:15 +08:00
var vm = $scope;
// vm.current_edit_member = rms.get('current_edit_member');
vm.role_id = 0;
vm.alertService = alertService.create();
vm.invite_code = "";
var tag = $routeParams.tag;
2016-08-02 15:50:15 +08:00
vm.cancel = function(){
if(tag){
window.history.back();
}
else{
wx.closeWindow();
}
2016-08-02 15:50:15 +08:00
};
vm.join_project = function(){
if(vm.role_id == 0){
vm.alertService.showMessage('提示', "请至少选择一个角色");
return;
}
if(vm.invite_code.length == 0)
{
vm.alertService.showMessage('提示', '请输入6位邀请码');
return;
}
if(vm.invite_code.length != 6)
{
vm.alertService.showMessage('提示', '邀请码格式不正确');
return;
}
$http.post(config.apiUrl+'projects/join_project', {
token: auth.token(),
invite_code: vm.invite_code,
role_id:vm.role_id
}).then(function(response){
if(response.data.status == 0){
vm.alertService.showMessage('提示', response.data.message,function(){
$location.path("/project_list");
});
2016-08-02 15:50:15 +08:00
} else {
vm.alertService.showMessage('提示', response.data.message);
}
});
};
vm.selectRole = function(role_id){
vm.role_id = role_id;
}
}] );