<template>
  <div style="background: #fff">
    <div class="account-settings-info-view">
      <a-divider orientation="left">公共参数</a-divider>
      <a-form ref="oemConfigInfoFormModelRef" :rules="oemConfigRules" :model="vdata.configData" layout="vertical">
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="系统名称" name="sysName">
              <a-input v-model:value="vdata.configData.sysName" placeholder="请填写系统名称" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="公司全称" name="companyName">
              <a-input v-model:value="vdata.configData.companyName" placeholder="请填写公司全称" />
            </a-form-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="公司电话" name="companyTel">
              <a-input v-model:value="vdata.configData.companyTel" placeholder="请填写公司电话" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="公司客服电话" name="companyServiceTel">
              <a-input v-model:value="vdata.configData.companyServiceTel" placeholder="请填写公司客服电话" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="公司email" name="companyEmail">
              <a-input v-model:value="vdata.configData.companyEmail" placeholder="请填写公司email" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="margin-top: 20px;">
          <a-col :span="6" :offset="2">
            <a-form-item label="系统logo(完整版)" name="sysLogoUrl">
              <JeepayUpload v-model:src="vdata.configData.sysLogoUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：418x64</span>
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="系统logo(仅图标)" name="sysMinLogoUrl">
              <JeepayUpload v-model:src="vdata.configData.sysMinLogoUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：64x64</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="margin-top: 20px;">
          <a-col :span="6" :offset="2">
            <a-form-item label="暗色模式系统logo(完整版)" name="darkSysLogoUrl">
              <JeepayUpload v-model:src="vdata.configData.darkSysLogoUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：418x64</span>
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="暗色模式系统logo(仅图标)" name="darkSysMinLogoUrl">
              <JeepayUpload v-model:src="vdata.configData.darkSysMinLogoUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：64x64</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="margin-top: 20px;">
          <a-col :span="6" :offset="2">
            <a-form-item label="标签栏图标" name="iconUrl">
              <JeepayUpload v-model:src="vdata.configData.iconUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：32x32</span>
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="授权函文件" name="promiseFile">
              <JeepayUpload v-model:src="vdata.configData.promiseFile" fileType="file" bizType="agentFile" />
              <span class="jeepay-tip-text">文件格式：pdf、docx</span>
            </a-form-item>
          </a-col>
        </a-row>

        <a-divider orientation="left">系统备案版权配置项</a-divider>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="工信部ICP备案信息" name="configDesc0">
              <a-input v-model:value.trim="vdata.oemReportIcp.configDesc" placeholder="请填写信息描述" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="工信部ICP链接地址" name="configUrl0">
              <a-input v-model:value.trim="vdata.oemReportIcp.configUrl" placeholder="请填写链接地址" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="公网安备案信息" name="configDesc1">
              <a-input v-model:value.trim="vdata.oemReportGa.configDesc" placeholder="请填写信息描述" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="公网安链接地址" name="configUrl1">
              <a-input v-model:value.trim="vdata.oemReportGa.configUrl" placeholder="请填写链接地址" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="中国支付清算协会备案信息" name="configDesc2">
              <a-input v-model:value.trim="vdata.oemReportJh.configDesc" placeholder="请填写信息描述" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="中国支付清算协会链接地址" name="configUrl2">
              <a-input v-model:value.trim="vdata.oemReportJh.configUrl" placeholder="请填写链接地址" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="电信增值业务许可信息" name="configDesc3">
              <a-input v-model:value.trim="vdata.oemReportDx.configDesc" placeholder="请填写信息描述" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="电信增值业务链接地址" name="configUrl3">
              <a-input v-model:value.trim="vdata.oemReportDx.configUrl" placeholder="请填写链接地址" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="版权信息" name="configDesc4">
              <a-input v-model:value.trim="vdata.oemCopyrightInfo.configDesc" placeholder="请填写信息描述" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="版权链接地址" name="configUrl4">
              <a-input v-model:value.trim="vdata.oemCopyrightInfo.configUrl" placeholder="请填写链接地址" />
            </a-form-item>
          </a-col>
        </a-row>

        <a-divider orientation="left">运营平台</a-divider>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="主题色" name="sysPrimaryColor">
              <!-- 色卡组件 value 莫名其妙接收不到-->
              <themeColor ref="themeColorMgr" v-model:value="vdata.oemMgr.sysPrimaryColor" />
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录卡片位置" name="loginPageCardPosition">
              <a-radio-group v-model:value="vdata.oemMgr.loginPageCardPosition" button-style="solid">
                <a-radio-button value="left">左</a-radio-button>
                <a-radio-button value="center">中</a-radio-button>
                <a-radio-button value="right">右</a-radio-button>
              </a-radio-group>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录页背景图" name="loginPageBGImgUrl">
              <JeepayUpload v-model:src="vdata.oemMgr.loginPageBGImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：1920x1080</span>
            </a-form-item>
          </a-col>
        </a-row>


        <a-row>
          <a-col :span="16" :offset="2">
            <a-collapse>
              <a-collapse-panel header="系统Logo">
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(完整版)" name="sysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMgr.sysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(仅图标)" name="sysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMgr.sysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(完整版)" name="darkSysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMgr.darkSysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(仅图标)" name="darkSysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMgr.darkSysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </a-col>
        </a-row>


        <a-divider v-if="$hasAgentEnt()" orientation="left">服务商系统</a-divider>
        <a-row v-if="$hasAgentEnt()">
          <a-col :span="6" :offset="2">
            <!-- 色卡组件 -->
            <themeColor ref="themeColorAgent" v-model:value="vdata.oemAgent.sysPrimaryColor" />
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录卡片位置" name="loginPageCardPosition">
              <a-radio-group v-model:value="vdata.oemAgent.loginPageCardPosition" button-style="solid">
                <a-radio-button value="left">左</a-radio-button>
                <a-radio-button value="center">中</a-radio-button>
                <a-radio-button value="right">右</a-radio-button>
              </a-radio-group>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row v-if="$hasAgentEnt()">
          <a-col :span="6" :offset="2">
            <a-form-item label="登录页背景类型" name="loginBgType">
              <a-radio-group v-model:value="vdata.oemAgent.loginBgType">
                <a-radio :value="0">
                  背景图
                </a-radio>
                <a-radio :value="1">
                  背景图 + 轮播图
                </a-radio>
              </a-radio-group>
              <a-button type="link" @click="goAdvertPage()">前往创建轮播图</a-button>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row v-if="$hasAgentEnt()">
          <a-col :span="6" :offset="2">
            <a-form-item label="登录页背景图" name="loginPageBGImgUrl">
              <JeepayUpload v-model:src="vdata.oemAgent.loginPageBGImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：1920x1080</span>
            </a-form-item>
          </a-col>
          <a-col v-if="vdata.oemAgent.loginBgType == 1" :span="6" :offset="2">
            <a-form-item label="登录页轮播图">
              <a-select v-model:value="vdata.oemAgent.loginBgId" placeholder="登录页轮播图">
                <a-select-option v-for="(item) in vdata.advertAgentList" :key="item.advertId">[{{ 'ID:' + item.advertId }}] {{ item.title }}</a-select-option>
              </a-select>
              <span class="jeepay-tip-text">
                *配置此轮播后：<br>
                当<span v-if="$hasAgentEnt()">服务商访问登录注册页时将显示该轮播配置。</span>
              </span>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row v-if="$hasAgentEnt()">
          <a-col :span="16" :offset="2">
            <a-collapse>
              <a-collapse-panel header="系统Logo">
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(完整版)" name="sysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemAgent.sysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(仅图标)" name="sysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemAgent.sysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(完整版)" name="darkSysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemAgent.darkSysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(仅图标)" name="darkSysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemAgent.darkSysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </a-col>
        </a-row>

        <a-divider orientation="left">商户系统</a-divider>
        <a-row>
          <a-col :span="6" :offset="2">
            <!-- 色卡组件 -->
            <themeColor ref="themeColorMch" v-model:value="vdata.oemMch.sysPrimaryColor" />
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录卡片位置" name="loginPageCardPosition">
              <a-radio-group v-model:value="vdata.oemMch.loginPageCardPosition" button-style="solid">
                <a-radio-button value="left">左</a-radio-button>
                <a-radio-button value="center">中</a-radio-button>
                <a-radio-button value="right">右</a-radio-button>
              </a-radio-group>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录页背景类型" name="loginBgType">
              <a-radio-group v-model:value="vdata.oemMch.loginBgType">
                <a-radio :value="0">
                  背景图
                </a-radio>
                <a-radio :value="1">
                  背景图 + 轮播图
                </a-radio>
              </a-radio-group>
              <a-button type="link" @click="goAdvertPage()">前往创建轮播图</a-button>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="登录页背景图" name="loginPageBGImgUrl">
              <JeepayUpload v-model:src="vdata.oemMch.loginPageBGImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：1920x1080</span>
            </a-form-item>
          </a-col>
          <a-col v-if="vdata.oemMch.loginBgType == 1" :span="6" :offset="2">
            <a-form-item label="登录页轮播图">
              <a-select v-model:value="vdata.oemMch.loginBgId" placeholder="登录页轮播图">
                <a-select-option v-for="(item) in vdata.advertMchList" :key="item.advertId">[{{ 'ID:' + item.advertId }}] {{ item.title }}</a-select-option>
              </a-select>
              <span class="jeepay-tip-text">
                *配置此轮播后：<br>
                当商户访问登录注册页时将显示该轮播配置。
              </span>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="16" :offset="2">
            <a-collapse>
              <a-collapse-panel header="系统Logo">
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(完整版)" name="sysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMch.sysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="系统logo(仅图标)" name="sysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMch.sysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row style="margin-top: 20px;">
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(完整版)" name="darkSysLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMch.darkSysLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：418x64</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="10" :offset="2">
                    <a-form-item label="暗色模式系统logo(仅图标)" name="darkSysMinLogoUrl">
                      <JeepayUpload v-model:src="vdata.oemMch.darkSysMinLogoUrl" bizType="oem" />
                      <span class="jeepay-tip-text">建议尺寸：64x64</span>
                    </a-form-item>
                  </a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </a-col>
        </a-row>
        <a-divider orientation="left">{{ $SYS_NAME_MAP.MCH_APP }}</a-divider>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="APP顶部图片" name="appTopImgUrl">
              <JeepayUpload v-model:src="vdata.configData.appTopImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：400x100</span>
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="小程序二维码" name="appletImgUrl">
              <JeepayUpload v-model:src="vdata.configData.appletImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：360x360</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="小程序分享图" name="shareImgUrl">
              <JeepayUpload v-model:src="vdata.configData.shareImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：360x360</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider orientation="left">{{ $SYS_NAME_MAP.AGENT_APP }}</a-divider>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="APP顶部图片" name="agentAppTopImgUrl">
              <JeepayUpload v-model:src="vdata.configData.agentAppTopImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：400x100</span>
            </a-form-item>
          </a-col>
          <a-col :span="6" :offset="2">
            <a-form-item label="小程序二维码" name="agentAppletImgUrl">
              <JeepayUpload v-model:src="vdata.configData.agentAppletImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：360x360</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6" :offset="2">
            <a-form-item label="小程序分享图" name="agentShareImgUrl">
              <JeepayUpload v-model:src="vdata.configData.agentShareImgUrl" bizType="oem" />
              <span class="jeepay-tip-text">建议尺寸：360x360</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-form-item class="bottom-btn" style="margin-top: 20px">
          <a-button v-if="$access('ENT_SYS_CONFIG_EDIT')" :disabled="!vdata.isEdit" type="primary" :loading="vdata.btnLoading" @click="confirm"><check-circle-outlined />确认更新</a-button>
        </a-form-item>
      </a-form>
    </div>
  </div>
