doum
2026-06-17 7ff92e90d2318f5c2597c4ba01e0cbfde983cec0
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<template>
 
  <view class="cu-page cu-bill-page">
 
    <view class="cu-bill-page__header">
 
      <view class="cu-tabs cu-bill-tabs">
 
        <view
 
          v-for="(t, i) in tabs"
 
          :key="i"
 
          :class="['cu-tab', tabIdx === i ? 'cu-tab--active' : '']"
 
          @click="tabIdx = i; load()"
 
        >{{ t }}</view>
 
      </view>
 
      <view class="cu-bill-summary">
 
        <text class="cu-bill-summary__count">{{ list.length }}</text>
 
        <text class="cu-bill-summary__label">笔账单</text>
 
      </view>
 
    </view>
 
 
 
    <view class="cu-list-wrap">
 
      <view
 
        v-for="item in list"
 
        :key="item.id"
 
        class="cu-bill-card"
 
        @click="goDetail(item.id)"
 
      >
 
        <view class="cu-bill-card__accent" :class="accentClass(item)" />
 
 
 
        <view class="cu-bill-card__body">
 
          <view class="cu-bill-card__head">
 
            <view class="cu-bill-card__head-main">
 
              <text class="cu-bill-card__type">{{ costTypeText(item.costType) }}</text>
 
              <text class="cu-bill-card__code">{{ item.code }}</text>
 
            </view>
 
            <text :class="['cu-status', payStatusClass(item.payStatus)]">{{ payText(item.payStatus) }}</text>
 
          </view>
 
 
 
          <view class="cu-bill-card__amount-box">
 
            <view class="cu-bill-card__amount-main">
 
              <text class="cu-bill-card__amount-label">应付金额</text>
 
              <text class="cu-bill-card__amount-value">¥{{ formatMoney(item.receivableFee) }}</text>
 
            </view>
 
            <view class="cu-bill-card__amount-side">
 
              <text class="cu-bill-card__amount-side-label">实付</text>
 
              <text class="cu-bill-card__amount-side-value">¥{{ formatMoney(item.actReceivableFee) }}</text>
 
            </view>
 
          </view>
 
 
 
          <view v-if="isOverdue(item)" class="cu-bill-card__overdue">已逾期,请尽快缴费</view>
 
 
 
          <view class="cu-bill-card__contract">
 
            <view class="cu-bill-card__contract-row">
 
              <text class="cu-bill-card__contract-label">合同编号</text>
 
              <text class="cu-bill-card__contract-value">{{ item.contractCode || '-' }}</text>
 
            </view>
 
            <view class="cu-bill-card__contract-row">
 
              <text class="cu-bill-card__contract-label">合同有效期</text>
 
              <text class="cu-bill-card__contract-value">{{ contractPeriod(item) }}</text>
 
            </view>
 
          </view>
 
 
 
          <view class="cu-bill-card__meta">
            <view class="cu-bill-card__meta-item cu-bill-card__meta-item--full">
              <text class="cu-bill-card__meta-label">计费周期</text>
              <text class="cu-bill-card__meta-value">{{ item.startDate }} ~ {{ item.endDate }}</text>
            </view>
          </view>
 
 
 
          <view class="cu-bill-card__foot">
 
            <text class="cu-bill-card__foot-hint">查看账单明细与支付记录</text>
 
            <text class="cu-bill-card__foot-link">详情 →</text>
 
          </view>
 
        </view>
 
      </view>
 
      <u-empty v-if="!list.length" text="暂无账单" margin-top="80" />
 
    </view>
 
  </view>
 
</template>
 
 
 
<script>
 
import { customerBillPage } from '@/api'
 
 
 
const COST_TYPE_MAP = {
 
  0: '租赁费',
 
  1: '物业费',
 
  2: '租赁押金',
 
  3: '物业押金',
 
  4: '水电费',
 
  5: '杂项费',
 
  6: '其他',
 
  7: '保证金'
 
}
 
 
 
export default {
 
  data () { return { list: [], tabIdx: 0, tabs: ['全部', '待支付', '已支付'] } },
 
  onShow () { this.load() },
 
  methods: {
 
    load () {
 
      const payTab = this.tabIdx === 0 ? null : (this.tabIdx === 1 ? 0 : 1)
 
      customerBillPage({ page: 1, capacity: 50, model: { payTab } })
 
        .then(res => { this.list = (res.data && res.data.records) || [] })
 
    },
 
    costTypeText (type) { return COST_TYPE_MAP[type] || '账单' },
 
    formatMoney (val) {
 
      if (val === null || val === undefined || val === '') return '0.00'
 
      return Number(val).toFixed(2)
 
    },
 
    payText (s) { return { 0: '待支付', 1: '已支付', 2: '部分支付' }[s] || '-' },
 
    payStatusClass (s) {
 
      if (s === 1) return 'cu-status--ok'
 
      if (s === 0) return 'cu-status--warn'
 
      return 'cu-status--muted'
 
    },
 
    accentClass (item) {
 
      if (item.payStatus === 1) return 'cu-bill-card__accent--ok'
 
      if (this.isOverdue(item)) return 'cu-bill-card__accent--danger'
 
      if (item.payStatus === 0) return 'cu-bill-card__accent--warn'
 
      return ''
 
    },
 
    isOverdue (item) {
 
      if (!item || item.payStatus === 1 || !item.planPayDate) return false
 
      const today = new Date()
 
      today.setHours(0, 0, 0, 0)
 
      const due = new Date(String(item.planPayDate).replace(/-/g, '/'))
 
      return due < today
 
    },
 
    contractPeriod (item) {
      if (!item) return '-'
      const start = this.formatDate(item.contractStartDate)
      const end = this.formatDate(item.contractEndDate)
      if (!start && !end) return '-'
      return `${start || '-'} ~ ${end || '-'}`
    },
    formatDate (val) {
      if (!val) return ''
      return String(val).replace('T', ' ').substring(0, 10)
    },
    goDetail (id) { uni.navigateTo({ url: `/pages/customer/bill/detail?id=${id}` }) }
 
  }
 
}
 
</script>