refund-record.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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 v-if="containerFeeExcluded" 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. containerFeeExcluded() {
  183. return this.data.containerFeeExcluded === true
  184. },
  185. userPhone() {
  186. return this.data.phone || this.data.maskedPhone || this.data.mobile || ''
  187. },
  188. showActions() {
  189. return this.data.merchantReviewable === true
  190. }
  191. },
  192. onLoad(query) {
  193. this.query = query || {}
  194. this.getData()
  195. this.getCodeList()
  196. },
  197. methods: {
  198. getData() {
  199. if (!this.query.hostOrderId) {
  200. this.loading = false
  201. uni.showToast({ title: '缺少订单信息', icon: 'none' })
  202. return
  203. }
  204. this.loading = true
  205. this.$http.post('/groupmeal/merchantPackageOrder/refundDetails', this.query).then((res) => {
  206. if (res.data.code !== 200) {
  207. uni.showToast({ title: res.data.message || '协商记录加载失败', icon: 'none' })
  208. return
  209. }
  210. this.data = res.data.result || {}
  211. }).catch(() => {
  212. uni.showToast({ title: '协商记录加载失败', icon: 'none' })
  213. }).finally(() => {
  214. this.loading = false
  215. })
  216. },
  217. getCodeList() {
  218. this.$http.get('/sys/api/getManyDictItems?dictCodeList=reason_refusal').then((res) => {
  219. const list = res.data && res.data.reason_refusal
  220. this.reasonList = Array.isArray(list) ? list.map((item) => ({ ...item, check: false })) : []
  221. })
  222. },
  223. onSelect(item, index) {
  224. this.reasonList.forEach((reason) => {
  225. reason.check = false
  226. })
  227. this.reasonList[index].check = true
  228. this.rejectData.refuseReason = item.value
  229. },
  230. onRefund() {
  231. if (this.rejectData.refuseReason === '') {
  232. uni.showToast({ title: '请选择拒绝原因', icon: 'none' })
  233. return
  234. }
  235. this.$http.post('/groupmeal/merchantPackageOrder/refundRefuse', {
  236. ...this.query,
  237. ...this.rejectData
  238. }).then((res) => {
  239. if (res.data.code !== 200) {
  240. uni.showToast({ title: res.data.message || '拒绝失败', icon: 'none' })
  241. return
  242. }
  243. uni.showToast({ title: res.data.message || '拒绝成功', icon: 'success' })
  244. this.resetRejectData()
  245. this.onClose()
  246. this.getData()
  247. })
  248. },
  249. onSubmit(type) {
  250. if (type === 0) {
  251. this.isRefuse = true
  252. return
  253. }
  254. uni.showModal({
  255. title: '提示',
  256. content: '是否同意退款?',
  257. success: (modalRes) => {
  258. if (!modalRes.confirm) return
  259. this.$http.post('/groupmeal/merchantPackageOrder/refundAgree', { ...this.query }).then((res) => {
  260. if (res.data.code !== 200) {
  261. uni.showToast({ title: res.data.message || '操作失败', icon: 'none' })
  262. return
  263. }
  264. uni.showToast({ title: res.data.message || '商家已同意退款', icon: 'success' })
  265. this.getData()
  266. })
  267. }
  268. })
  269. },
  270. onClose() {
  271. this.isRefuse = false
  272. },
  273. resetRejectData() {
  274. this.rejectData = {
  275. refuseReason: '',
  276. refuseReasonExplain: ''
  277. }
  278. this.reasonList.forEach((reason) => {
  279. reason.check = false
  280. })
  281. },
  282. getRefuseReasonText(value) {
  283. const selected = this.reasonList.find((item) => String(item.value) === String(value))
  284. return selected ? selected.text : value
  285. },
  286. makePhoneCall(phone) {
  287. const phoneNumber = String(phone || '')
  288. if (!phoneNumber || phoneNumber.includes('*')) {
  289. uni.showToast({ title: '手机号暂不可拨打', icon: 'none' })
  290. return
  291. }
  292. uni.makePhoneCall({ phoneNumber })
  293. },
  294. resolveImage(value) {
  295. const image = String(value || '').split(',').filter(Boolean)[0] || ''
  296. if (!image || /^https?:\/\//.test(image)) return image
  297. return this.$config && this.$config.apiUrl ? `${this.$config.apiUrl}/${image}` : image
  298. },
  299. formatMoney(value) {
  300. const number = Number(value)
  301. if (!Number.isFinite(number)) return '0'
  302. return number.toFixed(2).replace(/\.00$/, '').replace(/(\.\d)0$/, '$1')
  303. },
  304. formatDateTime(value) {
  305. return value ? String(value).replace(/-/g, '.') : '--'
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .page {
  312. display: flex;
  313. flex-direction: column;
  314. height: 100vh;
  315. background: #f7f8fa;
  316. overflow: hidden;
  317. }
  318. .content {
  319. flex: 1;
  320. height: 0;
  321. box-sizing: border-box;
  322. padding: 32rpx 32rpx calc(32rpx + env(safe-area-inset-bottom));
  323. }
  324. .state-tip {
  325. padding: 100rpx 24rpx;
  326. color: #86909c;
  327. font-size: 28rpx;
  328. text-align: center;
  329. }
  330. .card {
  331. box-sizing: border-box;
  332. margin-bottom: 16rpx;
  333. padding: 32rpx;
  334. border-radius: 16rpx;
  335. background: #fff;
  336. }
  337. .product-row,
  338. .product-title-row,
  339. .product-desc-row,
  340. .product-summary,
  341. .refund-amount,
  342. .history-card,
  343. .info-row,
  344. .phone-value,
  345. .actions,
  346. .refused-header,
  347. .popup-header,
  348. .reason-item,
  349. .popup-actions {
  350. display: flex;
  351. align-items: center;
  352. }
  353. .product-row {
  354. align-items: stretch;
  355. gap: 20rpx;
  356. }
  357. .product-info {
  358. display: flex;
  359. flex: 1;
  360. min-width: 0;
  361. flex-direction: column;
  362. justify-content: space-between;
  363. }
  364. .product-title-row,
  365. .product-desc-row,
  366. .product-summary,
  367. .history-card,
  368. .info-row,
  369. .refused-header,
  370. .popup-header,
  371. .reason-item {
  372. justify-content: space-between;
  373. }
  374. .product-name {
  375. flex: 1;
  376. min-width: 0;
  377. overflow: hidden;
  378. color: #1d2129;
  379. font-size: 30rpx;
  380. font-weight: 600;
  381. text-overflow: ellipsis;
  382. white-space: nowrap;
  383. }
  384. .delivery-status {
  385. flex-shrink: 0;
  386. margin-left: 16rpx;
  387. color: #86909c;
  388. font-size: 28rpx;
  389. }
  390. .product-desc {
  391. flex: 1;
  392. min-width: 0;
  393. overflow: hidden;
  394. color: #86909c;
  395. font-size: 24rpx;
  396. text-overflow: ellipsis;
  397. white-space: nowrap;
  398. }
  399. .quantity {
  400. flex-shrink: 0;
  401. margin-left: 16rpx;
  402. color: #86909c;
  403. font-size: 24rpx;
  404. }
  405. .item-price {
  406. color: #1d2129;
  407. font-size: 28rpx;
  408. font-weight: 600;
  409. }
  410. .currency {
  411. font-size: 20rpx;
  412. }
  413. .product-summary {
  414. margin-top: 16rpx;
  415. color: #333;
  416. font-size: 24rpx;
  417. }
  418. .refund-amount {
  419. align-items: baseline;
  420. white-space: nowrap;
  421. }
  422. .refund-label {
  423. margin-right: 6rpx;
  424. }
  425. .refund-currency {
  426. font-size: 26rpx;
  427. font-weight: 600;
  428. }
  429. .refund-value {
  430. font-size: 36rpx;
  431. font-weight: 600;
  432. }
  433. .refund-note {
  434. margin-left: 8rpx;
  435. color: #1c7cf9;
  436. font-size: 20rpx;
  437. }
  438. .history-card {
  439. height: 108rpx;
  440. }
  441. .card-title {
  442. color: #1d2129;
  443. font-size: 32rpx;
  444. font-weight: 500;
  445. }
  446. .history-status {
  447. color: #f8b328;
  448. font-size: 28rpx;
  449. }
  450. .info-card {
  451. display: flex;
  452. flex-direction: column;
  453. gap: 24rpx;
  454. }
  455. .info-row {
  456. gap: 24rpx;
  457. min-height: 32rpx;
  458. font-size: 28rpx;
  459. }
  460. .avatar-row {
  461. min-height: 60rpx;
  462. }
  463. .info-label {
  464. flex-shrink: 0;
  465. color: #4e5969;
  466. }
  467. .info-value,
  468. .phone-value {
  469. min-width: 0;
  470. color: #1d2129;
  471. text-align: right;
  472. }
  473. .reason-value {
  474. overflow: hidden;
  475. text-overflow: ellipsis;
  476. white-space: nowrap;
  477. }
  478. .phone-value {
  479. justify-content: flex-end;
  480. gap: 12rpx;
  481. }
  482. .phone-icon {
  483. width: 32rpx;
  484. height: 32rpx;
  485. }
  486. .actions {
  487. justify-content: flex-end;
  488. gap: 24rpx;
  489. }
  490. .action-button {
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. width: 152rpx;
  495. height: 64rpx;
  496. border-radius: 64rpx;
  497. font-size: 26rpx;
  498. }
  499. .reject-button {
  500. background: rgba(51, 51, 53, 0.05);
  501. color: #1d2129;
  502. }
  503. .agree-button {
  504. background: linear-gradient(92deg, #10abfe 0%, #2260f6 100%);
  505. color: #fff;
  506. }
  507. .refused-card {
  508. display: flex;
  509. flex-direction: column;
  510. gap: 16rpx;
  511. }
  512. .refused-time {
  513. color: #86909c;
  514. font-size: 24rpx;
  515. }
  516. .refused-row {
  517. color: #4e5969;
  518. font-size: 26rpx;
  519. }
  520. .refuse-popup {
  521. display: flex;
  522. flex-direction: column;
  523. gap: 24rpx;
  524. box-sizing: border-box;
  525. background: #fff;
  526. }
  527. .popup-header {
  528. position: relative;
  529. height: 100rpx;
  530. box-sizing: border-box;
  531. justify-content: center;
  532. padding: 25rpx 32rpx;
  533. border-bottom: 1rpx solid #e7e7e7;
  534. }
  535. .popup-title {
  536. color: #333;
  537. font-size: 36rpx;
  538. font-weight: 500;
  539. line-height: 50rpx;
  540. }
  541. .popup-close {
  542. position: absolute;
  543. right: 32rpx;
  544. top: 35rpx;
  545. }
  546. .popup-content {
  547. display: flex;
  548. flex-direction: column;
  549. gap: 32rpx;
  550. box-sizing: border-box;
  551. padding: 16rpx 32rpx 0;
  552. }
  553. .reason-item {
  554. height: 32rpx;
  555. color: #4e5969;
  556. font-size: 28rpx;
  557. line-height: 32rpx;
  558. }
  559. .radio {
  560. display: flex;
  561. align-items: center;
  562. justify-content: center;
  563. width: 32rpx;
  564. height: 32rpx;
  565. box-sizing: border-box;
  566. border: 1rpx solid #c9cdd4;
  567. border-radius: 50%;
  568. }
  569. .radio.checked {
  570. border-color: #168cff;
  571. background: #168cff;
  572. }
  573. .radio-check {
  574. color: #fff;
  575. font-size: 22rpx;
  576. font-weight: 600;
  577. line-height: 32rpx;
  578. }
  579. .explain-section {
  580. display: flex;
  581. flex-direction: column;
  582. gap: 16rpx;
  583. }
  584. .explain-title {
  585. color: #1d2129;
  586. font-size: 28rpx;
  587. font-weight: 500;
  588. line-height: 40rpx;
  589. }
  590. .explain-box {
  591. position: relative;
  592. box-sizing: border-box;
  593. height: 160rpx;
  594. padding: 16rpx;
  595. border-radius: 8rpx;
  596. background: #f8f8f8;
  597. }
  598. .explain-input {
  599. width: 100%;
  600. height: 88rpx;
  601. color: #1d2129;
  602. font-size: 24rpx;
  603. line-height: 34rpx;
  604. }
  605. .word-count {
  606. position: absolute;
  607. right: 16rpx;
  608. bottom: 16rpx;
  609. color: #86909c;
  610. font-size: 24rpx;
  611. line-height: 34rpx;
  612. text-align: right;
  613. }
  614. .popup-actions {
  615. gap: 32rpx;
  616. box-sizing: border-box;
  617. padding: 24rpx 48rpx;
  618. background: #fff;
  619. }
  620. .popup-button {
  621. display: flex;
  622. flex: 1;
  623. height: 88rpx;
  624. align-items: center;
  625. justify-content: center;
  626. border-radius: 140rpx;
  627. font-size: 32rpx;
  628. }
  629. .cancel-button {
  630. background: rgba(51, 51, 53, 0.05);
  631. color: #1d2129;
  632. }
  633. .confirm-button {
  634. background: linear-gradient(92deg, #10abfe 0%, #2260f6 100%);
  635. color: #fff;
  636. }
  637. </style>