</template>
<script setup lang="ts">
import { API_URL_SYS_CONFIG, API_URL_ADVERT, req, $getConfigs } from '@/api/manage'
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
import router from '@/router'
import themeColor from '../ThemeColor.vue'

const { $infoBox, $access, $hasAgentEnt, $SYS_NAME_MAP } = getCurrentInstance()!.appContext.config.globalProperties

const oemConfigInfoFormModelRef = ref()

const vdata = reactive ({
  isEdit:$access('ENT_PUSH_CONFIG_EDIT'),
  btnLoading: false,
  groupKey: 'oemConfig',
  configData: {} as any, // 配置保存对象
  oemMgr: {},
  oemMch: {},
  oemAgent: {},
  oemReportIcp: {} as any, // 工信部ICP备案
  oemReportGa: {} as any, // 公安备案
  oemReportJh: {} as any, // 聚合支付备案
  oemReportDx: {} as any, // 电信增值备案
  oemCopyrightInfo: {} as any, // 版权
  advertAgentList: [], // 服务商登录页广告配置
  advertMchList: [], // 商户登录页广告配置
}) as any

const oemConfigRules = {
  configDesc0: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(!vdata.oemReportIcp.configDesc && vdata.oemReportIcp.configUrl){
      return Promise.reject('请填写信息描述')
    }
    return Promise.resolve()
  }
  }],
  configUrl0: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(vdata.oemReportIcp.configDesc && !vdata.oemReportIcp.configUrl){
      return Promise.reject('请填写链接地址')
    }
    return Promise.resolve()
  }
  }],
  configDesc1: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(!vdata.oemReportGa.configDesc && vdata.oemReportGa.configUrl){
      return Promise.reject('请填写信息描述')
    }
    return Promise.resolve()
  }
  }],
  configUrl1: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(vdata.oemReportGa.configDesc && !vdata.oemReportGa.configUrl){
      return Promise.reject('请填写链接地址')
    }
    return Promise.resolve()
  }
  }],
  configDesc2: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(!vdata.oemReportJh.configDesc && vdata.oemReportJh.configUrl){
      return Promise.reject('请填写信息描述')
    }
    return Promise.resolve()
  }
  }],
  configUrl2: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(vdata.oemReportJh.configDesc && !vdata.oemReportJh.configUrl){
      return Promise.reject('请填写链接地址')
    }
    return Promise.resolve()
  }
  }],
  configDesc3: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(!vdata.oemReportDx.configDesc && vdata.oemReportDx.configUrl){
      return Promise.reject('请填写信息描述')
    }
    return Promise.resolve()
  }
  }],
  configUrl3: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(vdata.oemReportDx.configDesc && !vdata.oemReportDx.configUrl){
      return Promise.reject('请填写链接地址')
    }
    return Promise.resolve()
  }
  }],
  configDesc4: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(!vdata.oemCopyrightInfo.configDesc && vdata.oemCopyrightInfo.configUrl){
      return Promise.reject('请填写信息描述')
    }
    return Promise.resolve()
  }
  }],
  configUrl4: [{required: false, trigger: 'blur', validator:  (rule, value) => {
    if(vdata.oemCopyrightInfo.configDesc && !vdata.oemCopyrightInfo.configUrl){
      return Promise.reject('请填写链接地址')
    }
    return Promise.resolve()
  }
  }],
}

