1
admin
2026-01-13 95e138158db3e61e0be67691a4142f20c561634c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
  <div class="money-record">
    <van-nav-bar
      :placeholder="true"
      :safe-area-inset-top="true"
      :title="$t('资金记录')"
      left-arrow
      @click-left="$router.go(-1)"
    />
 
    <div class="record-list" v-if="recordList.length > 0">
      <div class="record-item" v-for="(item, index) in recordList" :key="index">
        <div class="item-header">
          <div class="item-type">{{ $t(item.type) }}</div>
          <div class="item-amount" :class="{ 'positive': parseFloat(item.amount) > 0, 'negative': parseFloat(item.amount) < 0 }">
            {{ item.amount > 0 ? '+' : '' }}{{ item.amount }}
          </div>
        </div>
        <div class="item-time">{{ formatTime(item.createTime) }}</div>
      </div>
    </div>
 
    <div class="empty-state" v-else>
      <van-empty :description="$t('zwsj')" />
    </div>
  </div>
</template>
 
<script>
import * as api from "@/axios/api";
import { Toast } from "vant";
 
export default {
  name: "moneyRecord",
  data() {
    return {
      recordList: [],
      loading: false
    };
  },
  mounted() {
    this.getMoneyRecord();
  },
  methods: {
    async getMoneyRecord() {
      if (this.loading) return;
      this.loading = true;
      try {
        const result = await api.moneylogAll({
          userId: this.$store.state.userInfo.id,
          pageSize: 9999
        });
        if (result.status === 0) {
          this.recordList = result.data.records || [];
        } else {
          Toast(result.msg || this.$t("获取数据失败"));
        }
      } catch (error) {
        Toast(this.$t("获取数据失败"));
      } finally {
        this.loading = false;
      }
    },
    formatTime(time) {
      if (!time) return "";
      return this.$moment(time).format("YYYY-MM-DD HH:mm:ss");
    }
  }
};
</script>
 
<style lang="less" scoped>
@green: #c4d600;
@red: #ee0a24;
@dark_green: #07c160;
 
.money-record {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
  font-size: 10vw;
  padding-bottom: 0.4rem;
 
  .record-list {
    padding: 0.2rem 0.25rem;
  }
 
  .record-item {
    background-color: #fff;
    border-radius: 0.2rem;
    padding: 0.4rem;
    margin-bottom: 0.2rem;
    box-shadow: 0 0.05rem 0.1rem rgba(0, 0, 0, 0.05);
 
    .item-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.2rem;
 
      .item-type {
        font-size: 0.42rem;
        color: #333;
        font-weight: 500;
        flex: 1;
      }
 
      .item-amount {
        font-size: 0.48rem;
        font-weight: 600;
        font-family: "DINPro", serif;
 
        &.positive {
          color: @dark_green;
        }
 
        &.negative {
          color: @red;
        }
      }
    }
 
    .item-time {
      font-size: 0.35rem;
      color: #999;
    }
  }
 
  .empty-state {
    padding-top: 2rem;
  }
}
 
/deep/ .van-nav-bar__content {
  height: 65px;
}
 
/deep/ .van-nav-bar__title {
  font-family: "DINPro";
  width: 100%;
  height: 1.17333rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-style: normal;
  font-weight: 500;
  font-size: 0.48rem;
  color: #14181f;
}
</style>