diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f8f2b3f..6b21eb1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -13,7 +13,7 @@ class ProjectsController < ApplicationController uc = Projects_user.where(:project_id => pid).size sc = Share.where(:project_id => pid).size data = [] - Project.find(pid) do |i| + Project.find(pid) do |i| data += [{ :id => i.id, :name => i.name, diff --git a/db/seeds.rb b/db/seeds.rb index 2545edf..0625414 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,7 +10,7 @@ users = [ {:name => '陈翊', :password => '123456', :email => '1085730215@qq.com', :phone => '18269771988', :created_at => "2016/12/28", :updated_at => "2016/12/27"} ] projects = [ - {:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'} + {:id=>'1001',:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'} ] users.each do |user| diff --git a/public/index.html b/public/index.html index 7ca1a24..2f3aeaa 100644 --- a/public/index.html +++ b/public/index.html @@ -30,15 +30,19 @@ - + \ No newline at end of file diff --git a/public/pages/project_select.html b/public/pages/project_select.html index 96a859b..56c410a 100644 --- a/public/pages/project_select.html +++ b/public/pages/project_select.html @@ -183,50 +183,50 @@ dataType:"json", url:"/projects.json", statusCode: { - 200: function() {// 请求成功 - var bg_color = ["bg-yellow","bg-blue","bg-purple","bg-red"]; - var jstr = htmlobj.responseText; - var robj = eval('('+jstr+')'); - console.log(jstr); - if(robj["code"]==0){ - var data = robj["data"]; - for(var i=data.length-1;i>=0;--i){ - var template = $("#cy_template"); - var tp = template.clone("true"); - var id = data[i]["id"]; - tp.find("#cy_template_name").html(data[i]["name"]); - tp.find("#cy_template_content").html(data[i]["content"]); - tp.find("#cy_template_mission_count").html(data[i]["mission_count"]); - tp.find("#cy_template_users_count").html(data[i]["users_count"]); - tp.find("#cy_template_shares_count").html(data[i]["shares_count"]); - tp.find("#cy_template_enterbtn").attr("onclick","cy_enter("+id+");"); + 200: function() {// 请求成功 + var bg_color = ["bg-yellow","bg-blue","bg-purple","bg-red"]; + var jstr = htmlobj.responseText; + var robj = eval('('+jstr+')'); + console.log(jstr); + if(robj["code"]==0){ + var data = robj["data"]; + for(var i=data.length-1;i>=0;--i){ + var template = $("#cy_template"); + var tp = template.clone("true"); + var id = data[i]["id"]; + tp.find("#cy_template_name").html(data[i]["name"]); + tp.find("#cy_template_content").html(data[i]["content"]); + tp.find("#cy_template_mission_count").html(data[i]["mission_count"]); + tp.find("#cy_template_users_count").html(data[i]["users_count"]); + tp.find("#cy_template_shares_count").html(data[i]["shares_count"]); + tp.find("#cy_template_enterbtn").attr("onclick","cy_enter("+id+");"); - tp.find("#cy_template_name").attr("id","cy_name_"+id); - tp.find("#cy_template_content").attr("id","cy_content_"+id); - tp.find("#cy_template_mission_count").attr("id","cy_mission_count_"+id); - tp.find("#cy_template_users_count").attr("id","cy_users_count_"+id); - tp.find("#cy_template_shares_count").attr("id","cy_shares_count_"+id); - tp.find("#cy_template_enterbtn").attr("id","cy_enter_"+id); + tp.find("#cy_template_name").attr("id","cy_name_"+id); + tp.find("#cy_template_content").attr("id","cy_content_"+id); + tp.find("#cy_template_mission_count").attr("id","cy_mission_count_"+id); + tp.find("#cy_template_users_count").attr("id","cy_users_count_"+id); + tp.find("#cy_template_shares_count").attr("id","cy_shares_count_"+id); + tp.find("#cy_template_enterbtn").attr("id","cy_enter_"+id); - tp.find("#cy_template_bg").attr("class","widget-user-header "+bg_color[Math.floor(Math.random()*4)]); - tp.find("#cy_template_bg").attr("id","cy_bg_"+id); + tp.find("#cy_template_bg").attr("class","widget-user-header "+bg_color[Math.floor(Math.random()*4)]); + tp.find("#cy_template_bg").attr("id","cy_bg_"+id); - tp.attr("id","cy_project_"+id); - - tp.css("display","block"); + tp.attr("id","cy_project_"+id); + + tp.css("display","block"); - $("#cy_container").prepend(tp); - } - } - else{ - //todo - } - }, - 401:function(){// 未授权 - alert("用户名或密码错误!"); - } + $("#cy_container").prepend(tp); } + } + else{ + //todo + } + }, + 401:function(){// 未授权 + alert("用户名或密码错误!"); + } + } }); }); $("#creat_project").click(function(){ @@ -249,12 +249,12 @@ } } }); - function cy_enter(id){ - LoginUserInfo.selectProject=id; - console.log(id); - //window.location.href="../index.html"; - } }); + + function cy_enter(id){ + console.log(id); + window.location.href="../index.html?projectid="+id; + } diff --git a/public/pages/task.html b/public/pages/task.html index cd23e33..d277db1 100644 --- a/public/pages/task.html +++ b/public/pages/task.html @@ -528,7 +528,9 @@ - + \ No newline at end of file