const _Http = getApp().globalData.http;
Component({
    properties: {
        disabled: Boolean
    },
    data: {
        list: [],
        sa_customersid: "",
        content: {
            "nacache": true,
            "pageNumber": 1,
            "pageSize": 10,
            "pageTotal": 1,
            "total": null,
            "where": {
                "condition": "",
            }
        },
    },
    methods: {
        getList(id, init) {
            let content = this.data.content;
            content.sa_customersid = id;
            if (init) {
                content.pageNumber = 1
                content.pageTotal = 1
            }
            _Http.basic({
                "id": "20221208163302",
                content
            }).then(res => {
                console.log("线索列表", res)
                if (res.msg != '成功') return wx.showToast({
                    title: res.data,
                    icon: "none"
                })
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    "content.pageNumber": res.pageNumber + 1,
                    "content.pageSize": res.pageSize,
                    "content.pageTotal": res.pageTotal,
                    "content.total": res.total,
                    sa_customersid: id
                })
            })
        },
        /* 修改总数 */
        changeTotal() {
            this.setData({
                "content.total": this.data.content.total - 1
            })
        },
        toAdd(e) {
            let data = getCurrentPages()[getCurrentPages().length - 1].data.detail;
            wx.navigateTo({
                url: '/packageA/saleClue/addClue?rowData=' + JSON.stringify({
                    enterprisename: data.enterprisename || "",
                    city: data.city || "",
                    county: data.county || "",
                    province: data.province || "",
                    address: data.address || "",
                    cluesource: "客户:" + data.enterprisename || "",
                    sa_customersid: data.sa_customersid
                }),
            });
        }
    }
})