doum
2026-06-17 ea689dd91eaa72425dc01759042c3b4eb2186512
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<template>
 
  <view :class="['cu-page cu-bill-detail', needPayAmount > 0 ? 'cu-page--with-footer' : '']" v-if="bill">
 
    <view :class="['cu-bill-detail-hero', heroClass]">
 
      <view class="cu-bill-detail-hero__bg" />
 
      <view class="cu-bill-detail-hero__content">
 
        <view class="cu-bill-detail-hero__top">
 
          <view>
 
            <text class="cu-bill-detail-hero__type">{{ costTypeText(bill.costType) }}</text>
 
            <view class="cu-bill-detail-hero__code">{{ bill.code }}</view>
 
          </view>
 
          <text class="cu-bill-detail-hero__status">{{ payText(bill.payStatus) }}</text>
 
        </view>
 
 
 
        <view class="cu-bill-detail-hero__amount-wrap">
 
          <text class="cu-bill-detail-hero__amount-label">{{ needPayAmount > 0 ? '需付金额' : '应付金额' }}</text>
 
          <text class="cu-bill-detail-hero__amount">
 
            ¥{{ formatMoney(needPayAmount > 0 ? needPayAmount : bill.receivableFee) }}
 
          </text>
 
          <text v-if="bill.planPayDate" class="cu-bill-detail-hero__due">应付日期 {{ bill.planPayDate }}</text>
 
        </view>
 
      </view>
 
    </view>
 
 
 
    <view class="cu-bill-stat-row">
 
      <view class="cu-bill-stat">
 
        <text class="cu-bill-stat__label">应付金额</text>
 
        <text class="cu-bill-stat__value cu-bill-stat__value--danger">¥{{ formatMoney(bill.receivableFee) }}</text>
 
      </view>
 
      <view class="cu-bill-stat">
 
        <text class="cu-bill-stat__label">实付金额</text>
 
        <text class="cu-bill-stat__value">¥{{ formatMoney(paidAmount) }}</text>
 
      </view>
 
      <view class="cu-bill-stat">
 
        <text class="cu-bill-stat__label">需付金额</text>
 
        <text :class="['cu-bill-stat__value', needPayAmount > 0 ? 'cu-bill-stat__value--danger' : '']">
 
          ¥{{ formatMoney(needPayAmount) }}
 
        </text>
 
      </view>
 
    </view>
 
 
 
    <view class="cu-panel cu-bill-panel">
 
      <view class="cu-panel__title">关联合同</view>
 
      <view class="cu-bill-info-grid">
 
        <view class="cu-bill-info-item">
 
          <text class="cu-bill-info-item__label">合同编号</text>
 
          <text class="cu-bill-info-item__value">{{ bill.contractCode || '-' }}</text>
 
        </view>
 
        <view class="cu-bill-info-item cu-bill-info-item--full">
 
          <text class="cu-bill-info-item__label">合同有效期</text>
 
          <text class="cu-bill-info-item__value">{{ contractPeriod(bill) }}</text>
 
        </view>
 
      </view>
 
    </view>
 
    <view class="cu-panel cu-bill-panel">
      <view class="cu-panel__title">房源信息</view>
      <view v-if="bill.roomList && bill.roomList.length" class="cu-room-list">
        <view v-for="(room, idx) in bill.roomList" :key="idx" class="cu-room-item">
          <text class="cu-room-item__name">{{ formatRoomLine(room) }}</text>
          <text class="cu-room-item__area">{{ formatArea(room.rentArea) }}</text>
        </view>
      </view>
      <view v-else class="cu-bill-info-grid">
        <view class="cu-bill-info-item cu-bill-info-item--full">
          <text class="cu-bill-info-item__value cu-kv__value--muted">{{ bill.roomInfo || '暂无房源信息' }}</text>
        </view>
      </view>
    </view>
 
    <view class="cu-panel cu-bill-panel">
      <view class="cu-panel__title">账单信息</view>
 
      <view class="cu-bill-info-grid">
 
        <view class="cu-bill-info-item">
 
          <text class="cu-bill-info-item__label">费用类型</text>
 
          <text class="cu-bill-info-item__value">{{ costTypeText(bill.costType) }}</text>
 
        </view>
 
        <view class="cu-bill-info-item">
 
          <text class="cu-bill-info-item__label">支付状态</text>
 
          <text class="cu-bill-info-item__value">{{ payText(bill.payStatus) }}</text>
 
        </view>
 
        <view class="cu-bill-info-item cu-bill-info-item--full">
 
          <text class="cu-bill-info-item__label">计费周期</text>
 
          <text class="cu-bill-info-item__value">{{ bill.startDate }} ~ {{ bill.endDate }}</text>
 
        </view>
 
      </view>
 
    </view>
 
 
 
    <view class="cu-panel cu-bill-panel">
      <view class="cu-panel__title">收支流水</view>
      <view v-if="revenues.length" class="cu-revenue-list">
        <view v-for="r in revenues" :key="r.id" class="cu-revenue-card">
          <view class="cu-revenue-card__head">
            <text :class="['cu-revenue-card__type', r.revenueType === 0 ? 'cu-revenue-card__type--out' : '']">
              {{ revenueTypeText(r.revenueType) }}
            </text>
            <text class="cu-revenue-card__amount">¥{{ formatMoney(r.actReceivableFee) }}</text>
          </view>
          <view class="cu-revenue-card__row">
            <text class="cu-revenue-card__label">付款方</text>
            <text class="cu-revenue-card__value">{{ r.customerName || '-' }}</text>
          </view>
          <view class="cu-revenue-card__row">
            <text class="cu-revenue-card__label">收款方式</text>
            <text class="cu-revenue-card__value">{{ payTypeText(r.payType) }}</text>
          </view>
          <view class="cu-revenue-card__row">
            <text class="cu-revenue-card__label">入账日期</text>
            <text class="cu-revenue-card__value">{{ formatDate(r.actPayDate) || '-' }}</text>
          </view>
          <view class="cu-revenue-card__row">
            <text class="cu-revenue-card__label">创建时间</text>
            <text class="cu-revenue-card__value">{{ formatTime(r.createDate) }}</text>
          </view>
          <view v-if="r.remark" class="cu-revenue-card__row">
            <text class="cu-revenue-card__label">备注</text>
            <text class="cu-revenue-card__value">{{ r.remark }}</text>
          </view>
        </view>
      </view>
      <view v-else class="cu-bill-empty-record cu-bill-empty-record--inset">
        <text class="cu-bill-empty-record__icon">📋</text>
        <text class="cu-bill-empty-record__text">暂无收支流水</text>
      </view>
    </view>
 
 
 
    <view v-if="needPayAmount > 0" class="cu-page-footer cu-bill-detail-footer">
 
      <view class="cu-bill-detail-footer__info">
 
        <text class="cu-bill-detail-footer__label">待支付</text>
 
        <text class="cu-bill-detail-footer__amount">¥{{ formatMoney(needPayAmount) }}</text>
 
      </view>
 
      <view class="cu-btn cu-btn--primary cu-bill-detail-footer__btn" @click="goPay">立即缴费</view>
 
    </view>
 
  </view>
 
