const _Http = getApp().globalData.http;

Page({
    data: {
        content: {
            nocache: true,
            pageNumber: 1,
            pageSize: 20,
            ownertable: "",
            ownerid: "",
            pageTotal: 1,
            total: 0,
            where: {
                "condition": "",
            }
        },
        list: [],
    },
    getList(init = false) {
        _Http.init(this.data.content, init).then(content => {
            try {
                content.phonenumber = getCurrentPages()[getCurrentPages().length - 2].selectComponent("#Form").query().phonenumber || '';
            } catch (error) {

            }
            _Http.basic({
                "id": 20240531152004,
                content
            }).then(res => {
                this.selectComponent('#ListBox').RefreshToComplete();
                console.log("通讯录列表", res)
                if (res.code != '1') return wx.showToast({
                    title: res.data,
                    icon: "none"
                });
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    content: _Http.paging(content, res),
                })
            })
        })
    },
    onLoad(options) {
        this.getList();
        getApp().globalData.Language.getLanguagePackage(this, '选择联系人');
    },
    onClick(e) {
        const {
            item
        } = e.currentTarget.dataset;
        getApp().globalData.handleSelect(item)
    },
    onSearch({
        detail
    }) {
        this.setData({
            'content.where.condition': detail ? detail : ""
        });
        this.getList(true);
    },
    onClear() {
        this.setData({
            'content.where.condition': ""
        });
        this.getList(true);
    },
})