const _Http = getApp().globalData.http;
let sa_projectid = "";
Page({
    data: {
        defeatreason: "",
        type: "其他",
        actions: [{
            name: getApp().globalData.Language.getMapText('价格'),
            value: "价格",
        }, {
            name: getApp().globalData.Language.getMapText('品牌'),
            value: "品牌",
        }, {
            name: getApp().globalData.Language.getMapText('商务'),
            value: "商务",
        }, {
            name: getApp().globalData.Language.getMapText('地域'),
            value: "地域",
        }, {
            name: getApp().globalData.Language.getMapText('其他'),
            value: "其他",
        }],
        show: false
    },
    onLoad(options) {
        sa_projectid = options.id;
        getApp().globalData.Language.getLanguagePackage(this, '项目失败原因');
    },
    //开始选择跟进方式
    openSelect() {
        this.setData({
            show: true
        })
    },
    //取消选择
    onCancel() {
        this.setData({
            show: false
        })
    },
    //确定选择
    onSelect({
        detail
    }) {
        this.setData({
            type: detail.value
        })
        this.onCancel();
    },
    //文本域输入
    onInput(e) {
        this.setData({
            defeatreason: e.detail.value
        })
    },
    submit() {
        _Http.basic({
            "id": 20230706152904,
            "content": {
                sa_projectid,
                "defeatreason": this.data.defeatreason,
                defeattype: this.data.type
            }
        }).then(res => {
            console.log("失败", res)
            wx.showToast({
                title: res.code == '1' ? getApp().globalData.Language.getMapText('已失败') : res.msg,
                icon: "none",
                mask: true
            });
            if (res.code == '1') {
                let page = getCurrentPages()[getCurrentPages().length - 2];
                page.getDetail()
                setTimeout(() => {
                    wx.navigateBack()
                }, 500)
            }
        })
    }
})