<template>
|
<view class="cu-page cu-page--with-footer cu-page--with-fab" v-if="billId">
|
<view class="cu-detail-hero cu-detail-hero--warm">
|
<view class="cu-detail-hero__label">本次缴费</view>
|
<view class="cu-detail-hero__amount">
|
<text class="cu-detail-hero__amount-value">¥{{ amount || '0.00' }}</text>
|
</view>
|
</view>
|
|
<view class="cu-pay-amount-box">
|
<view class="cu-pay-amount-box__label">调整缴费金额</view>
|
<view class="cu-pay-amount-box__input-wrap">
|
<text class="cu-pay-amount-box__symbol">¥</text>
|
<input v-model="amount" class="cu-pay-amount-box__input" type="digit" placeholder="0.00" />
|
</view>
|
<view class="cu-pay-amount-box__remark">
|
<text class="cu-pay-amount-box__remark-label">备注</text>
|
<input v-model="remark" placeholder="选填" />
|
</view>
|
</view>
|
|
<view class="cu-page-footer">
|
<view class="cu-btn cu-btn--primary" @click="submit">确认缴费{{ amount ? ' ¥' + amount : '' }}</view>
|
</view>
|
<cu-workbench-fab />
|
</view>
|
</template>
|
|
<script>
|
import { customerBillDetail, customerPayCreate } from '@/api'
|
import { invokeWxPay } from '@/utils/wxpay.js'
|
export default {
|
data () { return { billId: null, amount: '', remark: '' } },
|
onLoad (q) {
|
this.billId = q.id
|
this.amount = q.amount || ''
|
if (!this.amount) {
|
customerBillDetail(q.id).then(res => { this.amount = String(res.data.needPayAmount || '') })
|
}
|
},
|
methods: {
|
submit () {
|
if (!this.amount) return uni.showToast({ title: '请输入金额', icon: 'none' })
|
customerPayCreate({
|
orderType: 2,
|
billId: Number(this.billId),
|
amount: Number(this.amount),
|
remark: this.remark,
|
openid: this.$store.state.openId
|
}).then(async res => {
|
try {
|
await invokeWxPay(res.data)
|
uni.redirectTo({ url: `/pages/customer/pay/result?success=1&orderNo=${res.data.orderNo}&type=bill&billId=${this.billId}` })
|
} catch (e) {
|
uni.redirectTo({ url: `/pages/customer/pay/result?success=0&orderNo=${res.data.orderNo}&type=bill` })
|
}
|
})
|
}
|
}
|
}
|
</script>
|