<!--
  Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

  https://www.mall4j.com/

  未经允许，不可做商业用途！

  版权所有，侵权必究！
-->
<template>
  <!-- 工商信息 -->
  <view class="Mall4j page-store-settings-business">
    <uni-forms
      ref="businessInfoFormRef"
      :model-value="businessInfoForm"
      validate-trigger="submit"
    >
      <view class="setting-info-item">
        <uni-forms-item name="creditCode">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('tongYiSheHuiXinYongDaiMa') }}
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.creditCode }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item firm-name">
        <uni-forms-item name="firmName">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('qiYeMingCheng') }}
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.firmName }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="residence">
          <view class="title">
            <text class="txt">
              {{ $t('zhuSuo') }}
            </text>
          </view>
          <view class="input-box">
            <text v-if="businessInfoForm.residence">
              {{ businessInfoForm.residence }}
            </text>
            <text
              v-else
              class="noyet-wrap"
            >
              {{ $t('zanWu') }}
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('faDingDaiBiaoRen') }}
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.representative }}
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="paySettlementType === 1"
        class="setting-info-item"
      >
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('faRenShenFenZheng') }}
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.legalIds }}
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="paySettlementType === 1"
        class="setting-info-item"
      >
        <uni-forms-item name="representative">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('faRenShouJiHao') }}
            </text>
          </view>
          <view class="input-box">
            {{ businessInfoForm.legalPhone }}
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item capital">
        <uni-forms-item name="capital">
          <view class="title">
            <text class="txt">
              {{ $t('zhuCeZiBen') }}
            </text>
          </view>
          <view class="input-box">
            <block v-if="businessInfoForm.capital">
              {{ businessInfoForm.capital }}
              <view class="unit">
                {{ $t('wanYuan') }}
              </view>
            </block>
            <text
              v-else
              class="noyet-wrap"
            >
              {{ $t('zanWu') }}
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item business-date">
        <uni-forms-item name="foundTime">
          <view class="title">
            <text class="txt">
              {{ $t('chengLiRiQi') }}
            </text>
          </view>
          <view class="input-box">
            <text v-if="businessInfoForm.foundTime">
              {{ businessInfoForm.foundTime }}
            </text>
            <text
              v-else
              class="noyet-wrap"
            >
              {{ $t('zanWu') }}
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item business-date">
        <uni-forms-item name="timeRange">
          <view class="title">
            <text class="txt">
              {{ $t('yingYeRiQi') }}
            </text>
          </view>
          <view class="input-box">
            <span v-if="businessInfoForm.startTime && businessInfoForm.endTime">
              {{ businessInfoForm.startTime }} - {{ businessInfoForm.endTime }}
            </span>
            <span v-else-if="businessInfoForm.startTime">
              {{ businessInfoForm.startTime + ' - ' + $t('wuGuDingQiXian') }}
            </span>
            <span
              v-else
              class="noyet-wrap"
            >
              {{ $t('zanWu') }}
            </span>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="businessScope">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('jingYingFanWei') }}
            </text>
          </view>
          <view class="textarea-box">
            <textarea
              v-model="businessInfoForm.businessScope"
              disabled
              :placeholder="$t('qingShuRuJingYingFanWei')"
              maxlength="500"
            />
          </view>
        </uni-forms-item>
      </view>
      <!-- 身份证证件照 -->
      <view class="setting-info-item">
        <view class="title">
          <text class="star">
            *
          </text>
          <text class="txt">
            {{ $t('faRenShenFenZheng') }}
          </text>
        </view>
        <view class="id-upload-image">
          <view class="id-front">
            <uni-forms-item name="identityCardFront">
              <view class="upload-image">
                <view
                  v-if="businessInfoForm.identityCardFront"
                  class="upload-con"
                >
                  <image
                    :src="util.checkFileUrl(businessInfoForm.identityCardFront)"
                    mode="aspectFill"
                    class="up-img-con"
                  />
                </view>
              </view>
            </uni-forms-item>
          </view>
          <uni-forms-item name="identityCardLater">
            <view class="upload-image">
              <view class="upload-con">
                <view
                  v-if="businessInfoForm.identityCardLater"
                  class="upload-con"
                >
                  <image
                    :src="util.checkFileUrl(businessInfoForm.identityCardLater)"
                    mode="aspectFill"
                    class="up-img-con"
                  />
                </view>
              </view>
            </view>
          </uni-forms-item>
        </view>
      </view>
      <!-- 营业执照电子版 -->
      <view class="setting-info-item">
        <uni-forms-item name="businessLicense">
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('yingYeZhiZhaoDianZiBan') }}
            </text>
          </view>
          <view class="upload-image bus-license">
            <view class="upload-con">
              <view
                v-if="businessInfoForm.businessLicense"
                class="upload-con"
              >
                <image
                  :src="util.checkFileUrl(businessInfoForm.businessLicense)"
                  mode="heightFix"
                  class="up-img-con "
                />
              </view>
            </view>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item name="businessLicense">
          <view class="title">
            <text class="txt">
              {{ $t('shenHeZhuangTai') }}
            </text>
          </view>
          <view class="input-box">
            <text>
              {{
                businessInfoForm.status === -1
                  ?
                    $t('weiTongGuo')
                  :
                    businessInfoForm.status === 1
                      ?
                        $t('yiTongGuo')
                      :
                        $t('weiShenHe')
              }}
            </text>
          </view>
        </uni-forms-item>
      </view>
      <view class="setting-info-item">
        <uni-forms-item
          v-if="businessInfoForm.status === -1"
          name="businessLicense"
        >
          <view class="title">
            <text class="star">
              *
            </text>
            <text class="txt">
              {{ $t('juJueYuanYin') }}
            </text>
          </view>
          <view class="textarea-box">
            <textarea
              v-model="businessInfoForm.remarks"
              disabled
              :placeholder="$t('zanWuJuJueYuanYin')"
              maxlength="50"
            />
          </view>
        </uni-forms-item>
      </view>
      <view
        v-if="businessInfoForm.status === 0 && paySettlementType !== 1"
        class="footer"
      >
        <button
          class="button"
          type="default"
          hover-class="none"
          @tap="withdrawReview"
        >
          {{ $t('cheXiaoXiuGaiShenQing') }}
        </button>
      </view>
    </uni-forms>
  </view>
