<template>
  <view class="myAccount">
    <capsule :showBorder="true" bgColor="#FF7451">
      <template v-slot:top>
        <view class="shop-top">
          <view class="back-icon" @click="backClick">
            <tui-icon name="arrowleft" :size="32" color="#FFFFFF"></tui-icon>
          </view>
          <view class="shop-name">我的账户</view>
        </view>
      </template>
    </capsule>
    <view class="seat"></view>
    <view class="acction-turnover">
      <view class="turnover-box">
        <view class="turnover-price">
          <text>营业额</text>
          <text>{{ myPriceInfo.turnover }}</text>
        </view>
        <view class="price-box">
          <view class="box-item">
            <text>途中金额</text>
            <text>{{ myPriceInfo.wayAmount }}</text>
          </view>
          <view class="box-item">
            <text>已到账金额（元）</text>
            <text>{{ myPriceInfo.theAmountReceived }}</text>
          </view>
        </view>
        <view class="price-detailed">
          <text>收入明细</text>
          <view class="goSee">
            <text>去查看</text>
            <tui-icon
              name="arrowright"
              color="rgba(0, 0, 0, 0.4)"
              :size="18"
            ></tui-icon>
          </view>
        </view>
      </view>
    </view>
    <view class="my-wallet">
      <view class="wallet-header">
        <view class="wallet-title">我的钱包</view>
        <view class="wallet-go">
          <text>收款账户</text>
          <tui-icon name="arrowright" color="#999999" :size="18"></tui-icon>
        </view>
      </view>
      <view class="waller-container">
        <view class="waller-all">
          <text>账户总余额</text>
          <text>{{ myPriceInfo.totalAccountBalance || 0 }}</text>
        </view>
        <view class="go-waller" @click="goTo">去提现</view>
        <view class="waller-list">
          <view class="waller-item">
            <text>可提现总余额</text>
            <text>{{ myPriceInfo.withdrawalAmount || 0 }}</text>
          </view>
          <view class="waller-item">
            <text>提现中总金额</text>
            <text>{{ myPriceInfo.withdrawalInAmount || 0 }}</text>
          </view>
        </view>
      </view>
    </view>
    <view class="box-container">
      <view
        class="acction-box"
        v-for="(item, index) in tradeAccount"
        :key="index"
      >
        <view class="box-title">{{ item.title }}</view>
        <view class="box-list" :class="item.isAct ? 'act' : ''">
          <view
            class="box-item"
            v-for="(item2, index2) in item.list"
            :key="index2"
          >
            <text>{{ item2.name }}</text>
            <text>{{ myPriceInfo[item2.price] || 0 }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { getMyAccount } from "@/config/index";
import { tradeAccount } from "./data.js";
export default {
  created() {
    this.getInfo();
  },
  data() {
    return {
      //  静态数据
      tradeAccount: tradeAccount,
      myPriceInfo: {},
    };
  },
  methods: {
    // navigateTo(`/pages_module/withdrawal/index?balance=${financialData.withdrawableMoney}&trading=${financialData.beeWithdrawal}
    async getInfo() {
      let res = await getMyAccount({});
      this.myPriceInfo = res.data;
      console.log(res);
    },
    goTo(){
      //  去提现
      this.navigateTo(`/pages_module/withdrawal/index?balance=${this.myPriceInfo.withdrawalAmount}&trading=${this.myPriceInfo.withdrawalConsumptionBalance}`);
    },
    backClick() {
      uni.navigateTo({
        delta: 1,
        //  兜底处理
        fail: () => {
          uni.switchTab({
            url: "/pages/tabbar/user/index",
          });
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>
