<template>
  <BasePage>
    <div class="cv">
      <div class="top">
        <div class="line">
          <span class="title">
            当前贡献值统计
          </span>
          <div class="explain" @click="showTerm = true">
            <img src="/img/explain.png" alt="">
            贡献值说明
          </div>
        </div>

        <b>
          {{ (data.gongxianzhi + data.maxgongxianzhi + data.othersgongxianzhi)?.toFixed(2) }}
        </b>
      </div>

      <div class="container">
        <div class="inf_box">
          <span class="title">
            团队贡献值构成
          </span>

          <div class="list">
            <div>
              <img src="/img/cv-i1.png" alt="">
              <span>个人贡献值累计</span>
              <b>{{ (data.gongxianzhi)?.toFixed(2) }}</b>
            </div>

            <div>
              <img src="/img/cv-i2.png" alt="">
              <span>网体大部门贡献值累计</span>
              <b>{{ (data.maxgongxianzhi)?.toFixed(2) }}</b>
            </div>

            <div>
              <img src="/img/cv-i3.png" alt="">
              <span>网体其他部门贡献值累计</span>
              <b>{{ (data.othersgongxianzhi)?.toFixed(2) }}</b>
            </div>
          </div>
        </div>
      </div>
    </div>
  </BasePage>


  <van-action-sheet v-model:show="showTerm" safe-area-inset-bottom :title="`贡献值说明`" closeable
    style="min-height: 50%; padding: 0px 10px 10px 10px">
    <div class="w100 html" v-html="data.Term" />
  </van-action-sheet>
</template>

<script>
export default {
  name: 'Point',
  mounted() {
    this.getCVList();
  },
  data() {
    return {
      data: {
        total: {
          Balance: 3680.50,
          TotalBalance: 10000.00,
          MonthBalance: 1250.00,
          MonthReduceBalance: 569.50,
        },
        Term: '贡献值说明：贡献值可用于升级会员、兑换礼品等。',
      },
      date: [`${new Date().getFullYear()}`, `${new Date().getMonth() + 1}`],
      currentDate: [`${new Date().getFullYear()}`, `${new Date().getMonth() + 1}`],
      show: false,
      showDate: false,
      searchParams: {
        WalletType: this.$route.query.type || 'CV',
        RecordSource: '',
        Year: new Date().getFullYear(),
        Month: new Date().getMonth() + 1,
      },
      loading: false,
      showTerm: false,
      list: [
        {
          CurValue: 200.00,
          OpeType: '1',
          RecordValue: 200.00,
          Remark: '完成任务奖励',
          TradeCode: 'CV202604200001',
          CTime: '2026-04-20 10:00:00',
        },
        {
          CurValue: 80.00,
          OpeType: '1',
          RecordValue: 80.00,
          Remark: '邀请新用户贡献',
          TradeCode: 'CV202604200002',
          CTime: '2026-04-20 11:30:00',
        },
        {
          CurValue: 150.00,
          OpeType: '2',
          RecordValue: 150.00,
          Remark: '兑换礼品',
          TradeCode: 'CV202604190001',
          CTime: '2026-04-19 14:00:00',
        },
        {
          CurValue: 50.00,
          OpeType: '1',
          RecordValue: 50.00,
          Remark: '每日签到奖励',
          TradeCode: 'CV202604190002',
          CTime: '2026-04-19 09:00:00',
        },
        {
          CurValue: 300.00,
          OpeType: '1',
          RecordValue: 300.00,
          Remark: '团队业绩奖励',
          TradeCode: 'CV202604180001',
          CTime: '2026-04-18 16:30:00',
        },
      ],
    }
  },
  methods: {
    getCVList() {
      this.$get('/v1/client/DUsergongxianzhisClient/statistics').then(data => {
        // this.list = data.data.items;
        this.data = data.data;
        // console.log(data);

      }).catch(err => {
        this.$showFailToast(err.message || '加载失败');
      });
    },
    onconfirm(value) {
      this.date = this.currentDate;
      this.showDate = false;
      this.searchParams.Year = Number.parseInt(this.currentDate[0]);
      this.searchParams.Month = Number.parseInt(this.currentDate[1]);
    },
    changeTabs(e) {
      this.show = false;
    },
    onShowTerm() {
      this.showTerm = true;
    }
  }
}
</script>