import BaseFormControl from '../../baseFormControl'
import Tpl from './tpl'
import JDRadio from '../../formType/radio'
class GoodFeeds extends BaseFormControl {
    constructor(config) {
        super(config)
        this.config = $.extend(true, {}, config)
        this.sw = 1
        this.render()
    }
    render() {
        this.appendFormControl(Tpl)
        if (
            this.config.moduleData &&
            Object.prototype.hasOwnProperty.call(this.config.moduleData, 'sw')
        ) {
            this.sw = this.config.moduleData.sw
        }
        this.showAddCartInstance = new JDRadio({
            domData: {
                name: 'sw',
                title: `购物车图标`,
                node: this.element.find('.J_goodFeeds'),
                formType: {
                    type: 'radio',
                    option: [
                        {
                            text: '显示',
                            value: 1,
                        },
                        {
                            text: '隐藏',
                            value: 0,
                        },
                    ],
                },
            },
            defaultChecked: this.sw,
        })
    }
    getData() {
        const { name } = this.config.domData
        return {
            [name]: this.showAddCartInstance.getData(),
        }
    }
}
export default GoodFeeds