const _Http = getApp().globalData.http;

Component({
    properties: {
        list: {
            type: Array
        }
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        toDetail(e) {
            const {
                id
            } = e.currentTarget.dataset;
            wx.redirectTo({
                url: `/packageA/offers/detail?sa_quotedpriceid=${id}`,
            })
        },
        copyItem(e) {
            const {
                billno,
                sa_quotedpriceid
            } = e.currentTarget.dataset.item;
            wx.showModal({
                title: getApp().globalData.Language.getMapText('提示'),
                content: getApp().globalData.Language.getMapText('是否确认复制') + `“${billno}”`,
                cancelText: getApp().globalData.Language.getMapText('取消'),
                confirmText: getApp().globalData.Language.getMapText('确定'),
                complete: ({
                    confirm
                }) => {
                    if (confirm) _Http.basic({
                        "id": 20221209094103,
                        "content": {
                            sa_quotedpriceid
                        },
                    }).then(res => {
                        wx.showToast({
                            title: res.code == '1' ? getApp().globalData.Language.getMapText('复制成功') : res.msg,
                            icon: "none"
                        });
                        setTimeout(() => {
                            wx.redirectTo({
                                url: `/packageA/offers/detail?sa_quotedpriceid=${res.data.sa_quotedpriceid}`,
                            })
                            let page = getCurrentPages().find(v => v.__route__ == 'packageA/offers/index');
                            if (page) page.getList(true);
                        }, 300)
                    })
                }
            })
        },
    }
})