<template>
  <div class="all-income">
    <template v-if="incomeList.length > 0">
      <div v-for="item in incomeList" :key="item.id" class="list-item">
        <span style="color:#333333">{{ item.yearMonth }}</span>
        <span>{{ item.income }}</span>
      </div>
    </template>
    <p v-else class="no-data">
      暂无数据~
    </p>
  </div>
</template>

<script>
import { showIncomeRecord } from "@/api/wallet";

export default {
  name: "AllIncome",
  data() {
    return {
      incomeList: []
    };
  },
  mounted() {
    this.getAllRecord();
  },
  methods: {
    getAllRecord() {
      const params = {
        userId: JSON.parse(localStorage.getItem("user")).userId
      };
      showIncomeRecord(params).then(res => {
        if (res.code === 0) {
          this.incomeList = res.data;
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.all-income {
  box-sizing: border-box;
  padding: 10px 16px;
}
.list-item {
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  margin-bottom: 10px;
  padding: 0 15px;
  font-size: 16px;
  background-color: #ffffff;
}
.no-data {
  text-align: center;
  font-size: 12px;
}
</style>
