<template>
  <view class="recharge">
    <view class="mine"> 我的余额（元） </view>
    <view class="money"> 500.00 </view>
    <view class="to-withdrawal">
      <AllRight name="去提现" :withdrawal="true" @toDetail="toWithdrawal" />
    </view>
    <view class="select-money">
      <view class="title"> 余额账户充值 </view>
      <!-- 选择充值金额 -->
      <view class="select-recharge">
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 100 }"
          @click="selectMoney(100)"
        >
          <text>￥</text>100
        </view>
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 200 }"
          @click="selectMoney(200)"
        >
          <text>￥</text>200
        </view>
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 300 }"
          @click="selectMoney(300)"
        >
          <text>￥</text>300
        </view>
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 600 }"
          @click="selectMoney(600)"
        >
          <text>￥</text>600
        </view>
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 800 }"
          @click="selectMoney(800)"
        >
          <text>￥</text>800
        </view>
        <view
          class="recharge-money"
          :class="{ 'back-red': backgroundRed == 1000 }"
          @click="selectMoney(1000)"
        >
          <text>￥</text>1000
        </view>
      </view>
      <!-- 选择充值金额 -->
      <u--input
        placeholder="输入自定义金额"
        prefixIcon="rmb"
        v-model="rmb"
        prefixIconStyle="font-size: 36rpx;color: #000;font-weight:600"
      ></u--input>

      <view class="payment">
        <view class="title"> 支付方式 </view>
        <view class="wx-pay">
          <view class="logo">
            <image
              src="../../static/mine/323.png"
              class="wx-logo"
              mode=""
            ></image>
            微信支付
          </view>
        </view>
      </view>
      <button class="recharge-btn" @click="recharge">充值</button>
    </view>
  </view>
</template>

<script>
import AllRight from "../mineComponent/allRight/allRight.vue";

export default {
  components: {
    AllRight,
  },
  data() {
    return {
      backgroundRed: 0,
      rmb: "",
    };
  },
  methods: {
    selectMoney(num) {
      this.backgroundRed = num;
    },
    toWithdrawal() {
      uni.navigateTo({
        url: "/pageC/withdrawal/withdrawal",
      });
    },
    //充值
    recharge() {
      let num = this.rmb == "" ? this.backgroundRed : this.rmb;
      uni.$u.http
        .post(`/api/recharge`, {
          account_type: "balance",
          amount: num,
        })
        .then((res) => {
          console.log(res);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.recharge {
  height: 100vh;
  background-color: #fff;

  .mine {
    padding-top: 63rpx;
    text-align: center;
    color: #222;
    font-size: 28rpx;
    border-top: 1px solid #ccc;
  }

  .money {
    font-size: 84rpx;
    text-align: center;
    color: #222;
    font-weight: 600;
    margin-top: 28rpx;
    margin-bottom: 20rpx;
  }

  .to-withdrawal {
    display: flex;
    justify-content: center;
  }

  .select-money {
    padding-top: 42rpx;
    border-top: 1px solid #ccc;
    margin: 0 auto;
    margin-top: 64rpx;
    width: 94%;

    .title {
      font-size: 32rpx;
      color: #222;
      font-weight: 500;
      margin-bottom: 36rpx;
    }

    .payment {
      margin-top: 46rpx;

      .wx-pay {
        height: 100rpx;
        background-color: #f4f4f4;
        width: 94%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20rpx;
        font-size: 32rpx;

        .logo {
          display: flex;
          align-items: center;
        }

        .wx-logo {
          width: 39rpx;
          height: 34rpx;
          margin-right: 18rpx;
        }
      }
    }

    .recharge-btn {
      background-color: #f83224;
      border-radius: 44rpx;
      color: #fff;
      margin-top: 150rpx;
    }

    .select-recharge {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;

      .recharge-money {
        width: 210rpx;
        height: 120rpx;
        border: 1px solid #f83224;
        border-radius: 16rpx;
        text-align: center;
        line-height: 120rpx;
        font-size: 40rpx;
        font-weight: 600;
        margin-bottom: 26rpx;

        text {
          font-size: 24rpx;
        }
      }

      .back-red {
        background-color: #f83224;
        color: #fff;
      }
    }
  }
}

/deep/.u-input {
  background-color: #f4f4f4;
  height: 80rpx;
}
</style>
