feat:财务和合同
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getBill } from '@/constants/bill-list'
|
||||
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
|
||||
import { getBillDetail } from '@/api/bill'
|
||||
import { BILL_STATUS_LABEL } from '@/constants/bill-list'
|
||||
import billPendingIcon from '@/static/icon/bill-pending.png'
|
||||
import notDueIcon from '@/static/icon/not-due.png'
|
||||
import successIcon from '@/static/icons/icon-register-success.png'
|
||||
import type { BillItem } from '@/types/bill'
|
||||
import { mapFinanceBillToItem } from '@/utils/map-bill'
|
||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||
|
||||
type PaymentMethod = 'wechat' | 'alipay'
|
||||
@@ -17,7 +18,7 @@ const paymentMethod = ref<PaymentMethod>('wechat')
|
||||
const statusLabel = computed(() => {
|
||||
if (!bill.value)
|
||||
return ''
|
||||
return PAYMENT_PLAN_STATUS_LABEL[bill.value.status] || ''
|
||||
return BILL_STATUS_LABEL[bill.value.status] || ''
|
||||
})
|
||||
|
||||
const heroIcon = computed(() => {
|
||||
@@ -33,8 +34,13 @@ const heroIcon = computed(() => {
|
||||
const paymentMethodLabel = computed(() => {
|
||||
if (!bill.value)
|
||||
return ''
|
||||
if (bill.value.status === 'paid')
|
||||
return paymentMethod.value === 'wechat' ? '微信支付' : '支付宝'
|
||||
if (bill.value.status === 'paid') {
|
||||
if (bill.value.paidMethod === 'alipay' || paymentMethod.value === 'alipay')
|
||||
return '支付宝'
|
||||
if (bill.value.paidMethod === 'wechat' || paymentMethod.value === 'wechat')
|
||||
return '微信支付'
|
||||
return bill.value.payChannel || '--'
|
||||
}
|
||||
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
||||
return '微信支付'
|
||||
return '--'
|
||||
@@ -46,13 +52,15 @@ const paymentTime = computed(() => {
|
||||
if (bill.value.paidAt)
|
||||
return bill.value.paidAt
|
||||
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
||||
return '2026-01-21 15:00:00'
|
||||
return bill.value.dueDate || '--'
|
||||
return '--'
|
||||
})
|
||||
|
||||
const orderCardTitle = computed(() => {
|
||||
if (bill.value?.status === 'paid' || bill.value?.status === 'pending')
|
||||
if (bill.value?.status === 'paid')
|
||||
return '已支付订单'
|
||||
if (bill.value?.status === 'pending')
|
||||
return '待支付订单'
|
||||
if (bill.value?.status === 'not_due')
|
||||
return '账单订单'
|
||||
return '账单订单'
|
||||
@@ -65,17 +73,33 @@ const showPaymentInfo = computed(() =>
|
||||
)
|
||||
|
||||
const showPayFooter = computed(() => bill.value?.status === 'pending')
|
||||
const showRefundFooter = computed(() => bill.value?.status === 'paid')
|
||||
const showFooter = computed(() => showPayFooter.value || showRefundFooter.value)
|
||||
|
||||
onLoad((options) => {
|
||||
const projectId = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
|
||||
const planId = options?.planId ? decodeURIComponent(String(options.planId)) : '1'
|
||||
onLoad(async (options) => {
|
||||
const id = options?.id
|
||||
? decodeURIComponent(String(options.id))
|
||||
: (options?.planId ? decodeURIComponent(String(options.planId)) : '')
|
||||
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
|
||||
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
|
||||
bill.value = getBill(projectId, planId)
|
||||
|
||||
if (!bill.value) {
|
||||
if (!id) {
|
||||
uni.showToast({ title: '账单不存在', icon: 'none' })
|
||||
setTimeout(() => uni.navigateBack(), 1500)
|
||||
return
|
||||
}
|
||||
|
||||
uni.showLoading({ title: '加载中...', mask: true })
|
||||
try {
|
||||
const vo = await getBillDetail(id)
|
||||
bill.value = mapFinanceBillToItem(vo)
|
||||
}
|
||||
catch {
|
||||
bill.value = null
|
||||
setTimeout(() => uni.navigateBack(), 1200)
|
||||
}
|
||||
finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -84,7 +108,7 @@ function handleBack() {
|
||||
}
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
return `¥ ${amount}`
|
||||
return `¥ ${Number(amount || 0).toFixed(2)}`
|
||||
}
|
||||
|
||||
function handlePayNow() {
|
||||
@@ -92,7 +116,16 @@ function handlePayNow() {
|
||||
return
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}`,
|
||||
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}&billId=${encodeURIComponent(bill.value.id)}`,
|
||||
})
|
||||
}
|
||||
|
||||
function handleApplyRefund() {
|
||||
if (!bill.value)
|
||||
return
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/project-center/refund-apply/index?billId=${encodeURIComponent(bill.value.id)}`,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -101,7 +134,7 @@ function handlePayNow() {
|
||||
<view
|
||||
v-if="bill"
|
||||
class="bill-detail"
|
||||
:class="{ 'bill-detail--with-footer': showPayFooter }"
|
||||
:class="{ 'bill-detail--with-footer': showFooter }"
|
||||
>
|
||||
<view class="bill-detail__navbar">
|
||||
<view
|
||||
@@ -203,15 +236,23 @@ function handlePayNow() {
|
||||
</scroll-view>
|
||||
|
||||
<view
|
||||
v-if="showPayFooter"
|
||||
v-if="showFooter"
|
||||
class="bill-detail__footer"
|
||||
>
|
||||
<view
|
||||
v-if="showPayFooter"
|
||||
class="bill-detail__pay-btn"
|
||||
@tap="handlePayNow"
|
||||
>
|
||||
立即支付
|
||||
</view>
|
||||
<view
|
||||
v-if="showRefundFooter"
|
||||
class="bill-detail__pay-btn bill-detail__pay-btn--ghost"
|
||||
@tap="handleApplyRefund"
|
||||
>
|
||||
申请退款
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user