<template>
    <div class="app-container">
        <div class="container">
            <el-form ref="form" :model="form" label-width="140px" label-position="left">
                <el-form-item label="功能启用">
                    <el-switch v-model="form.enable"></el-switch>
                </el-form-item>
                <el-form-item label="充值设置">
                    <template>
                        <div class="labelbox">
                            用户消费结账时，成功充值消费
                            <el-input style="width: 80px;margin: 0 15px;" v-model="form.rechargeTimes"></el-input>
                            倍的金额，本单即可享受免单
                        </div>
                    </template>
                </el-form-item>
                <el-form-item label="充值门槛">
                    <template>
                        <div class="labelbox">
                            订单支付金额需满
                            <el-input style="width: 80px;margin: 0  15px;" v-model="form.rechargeThreshold"></el-input>
                            元才能使用
                        </div>
                    </template>

                </el-form-item>
                <!-- <el-form-item label="适用门店">
                    <el-radio-group v-model="form.resource">
                        <el-radio label="全部门店"></el-radio>
                        <el-radio label="指定门店"></el-radio>
                        <el-radio label="仅本店使用"></el-radio>
                    </el-radio-group>
                </el-form-item> -->
                <!-- <el-form-item label="使用方式">
                    <el-checkbox-group v-model="form.useTypeList">
                        <el-checkbox label="堂食" name="dine-in" value="dine-in"></el-checkbox>
                        <el-checkbox label="自取" name="takeout" value="takeout"></el-checkbox>
                        <el-checkbox label="配送" name="takeaway" value="takeaway"></el-checkbox>
                        <el-checkbox label="快递" name="post" value="post"></el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="是否与优惠券共享">
                    <el-switch v-model="form.withCoupon"></el-switch>
                </el-form-item>
                <el-form-item label="是否与积分共享">
                    <el-switch v-model="form.withPoints"></el-switch>
                </el-form-item>
                <el-form-item label="不参与集章">
                    <el-switch v-model="form.childShopIdList"></el-switch>
                </el-form-item>  -->
                <el-form-item label="充值说明">
                    <el-input type="textarea" v-model="form.rechargeDesc"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="editlist">保存</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
import { get, edit } from "@/api/bwc";
export default {
    name: 'bwc',
    data() {
        return {
            form: {
                id: '',
                enable: '',
                rechargeTimes: '',
                rechargeThreshold: '',
                withCoupon: '',
                withPoints: '',
                rechargeDesc: '',
                useTypeList: [],
                childShopIdList: '',
            }
        }
    },
    created() {
        this.getlist()
    },
    methods: {
        async getlist() {
            let res = await get({
                shopId: localStorage.getItem("shopId")
            })
            this.form = res
        },
        async editlist() {
            this.form.shopId = localStorage.getItem("shopId")
            let res = await edit(this.form)
            this.$message({
                message: '保存成功',
                type: 'success'
            });
            this.form = res
        },

    }
}
</script>

<style scoped lang="scss">
.app-container {
    padding: 12px 20px;
    height: auto;
    background-color: #f4f9ff;

    .container {
        padding: 30px;
        width: 100%;
        height: 100%;
        background: #FFFFFF;

        .labelbox {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            font-family: Source Han Sans CN, Source Han Sans CN;
            font-weight: 400;
            font-size: 16px;
            color: #666666;
        }
    }
}
</style>