<template>
  <div>
    <p class="reset-view">
      <span style="margin-right: 10px">更新时间：{{ now_date }}</span>
      <el-button
        size="small"
        type="text"
        :loading="is_reset"
        @click="resetData"
      >
        刷新
      </el-button>
    </p>
    <el-card shadow="hover">
      <div slot="header">
        <span>
          <vab-remix-icon icon-class="money-cny-box-line"></vab-remix-icon>
          可提现
        </span>
      </div>
      <div class="data-sec">
        <div class="data-secbox sec-left">
          <div class="data-item">
            <p class="data-label">
              <span>可提现金额（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">可申请提现订单金额（已完结订单）。</div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ balance.balance.balance }}</p>
            <p class="data-subval">订单数：{{ balance.balance.num }}</p>
            <p class="data-btn">
              <el-button
                size="small"
                type="primary"
                @click="$router.push('/settlement/SettlementDetail')"
              >
                申请提现
              </el-button>
            </p>
          </div>
        </div>
        <div class="data-secbox sec-right">
          <div class="data-item">
            <p class="data-label">
              <span>商品订单金额（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  可申请结算的商品订单金额总和（已完结订单）
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ balance.total.total }}</p>
          </div>
          <div class="data-item">
            <p class="data-label">
              <span>退款金额（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  退款金额 = 维权退款 + 拼团失败退款 + 卖家手动取消订单退款
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ balance.ret.total }}</p>
          </div>
          <div class="data-item"></div>
          <div class="data-item"></div>
        </div>
      </div>
    </el-card>
    <el-card shadow="hover">
      <div slot="header">
        <span>
          <vab-remix-icon icon-class="shield-check-line"></vab-remix-icon>
          审核中
        </span>
      </div>
      <div class="data-sec">
        <div class="data-secbox sec-left">
          <div class="data-item">
            <p class="data-label">
              <span>审核中金额（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  审核中金额：已申请结算金额，待主商城审核
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">
              {{ audit.waitAuditWithdraw.waitAuditWithdraw }}
            </p>
            <p class="data-subval">订单数：{{ audit.waitAuditWithdraw.num }}</p>
          </div>
        </div>
        <div class="data-secbox sec-right">
          <div class="data-item">
            <p class="data-label">
              <span>预计打款（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  预计打款金额 = 审核中金额 - 预计抽成金额。
                  <br />
                  预计打款金额按全部订单审核通过的前提计算，不是实际打款金额，仅供参考
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ audit.estimate.estimate }}</p>
            <p class="data-subval">订单数：{{ audit.estimate.num }}</p>
          </div>
          <div class="data-item">
            <p class="data-label">
              <span>预计抽成（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  预计抽成金额按全部订单审核通过的前提计算，不是实际抽成金额，仅供参考
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ audit.fee.fee }}</p>
            <p class="data-subval">抽成比例：{{ audit.fee.rate }}%</p>
          </div>

          <div class="data-item"></div>
          <div class="data-item"></div>
          <div class="data-item"></div>
        </div>
      </div>
    </el-card>
    <el-card shadow="hover">
      <div slot="header">
        <span>
          <vab-remix-icon icon-class="bank-card-line"></vab-remix-icon>
          已结算
        </span>
      </div>
      <div class="data-sec">
        <div class="data-secbox sec-left" style="align-items: center">
          <div class="data-item">
            <p class="data-label">
              <span>已结算金额（元）</span>
              <el-tooltip effect="light" placement="top">
                <div slot="content">
                  主商城完成结算金额总和，包括审核通过和审核未通过订单
                </div>
                <i class="el-icon-question help-icon"></i>
              </el-tooltip>
            </p>
            <p class="data-num">{{ finish.withdraw.withdraw }}</p>
            <p class="data-subval">订单数：{{ finish.withdraw.num }}</p>
          </div>
        </div>
        <div class="sec-right">
          <div
            class="data-secbox sec-right"
            style="border-bottom: 1px solid #f2f2f2; margin-bottom: 20px"
          >
            <div class="data-item">
              <p class="data-label">
                <span>审核通过（元）</span>
                <el-tooltip effect="light" placement="top">
                  <div slot="content">通过主商城审核的结算订单总和</div>
                  <i class="el-icon-question help-icon"></i>
                </el-tooltip>
              </p>
              <p class="data-num">{{ finish.pass.pass }}</p>
              <p class="data-subval">订单数：{{ finish.pass.num }}</p>
            </div>
            <div class="data-item">
              <p class="data-label">
                <span>已打款（元）</span>
                <el-tooltip effect="light" placement="top">
                  <div slot="content">结算订单审核通过，主商城实际打款金额</div>
                  <i class="el-icon-question help-icon"></i>
                </el-tooltip>
              </p>
              <p class="data-num">{{ finish.finish.finish }}</p>
              <p class="data-subval">抽成：{{ finish.finish.fee }}</p>
            </div>

            <div class="data-item"></div>
            <div class="data-item"></div>
            <div class="data-item"></div>
          </div>
          <div class="data-secbox sec-right">
            <div class="data-item">
              <p class="data-label">
                <span>审核未通过（元）</span>
                <el-tooltip effect="light" placement="top">
                  <div slot="content">
                    审核未通过订单金额总和，不可重新申请结算
                  </div>
                  <i class="el-icon-question help-icon"></i>
                </el-tooltip>
              </p>
              <p class="data-num">{{ finish.not.not }}</p>
              <p class="data-subval">订单数：{{ finish.not.num }}</p>
            </div>

            <div class="data-item"></div>
            <div class="data-item"></div>
            <div class="data-item"></div>
            <div class="data-item"></div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { getMerchantWithdraw } from "@/api/Merchants";
  export default {
    name: "SettlementData",
    data() {
      return {
        is_reset: false,
        now_date: "",
        balance: {}, //可提现
        audit: {}, //审核中
        finish: {}, //已结算
      };
    },
    created() {
      this.now_date = this.$_common.formatDate(
        new Date().getTime(),
        "yyyy-MM-dd hh:mm:ss"
      );
      this.getMerchantWithdraw();
    },
    methods: {
      resetData() {
        this.is_reset = true;
        this.getMerchantWithdraw();
      },
      async getMerchantWithdraw() {
        const data = await getMerchantWithdraw();
        this.now_date = this.$_common.formatDate(
          new Date().getTime(),
          "yyyy-MM-dd hh:mm:ss"
        );
        this.is_reset = false;
        this.balance = data.data.balance;
        this.audit = data.data.audit;
        this.finish = data.data.finish;
      },
    },
  };
</script>

<style scoped lang="scss">
  .data-sec {
    flex: 1;
    position: relative;
    display: flex;

    .data-secbox {
      padding-right: 50px;
      padding-top: 10px;
      padding-bottom: 10px;
      display: flex;
      justify-content: flex-start;
      .data-item {
        flex: 1;
        text-align: center;
        .data-label {
          font-size: 14px;
          color: #666;
          line-height: 16px;
          margin-bottom: 24px;
          font-weight: 700;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;
          .help-icon {
            color: #999999;
            margin-left: 5px;
          }
        }
        .data-num {
          font-size: 30px;
          line-height: 30px;
          color: #333;
          font-weight: 700;
        }
        .data-btn {
          margin-top: 10px;
        }
        .data-subval {
          font-size: 12px;
          color: #666;
          line-height: 40px;
        }
      }

      &.sec-left {
        width: 250px;
        border-right: 1px solid #f2f2f2;
      }
      &.sec-right {
        padding-left: 50px;
        flex: 1;
        .data-item {
          flex: 5;
        }
      }
    }
    .sec-right {
      flex: 1;
    }
  }
  .reset-view {
    line-height: 50px;
    font-size: 12px;
  }
</style>
