添加伙伴

dev_local
cxt 6 years ago
parent 85d8355541
commit 3f60c7eae3

@ -1224,7 +1224,7 @@ end
def add_partner def add_partner
school_ids = params[:ids] school_ids = params[:school]
if school_ids.count > 0 if school_ids.count > 0
print school_ids print school_ids
school_ids.each do |s| school_ids.each do |s|

@ -28,21 +28,20 @@
$(function() { $(function() {
unitDownOption(); unitDownOption();
showprovince("province"); showprovince("province");
submit_add_partner();
var i = 1; //设置当前页数 var i = 1; //设置当前页数
var msg_list_loading = false; var msg_list_loading = false;
$(function() { $(function() {
var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动
var winH = $(window).height(); //页面可视区域高度 var winH = $(window).height(); //页面可视区域高度
get_schools(1)
$("#search_user_list").scroll(function() { $("#search_user_list").scroll(function() {
if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载
var pageH = $(document.body).height(); var pageH = $(document.body).height();
var scrollT = $(window).scrollTop(); //滚动条top var scrollT = $(window).scrollTop(); //滚动条top
var aa = (pageH - winH - scrollT) / winH; var aa = (pageH - winH - scrollT) / winH;
console.log(aa) console.log(aa);
if ( !msg_list_loading ){ if ( !msg_list_loading ){
if (aa < 0.01 ) { if (aa < 0.01 ) {
get_schools(i+1) get_schools(i+1)
@ -51,20 +50,16 @@
} }
}); });
}); });
});
function get_schools(page) { function get_schools(page) {
var msg_list = $('#search_user_list'); 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) { if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
msg_list_loading = true; msg_list_loading = true;
$.getJSON("<%= all_path %>?page="+limit_page, function(schools) { $.getJSON("<%= all_path %>?page="+page, function(schools) {
if (schools) { if (schools) {
msg_list_loading = false; msg_list_loading = false;
let s_html = ""; var s_html = "";
$.each(schools,function (index,array) { $.each(schools,function (index,array) {
s_html = s_html+ "<p class='clearfix mt5'>" + s_html = s_html+ "<p class='clearfix mt5'>" +
" <span class='fl with70'>" + " <span class='fl with70'>" +
@ -76,19 +71,19 @@
" <span class='fl with30'>"+array["school"]["province"]+"</span>" + " <span class='fl with30'>"+array["school"]["province"]+"</span>" +
" </p>" " </p>"
}); });
$("#search_user_list").html(s_html); $("#search_user_list").append(s_html);
i ++; i ++;
} }
}); });
} }
} }
function submit_add_partner(){ function submit_add_partner(){
if($("input[name='school[id]']:checked").length==0){ if($("input[name='school[]']:checked").length==0){
$("#checkNotice").html("请选择需要添加的内容").removeClass("none"); $("#checkNotice").html("请选择需要添加的内容").removeClass("none");
return; return;
}else{ }else{
let checked_array = []; let checked_array = [];
$("input[name='school[id]']:checked").each(function () { $("input[name='school[]']:checked").each(function () {
checked_array.push($(this).val()) checked_array.push($(this).val())
}); });
let check_ids = {ids:checked_array}; let check_ids = {ids:checked_array};
@ -104,7 +99,4 @@
} }
} }
});
</script> </script>

@ -0,0 +1,11 @@
<% @schools.each do |school| %>
<p class='clearfix mt5'>
<span class='fl with70'>
<span>
<input type='checkbox' name='school[]' value='<%= school.id %>' id='school_<%= school.id %>' class='magic-checkbox'>
<label for='school_<%= school.id %>'></label>
</span>
</span>
<span class='fl with30'><%= school.province %></span>
</p>
<% end %>
Loading…
Cancel
Save