|
|
/**
|
|
|
* 申请退款:弹窗收集必填理由
|
|
|
* @returns {Promise<string|null>}
|
|
|
*/
|
|
|
export function promptRefundReason() {
|
|
|
return new Promise((resolve) => {
|
|
|
uni.showModal({
|
|
|
title: '申请退款',
|
|
|
content: '',
|
|
|
editable: true,
|
|
|
placeholderText: '请填写退款理由(必填)',
|
|
|
confirmText: '下一步',
|
|
|
cancelText: '取消',
|
|
|
success: (r) => {
|
|
|
if (!r.confirm) {
|
|
|
resolve(null)
|
|
|
return
|
|
|
}
|
|
|
const reason = String(r.content || '').trim()
|
|
|
if (!reason) {
|
|
|
uni.showToast({ title: '请填写退款理由', icon: 'none' })
|
|
|
resolve(null)
|
|
|
return
|
|
|
}
|
|
|
resolve(reason)
|
|
|
},
|
|
|
fail: () => resolve(null)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/** 解析退款审核接口返回(uView 失败时可能为 false) */
|
|
|
export function parseApiRecord(res) {
|
|
|
if (res === false || res == null) return null
|
|
|
if (res.errcode !== undefined && res.errcode !== null && Number(res.errcode) !== 0) {
|
|
|
return null
|
|
|
}
|
|
|
if (typeof res.data !== 'undefined' && res.data !== null && res.id === undefined) {
|
|
|
return res.data
|
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
export function hasPendingRefund(item) {
|
|
|
if (!item) return false
|
|
|
if (item.has_pending_refund === true || item.has_pending_refund === 1 || item.has_pending_refund === '1') {
|
|
|
return true
|
|
|
}
|
|
|
if (item.refund_display_status === 'pending') return true
|
|
|
const pending = item.pending_accompany_order_refund || item.pendingAccompanyOrderRefund
|
|
|
if (pending && pending.id) return true
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
export function orderListStatusLabel(item, tabName) {
|
|
|
if (!item) return tabName || ''
|
|
|
if (Number(item.pay_status) === 2 || item.refund_display_status === 'refunded') {
|
|
|
return '退款成功'
|
|
|
}
|
|
|
if (hasPendingRefund(item)) {
|
|
|
return '退款审核中'
|
|
|
}
|
|
|
if (item.refund_display_status === 'rejected') {
|
|
|
return '退款已驳回'
|
|
|
}
|
|
|
return tabName || ''
|
|
|
}
|
|
|
|
|
|
export function refundStatusText(s) {
|
|
|
const n = Number(s)
|
|
|
if (n === 0) return '退款审核中'
|
|
|
if (n === 1) return '退款成功'
|
|
|
if (n === 2) return '已驳回'
|
|
|
return '—'
|
|
|
}
|
|
|
|
|
|
/** 退款管理子 Tab 文案(待审核/已退款/已驳回) */
|
|
|
export function refundManageTabText(s) {
|
|
|
const n = Number(s)
|
|
|
if (n === 0) return '待审核'
|
|
|
if (n === 1) return '已退款'
|
|
|
if (n === 2) return '已驳回'
|
|
|
return '—'
|
|
|
}
|