HTML5滚动加载
@using YoSoft.DSM.YoDSMModel;
@using YoSoft.DSM.YoDSMBLL;
@{
Layout = "~/Views/Shared/_LayoutCompanySend.cshtml";
ViewBag.Title = "";
}
@*<link href="~/Content/person.css" rel="stylesheet" />*@
<style>
ul {
/*display: flex;*/
}
li {
position: relative;
}
#containermain {
/*margin-bottom:60px;*/
}
footer {
/*display:none;*/
}
</style>
<div class="middle-form">
<div class="weui_cell weui_cell_select weui_select_after" style="width:50%;float: left">
<div class="weui_cell_bd weui_cell_primary">
<select class="selectpicker" id="ddl_GuestName" style="width:100%">
<option value="" style="">请选择经销商</option>
@if (ViewBag.Products.Count > 0)
{
foreach (GL_GuestInfo p in ViewBag.GuestID)
{
<option value="@p.cID" style="">@p.cGuestName</option>
}
}
</select>
</div>
</div>
<div class="weui_cell weui_cell_select weui_select_after" style="width:50%;float: left">
<div class="weui_cell_bd weui_cell_primary">
<select class="selectpicker" id="ddlproduct" style="width:100%">
<option value="" style="">请选择产品</option>
@if (ViewBag.Products.Count > 0)
{
foreach (GL_GoodsInfo p in ViewBag.Products)
{
<option value="@p.cID" style="">@p.cGoodsName</option>
}
}
</select>
</div>
</div>
</div>
<div class="middle-form">
<div id="datePlugin" style="width: 50%;float: left">
<input type="text" readonly="" class="selectpicker select-input" id="txtStartDate" style="width: 100%;" name="txtStartDate" placeholder="请输入开始日期" data-lcalendar="2000-01-01,2099-12-31" />
</div> <div id="datePlugin1" style="width: 49%;float: left">
<input type="text" readonly="" class="selectpicker select-input" id="txtEndDate" style="width: 100%;" name="txtEndDate" placeholder="请输入结束日期" data-lcalendar="2000-01-01,2099-12-31" />
</div>
</div>
<div class="middle-form" style="display:none">
<button type="button" id="btn-query" class="btn btn-primary">查询</button>
</div>
<div id="containermain" class="">
<table id="tbSendList">
<thead class="thead-dark">
<tr>
<th>商品名称</th>
<th>数量</th>
</tr>
</thead>
<tbody style="height:100%;"></tbody>
</table>
<p id="mgsdone" style="display:none;padding:10px 0px;color:#AAA;font-weight:bold;text-align:center;">不要再刷啦,我是有底线的。</p>
</div>
<footer>
<div class="container-fluid navbar navbar-default navbar-fixed-bottom text-center nav-container" style="height:35px">
<div style="width: 50%;float: left;background-color:#0fcd77;font-size:18px">合计</div>
<div style="width: 50%;float: left;font-size:18px"><a id="RecordCount" style="font-size:18px">数量:0</a></div>
</div>
</footer>
<script src="~/Scripts/Person/companysend.js"></script>
<script>
</script>
var CurrentPageIndex = 1;
var PageCount = 0;
var RecordCount = 0;
var PageSize = 10;
var startY = 0;
var endY = 0;
var queryDone = true;
var bShow = false;
$(function () {
$("#mgsdone").hide();
var calendar0 = new LCalendar();
calendar0.init({
'trigger': '#txtStartDate',//标签id
'type': 'date',//date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择
'minDate': '2000-01-01',//最小日期 注意:该值会覆盖标签内定义的日期范围
'maxDate': '2099-12-31'//最大日期 注意:该值会覆盖标签内定义的日期范围
});
var calendar1 = new LCalendar();
calendar1.init({
'trigger': '#txtEndDate',//标签id
'type': 'date',//date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择
'minDate': '2000-01-01',//最小日期 注意:该值会覆盖标签内定义的日期范围
'maxDate': '2099-12-31'//最大日期 注意:该值会覆盖标签内定义的日期范围
});
$("#btn-store").click(function () {
$("#modalstore").modal("show");
});
$("#btn-product").click(function () {
$("#modalproduct").modal("show");
});
$("#btn-date").click(function () {
$("#modaldate").modal("show");
});
$("select").change(function () {
var selectVal = $(this).val();
var id = $(this).attr("id");
console.log(selectVal);
$("#" + id + " option[selected='selected']").each(function () {
//console.log(this);
if ($(this).attr("value") != selectVal) {
$(this).removeAttr("selected");
}
});
$(this).find("option[value='" + $(this).val() + "']").attr("selected", true);
CurrentPageIndex = 1;
PageCount = 0;
RecordCount = 0;
$("#mgsdone").hide();
bShow = false;
});
$("#txtStartDate").change(function () {
CurrentPageIndex = 1;
PageCount = 0;
RecordCount = 0;
alert(433443);
$("#mgsdone").hide();
bShow = false;
});
$("#txtEndDate").change(function () {
CurrentPageIndex = 1;
PageCount = 0;
RecordCount = 0;
alert(433443);
$("#mgsdone").hide();
bShow = false;
});
$("#btn-query").click(function () {
console.log('查询', CurrentPageIndex, RecordCount, PageCount);
CurrentPageIndex = 1;
PageCount = 0;
RecordCount = 0;
queryData();
$("#mgsdone").hide();
bShow = false;
});
//$(window).scroll(function () {
// var scrollTop = $(this).scrollTop(),
// scrollHeight = $(document).height(),
// windowHeight = $(this).height();
// var positionValue = (scrollTop + windowHeight) - scrollHeight;
// console.log(scrollTop, scrollHeight, windowHeight, positionValue)
// if (positionValue == 0) {
// console.log("加载");
// //do something
// }
//});
$("#containermain").on("touchstart", function (e) {
//if (e.cancelable) {
// if (!e.defaultPrevented) {
// e.preventDefault();
// }
//} 这几行不要,否则会影响滑动时的滚动惯性
startY = e.touches[0].clientY;
});
$("#containermain").on("touchend", function (e) {
//if (e.cancelable) {
// if (!e.defaultPrevented) {
// e.preventDefault();
// }
//}这几行不要,否则会影响滑动时的滚动惯性
endY = e.originalEvent.changedTouches[0].clientY,
Y = endY - startY;
//下滑
if (Y > 0) {
//$(document).scrollTop($(document).scrollTop() - Y);
console.log('下滑');
//if ($(document).scrollTop() > 0 && $(document).scrollTop() >= $(document).height() - $(window).height()) {
// console.log("滚动条已经到达底部为" + $(document).scrollTop(), ($(document).height() - $(window).height()), $(document).height(), $(window).height(),startY, endY,CurrentPageIndex);
//}
}
//上滑
else if (Y < 0) {
$(document).scrollTop($(document).scrollTop() - Y + 1);
//alert($(document).scrollTop() - Y);
//alert($(document).scrollTop());
//alert($(document).height() - $(window).height());
//console.log('上滑', $(document).scrollTop(), ($(document).height() - $(window).height()), CurrentPageIndex, RecordCount, PageCount, Y);
console.log('上滑', CurrentPageIndex, PageCount, queryDone);
if ($(document).scrollTop() > 0 && $(document).scrollTop() >= $(document).height() - $(window).height() && CurrentPageIndex <= PageCount) {
scrollLoad();
$(document).scrollTop($(document).height());
}
else if (CurrentPageIndex > PageCount & !bShow) {
bShow = true;
$("#mgsdone").show();
$(document).scrollTop($(document).height());
}
}
//单击
else {
console.log('单击', CurrentPageIndex);
//queryData();
}
});
queryData();
});
$('#ddl_GuestName,#ddlproduct').on('change', function () {
queryData();
});
function queryData() {
if (!queryDone || (CurrentPageIndex > PageCount && CurrentPageIndex > 1)) {
return;
}
queryDone = false;
var store = $("#ddlstore").val();
var product = $("#ddlproduct").val();
var guestid = $("#ddl_GuestName").val();
var startDate = $("#txtStartDate").val();
var endDate = $("#txtEndDate").val();
$("#tbSendList tbody").empty();
//console.log(CurrentPageIndex , PageCount)
$.ajax({
url: "/Person/SendList",
type: "post",
data: { store: store, product: product, startDate: startDate, endDate: endDate, PageSize: PageSize, CurrentPageIndex: CurrentPageIndex, guestid: guestid },
dataType: "json",
async: false,
success: function (data) {
//console.log(data);
//console.log($("#tbSendList tbody"));
RecordCount = data.RecordCount;
PageCount = parseInt(RecordCount / PageSize) + 1;
var iNum = 0;
var html = "";
if (data.success) {
var list = JSON.parse(data.sendlist);
console.log(list)
for (var i in list) {
html += "<tr><td>" + list[i].cGoodsName + "</td><td>" + list[i].iNum + "</td></tr>"
iNum += parseInt(list[i].iNum);
}
$('#RecordCount').text("数量:" + iNum);
$("#tbSendList tbody").html(html);
if (list.length > 0) {
CurrentPageIndex++;
}
}
else {
$("#tbSendList tbody").html('<tr><td colspan="2">没有数据</td></tr>');
}
queryDone = true;
},
error: function (err) {
console.log(err);
queryDone = true;
}
});
}
function scrollLoad() {
if (!queryDone || CurrentPageIndex > PageCount) {
return;
}
//console.log(CurrentPageIndex, PageCount)
queryDone = false;
var store = $("#ddlstore").val();
var product = $("#ddlproduct").val();
var startDate = $("#txtStarTime").val();
var endDate = $("#txtEndTime").val();
$.ajax({
url: "/Person/SendList",
type: "post",
data: { store: store, product: product, startDate: startDate, endDate: endDate, PageSize: PageSize, CurrentPageIndex: CurrentPageIndex },
dataType: "json",
async: false,
success: function (data) {
//console.log(data);
//console.log($("#tbSendList tbody"));
RecordCount = data.RecordCount;
PageCount = parseInt(RecordCount / PageSize) + 1;
var html = $("#tbSendList tbody").html();
if (data.success) {
var list = JSON.parse(data.sendlist);
console.log(list)
for (var i in list) {
html += "<tr><td>" + list[i].cGoodsName + "</td><td>" + list[i].iNum + "</td></tr>"
}
$("#tbSendList tbody").html(html);
if (list.length > 0) {
CurrentPageIndex++;
//$(document).scrollTop($(document).scrollTop() + 80);
}
}
else {
$("#tbSendList tbody").html('<tr><td colspan="2">没有数据</td></tr>');
}
queryDone = true;
},
error: function (err) {
console.log(err);
queryDone = true;
}
});
}
HTML5滚动加载的更多相关文章
- HTML5商城开发一 楼层滚动加载数据
对于楼层加载在以前只是个想法,从来没实现过,刚好项目中碰到,再此总结一下 场景:HTML5,局部商品列表信息滚动(局部滚动条) 1.通过jq设置subCategoryScroll的高度为屏幕显示高度( ...
- js 滚动加载iframe框中内容
var isIE6 = !!window.ActiveXObject&&!window.XMLHttpRequest; //滚动加载 var scrollLoad =function( ...
- [转] Jquery滚动加载
原文地址:http://hi.baidu.com/vipxiaofan/item/9eb927b795671f77254b0985 另外一个asp.net的例子:http://blog.csdn.ne ...
- js滚动加载小插件
本文实例讲述了jquery滚动加载数据的方法.分享给大家供大家参考.具体分析如下: 少废话直接上代码!!!粗暴,直接,干脆 0//lk-2017-05-04 1(function($, win) { ...
- 基于 Vue.js 的移动端组件库mint-ui实现无限滚动加载更多
通过多次爬坑,发现了这些监听滚动来加载更多的组件的共同点, 因为这些加载更多的方法是绑定在需要加载更多的内容的元素上的, 所以是进入页面则直接触发一次,当监听到滚动事件之后,继续加载更多, 所以对于无 ...
- 记录WEUI中滚动加载的一个BUG
最近写微信公众号,用到的技术栈是jq+vue的混合开发,采用的UI是移动端比较火的WEUI,在微信开发中应该较广泛.个人看惯了elementUI文档,相对于饿了么组件文档的详细,WEUI的文档还是比较 ...
- HTML5 预加载
原文地址: HTML5 Link Prefetching 原文日期: 2010年07月07日 翻译日期: 2013年08月13日 浏览器厂商和开发者之间共同努力的一个方向就是让网站更快.现在已有很多广 ...
- 兼容IE8,滚动加载下一页
// 滚动加载下一页 var nowScrolledHeight = document.documentElement.scrollTop || document.body.scrol ...
- vue2.0无限滚动加载数据插件
做vue项目用到下拉滚动加载数据功能,由于选的UI库(element)没有这个组件,就用Vue-infinite-loading 这个插件代替,使用中遇到的一些问题及使用方法,总结作记录! 安装: ...
随机推荐
- 转:三款免费好用的Gif录屏神器
原文链接:三款免费好用的Gif录屏神器 自己用了 ScreenToGif 版本2.14.1下载地址 原文内容: 三款免费好用的Gif录屏神器 2018年06月02日 18:52:21 独家雨 ...
- mybatis中传入String类型参数的问题
1. 出现的问题 需求是想写一个按公司名字查询公司列表的功能,最开始的代码如下 Dao层接口如下 @MyBatisDao public interface OfficeDao extends Tree ...
- NABCD分析---校园服务
N(需求): 大学生活中,很多琐碎的小事浪费同学时间精力.我们的APP本着为同学服务的宗旨,解决生活中各方面的问题,同学们可以在APP上发布各种信息,例如兼职,二手买卖等等. A(做法): 用户打开A ...
- Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
很长的报错,截取 ERROR c.a.d.p.DruidDataSource - discard connection com.mysql.jdbc.exceptions.jdbc4.Comm ...
- OOA/OOD/OOP
转载自https://www.cnblogs.com/zzyoucan/p/3576932.html Object-Oriented Analysis:面向对象分析方法 是在一个系统的开发过程中进行了 ...
- The Non-Inverting Amplifier Output Resistance by Adrian S. Nastase [转载]
Source Address: http://masteringelectronicsdesign.com/the-non-inverting-amplifier-output-resistance/ ...
- 字节转化为结构体BytesToStruct
//结构体转字节数组 public byte[] StructToBytes (object structObj) { int size = Marshal.SizeOf (structObj);// ...
- 解决CentOS(6和7版本),/etc/sysconfig/下没有iptables的问题
一.Centos 6版本解决办法: 1.任意运行一条iptables防火墙规则配置命令: iptables -P OUTPUT ACCEPT 2.对iptables服务进行保存: service ip ...
- Centos7 update dotnet 无法识别
使用了yum update 后 原来好好的dotnet 用不了了 /usr/bin/dotnet 找不到 卸载重装都没法了.... 解决方法: 把dotnet 拷贝到 /usr/bin 下面去就好了 ...
- 04-python3.5-模拟三级菜单-省-县-区域--01
#!/usr/bin/env python # -*- coding:utf-8 -*- #Author:XZ data = { '北京':{ "昌平":{ "沙河&qu ...