let themeColorMgr = ref() // 两个色卡组件
let themeColorMch = ref()
let themeColorAgent = ref()

onMounted(()=>{
  $getConfigs(vdata.groupKey).then(res => {
    vdata.configData = JSON.parse(res[0].configVal || '{}')

    console.log(vdata.configData)

    vdata.oemMgr = vdata.configData.mgr
    vdata.oemMch = vdata.configData.mch
    vdata.oemAgent = vdata.configData.agent
    vdata.oemReportIcp = vdata.configData.reportIcp || {}
    vdata.oemReportGa = vdata.configData.reportGa || {}
    vdata.oemReportJh = vdata.configData.reportJh || {}
    vdata.oemReportDx = vdata.configData.reportDx|| {}
    vdata.oemCopyrightInfo = vdata.configData.copyrightInfo || {}

    // 为两个色卡组件赋值
    themeColorMgr.value.setColor(vdata.oemMgr.sysPrimaryColor)
    themeColorMch.value.setColor(vdata.oemMch.sysPrimaryColor)
    themeColorAgent.value.setColor(vdata.oemAgent.sysPrimaryColor)
  })

  // 服务商登录页轮播列表
  getAdvertAgentList()
  // 商户登录页轮播列表
  getAdvertMchList()
})

function getAdvertMchList() {
    req.list(API_URL_ADVERT, { advertType: 5 }).then(res => {
      vdata.advertMchList = res.records
    })
  }

