106 lines
3.4 KiB
Vue
106 lines
3.4 KiB
Vue
<template>
|
|
<view class="bill-page tn-safe-area-inset-bottom">
|
|
<tn-nav-bar :isBack="true" :bottomShadow="false" backgroundColor="transparent">
|
|
<view class="tn-text-bold tn-text-xl tn-color-black">{{ $tr('账单管理') }}</view>
|
|
</tn-nav-bar>
|
|
|
|
<view class="bill-body tn-padding" :style="{ paddingTop: vuex_custom_bar_height + 'px', paddingBottom: '48rpx' }">
|
|
<current-application-bill-panel
|
|
ref="billPanel"
|
|
:reference-type-no="referenceTypeNo"
|
|
:auto-resolve-reference="!pendingBillNo || !!referenceTypeNo"
|
|
@reference-resolved="handleReferenceResolved"
|
|
@all-paid="handleAllPaid"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { accountQueryBill } from '@/api/index.js'
|
|
import { fetchEnums } from '@/utils/enum-store.js'
|
|
import { saveActiveApplicationCode, saveHomePageTabId } from '@/utils/app-state'
|
|
import CurrentApplicationBillPanel from '../components/CurrentApplicationBillPanel.vue'
|
|
|
|
export default {
|
|
components: {
|
|
CurrentApplicationBillPanel
|
|
},
|
|
data() {
|
|
return {
|
|
referenceTypeNo: '',
|
|
pendingBillNo: ''
|
|
}
|
|
},
|
|
async onLoad(options) {
|
|
await fetchEnums(false, this.$getLanguage())
|
|
this.referenceTypeNo = options && options.referenceTypeNo ? decodeURIComponent(options.referenceTypeNo) : ''
|
|
this.pendingBillNo = options && options.billNo ? decodeURIComponent(options.billNo) : ''
|
|
if (!this.referenceTypeNo && this.pendingBillNo) {
|
|
await this.resolveReferenceTypeNoByBillNo(this.pendingBillNo)
|
|
}
|
|
if (this.referenceTypeNo) {
|
|
saveActiveApplicationCode(this.referenceTypeNo)
|
|
}
|
|
},
|
|
methods: {
|
|
extractBillDetail(response) {
|
|
const payload = response && response.data ? response.data : response
|
|
if (payload && payload.data && typeof payload.data === 'object' && !Array.isArray(payload.data)) {
|
|
return payload.data
|
|
}
|
|
return payload && typeof payload === 'object' && !Array.isArray(payload) ? payload : {}
|
|
},
|
|
async resolveReferenceTypeNoByBillNo(billNo = '') {
|
|
const currentBillNo = String(billNo || '').trim()
|
|
if (!currentBillNo) {
|
|
return ''
|
|
}
|
|
try {
|
|
const response = await accountQueryBill({ billNo: currentBillNo }, this.$getLanguage())
|
|
const detail = this.extractBillDetail(response)
|
|
const referenceTypeNo = String(
|
|
detail.referenceTypeNo
|
|
|| detail.ReferenceTypeNo
|
|
|| detail.detailCode
|
|
|| detail.applicationCode
|
|
|| ''
|
|
).trim()
|
|
if (referenceTypeNo) {
|
|
this.referenceTypeNo = referenceTypeNo
|
|
saveActiveApplicationCode(referenceTypeNo)
|
|
}
|
|
return referenceTypeNo
|
|
} catch (error) {
|
|
console.error('根据账单号解析申请单号失败', error)
|
|
return ''
|
|
}
|
|
},
|
|
handleReferenceResolved(referenceTypeNo) {
|
|
this.referenceTypeNo = referenceTypeNo || ''
|
|
if (this.referenceTypeNo) {
|
|
saveActiveApplicationCode(this.referenceTypeNo)
|
|
}
|
|
},
|
|
goStayServiceHome() {
|
|
saveHomePageTabId('stay-service')
|
|
uni.reLaunch({
|
|
url: '/pages/index/index?pageId=stay-service'
|
|
})
|
|
},
|
|
handleAllPaid() {
|
|
setTimeout(() => {
|
|
this.goStayServiceHome()
|
|
}, 800)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.bill-page {
|
|
min-height: 100vh;
|
|
background: linear-gradient(180deg, #F0F6FF 0%, #F8FAFF 100%);
|
|
}
|
|
</style>
|