refund-detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="detail-container">
  3. <!-- 状态卡片 -->
  4. <view class="status-card">
  5. <text class="status-text" :style="{ color: statusColor }">{{ fmtDictName('RefundLog.status', detail.status) }}</text>
  6. <text class="status-amount">¥{{ formatAmount(detail.refund) }}</text>
  7. <text class="status-label">退款金额</text>
  8. <button v-if="detail.status === 'NEW'" class="process-btn" :loading="processing" @click="handleProcessRefund">退款处理</button>
  9. </view>
  10. <!-- 退款信息 -->
  11. <view class="section">
  12. <view class="section-title">退款信息</view>
  13. <view class="info-card">
  14. <view class="info-row" @click="showFullText('商户退款单号', detail.outRefundNo)">
  15. <text class="info-label">商户退款单号</text>
  16. <text class="info-value">{{ detail.outRefundNo || '-' }}</text>
  17. </view>
  18. <view class="info-row" @click="showFullText('商户订单号', detail.outTradeNo)">
  19. <text class="info-label">商户订单号</text>
  20. <text class="info-value">{{ detail.outTradeNo || '-' }}</text>
  21. </view>
  22. <view class="info-row" @click="showFullText('微信支付订单号', detail.transactionId)">
  23. <text class="info-label">微信支付订单号</text>
  24. <text class="info-value">{{ detail.transactionId || '-' }}</text>
  25. </view>
  26. <view class="info-row" @click="showFullText('微信退款单号', detail.refundId)">
  27. <text class="info-label">微信退款单号</text>
  28. <text class="info-value">{{ detail.refundId || '-' }}</text>
  29. </view>
  30. <view class="info-row">
  31. <text class="info-label">退款原因</text>
  32. <text class="info-value info-value-wrap">{{ detail.reason || '-' }}</text>
  33. </view>
  34. <view class="info-row">
  35. <text class="info-label">退款渠道</text>
  36. <text class="info-value">{{ detail.channel || '-' }}</text>
  37. </view>
  38. <view class="info-row">
  39. <text class="info-label">退款入账账户</text>
  40. <text class="info-value">{{ detail.userReceivedAccount || '-' }}</text>
  41. </view>
  42. <view class="info-row">
  43. <text class="info-label">资金账户</text>
  44. <text class="info-value">{{ detail.fundsAccount || '-' }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 金额信息 -->
  49. <view class="section">
  50. <view class="section-title">金额明细</view>
  51. <view class="info-card">
  52. <view class="info-row">
  53. <text class="info-label">原充值金额</text>
  54. <text class="info-value amount">¥{{ formatAmount(detail.total) }}</text>
  55. </view>
  56. <view class="info-row">
  57. <text class="info-label">退款金额</text>
  58. <text class="info-value amount-refund">¥{{ formatAmount(detail.refund) }}</text>
  59. </view>
  60. <view class="info-row">
  61. <text class="info-label">不可退优惠金额</text>
  62. <text class="info-value">{{ formatAmount(detail.discountAmount) }}</text>
  63. </view>
  64. <view class="info-row">
  65. <text class="info-label">币种</text>
  66. <text class="info-value">{{ detail.currency || 'CNY' }}</text>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 操作信息 -->
  71. <view class="section">
  72. <view class="section-title">操作信息</view>
  73. <view class="info-card">
  74. <view class="info-row">
  75. <text class="info-label">退款人</text>
  76. <text class="info-value">{{ detail.adminUsername || '-' }}</text>
  77. </view>
  78. <view class="info-row">
  79. <text class="info-label">申请时间</text>
  80. <text class="info-value">{{ formatTime(detail.createTime) }}</text>
  81. </view>
  82. <view class="info-row">
  83. <text class="info-label">退款成功时间</text>
  84. <text class="info-value">{{ detail.successTime ? formatTime(detail.successTime) : '-' }}</text>
  85. </view>
  86. <view class="info-row">
  87. <text class="info-label">更新时间</text>
  88. <text class="info-value">{{ detail.updateTime ? formatTime(detail.updateTime) : '-' }}</text>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 加载状态 -->
  93. <view class="loading-state" v-if="loading">
  94. <view class="loading-spinner"></view>
  95. <text class="loading-text">加载中...</text>
  96. </view>
  97. </view>
  98. </template>
  99. <script setup>
  100. import { ref, onMounted, computed } from 'vue'
  101. import { onLoad } from '@dcloudio/uni-app'
  102. import { getRefundDetail, processRefund } from '../../api/finance.js'
  103. import { formatTime, showToast, formatAmount, fmtDictName, getDictColor } from '../../utils/index.js'
  104. import { loadDicts } from '../../utils/dict.js'
  105. const detail = ref({})
  106. const loading = ref(true)
  107. const processing = ref(false)
  108. const statusColor = computed(() => {
  109. return getDictColor('RefundLog.status', detail.value.status) || '#666666'
  110. })
  111. const showFullText = (label, value) => {
  112. if (!value) return
  113. uni.showModal({
  114. title: label,
  115. content: value,
  116. showCancel: false,
  117. confirmText: '关闭'
  118. })
  119. }
  120. const handleProcessRefund = () => {
  121. const refundLogId = detail.value.id
  122. if (!refundLogId) {
  123. showToast('退款记录ID不存在')
  124. return
  125. }
  126. uni.showModal({
  127. title: '确认退款',
  128. content: `确定对该笔退款进行处理吗?`,
  129. success: async (res) => {
  130. if (res.confirm) {
  131. processing.value = true
  132. try {
  133. const result = await processRefund(refundLogId)
  134. if (result && result.code === 200) {
  135. showToast('退款处理成功', 'success')
  136. loadDetail(detail.value.outRefundNo)
  137. } else {
  138. showToast(result?.msg || '退款处理失败')
  139. }
  140. } catch (error) {
  141. showToast('退款处理失败')
  142. } finally {
  143. processing.value = false
  144. }
  145. }
  146. }
  147. })
  148. }
  149. const loadDetail = async (outRefundNo) => {
  150. loading.value = true
  151. try {
  152. const res = await getRefundDetail(outRefundNo)
  153. if (res && res.code === 200) {
  154. detail.value = res.data || {}
  155. } else {
  156. showToast(res?.msg || '加载退款详情失败')
  157. }
  158. } catch (error) {
  159. showToast('加载退款详情失败')
  160. } finally {
  161. loading.value = false
  162. }
  163. }
  164. onLoad((options) => {
  165. if (options && options.outRefundNo) {
  166. loadDetail(options.outRefundNo)
  167. }
  168. })
  169. onMounted(async () => {
  170. await loadDicts()
  171. })
  172. </script>
  173. <style scoped>
  174. .detail-container {
  175. min-height: 100vh;
  176. background-color: #F5F7FA;
  177. padding-bottom: 40rpx;
  178. }
  179. .status-card {
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. padding: 48rpx 30rpx;
  184. background-color: #FFFFFF;
  185. margin-bottom: 20rpx;
  186. }
  187. .status-text {
  188. font-size: 32rpx;
  189. font-weight: 600;
  190. margin-bottom: 16rpx;
  191. }
  192. .status-amount {
  193. font-size: 56rpx;
  194. font-weight: 700;
  195. color: #1A1A1A;
  196. margin-bottom: 8rpx;
  197. }
  198. .status-label {
  199. font-size: 24rpx;
  200. color: #999999;
  201. margin-bottom: 24rpx;
  202. }
  203. .process-btn {
  204. padding: 16rpx 60rpx;
  205. background: #C6171E;
  206. color: #FFFFFF;
  207. border-radius: 44rpx;
  208. font-size: 28rpx;
  209. border: none;
  210. font-weight: 500;
  211. }
  212. .process-btn:active {
  213. background: #A81212;
  214. transform: scale(0.97);
  215. }
  216. .section {
  217. padding: 0 20rpx;
  218. margin-bottom: 20rpx;
  219. }
  220. .section-title {
  221. font-size: 26rpx;
  222. color: #999999;
  223. padding: 16rpx 10rpx 12rpx;
  224. }
  225. .info-card {
  226. background-color: #FFFFFF;
  227. border-radius: 24rpx;
  228. padding: 8rpx 24rpx;
  229. box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  230. }
  231. .info-row {
  232. display: flex;
  233. justify-content: space-between;
  234. align-items: center;
  235. padding: 20rpx 0;
  236. border-bottom: 1rpx solid #F5F5F5;
  237. }
  238. .info-row:last-child {
  239. border-bottom: none;
  240. }
  241. .info-label {
  242. font-size: 26rpx;
  243. color: #999999;
  244. flex-shrink: 0;
  245. }
  246. .info-value {
  247. font-size: 26rpx;
  248. color: #1A1A1A;
  249. max-width: 420rpx;
  250. text-align: right;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. .info-value-wrap {
  256. white-space: normal;
  257. word-break: break-all;
  258. text-overflow: clip;
  259. }
  260. .info-value.amount {
  261. color: #C6171E;
  262. font-weight: 500;
  263. }
  264. .info-value.amount-refund {
  265. color: #52C41A;
  266. font-weight: 500;
  267. }
  268. .loading-state {
  269. display: flex;
  270. flex-direction: column;
  271. align-items: center;
  272. padding: 80rpx 0;
  273. }
  274. .loading-spinner {
  275. width: 60rpx;
  276. height: 60rpx;
  277. border: 4rpx solid rgba(0, 0, 0, 0.1);
  278. border-top-color: #C6171E;
  279. border-radius: 50%;
  280. animation: spin 0.8s linear infinite;
  281. }
  282. @keyframes spin {
  283. to { transform: rotate(360deg); }
  284. }
  285. .loading-text {
  286. font-size: 28rpx;
  287. color: #999999;
  288. margin-top: 16rpx;
  289. }
  290. </style>