<template>
  <view>
    <Navbar title="余额/充值" :showRightText="true" :isBack="false" :text="'充值记录'" @clickIcon="handleRightText" />
    <div class="content">
      <div class="top-cont">
        <div>总余额(元)</div>
        <div class="acc-bal">{{ balance.accBal }}</div>
        <div class="money">
          <div class="money-item">
            <div>个人钱包</div>
            <div class="item">
              <span style="font-size: 11px">￥</span>
              {{ balance.walletBal }}
            </div>
          </div>
          <div class="money-item">
            <div>补贴钱包</div>
            <div class="item">
              <span style="font-size: 11px">￥</span>
              {{ balance.subsidyBal }}
            </div>
          </div>
        </div>
      </div>

      <div class="up">快捷充值</div>
      <div class="box">
        <div class="box-item" :class="{ active: active == 1 }" @click="handleRecharge(1)">
          <span>￥</span>
          <span>50.00</span>
          <u-icon v-if="active == 1" class="icon" name="../../static/images/active.png" size="12" />
        </div>
        <div class="box-item" :class="{ active: active == 2 }" @click="handleRecharge(2)">
          <span>￥</span>
          <span>100.00</span>
          <u-icon v-if="active == 2" class="icon" name="../../static/images/active.png" size="12" />
        </div>
        <div class="box-item" :class="{ active: active == 3 }" @click="handleRecharge(3)">
          <span>￥</span>
          <span>200.00</span>
          <u-icon v-if="active == 3" class="icon" name="../../static/images/active.png" size="12" />
        </div>
        <div class="box-item" :class="{ active: active == 4 }" @click="handleRecharge(4)">
          <span>￥</span>
          <span>300.00</span>
          <u-icon v-if="active == 4" class="icon" name="../../static/images/active.png" size="12" />
        </div>
        <div class="box-item" :class="{ active: active == 5 }" @click="handleRecharge(5)">
          <span>￥</span>
          <span>500.00</span>
          <u-icon v-if="active == 5" class="icon" name="../../static/images/active.png" size="12" />
        </div>
        <div class="box-item" :class="{ active: active == 6 }" @click="handleRecharge(6)">
          自定义
          <u-icon v-if="active == 6" class="icon" name="../../static/images/active.png" size="12" />
        </div>
      </div>

      <!-- 充值 -->
      <u-button shape="circle" color="#FF6816" @click="" style="height: 32; margin-top: 100px">立即充值</u-button>
    </div>
  </view>
</template>

<script>
import { getAccountBalance } from '@/api/dining-hall'
import uIcon from '../../uni_modules/uview-ui/components/u-icon/u-icon.vue'

export default {
  components: { uIcon },
  data() {
    return {
      // 余额
      balance: {
        accBal: '1.23', // 账户总余额
        walletBal: '1.23', // 个人钱包
        subsidyBal: '1.23' // 补贴钱包
      },
      custId: '', // 用户id
      custThirdId: '', // 用户第三方id
      active: 1,
      accTradeType: 8, // 交易类型 8微信扫码充值 9支付宝扫码充值 10现金充值
      accType: 1, // 钱包类型 1个人钱包 2补贴钱包
      rechargeAmount: 0, // 充值金额
      payChannel: '', // 支付渠道
      payType: '', // 支付方式
      thirdRechargeNum: '' // 第三方充值流水号
    }
  },
  onLoad() {},
  methods: {
    handleRightText() {
      console.log('🚀 ~ handleRightText ~ ')
      // uni.navigateTo({
      //   url: ''
      // })
    },
    // 获取余额
    async getBalance() {
      const params = {
        custId: this.custId,
        custThirdId: this.custThirdId
      }
      const res = await getAccountBalance(params)
      console.log('🚀 ~ getBalance ~ res', res)
    },
    // 充值
    handleRecharge(index) {
      this.active = index
      if (index == 1) {
        this.rechargeAmount = 50
      } else if (index == 2) {
        this.rechargeAmount = 100
      } else if (index == 3) {
        this.rechargeAmount = 200
      } else if (index == 4) {
        this.rechargeAmount = 300
      } else if (index == 5) {
        this.rechargeAmount = 500
      } else if (index == 6) {
        this.rechargeAmount = 0
      }
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  background: #fff;
}
.content {
  padding: 16px;
  .top-cont {
    padding: 16px;
    height: 190px;
    color: #fff;
    font-size: 14px;
    background: linear-gradient(134deg, #ff6816 0%, rgba(255, 104, 22, 0.2) 99%), rgba(255, 104, 22, 0.6);
    border-radius: 12px 12px 12px 12px;
    position: relative;

    .acc-bal {
      margin-top: 15px;
      font-weight: 500;
      font-size: 48px;
    }

    .money {
      display: flex;
      position: absolute;
      bottom: 16px;
      .money-item {
        margin-right: 60px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        .item {
          margin-top: 10px;
          font-size: 14px;
        }
      }
    }
  }

  .up {
    margin: 20px 0 10px;
    font-weight: 500;
    font-size: 14px;
    color: #0f274b;
    line-height: 16px;
  }
  .box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .box-item {
      margin-bottom: 12px;
      width: 30%;
      height: 66px;
      border-radius: 4px 4px 4px 4px;
      border: 1px solid rgba(15, 39, 75, 0.4);
      font-weight: 500;
      font-size: 18px;
      color: #0f274b;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      :first-child {
        font-size: 12px;
      }
      .icon {
        position: absolute;
        right: 0;
        bottom: 0;
      }
    }
    .active {
      background: rgba(255, 104, 22, 0.1);
      border: 1px solid #ff6816;
    }
  }
}
</style>
