const _Http = getApp().globalData.http;
Page({
    data: {
        content: {
            nocache: true,
            "sa_projectid": 1,
            "pageNumber": 1,
            "pageTotal": 1,
            "pageSize": 20,
            total: null,
            "where": {
                "condition": ""
            }
        },
    },
    onLoad(options) {
        this.setData({
            "content.sa_projectid": options.sa_projectid
        })
        this.getList();
    },
    getList(init = false) {
        if (init.detail != undefined) init = init.detail;
        let content = this.data.content;
        if (init) content.pageNumber = 1;
        if (content.pageNumber > content.pageTotal) return;
        _Http.basic({
            "id": 20221111131004,
            content
        }).then(res => {
            console.log("项目联系人搜索", res)
            this.selectComponent('#ListBox').RefreshToComplete();
            if (res.msg != '成功') return wx.showToast({
                title: res.data,
                icon: "none"
            })
            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)
            })
        })
    },
    /* 开始搜索 */
    onSearch({
        detail
    }) {
        if (this.data.content.where.condition == detail) return;
        this.setData({
            'content.where.condition': detail
        });
        this.getList(true)
    },
    onClear() {
        this.setData({
            'content.where.condition': ""
        });
        this.getList(true)
    },
    onReady() {
        this.selectComponent("#ListBox").setHeight(".search", this);
    },
})