</template>
 
 
 
<script>
 
import { customerBillDetail } from '@/api'
 
 
 
const COST_TYPE_MAP = {
 
  0: '租赁费',
 
  1: '物业费',
 
  2: '租赁押金',
 
  3: '物业押金',
 
  4: '水电费',
 
  5: '杂项费',
 
  6: '其他',
 
  7: '保证金'
 
}
 
 
 
export default {
 
  data () { return { id: null, bill: null, revenues: [], paidAmount: 0, needPayAmount: 0 } },
 
  computed: {
 
    heroClass () {
 
      if (!this.bill) return ''
 
      if (this.bill.payStatus === 1) return 'cu-bill-detail-hero--ok'
 
      if (this.needPayAmount > 0) return 'cu-bill-detail-hero--warn'
 
      return ''
 
    }
 
  },
 
  onLoad (q) { this.id = q.id; this.load() },
 
  methods: {
 
    load () {
 
      customerBillDetail(this.id).then(res => {
        this.bill = res.data.bill
        this.revenues = res.data.revenues || (res.data.bill && res.data.bill.ywContractRevenueList) || []
        this.paidAmount = res.data.paidAmount != null ? res.data.paidAmount : (res.data.bill && res.data.bill.actReceivableFee)
        this.needPayAmount = res.data.needPayAmount != null ? res.data.needPayAmount : (res.data.bill && res.data.bill.needReceivableFee)
      })
 
    },
 
    costTypeText (type) { return COST_TYPE_MAP[type] || '账单' },
 
    formatMoney (val) {
 
      if (val === null || val === undefined || val === '') return '0.00'
 
      return Number(val).toFixed(2)
 
    },
 
    formatTime (t) { return t ? String(t).replace('T', ' ').substring(0, 19) : '-' },
 
    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)
    },
    formatArea (area) {
      if (area === null || area === undefined || area === '') return '-'
      return `${area}㎡`
    },
    formatRoomLine (room) {
      if (!room) return '-'
      const parts = [room.projectName, room.buildingName, room.floorName, room.roomNum].filter(Boolean)
      return parts.length ? parts.join('/') : '-'
    },
    revenueTypeText (type) {
      if (type === 1) return '收款'
      return '付款'
    },
    payTypeText (type) {
      const map = { 0: '现金', 1: '网银转账', 2: 'POS机', 3: '支付宝', 4: '微信', 5: '转账支票', 6: '其他' }
      return map[type] || '-'
    },
    payText (s) { return { 0: '待支付', 1: '已支付', 2: '部分支付' }[s] || '-' },
 
    goPay () { uni.navigateTo({ url: `/pages/customer/bill/pay?id=${this.id}&amount=${this.needPayAmount}` }) }
 
  }
 
}
 
</script>