function getAdvertAgentList() {
  req.list(API_URL_ADVERT, { advertType: 6 }).then(res => {
    vdata.advertAgentList = res.records
  })
}

// 更新配置
function confirm () {
  oemConfigInfoFormModelRef.value.validate().then(valid => {
    $infoBox.confirmPrimary('确认更新平台配置吗？', '', () => {
      vdata.btnLoading = true // 打开按钮上的 loading
      const reqData:any = {}
      reqData.iconUrl = vdata.configData.iconUrl
      reqData.sysLogoUrl = vdata.configData.sysLogoUrl
      reqData.sysMinLogoUrl = vdata.configData.sysMinLogoUrl
      reqData.darkSysLogoUrl = vdata.configData.darkSysLogoUrl
      reqData.darkSysMinLogoUrl = vdata.configData.darkSysMinLogoUrl
      reqData.appTopImgUrl = vdata.configData.appTopImgUrl
      reqData.appletImgUrl = vdata.configData.appletImgUrl
      reqData.shareImgUrl = vdata.configData.shareImgUrl
      reqData.agentAppTopImgUrl = vdata.configData.agentAppTopImgUrl
      reqData.agentAppletImgUrl = vdata.configData.agentAppletImgUrl
      reqData.agentShareImgUrl = vdata.configData.agentShareImgUrl
      reqData.promiseFile = vdata.configData.promiseFile
      reqData.sysName = vdata.configData.sysName
      reqData.companyName = vdata.configData.companyName
      reqData.companyServiceTel = vdata.configData.companyServiceTel
      reqData.companyTel = vdata.configData.companyTel
      reqData.companyEmail = vdata.configData.companyEmail
      reqData.mgr = JSON.stringify(vdata.oemMgr)
      reqData.mch = JSON.stringify(vdata.oemMch)
      reqData.agent = JSON.stringify(vdata.oemAgent)
      reqData.reportIcp = JSON.stringify(vdata.oemReportIcp)
      reqData.reportGa = JSON.stringify(vdata.oemReportGa)
      reqData.reportJh = JSON.stringify(vdata.oemReportJh)
      reqData.reportDx = JSON.stringify(vdata.oemReportDx)
      reqData.copyrightInfo = JSON.stringify(vdata.oemCopyrightInfo)
      req.updateById(API_URL_SYS_CONFIG, vdata.groupKey, reqData)
          .then(res => {
            $infoBox.message.success('修改成功')
            vdata.btnLoading = false
          }).catch(res => {
        vdata.btnLoading = false
      })
    })
  })
}

function goAdvertPage () { // 智能pos管理
  router.push({
    path: '/advert'
  })
}

</script>
<style lang="less" scoped>
  .bottom-btn{
    /deep/ div{
      display: flex;
      justify-content: center;
    }
  }
</style>
