refund-record.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <view class="page">
  3. <u-navbar title="协商记录" :autoBack="true" :placeholder="true" :border-bottom="false"></u-navbar>
  4. <view v-if="loading" class="state-tip">加载中...</view>
  5. <view v-else-if="!hasDetail" class="state-tip">暂无协商记录</view>
  6. <scroll-view v-else class="content" scroll-y>
  7. <view class="card product-card">
  8. <view class="product-row">
  9. <u-image
  10. width="120rpx"
  11. height="120rpx"
  12. border-radius="12rpx"
  13. :src="productImageUrl"
  14. mode="aspectFill"
  15. ></u-image>
  16. <view class="product-info">
  17. <view class="product-title-row">
  18. <text class="product-name">{{ data.packageName || data.productName || '团餐套餐' }}</text>
  19. <text class="delivery-status">{{ deliveryStatusText }}</text>
  20. </view>
  21. <view class="product-desc-row">
  22. <text class="product-desc">{{ dishDescription }}</text>
  23. <text class="quantity">x{{ quantity }}</text>
  24. </view>
  25. <view class="item-price">
  26. <text class="currency">¥</text>
  27. <text>{{ formatMoney(itemPrice) }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="product-summary">
  32. <text>餐盒费:{{ formatMoney(containerFee) }}元</text>
  33. <view class="refund-amount">
  34. <text class="refund-label">退款金额</text>
  35. <text class="refund-currency">¥</text>
  36. <text class="refund-value">{{ formatMoney(refundAmount) }}</text>
  37. <text class="refund-note">不包含餐盒费</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="card history-card">
  42. <text class="card-title">协商历史</text>
  43. <text class="history-status">{{ data.orderStatusName || '--' }}</text>
  44. </view>
  45. <view class="card info-card">
  46. <text class="card-title">订单信息</text>
  47. <view class="info-row avatar-row">
  48. <text class="info-label">用户昵称</text>
  49. <u-image
  50. width="60rpx"
  51. height="60rpx"
  52. border-radius="8rpx"
  53. :src="avatarUrl"
  54. mode="aspectFill"
  55. ></u-image>
  56. </view>
  57. <view class="info-row">
  58. <text class="info-label">退货数量</text>
  59. <text class="info-value">{{ quantity }}份</text>
  60. </view>
  61. <view class="info-row">
  62. <text class="info-label">退货金额</text>
  63. <text class="info-value">¥{{ formatMoney(refundAmount) }}</text>
  64. </view>
  65. <view class="info-row">
  66. <text class="info-label">联系人</text>
  67. <text class="info-value">{{ data.linkName || data.userName || '--' }}</text>
  68. </view>
  69. <view class="info-row">
  70. <text class="info-label">联系方式</text>
  71. <view class="phone-value" @click.stop="makePhoneCall(userPhone)">
  72. <text>{{ userPhone || '--' }}</text>
  73. <image v-if="userPhone" class="phone-icon" src="/static/merchantDish/call.png" mode="aspectFit"></image>
  74. </view>
  75. </view>
  76. <view class="info-row">
  77. <text class="info-label">申请原因</text>
  78. <text class="info-value reason-value">{{ data.reason || data.refundReason || '--' }}</text>
  79. </view>
  80. <view v-if="showActions" class="actions">
  81. <view class="action-button reject-button" @click="onSubmit(0)">拒绝</view>
  82. <view class="action-button agree-button" @click="onSubmit(1)">同意</view>
  83. </view>
  84. </view>
  85. <view v-if="data.refuseReason !== null && data.refuseReason !== undefined && data.refuseReason !== ''" class="card refused-card">
  86. <view class="refused-header">
  87. <text class="card-title">商家拒绝退款</text>
  88. <text class="refused-time">{{ formatDateTime(data.refundTime) }}</text>
  89. </view>
  90. <view class="refused-row">拒绝原因:{{ getRefuseReasonText(data.refuseReason) }}</view>
  91. <view v-if="data.refuseReasonExplain" class="refused-row">补充说明:{{ data.refuseReasonExplain }}</view>
  92. </view>
  93. </scroll-view>
  94. <u-popup v-model="isRefuse" mode="bottom" :border-radius="32" :safe-area-inset-bottom="true">
  95. <view class="refuse-popup">
  96. <view class="popup-header">
  97. <text class="popup-title">拒绝原因</text>
  98. <u-icon class="popup-close" name="close" size="30" color="#4e5969" @click="onClose"></u-icon>
  99. </view>
  100. <view class="popup-content">
  101. <view
  102. v-for="(item, index) in reasonList"
  103. :key="item.value || index"
  104. class="reason-item"
  105. @click="onSelect(item, index)"
  106. >
  107. <text>{{ item.text }}</text>
  108. <view :class="['radio', { checked: item.check }]">
  109. <text v-if="item.check" class="radio-check">✓</text>
  110. </view>
  111. </view>
  112. <view class="explain-section">
  113. <text class="explain-title">补充说明(选填)</text>
  114. <view class="explain-box">
  115. <textarea
  116. v-model="rejectData.refuseReasonExplain"
  117. class="explain-input"
  118. :maxlength="50"
  119. placeholder="输入退款说明"
  120. ></textarea>
  121. <text class="word-count">{{ rejectData.refuseReasonExplain.length }}/50</text>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="popup-actions">
  126. <view class="popup-button cancel-button" @click="onClose">取消</view>
  127. <view class="popup-button confirm-button" @click="onRefund">确定</view>
  128. </view>
  129. </view>
  130. </u-popup>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. data() {
  136. return {
  137. data: {},
  138. query: {},
  139. reasonList: [],
  140. isRefuse: false,
  141. loading: true,
  142. rejectData: {
  143. refuseReason: '',
  144. refuseReasonExplain: ''
  145. }
  146. }
  147. },
  148. computed: {
  149. hasDetail() {
  150. return Object.keys(this.data || {}).length > 0
  151. },
  152. productImageUrl() {
  153. return this.resolveImage(this.data.productImage)
  154. },
  155. avatarUrl() {
  156. return this.resolveImage(this.data.userAvatar || this.data.avatar)
  157. },
  158. deliveryStatusText() {
  159. return this.data.deliveryStatusName || this.data.packageOrderStatusName || this.data.merchantOrderStatusName || this.data.statusName || '待送达'
  160. },
  161. dishDescription() {
  162. return this.data.dishName || this.data.packageContent || this.data.dishNames || '暂无菜品信息'
  163. },
  164. quantity() {
  165. return Number(this.data.packageNumber || this.data.buyNumber || this.data.quantity || 1)
  166. },
  167. itemPrice() {
  168. if (this.data.priceEach != null) return this.data.priceEach
  169. if (this.data.groupPrice != null) return this.data.groupPrice
  170. return this.data.price || 0
  171. },
  172. refundAmount() {
  173. if (this.data.refundAmount != null) return this.data.refundAmount
  174. if (this.data.refundPrice != null) return this.data.refundPrice
  175. return this.data.price || 0
  176. },
  177. containerFee() {
  178. if (this.data.containerFee != null) return this.data.containerFee
  179. if (this.data.boxFee != null) return this.data.boxFee
  180. return Number(this.data.boxPrice || 0) * this.quantity
  181. },
  182. userPhone() {
  183. return this.data.phone || this.data.maskedPhone || this.data.mobile || ''
  184. },
  185. showActions() {
  186. return this.data.orderStatusName === '售后申请中' || Number(this.data.fundStatus) === 2
  187. }
  188. },
  189. onLoad(query) {
  190. this.query = query || {}
  191. this.getData()
  192. this.getCodeList()
  193. },
  194. methods: {
  195. getData() {
  196. if (!this.query.hostOrderId) {
  197. this.loading = false
  198. uni.showToast({ title: '缺少订单信息', icon: 'none' })
  199. return
  200. }
  201. this.loading = true
  202. this.$http.post('/groupmeal/merchantPackageOrder/refundDetails', this.query).then((res) => {
  203. if (res.data.code !== 200) {
  204. uni.showToast({ title: res.data.message || '协商记录加载失败', icon: 'none' })
  205. return
  206. }
  207. this.data = res.data.result || {}
  208. }).catch(() => {
  209. uni.showToast({ title: '协商记录加载失败', icon: 'none' })
  210. }).finally(() => {
  211. this.loading = false
  212. })
  213. },
  214. getCodeList() {
  215. this.$http.get('/sys/api/getManyDictItems?dictCodeList=reason_refusal').then((res) => {
  216. const list = res.data && res.data.reason_refusal
  217. this.reasonList = Array.isArray(list) ? list.map((item) => ({ ...item, check: false })) : []
  218. })
  219. },
  220. onSelect(item, index) {
  221. this.reasonList.forEach((reason) => {
  222. reason.check = false
  223. })
  224. this.reasonList[index].check = true
  225. this.rejectData.refuseReason = item.value
  226. },
  227. onRefund() {
  228. if (this.rejectData.refuseReason === '') {
  229. uni.showToast({ title: '请选择拒绝原因', icon: 'none' })
  230. return
  231. }
  232. this.$http.post('/groupmeal/merchantPackageOrder/refundRefuse', {
  233. ...this.query,
  234. ...this.rejectData
  235. }).then((res) => {
  236. if (res.data.code !== 200) {
  237. uni.showToast({ title: res.data.message || '拒绝失败', icon: 'none' })
  238. return
  239. }
  240. uni.showToast({ title: res.data.message || '拒绝成功', icon: 'success' })
  241. this.resetRejectData()
  242. this.onClose()
  243. this.getData()
  244. })
  245. },
  246. onSubmit(type) {
  247. if (type === 0) {
  248. this.isRefuse = true
  249. return
  250. }
  251. uni.showModal({
  252. title: '提示',
  253. content: '是否同意退款?',
  254. success: (modalRes) => {
  255. if (!modalRes.confirm) return
  256. this.$http.post('/groupmeal/merchantPackageOrder/refundAgree', { ...this.query }).then((res) => {
  257. if (res.data.code !== 200) {
  258. uni.showToast({ title: res.data.message || '操作失败', icon: 'none' })
  259. return
  260. }
  261. uni.showToast({ title: res.data.message || '商家已同意退款', icon: 'success' })
  262. this.getData()
  263. })
  264. }
  265. })
  266. },
  267. onClose() {
  268. this.isRefuse = false
  269. },
  270. resetRejectData() {
  271. this.rejectData = {
  272. refuseReason: '',
  273. refuseReasonExplain: ''
  274. }
  275. this.reasonList.forEach((reason) => {
  276. reason.check = false
  277. })
  278. },
  279. getRefuseReasonText(value) {
  280. const selected = this.reasonList.find((item) => String(item.value) === String(value))
  281. return selected ? selected.text : value
  282. },
  283. makePhoneCall(phone) {
  284. const phoneNumber = String(phone || '')
  285. if (!phoneNumber || phoneNumber.includes('*')) {
  286. uni.showToast({ title: '手机号暂不可拨打', icon: 'none' })
  287. return
  288. }
  289. uni.makePhoneCall({ phoneNumber })
  290. },
  291. resolveImage(value) {
  292. const image = String(value || '').split(',').filter(Boolean)[0] || ''
  293. if (!image || /^https?:\/\//.test(image)) return image
  294. return this.$config && this.$config.apiUrl ? `${this.$config.apiUrl}/${image}` : image
  295. },
  296. formatMoney(value) {
  297. const number = Number(value)
  298. if (!Number.isFinite(number)) return '0'
  299. return number.toFixed(2).replace(/\.00$/, '').replace(/(\.\d)0$/, '$1')
  300. },
  301. formatDateTime(value) {
  302. return value ? String(value).replace(/-/g, '.') : '--'
  303. }
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. .page {
  309. display: flex;
  310. flex-direction: column;
  311. height: 100vh;
  312. background: #f7f8fa;
  313. overflow: hidden;
  314. }
  315. .content {
  316. flex: 1;
  317. height: 0;
  318. box-sizing: border-box;
  319. padding: 32rpx 32rpx calc(32rpx + env(safe-area-inset-bottom));
  320. }
  321. .state-tip {
  322. padding: 100rpx 24rpx;
  323. color: #86909c;
  324. font-size: 28rpx;
  325. text-align: center;
  326. }
  327. .card {
  328. box-sizing: border-box;
  329. margin-bottom: 16rpx;
  330. padding: 32rpx;
  331. border-radius: 16rpx;
  332. background: #fff;
  333. }
  334. .product-row,
  335. .product-title-row,
  336. .product-desc-row,
  337. .product-summary,
  338. .refund-amount,
  339. .history-card,
  340. .info-row,
  341. .phone-value,
  342. .actions,
  343. .refused-header,
  344. .popup-header,
  345. .reason-item,
  346. .popup-actions {
  347. display: flex;
  348. align-items: center;
  349. }
  350. .product-row {
  351. align-items: stretch;
  352. gap: 20rpx;
  353. }
  354. .product-info {
  355. display: flex;
  356. flex: 1;
  357. min-width: 0;
  358. flex-direction: column;
  359. justify-content: space-between;
  360. }
  361. .product-title-row,
  362. .product-desc-row,
  363. .product-summary,
  364. .history-card,
  365. .info-row,
  366. .refused-header,
  367. .popup-header,
  368. .reason-item {
  369. justify-content: space-between;
  370. }
  371. .product-name {
  372. flex: 1;
  373. min-width: 0;
  374. overflow: hidden;
  375. color: #1d2129;
  376. font-size: 30rpx;
  377. font-weight: 600;
  378. text-overflow: ellipsis;
  379. white-space: nowrap;
  380. }
  381. .delivery-status {
  382. flex-shrink: 0;
  383. margin-left: 16rpx;
  384. color: #86909c;
  385. font-size: 28rpx;
  386. }
  387. .product-desc {
  388. flex: 1;
  389. min-width: 0;
  390. overflow: hidden;
  391. color: #86909c;
  392. font-size: 24rpx;
  393. text-overflow: ellipsis;
  394. white-space: nowrap;
  395. }
  396. .quantity {
  397. flex-shrink: 0;
  398. margin-left: 16rpx;
  399. color: #86909c;
  400. font-size: 24rpx;
  401. }
  402. .item-price {
  403. color: #1d2129;
  404. font-size: 28rpx;
  405. font-weight: 600;
  406. }
  407. .currency {
  408. font-size: 20rpx;
  409. }
  410. .product-summary {
  411. margin-top: 16rpx;
  412. color: #333;
  413. font-size: 24rpx;
  414. }
  415. .refund-amount {
  416. align-items: baseline;
  417. white-space: nowrap;
  418. }
  419. .refund-label {
  420. margin-right: 6rpx;
  421. }
  422. .refund-currency {
  423. font-size: 26rpx;
  424. font-weight: 600;
  425. }
  426. .refund-value {
  427. font-size: 36rpx;
  428. font-weight: 600;
  429. }
  430. .refund-note {
  431. margin-left: 8rpx;
  432. color: #1c7cf9;
  433. font-size: 20rpx;
  434. }
  435. .history-card {
  436. height: 108rpx;
  437. }
  438. .card-title {
  439. color: #1d2129;
  440. font-size: 32rpx;
  441. font-weight: 500;
  442. }
  443. .history-status {
  444. color: #f8b328;
  445. font-size: 28rpx;
  446. }
  447. .info-card {
  448. display: flex;
  449. flex-direction: column;
  450. gap: 24rpx;
  451. }
  452. .info-row {
  453. gap: 24rpx;
  454. min-height: 32rpx;
  455. font-size: 28rpx;
  456. }
  457. .avatar-row {
  458. min-height: 60rpx;
  459. }
  460. .info-label {
  461. flex-shrink: 0;
  462. color: #4e5969;
  463. }
  464. .info-value,
  465. .phone-value {
  466. min-width: 0;
  467. color: #1d2129;
  468. text-align: right;
  469. }
  470. .reason-value {
  471. overflow: hidden;
  472. text-overflow: ellipsis;
  473. white-space: nowrap;
  474. }
  475. .phone-value {
  476. justify-content: flex-end;
  477. gap: 12rpx;
  478. }
  479. .phone-icon {
  480. width: 32rpx;
  481. height: 32rpx;
  482. }
  483. .actions {
  484. justify-content: flex-end;
  485. gap: 24rpx;
  486. }
  487. .action-button {
  488. display: flex;
  489. align-items: center;
  490. justify-content: center;
  491. width: 152rpx;
  492. height: 64rpx;
  493. border-radius: 64rpx;
  494. font-size: 26rpx;
  495. }
  496. .reject-button {
  497. background: rgba(51, 51, 53, 0.05);
  498. color: #1d2129;
  499. }
  500. .agree-button {
  501. background: linear-gradient(92deg, #10abfe 0%, #2260f6 100%);
  502. color: #fff;
  503. }
  504. .refused-card {
  505. display: flex;
  506. flex-direction: column;
  507. gap: 16rpx;
  508. }
  509. .refused-time {
  510. color: #86909c;
  511. font-size: 24rpx;
  512. }
  513. .refused-row {
  514. color: #4e5969;
  515. font-size: 26rpx;
  516. }
  517. .refuse-popup {
  518. display: flex;
  519. flex-direction: column;
  520. gap: 24rpx;
  521. box-sizing: border-box;
  522. background: #fff;
  523. }
  524. .popup-header {
  525. position: relative;
  526. height: 100rpx;
  527. box-sizing: border-box;
  528. justify-content: center;
  529. padding: 25rpx 32rpx;
  530. border-bottom: 1rpx solid #e7e7e7;
  531. }
  532. .popup-title {
  533. color: #333;
  534. font-size: 36rpx;
  535. font-weight: 500;
  536. line-height: 50rpx;
  537. }
  538. .popup-close {
  539. position: absolute;
  540. right: 32rpx;
  541. top: 35rpx;
  542. }
  543. .popup-content {
  544. display: flex;
  545. flex-direction: column;
  546. gap: 32rpx;
  547. box-sizing: border-box;
  548. padding: 16rpx 32rpx 0;
  549. }
  550. .reason-item {
  551. height: 32rpx;
  552. color: #4e5969;
  553. font-size: 28rpx;
  554. line-height: 32rpx;
  555. }
  556. .radio {
  557. display: flex;
  558. align-items: center;
  559. justify-content: center;
  560. width: 32rpx;
  561. height: 32rpx;
  562. box-sizing: border-box;
  563. border: 1rpx solid #c9cdd4;
  564. border-radius: 50%;
  565. }
  566. .radio.checked {
  567. border-color: #168cff;
  568. background: #168cff;
  569. }
  570. .radio-check {
  571. color: #fff;
  572. font-size: 22rpx;
  573. font-weight: 600;
  574. line-height: 32rpx;
  575. }
  576. .explain-section {
  577. display: flex;
  578. flex-direction: column;
  579. gap: 16rpx;
  580. }
  581. .explain-title {
  582. color: #1d2129;
  583. font-size: 28rpx;
  584. font-weight: 500;
  585. line-height: 40rpx;
  586. }
  587. .explain-box {
  588. position: relative;
  589. box-sizing: border-box;
  590. height: 160rpx;
  591. padding: 16rpx;
  592. border-radius: 8rpx;
  593. background: #f8f8f8;
  594. }
  595. .explain-input {
  596. width: 100%;
  597. height: 88rpx;
  598. color: #1d2129;
  599. font-size: 24rpx;
  600. line-height: 34rpx;
  601. }
  602. .word-count {
  603. position: absolute;
  604. right: 16rpx;
  605. bottom: 16rpx;
  606. color: #86909c;
  607. font-size: 24rpx;
  608. line-height: 34rpx;
  609. text-align: right;
  610. }
  611. .popup-actions {
  612. gap: 32rpx;
  613. box-sizing: border-box;
  614. padding: 24rpx 48rpx;
  615. background: #fff;
  616. }
  617. .popup-button {
  618. display: flex;
  619. flex: 1;
  620. height: 88rpx;
  621. align-items: center;
  622. justify-content: center;
  623. border-radius: 140rpx;
  624. font-size: 32rpx;
  625. }
  626. .cancel-button {
  627. background: rgba(51, 51, 53, 0.05);
  628. color: #1d2129;
  629. }
  630. .confirm-button {
  631. background: linear-gradient(92deg, #10abfe 0%, #2260f6 100%);
  632. color: #fff;
  633. }
  634. </style>