var test = true; window.onload = function (ev) { init(); } init = function () { getProductInfo("", 1, 10); } getProductInfo = function (judge, pageindex, pagesize) { var parameter = urlEncode(["SelectAllProduct", judge, pageindex, pagesize]); $.ajax({ type: "post", url: "/taiwan/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (data.length == 0 || data == -1) { var th = '暂无数据'; $("#warp").html(th); $("#Page").html(""); // $("#warp").append(th); return; } if (test) { test = false; var totalSize = data[0].allcount, totalPage = Math.ceil(totalSize / pagesize); $("#Page").html(""); // $("#Page").whjPaging("setPage", {currPage: pageindex, totalPage: totalPage, totalSize: totalSize}); $("#Page").whjPaging({ currPage: pageindex, totalSize: totalSize,//可选,总条数 totalPage: totalPage,//可选,总页数 isShowRefresh: false,//可选,是否展示刷新,默认true isShowPageSizeOpt: false,//可选,是否展示每页条数下拉框,默认true,如果设置显示,总条数必须设置 // isResetPage:true, callBack: function (currPage) { $("#loading").css({display: "block"}); $("#warp").css({display: "none"}); getProductInfo(judge, currPage, pagesize); // test = true; // console.log('currPage:' + currPage + ' pageSize:' + pageSize); } }); } printProductInfo(data); console.log(data); } }); } printProductInfo = function (data) { var warp = $("#warp"), tr, href, title = "'查看商品信息'"; warp.html(""); for (var i = 0; i < data.length; i++) { href = "'product-add.html?pid=" + data[i].ProductId + "'"; tr = $('' + '' + data[i].ProductId + '' + '' + data[i].ProductRemarks + '' + '' + data[i].ProductName + '' + '' + data[i].ProductPrimeCost + '' + '' + data[i].ProductPrice + '' + // '' + data[i].ProductIntroduce + '' + '' + data[i].ProductIntroduce + '' + '' + data[i].ProductAddTime + '' + '' + '查看H5页面' + '查看产品信息' + ''); warp.append(tr); } $("#loading").css({"display": "none"}); $("#warp").css({"display": "table-row-group"}); } keySearchProductInfo = function () { if (event.keyCode == 13) { searchProductInfo(); } } searchProductInfo = function () { var _val = $("#SearchPlaceBtn").val().trim(); if (_val == "") { layer.msg('请输入订单号、人名、地址、手机号其中一个', {icon: 1}); } else { getProductInfo(_val, 1, 10); } } product_add = function (title, url) { var index = layer.open({ type: 2, title: title, content: url }); layer.full(index); } urlEncode = function (arr) { var i; //循环初始化 for (i = 0; i < arr.length; i++) { arr[i] = encodeURIComponent(encodeURIComponent(arr[i])); } return arr.join(); } toogle = function (cs) { var child = $(cs); for (var i = 0; i < child.length; i++) { if (child[i].style.display == "none") { child[i].style.display = "block"; } else { child[i].style.display = "none"; } } }