const _Http = getApp().globalData.http;
Component({
    data: {
        content: {
            nocache: true,
            "pageNumber": 1,
            "pageTotal": 1,
            "pageSize": 20
        },
        list: []
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        getList(init = false) {
            let content = this.data.content;
            if (init) content.pageNumber = 1;
            const page = getCurrentPages().find(v => v.__route__ == 'packageA/report/index');
            if (content.pageNumber > content.pageTotal) return page.setData({
                total: this.data.total
            });
            content.where = page.data.where;
            _Http.basic({
                "id": "20230524102802",
                content
            }).then(res => {
                console.log("我发出的", res)
                if (res.code != '1') return wx.showToast({
                    title: res.msg,
                    icon: 'none',
                    mask: true
                })
                content.pageTotal = res.pageTotal;
                content.pageNumber = res.pageNumber + 1;
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    content,
                    total: res.total
                })
                page.selectComponent('#ListBox').RefreshToComplete();
                page.setData({
                    total: res.total
                })
            })
        },
        onSearch({
            detail
        }) {
            if (this.data.content.where.condition == detail) return;
            this.data.content.where.condition = detail
            this.getList(true);
        }
    }
})