<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="充值设置">
          <div class="labelbox">
            用户消费结账时，成功充值消费
            <el-input-number
              :min="2"
              class="u-m-l-10 u-m-r-10"
              v-model="form.rechargeTimes"
            ></el-input-number>
            倍的金额，本单即可享受免单
          </div>
        </el-form-item>
        <el-form-item label="充值门槛">
          <div class="labelbox">
            订单支付金额需满
            <el-input
              style="width: 80px; margin: 0 15px"
              v-model="form.rechargeThreshold"
            ></el-input>
            元才能使用
          </div>
        </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 bwcApi from "@/api/account/bwc";
import { ElMessage } from "element-plus";
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 bwcApi.getList();
      this.form = res;
    },
    async editlist() {
      let res = await bwcApi.edit(this.form);
      ElMessage({
        message: "保存成功",
        type: "success",
      });
      this.getlist();
    },
  },
};
</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>