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

89 lines
3.2 KiB
JavaScript
Raw Normal View History

2016-07-25 15:20:01 +08:00
/**
* Created by guange on 16/6/27.
*/
app.controller('ProjectListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService','rms','common',
function ($scope, config, auth, $http, $location, alertService,rms,common) {
common.checkLogin();
2016-07-25 15:20:01 +08:00
var vm = $scope;
2016-07-27 14:30:19 +08:00
// vm.projects = rms.get('projects') || [];
vm.projects = [];
2016-07-25 15:20:01 +08:00
vm.alertService_1 = alertService.create();
vm.alertService_3 = alertService.create();
var loadProjectList = function () {
$http.get(config.apiUrl + "projects?token=" + auth.token()).then(
function (response) {
console.log(response.data);
vm.projects = response.data.data;
2016-07-25 15:20:01 +08:00
rms.save('projects', vm.projects);
}
);
};
if(vm.projects.length<=0){
loadProjectList();
}
vm.goProject = function (project_id) {
2016-07-27 14:30:19 +08:00
rms.save('project_activities_page',0);
rms.save("project_activities",[]);
rms.save("project_has_more",false);
rms.save("project",null);
rms.save("project_master_members",[]);
rms.save("project_develop_members",[]);
rms.save("project_report_members",[]);
rms.save("review_master_members",[]);
rms.save("review_develop_members",[]);
2016-07-27 14:30:19 +08:00
rms.save('tab_num',null);
2016-07-25 15:20:01 +08:00
console.log(project_id);
$location.path("/project").search({id: project_id});
2016-07-27 14:30:19 +08:00
};
2016-07-25 15:20:01 +08:00
vm.newProject = function () {
2016-07-27 14:30:19 +08:00
$location.path("/new_project");
};
2016-07-25 15:20:01 +08:00
vm.joinProject = function () {
2016-08-01 11:14:03 +08:00
// vm.alertService_1.showMessage('提示', "该功能将在近日开放,敬请期待!");
2016-08-02 15:50:15 +08:00
// vm.alertService_3.showMessage('提示', '请输入6位项目邀请码(不区分大小写)', function(){
// if (vm.alertService_3.invite && vm.alertService_3.invite.length == 6) {
// $http.post(config.apiUrl + "projects/join", {
// token: auth.token(),
// invite_code: vm.alertService_3.invite
// }).then(function (response) {
// console.log(response.data);
// if (response.data.status != 0) {
// vm.alertService_1.showMessage('提示', response.data.message);
// } else {
// vm.alertService_1.showMessage('提示', '加入项目成功');
// vm.alertService_3.invite = "";
// loadProjectList();
// }
// });
// } else {
// if(vm.alertService_3.invite){
// vm.alertService_1.showMessage('提示', '邀请码格式不正确');
// }
// }
// });
$location.path("/join_project").search({tag: 1});
2016-07-25 15:20:01 +08:00
};
vm.onSetting = function (project) {
console.log(project);
rms.save('current_edit_project', project);
$location.path("/edit_project").search({id: project.id});
}
}]);