mui.init({
    pullRefresh: {
        container: '#pullrefresh',
        down: {},
        up: {contentrefresh: '正在加载...', callback: pullupRefresh}
    }
});
var pageNumber = 0, pagesize = 10, endNo = 0;
function pullupRefresh() {
    pageNumber += 1;
    var btnArray = ['否', '是'];
    mui.ajax(base_path + '/rebackStatic/underDrpListInfo?dates=' + new Date().getTime(), {
        data: {
            "pageSize": pagesize,
            "pageNumber": pageNumber,
            "endNo": endNo
        }, dataType: 'json', type: 'post', timeout: 15000, success: function (dt) {
            if (dt.status) {
                var itemSum = dt.data.itemNum;
                var chanpin_data = [];
                if (dt.data.list != null) {
                    chanpin_data = dt.data.list
                }
                document.querySelector("#b_accounts").innerHTML = dt.data.size;
                endNo = dt.data.endNo;
                mui('#pullrefresh').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize);
                var table = document.body.querySelector('.my-tab-view-pull');
                var isZuan = dt.data.isZuan;
                if (isZuan == 1) {
                    $('#itemLi').show();
                    mui(chanpin_data).each(function (index) {
                        var li = document.createElement('li');
                        li.className = 'mui-table-view-cell';
                        if (this.img == null) {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="//s.iamberry.com/images/shop/logo_head.png"></td><td></td><td style="color:blue;">' + this.num + '台</td></tr></table>'
                        } else if (typeof(this.num) == "undefined") {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td>' + decodeURI(this.name) + '</td><td style="color:blue;">0台</td></tr></table>'
                        } else {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td>' + decodeURI(this.name) + '</td><td style="color:blue;">' + this.num + '台</td></tr></table>'
                        }
                        table.appendChild(li)
                    });
                    if (itemSum == null) {
                        itemSum = 0
                    }
                    $('#itemSum').html(itemSum)
                } else {
                    $('#itemLi').hide();
                    mui(chanpin_data).each(function (index) {
                        var li = document.createElement('li');
                        li.className = 'mui-table-view-cell';
                        if (this.img == null) {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="//s.iamberry.com/images/shop/logo_head.png"></td><td>' + this.strDate + '</td><td style="color:blue;">' + this.num + '</td></tr></table>'
                        } else if (typeof(this.num) == "undefined") {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td>' + this.strDate + '</td><td style="color:blue;">0台</td></tr></table>'
                        } else {
                            li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td>' + this.strDate + '</td><td style="color:blue;">' + this.num + '台</td></tr></table>'
                        }
                        table.appendChild(li)
                    })
                }
            } else {
                mui.confirm(dt.message, '提示', btnArray, function (e) {
                    if (e.index == 1) {
                    }
                })
            }
        }, error: function (xhr, type, errorThrown) {
            console.log(xhr)
        }
    })
};mui.ready(function () {
    mui('#pullrefresh').pullRefresh().pullupLoading();
    getCartNum();
    document.querySelector('.loading-bg').style.display = 'none'
});