From 3f60c7eae3967f6b0bb089a3cc74fe8de348c055 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 4 Apr 2019 11:49:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=99=E4=BC=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- .../managements/_partner_addUnit.html.erb | 104 ++++++++---------- app/views/managements/_partners_list.html.erb | 11 ++ 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 341ac98c..264012bb 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1224,7 +1224,7 @@ end def add_partner - school_ids = params[:ids] + school_ids = params[:school] if school_ids.count > 0 print school_ids school_ids.each do |s| diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 6ad69b66..8a877398 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -28,21 +28,20 @@ $(function() { unitDownOption(); showprovince("province"); - submit_add_partner(); var i = 1; //设置当前页数 var msg_list_loading = false; $(function() { var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 var winH = $(window).height(); //页面可视区域高度 - get_schools(1) + $("#search_user_list").scroll(function() { if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 var pageH = $(document.body).height(); var scrollT = $(window).scrollTop(); //滚动条top var aa = (pageH - winH - scrollT) / winH; - console.log(aa) + console.log(aa); if ( !msg_list_loading ){ if (aa < 0.01 ) { get_schools(i+1) @@ -51,60 +50,53 @@ } }); }); - function get_schools(page) { - var msg_list = $('#search_user_list'); - var limit_page = 1 - if (page > 1){ - limit_page = page - }else{ - limit_page = 1 - } - if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { - msg_list_loading = true; - $.getJSON("<%= all_path %>?page="+limit_page, function(schools) { - if (schools) { - msg_list_loading = false; - let s_html = ""; - $.each(schools,function (index,array) { - s_html =s_html+ "
" + - " " + - " " + - " " + - " " + - " \n" + - " \n" + - " "+array["school"]["province"]+"" + - "
" - }); - $("#search_user_list").html(s_html); - i ++; - } - }); - } - } - function submit_add_partner(){ - if($("input[name='school[id]']:checked").length==0){ - $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); - return; - }else{ - let checked_array = []; - $("input[name='school[id]']:checked").each(function () { - checked_array.push($(this).val()) - }); - let check_ids = {ids:checked_array}; - $.ajax({ - url: "/managements/add_partner", - type: 'POST', - data: check_ids, - success: function (e) { - if(e.status === 1){} - $("#popupAll").remove() - } - }) - } - } - }); + function get_schools(page) { + var msg_list = $('#search_user_list'); + if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { + msg_list_loading = true; + $.getJSON("<%= all_path %>?page="+page, function(schools) { + if (schools) { + msg_list_loading = false; + var s_html = ""; + $.each(schools,function (index,array) { + s_html = s_html+ "" + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " "+array["school"]["province"]+"" + + "
" + }); + $("#search_user_list").append(s_html); + i ++; + } + }); + } + } + function submit_add_partner(){ + if($("input[name='school[]']:checked").length==0){ + $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); + return; + }else{ + let checked_array = []; + $("input[name='school[]']:checked").each(function () { + checked_array.push($(this).val()) + }); + let check_ids = {ids:checked_array}; + $.ajax({ + url: "/managements/add_partner", + type: 'POST', + data: check_ids, + success: function (e) { + if(e.status === 1){} + $("#popupAll").remove() + } + }) + } + } \ No newline at end of file diff --git a/app/views/managements/_partners_list.html.erb b/app/views/managements/_partners_list.html.erb index e69de29b..10069306 100644 --- a/app/views/managements/_partners_list.html.erb +++ b/app/views/managements/_partners_list.html.erb @@ -0,0 +1,11 @@ +<% @schools.each do |school| %> ++ + + + + + + <%= school.province %> +
+<% end %> \ No newline at end of file