<template>
  <div class="basic-box">
    <el-form ref="formData" :model="formData" label-width="220px">
      <div v-if="formData.advertisement">
        <div class="basic-title">广告设置</div>
        <el-form-item label="开屏广告" prop="advertisement.open_screen_ad.is_select">
          <el-switch
            v-model="formData.advertisement.open_screen_ad.is_select"
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
          <div style="display: flex">
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement.open_screen_ad.you_liang_hui">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.open_screen_ad.you_liang_hui"
                  >优量汇</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item
                label=""
                prop="advertisement.open_screen_ad.kuai_shou_lian_meng"
              >
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.open_screen_ad.kuai_shou_lian_meng"
                  >快手联盟</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement.open_screen_ad.chuang_sha_jia">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.open_screen_ad.chuang_sha_jia"
                  >穿山甲</el-checkbox
                ></el-form-item
              >
            </div>
          </div>
        </el-form-item>

        <el-form-item
          label="动态信息流"
          prop="advertisement.dynamic_information_flow.is_select"
        >
          <el-switch
            v-model="formData.advertisement.dynamic_information_flow.is_select"
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
          <div style="display: flex">
            <div style="margin-right: 60px">
              <el-form-item
                label=""
                prop="advertisement.dynamic_information_flow.you_liang_hui"
              >
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.dynamic_information_flow.you_liang_hui"
                  >优量汇</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item
                label=""
                prop="advertisement.dynamic_information_flow.kuai_shou_lian_meng"
              >
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="
                    formData.advertisement.dynamic_information_flow.kuai_shou_lian_meng
                  "
                  >快手联盟</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item
                label=""
                prop="advertisement.dynamic_information_flow.chuang_sha_jia"
              >
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.dynamic_information_flow.chuang_sha_jia"
                  >穿山甲</el-checkbox
                ></el-form-item
              >
            </div>
          </div>
        </el-form-item>

        <el-form-item label="banner广告" prop="advertisement.banner_ad.is_select">
          <el-switch
            v-model="formData.advertisement.banner_ad.is_select"
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
          <div style="display: flex">
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement.banner_ad.you_liang_hui">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.banner_ad.you_liang_hui"
                  >优量汇</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement.banner_ad.kuai_shou_lian_meng">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.banner_ad.kuai_shou_lian_meng"
                  >快手联盟</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement.banner_ad.chuang_sha_jia">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement.banner_ad.chuang_sha_jia"
                  >穿山甲</el-checkbox
                ></el-form-item
              >
            </div>
          </div>
        </el-form-item>
      </div>

      <div v-if="formData.mob">
        <div class="basic-title">广告SDK设置</div>

        <el-form-item label=" ">
          <div style="display: flex">
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement_sdk.you_liang_hui">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement_sdk.you_liang_hui"
                  >优量汇</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement_sdk.kuai_shou_lian_meng">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement_sdk.kuai_shou_lian_meng"
                  >快手联盟</el-checkbox
                ></el-form-item
              >
            </div>
            <div style="margin-right: 60px">
              <el-form-item label="" prop="advertisement_sdk.chuang_sha_jia">
                <el-checkbox
                  :true-label="1"
                  :false-label="0"
                  v-model="formData.advertisement_sdk.chuang_sha_jia"
                  >穿山甲</el-checkbox
                ></el-form-item
              >
            </div>
          </div>
          <div style="color: #1890ff; font-size: 12px">
            <i class="el-icon-warning"></i>
            可多选，选多个会自动选择适合的进行展示，打包时需要同时勾选
          </div>
        </el-form-item>

        <el-form-item label="优量汇媒体ID（Android）:" prop="advertisement_sdk_value.you_liang_hui.media_id_android">
          <el-input v-model="formData.advertisement_sdk_value.you_liang_hui.media_id_android" show-password></el-input>
        </el-form-item>
        <el-form-item label="优量汇媒体ID（iOS）:" prop="advertisement_sdk_value.you_liang_hui.media_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.you_liang_hui.media_id_ios" show-password></el-input>
        </el-form-item>

        <el-form-item label="优量汇广告位ID（Android）:" prop="advertisement_sdk_value.you_liang_hui.ad_space_id_android">
          <el-input v-model="formData.advertisement_sdk_value.you_liang_hui.ad_space_id_android"show-password></el-input>
        </el-form-item>

        <el-form-item label="优量汇广告位ID（iOS）:" prop="advertisement_sdk_value.you_liang_hui.ad_space_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.you_liang_hui.ad_space_id_ios"show-password></el-input>
        </el-form-item>

        <el-form-item label="快手联盟媒体ID（Android）:" prop="advertisement_sdk_value.kuai_shou_lian_meng.media_id_android">
          <el-input v-model="formData.advertisement_sdk_value.kuai_shou_lian_meng.media_id_android" show-password></el-input>
        </el-form-item>
        <el-form-item label="快手联盟媒体ID（iOS）:" prop="advertisement_sdk_value.kuai_shou_lian_meng.media_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.kuai_shou_lian_meng.media_id_ios" show-password></el-input>
        </el-form-item>
        <el-form-item label="快手联盟广告位ID（Android）:" prop="advertisement_sdk_value.kuai_shou_lian_meng.ad_space_id_android">
          <el-input v-model="formData.advertisement_sdk_value.kuai_shou_lian_meng.ad_space_id_android" show-password></el-input>
        </el-form-item>
            <el-form-item label="快手联盟广告位ID（iOS）:" prop="advertisement_sdk_value.kuai_shou_lian_meng.ad_space_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.kuai_shou_lian_meng.ad_space_id_ios" show-password></el-input>
        </el-form-item>




                <el-form-item label="穿山甲媒体ID（Android）:" prop="advertisement_sdk_value.chuang_sha_jia.media_id_android">
          <el-input v-model="formData.advertisement_sdk_value.chuang_sha_jia.media_id_android" show-password></el-input>
        </el-form-item>
                <el-form-item label="穿山甲媒体ID（iOS）:" prop="advertisement_sdk_value.chuang_sha_jia.media_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.chuang_sha_jia.media_id_ios" show-password></el-input>
        </el-form-item>
        <el-form-item label="穿山甲广告位ID（Android）:" prop="advertisement_sdk_value.chuang_sha_jia.ad_space_id_android">
          <el-input  v-model="formData.advertisement_sdk_value.chuang_sha_jia.ad_space_id_android" show-password></el-input>
        </el-form-item>
            <el-form-item label="穿山甲广告位ID（iOS）:" prop="advertisement_sdk_value.chuang_sha_jia.ad_space_id_ios">
          <el-input v-model="formData.advertisement_sdk_value.chuang_sha_jia.ad_space_id_ios" show-password></el-input>
        </el-form-item>
      </div>
      <el-form-item class="ml-100" style="margin-top: 50px">
        <button class="blue-btn" @click.prevent="handleSubmit">提交</button>
        <button class="gray-btn ml-10" @click="resetQuery">重置</button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getBasicSetting, getBasicCreate } from "@/api/basic-setting";

export default {
  data() {
    return {
      formData: {},
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      getBasicSetting().then((res) => {
        this.formData = res.data;
      });
    },

    handleSubmit() {
      getBasicCreate(this.formData)
        .then((res) => {
          this.$message.success("保存成功");
          this.init();
        })
        .catch((err) => {
          return;
        });
    },
    resetQuery() {
      this.$refs.formData.resetFields();
    },
  },
};
</script>

<style lang="scss" scoped>
.basic-box {
  width: 80%;
  box-sizing: border-box;
  padding: 63px 0 0px 150px;
  .basic-title {
    color: #333333;
    font-size: 16px;
    padding-left: 10px;
    height: 16px;
    line-height: 16px;
    border-left: #1890ff 5px solid;
    font-weight: bold;
    margin-bottom: 30px;
    margin-left: 50px;
  }
}
</style>
