const _Http = getApp().globalData.http;
Page({
    data: {
        ownerid: null,
        ownertable: null,
        sys_datafollowupid: 0,
        type: "",
        content: "",
        actions: [{
            name: "上门拜访"
        }, {
            name: "电话拜访"
        }, {
            name: "微信联系"
        }, {
            name: "QQ联系"
        }],
        show: false
    },
    onLoad(options) {
        if (options.ownertable) {
            this.setData({
                ...options
            })
        }
    },
    openSelect() {
        this.setData({
            show: true
        })
    },
    onCancel() {
        this.setData({
            show: false
        })
    },
    onSelect({
        detail
    }) {
        this.setData({
            type: detail.name
        })
        this.onCancel();
    },
    onInput(e) {
        this.setData({
            content: e.detail.value
        })
    },
    selectUser() {
        wx.navigateTo({
            url: `/packageA/group/index?ownertable=${this.data.ownertable}&ownerid=${this.data.ownerid}&radio`,
        })
    },
    submit() {
        const content = {
            type: this.data.type,
            content: this.data.content,
            ownerid: this.data.ownerid,
            ownertable: this.data.ownertable,
            sys_datafollowupid: this.data.sys_datafollowupid
        };
        if (!content.content) return;
        _Http.basic({
            "id": 20220930121601,
            content
        }).then(res => {
            console.log(res)
            if (res.msg != '成功') return wx.showToast({
                title: res.data,
                icon: "none"
            });
            wx.showToast({
                title: '保存成功',
                icon: "none"
            });
            setTimeout(() => {
                let pages = getCurrentPages();
                pages[pages.length - 2].partialRenewal(true);
                wx.navigateBack();
            }, 500)
        })
    },
})