const _Http = getApp().globalData.http;
Page({
    data: {
        content: {
            nocache: true,
            "type": 0,
            "pageNumber": 1,
            "pageSize": 20,
            "isExport": 0,
            "where": {
                "condition": "",
                "status": "", //状态
                "startdate": "",
                "enddate": ""
            },
        },
        list: []
    },
    onLoad(options) {
        this.getList();
    },
    /* 开始搜索 */
    startSearch({
        detail
    }) {
        this.setData({
            "content.where.condition": detail
        });
        this.getList(true);
    },
    onClear() {
        this.setData({
            "content.where.condition": ""
        });
        this.getList(true);
    },
    getList(init = false) {
        //init 用于初始化分页
        let content = this.data.content;
        if (init) content.pageNumber = 1;
        if (content.pageNumber > content.pageTotal) return;
        _Http.basic({
            "id": 20221012164402,
            content
        }).then(res => {
            console.log("搜索客户列表", res)
            if (res.msg != '成功') return wx.showToast({
                title: res.data,
                icon: "none"
            })
            // this.getTags(res.data.map(v => v.sys_enterpriseid));
            this.setData({
                'content.pageNumber': res.pageNumber + 1,
                'content.pageTotal': res.pageTotal,
                'content.total': res.total,
                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
            })
        })
    },
    onReachBottom() {
        this.getList();
    },
})