</template>

<script setup>
import { reactive } from 'vue'
import dayjs from 'dayjs'
import util from '@/utils/util'
const paySettlementType = uni.getStorageSync('bbcPaySettlementType')
const Data = reactive({
  // 工商信息
  businessInfoForm: {
    creditCode: '',
    firmName: '',
    residence: '',
    representative: '',
    capital: null,
    foundTime: '',
    businessScope: '',
    startTime: '',
    endTime: '',
    identityCardFront: '',
    identityCardLater: '',
    businessLicense: ''
  }
})

const { businessInfoForm } = toRefs(Data)

onShow(() => {
  getShopDetailnfo()
  uni.setNavigationBarTitle({
    title: $t('gongShangXinXiBianGengShenQing')
  })
})

// 撤销申请
const withdrawReview = () => {
  http.request({
    url: '/shop/companyAuditing/revoke',
    method: 'put',
    data: Data.businessInfoForm.companyAuditingId.toString()
  }).then(() => {
    uni.showToast({
      title: $t('cheXiaoXiuGaiShenQingChengGong'),
      icon: 'none',
      duration: 1500
    })
    uni.$emit('updateShopCompany')
    uni.navigateBack()
  })
}

/**
     * 获取申请信息
     */
const getShopDetailnfo = () => {
  http.request({
    url: '/shop/companyAuditing/auditInfo',
    method: 'GET'
  }).then(({ data: res }) => {
    const formData = { ...res, ...res.shopCompany }
    // 日期
    formData.foundTime = formData.foundTime ? dayjs(formData.foundTime).format('YYYY-MM-DD') : formData.foundTime
    formData.startTime = formData.startTime ? dayjs(formData.startTime).format('YYYY-MM-DD') : formData.startTime
    formData.endTime = formData.endTime ? dayjs(formData.endTime).format('YYYY-MM-DD') : formData.endTime
    Data.businessInfoForm = formData
    Data.businessInfoForm.status = res.status
  })
}
</script>

<style lang="scss" scoped>
@use "modify-infor";
</style>
