refund.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. <!--
  2. 商城订单申请售后页
  3. 供订单详情「申请售后」进入;顾客勾选商品/金额后提交待审核申请,商家在 hdApp 审核
  4. 撤销后仍可重新申请:把已取消记录改回待审核
  5. 退货并退款金额:普通商品按勾选原价分摊会员折/满减;秒杀、团购按活动单价退,不再叠整单优惠
  6. 红包全额抵扣导致实付为 0 时仍可申请:提交 0 元,审核通过后退回红包
  7. -->
  8. <template>
  9. <view class="refund-page">
  10. <!-- 已有申请:展示进度(点「重新申请」后切到表单) -->
  11. <template v-if="showApplyProgress">
  12. <view class="card-section">
  13. <view class="section-title">
  14. <text class="title-text">申请进度</text>
  15. </view>
  16. <view class="status-block">
  17. <text class="status-tag" :class="'st-' + apply.status">{{ apply.statusText || statusText(apply.status) }}</text>
  18. <view class="status-row">
  19. <text class="label">退款金额</text>
  20. <text class="price">¥{{ parseFloat(apply.refundPrice) || 0 }}</text>
  21. </view>
  22. <view class="status-row" v-if="apply.remark">
  23. <text class="label">备注</text>
  24. <text class="value">{{ apply.remark }}</text>
  25. </view>
  26. <view class="status-row" v-if="apply.status == 2 && apply.rejectReason">
  27. <text class="label">驳回原因</text>
  28. <text class="value reject">{{ apply.rejectReason }}</text>
  29. </view>
  30. <view class="status-row">
  31. <text class="label">申请时间</text>
  32. <text class="value">{{ apply.addTime || '' }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="bottom-actions" v-if="apply.status == 0">
  37. <button class="action-btn cancel-btn" @tap="doCancel">撤销申请</button>
  38. </view>
  39. <view class="bottom-actions" v-else-if="canReapply">
  40. <button class="action-btn cancel-btn" @tap="goBack">返回</button>
  41. <button class="action-btn confirm-btn" @tap="startReapply">重新申请</button>
  42. </view>
  43. <view class="bottom-actions" v-else>
  44. <button class="action-btn cancel-btn" @tap="goBack">返回</button>
  45. </view>
  46. </template>
  47. <!-- 无可申请金额 / 不可申请 -->
  48. <template v-else-if="!canApply">
  49. <view class="card-section empty-tip">
  50. <text>当前订单暂不支持申请售后</text>
  51. <text class="sub" v-if="refundDeadlineTip">{{ refundDeadlineTip }}</text>
  52. </view>
  53. <view class="bottom-actions">
  54. <button class="action-btn cancel-btn" @tap="goBack">返回</button>
  55. </view>
  56. </template>
  57. <!-- 申请表单 -->
  58. <template v-else>
  59. <view class="tip-bar" v-if="refundDeadlineTip">
  60. <text>{{ refundDeadlineTip }}</text>
  61. </view>
  62. <!-- 退款方式 -->
  63. <view class="card-section">
  64. <view class="section-title">
  65. <text class="title-text">退款方式</text>
  66. </view>
  67. <view class="refund-type-buttons">
  68. <button
  69. class="type-btn"
  70. :class="refundType == 1 ? 'active' : ''"
  71. @tap="refundType = 1"
  72. >退货并退款</button>
  73. <button
  74. class="type-btn"
  75. :class="refundType == 2 ? 'active' : ''"
  76. @tap="onOnlyRefund"
  77. >只退款</button>
  78. </view>
  79. </view>
  80. <!-- 商品选择(退货并退款) -->
  81. <view class="card-section" v-if="refundType == 1">
  82. <view class="section-title">
  83. <text class="title-text">退货商品</text>
  84. </view>
  85. <view class="product-list-compact">
  86. <template v-if="!$util.isEmpty(goodsInfoList)">
  87. <!-- key 勿用 'g'+i 字符串拼接:会随 v-model 编进 data-event-opts 导致小程序编译失败 -->
  88. <view class="product-row" v-for="(res, i) in goodsInfoList" :key="res.goodsId || i">
  89. <view class="product-basic-info">
  90. <text class="product-name-compact">{{ res.name }}</text>
  91. <view class="product-meta">
  92. <text class="stock-info">{{ parseFloat(res.num) }}份 × ¥{{ parseFloat(res.unitPrice) }}</text>
  93. <text class="activity-info" v-if="goodsActivityLabel(res)">{{ goodsActivityLabel(res) }}</text>
  94. <text class="available-info">可退 {{ getRemainNum(res) }}份</text>
  95. </view>
  96. </view>
  97. <view class="refund-control">
  98. <view class="input-item">
  99. <text class="input-label">数量</text>
  100. <input
  101. class="refund-input-compact"
  102. type="number"
  103. placeholder="0"
  104. :value="res.refundCount"
  105. placeholder-style="color:#ccc"
  106. @input="onGoodsCountInput(i, $event)"
  107. />
  108. <text class="unit-label">份</text>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <template v-if="!$util.isEmpty(itemInfoList)">
  114. <view class="product-row" v-for="(res, i) in itemInfoList" :key="res.itemId || i">
  115. <view class="product-basic-info">
  116. <text class="product-name-compact">{{ res.name }}</text>
  117. <view class="product-meta">
  118. <text class="stock-info">{{ parseFloat(res.num) }}{{ res.unitName || '份' }} × ¥{{ parseFloat(res.unitPrice) }}</text>
  119. <text class="activity-info" v-if="goodsActivityLabel(res)">{{ goodsActivityLabel(res) }}</text>
  120. <text class="available-info">可退 {{ getRemainNum(res) }}{{ res.unitName || '份' }}</text>
  121. </view>
  122. </view>
  123. <view class="refund-control">
  124. <view class="input-item">
  125. <text class="input-label">数量</text>
  126. <input
  127. class="refund-input-compact"
  128. type="number"
  129. placeholder="0"
  130. :value="res.refundCount"
  131. placeholder-style="color:#ccc"
  132. @input="onItemCountInput(i, $event)"
  133. />
  134. <text class="unit-label">{{ res.unitName || '份' }}</text>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <view v-if="$util.isEmpty(goodsInfoList) && $util.isEmpty(itemInfoList)" class="empty-tip">
  140. <text>暂无可退商品</text>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 金额信息 -->
  145. <view class="card-section">
  146. <view class="section-title">
  147. <text class="title-text">金额信息</text>
  148. </view>
  149. <view class="amount-info">
  150. <view class="amount-row">
  151. <text class="amount-label">订单金额</text>
  152. <text class="amount-value">¥{{ parseFloat(orderInfo.orderPrice) || 0 }}</text>
  153. </view>
  154. <view class="amount-row" v-if="hasTkPrice">
  155. <text class="amount-label">已退金额</text>
  156. <text class="amount-value">¥{{ parseFloat(orderInfo.tkPrice) || 0 }}</text>
  157. </view>
  158. <view class="amount-row">
  159. <text class="amount-label">可退金额</text>
  160. <text class="amount-value available">¥{{ couldRefundPrice }}</text>
  161. </view>
  162. <view class="amount-row" v-if="hasDiscountAmount">
  163. <text class="amount-label">优惠金额</text>
  164. <text class="amount-value">¥{{ parseFloat(orderInfo.discountAmount) || 0 }}</text>
  165. </view>
  166. <view class="amount-row" v-if="hasMeetCut">
  167. <text class="amount-label">订单满减</text>
  168. <text class="amount-value">¥{{ parseFloat(orderInfo.orderReachDiscountPrice) || 0 }}</text>
  169. </view>
  170. <view class="amount-row" v-if="hasHbAmount">
  171. <text class="amount-label">红包减免</text>
  172. <text class="amount-value">¥{{ parseFloat(orderInfo.hbAmount) || 0 }}</text>
  173. </view>
  174. <view class="amount-row">
  175. <text class="amount-label required">退款金额</text>
  176. <text class="amount-value refund-money">¥{{ refundMoney }}</text>
  177. </view>
  178. <view class="amount-hint" v-if="refundType == 1">秒杀/团购按活动价,其余已计入优惠与满减,不可修改</view>
  179. <view class="amount-hint" v-else>仅退款默认按可退金额申请,全额退清后未过期红包将自动退回</view>
  180. </view>
  181. </view>
  182. <!-- 退款方式提示:对齐采购售后,按原单 onlinePay / payWay 说明审核后资金去向 -->
  183. <view class="tip-section">
  184. <text v-if="Number(orderInfo.onlinePay) == 2" class="tip-text online-tip">此单线上付款,审核通过后钱将原路退回</text>
  185. <text v-else-if="Number(orderInfo.payWay) == 2" class="tip-text online-tip">此单余额付款,审核通过后钱将退回账户余额</text>
  186. <text v-else-if="Number(orderInfo.payWay) == 3 || Number(orderInfo.debt) == 1" class="tip-text debt-tip">此单挂账,审核通过后挂账金额会相应减少</text>
  187. <text v-else class="tip-text offline-tip">此单线下付款,审核通过后需商家确认退回方式</text>
  188. </view>
  189. <!-- 备注 -->
  190. <view class="card-section">
  191. <view class="section-title">
  192. <text class="title-text">备注</text>
  193. </view>
  194. <view class="remark-container">
  195. <textarea
  196. class="remark-textarea"
  197. v-model="remark"
  198. placeholder="选填,说明售后原因"
  199. placeholder-style="color:#999"
  200. />
  201. </view>
  202. </view>
  203. <view class="bottom-actions">
  204. <button class="action-btn cancel-btn" @tap="onFormCancel">取消</button>
  205. <button class="action-btn confirm-btn" @tap="askSubmit">提交申请</button>
  206. </view>
  207. </template>
  208. </view>
  209. </template>
  210. <script>
  211. import { getRefundData, createRefund, cancelRefund } from '@/api/refund'
  212. export default {
  213. name: 'orderRefund',
  214. data() {
  215. return {
  216. orderInfo: {},
  217. goodsInfoList: [],
  218. itemInfoList: [],
  219. couldRefundPrice: 0,
  220. refundType: 1,
  221. remark: '',
  222. apply: null,
  223. canApply: 0,
  224. refundDeadlineTip: '',
  225. submitting: false,
  226. // 已取消后点「重新申请」进入表单,提交时把原记录改回待审核
  227. reapplying: false
  228. }
  229. },
  230. computed: {
  231. /** 是否展示申请进度;重新申请中不锁在进度页 */
  232. showApplyProgress() {
  233. if (!this.apply || !this.apply.id) {
  234. return false
  235. }
  236. if (this.reapplying) {
  237. return false
  238. }
  239. return true
  240. },
  241. /** 已取消且订单仍可售后时允许重新申请 */
  242. canReapply() {
  243. if (!this.apply || !this.apply.id) {
  244. return false
  245. }
  246. return Number(this.apply.status) === 3 && Number(this.canApply) === 1
  247. },
  248. /** 是否展示已退金额行(避免模板里写 > 比较,兼容小程序 WXML) */
  249. hasTkPrice() {
  250. return Number(this.orderInfo.tkPrice) > 0
  251. },
  252. /** 是否展示红包减免行 */
  253. hasHbAmount() {
  254. return this.orderInfo.hbAmount && Number(this.orderInfo.hbAmount) > 0
  255. },
  256. /** 是否展示优惠金额(会员折等整单优惠) */
  257. hasDiscountAmount() {
  258. return Number(this.orderInfo.discountAmount) > 0
  259. },
  260. /** 是否展示订单满减 */
  261. hasMeetCut() {
  262. return Number(this.orderInfo.orderReachDiscountPrice) > 0
  263. },
  264. /** 整单拼团:下单已跳过会员折/满减,商品按团购价退 */
  265. isGroupBuyOrder() {
  266. return Number(this.orderInfo.groupBuyId) > 0
  267. },
  268. /**
  269. * 退款金额:仅退款用可退金额;退货并退款时秒杀/团购按活动价,其余分摊整单优惠
  270. */
  271. refundMoney() {
  272. if (this.refundType == 2) {
  273. return this.couldRefundPrice
  274. }
  275. const parts = this.sumSelectedPriceParts()
  276. const activityMoney = Number(parts.activity) || 0
  277. const normalMoney = this.applyOrderDiscounts(Number(parts.normal) || 0)
  278. const money = activityMoney + normalMoney
  279. if (!(money > 0)) {
  280. return 0
  281. }
  282. const could = Number(this.couldRefundPrice) || 0
  283. const capped = money > could ? could : money
  284. if (!(capped > 0)) {
  285. return 0
  286. }
  287. return parseFloat(capped.toFixed(2))
  288. },
  289. /**
  290. * 现金为 0 仍可提交:红包未退回,且红包金额大于订单实付(与后端 canApplyRefund 一致)
  291. */
  292. allowZeroCashRefund() {
  293. if (!(Number(this.orderInfo.hbId) > 0)) {
  294. return false
  295. }
  296. if (Number(this.couldRefundPrice) > 0) {
  297. return false
  298. }
  299. const payAmount = Number(
  300. this.orderInfo.mainPay != null ? this.orderInfo.mainPay : this.orderInfo.orderPrice
  301. ) || 0
  302. return Number(this.orderInfo.hbAmount || 0) > payAmount
  303. }
  304. },
  305. methods: {
  306. statusText(status) {
  307. const map = { 0: '待审核', 1: '已通过', 2: '已驳回', 3: '已取消' }
  308. return map[status] || ''
  309. },
  310. /** 可退剩余数量 */
  311. getRemainNum(res) {
  312. return Number(res.num) - Number(res.refundNum || 0)
  313. },
  314. /**
  315. * 商品活动标签:秒杀行 / 整单拼团。给模板展示,避免复杂表达式
  316. * @param {object} res 订单商品或花材行
  317. * @returns {string} 秒杀|团购|空
  318. */
  319. goodsActivityLabel(res) {
  320. if (this.isGroupBuyOrder) {
  321. return '团购'
  322. }
  323. if (res && Number(res.seckillGoodsId) > 0) {
  324. return '秒杀'
  325. }
  326. return ''
  327. },
  328. /**
  329. * 是否按活动价退、不摊会员折/满减:拼团整单,或花束行 seckillGoodsId>0
  330. * @param {object} item 订单行
  331. */
  332. isActivityLine(item) {
  333. if (this.isGroupBuyOrder) {
  334. return true
  335. }
  336. return Number(item && item.seckillGoodsId) > 0
  337. },
  338. /**
  339. * 勾选退货拆成活动价合计与普通原价合计
  340. * 秒杀/团购按行上的活动单价;普通商品再去分摊整单优惠
  341. */
  342. sumSelectedPriceParts() {
  343. let activity = 0
  344. let normal = 0
  345. const addList = list => {
  346. ;(list || []).forEach(item => {
  347. const count = Number(item.refundCount) || 0
  348. if (!(count > 0)) {
  349. return
  350. }
  351. const line = count * Number(item.unitPrice || 0)
  352. if (this.isActivityLine(item)) {
  353. activity += line
  354. } else {
  355. normal += line
  356. }
  357. })
  358. }
  359. addList(this.goodsInfoList)
  360. addList(this.itemInfoList)
  361. return {
  362. activity: parseFloat(activity.toFixed(2)),
  363. normal: parseFloat(normal.toFixed(2))
  364. }
  365. },
  366. /**
  367. * 整单里秒杀/团购商品原价合计,用来从优惠分摊基数里剔除
  368. * 下单时会员折/满减本来就不打在这些活动价上
  369. */
  370. sumOrderActivityOriginal() {
  371. if (this.isGroupBuyOrder) {
  372. return Number(this.orderInfo.goodsPrice) || 0
  373. }
  374. let price = 0
  375. ;(this.goodsInfoList || []).forEach(item => {
  376. if (Number(item.seckillGoodsId) > 0) {
  377. price += Number(item.num || 0) * Number(item.unitPrice || 0)
  378. }
  379. })
  380. return parseFloat(price.toFixed(2))
  381. },
  382. /**
  383. * 整单优惠分摊基数:会员折/满减按「商品+运费包装-红包」后的应付计算,
  384. * prePrice 已扣红包,这里加回红包得到扣优惠前的应付,与下单口径一致
  385. */
  386. getDiscountAllocBase() {
  387. const info = this.orderInfo || {}
  388. const hb = Number(info.hbAmount) || 0
  389. const pre = Number(info.prePrice) || 0
  390. if (pre > 0) {
  391. return parseFloat((pre + hb).toFixed(2))
  392. }
  393. const goods = Number(info.goodsPrice) || 0
  394. const send = Number(info.sendCost) || 0
  395. const pack = Number(info.packingFee) || 0
  396. const labour = Number(info.labourCost) || 0
  397. const service = Number(info.serviceFee) || 0
  398. const base = goods + send + pack + labour + service
  399. return parseFloat(base.toFixed(2))
  400. },
  401. /**
  402. * 只对普通商品勾选原价分摊会员折、满减、红包
  403. * 秒杀已按活动价成交,红包/会员折打在非秒杀应付上,故从分摊基数剔除活动商品原价
  404. * @param {number} original 普通商品勾选原价合计
  405. * @returns {number} 扣除整单优惠后的应退金额
  406. */
  407. applyOrderDiscounts(original) {
  408. if (!(original > 0)) {
  409. return 0
  410. }
  411. const info = this.orderInfo || {}
  412. const discountAmount = Number(info.discountAmount) || 0
  413. const meetCut = Number(info.orderReachDiscountPrice) || 0
  414. const hbAmount = Number(info.hbAmount) || 0
  415. const discountTotal = discountAmount + meetCut + hbAmount
  416. const allocBase = this.getDiscountAllocBase()
  417. const activityOriginal = this.sumOrderActivityOriginal()
  418. let normalBase = allocBase - activityOriginal
  419. if (!(normalBase > 0)) {
  420. normalBase = 0
  421. }
  422. if (!(discountTotal > 0) || !(normalBase > 0)) {
  423. return parseFloat(original.toFixed(2))
  424. }
  425. const deduct = original * discountTotal / normalBase
  426. const money = original - deduct
  427. if (!(money > 0)) {
  428. return 0
  429. }
  430. return parseFloat(money.toFixed(2))
  431. },
  432. /**
  433. * 成品退货数量输入
  434. * 不用 v-model 绑 v-for 项,避免 key 表达式写入 data-event-opts
  435. */
  436. onGoodsCountInput(index, e) {
  437. const val = e && e.detail ? e.detail.value : ''
  438. this.$set(this.goodsInfoList[index], 'refundCount', val)
  439. },
  440. /** 单品退货数量输入 */
  441. onItemCountInput(index, e) {
  442. const val = e && e.detail ? e.detail.value : ''
  443. this.$set(this.itemInfoList[index], 'refundCount', val)
  444. },
  445. goBack() {
  446. uni.navigateBack({ delta: 1 })
  447. },
  448. /**
  449. * 表单取消:重新申请中退回已取消进度页,首次申请则离开本页
  450. */
  451. onFormCancel() {
  452. if (this.reapplying) {
  453. this.reapplying = false
  454. return
  455. }
  456. this.goBack()
  457. },
  458. /**
  459. * 已取消后重新申请:切到表单,提交时后端把该记录改回待审核
  460. */
  461. startReapply() {
  462. if (!this.canReapply) {
  463. return
  464. }
  465. this.reapplying = true
  466. this.remark = ''
  467. this.refundType = 1
  468. },
  469. /** 切换为只退款 */
  470. onOnlyRefund() {
  471. this.refundType = 2
  472. },
  473. init() {
  474. this.reapplying = false
  475. const id = this.option.id
  476. if (!id) {
  477. this.$msg('缺少订单信息')
  478. return
  479. }
  480. uni.showLoading({ mask: true })
  481. getRefundData({ id }).then(res => {
  482. uni.hideLoading()
  483. if (res.code != 1) {
  484. return
  485. }
  486. const data = res.data || {}
  487. this.orderInfo = data.orderInfo || {}
  488. this.couldRefundPrice = Number(data.couldRefundPrice) || 0
  489. this.apply = data.apply || null
  490. this.canApply = data.canApply || 0
  491. this.refundDeadlineTip = data.refundDeadlineTip || ''
  492. this.goodsInfoList = (data.goodsInfoList || []).map(ele => ({
  493. ...ele,
  494. refundCount: '',
  495. refundNum: ele.refundNum || 0
  496. }))
  497. this.itemInfoList = (data.itemInfoList || []).map(ele => ({
  498. ...ele,
  499. refundCount: '',
  500. refundNum: ele.refundNum || 0
  501. }))
  502. }).catch(() => {
  503. uni.hideLoading()
  504. })
  505. },
  506. /**
  507. * 组装勾选商品参数并校验数量
  508. */
  509. buildProduct() {
  510. const selectProduct = []
  511. let hasError = false
  512. ;(this.goodsInfoList || []).forEach(ele => {
  513. const count = Number(ele.refundCount) || 0
  514. const remain = Number(ele.num) - Number(ele.refundNum || 0)
  515. if (count > remain) {
  516. this.$msg(ele.name + '超过可退数量')
  517. hasError = true
  518. return
  519. }
  520. if (count > 0) {
  521. selectProduct.push({
  522. productId: ele.goodsId,
  523. name: ele.name || '',
  524. num: count,
  525. unitType: ele.unitType || 0,
  526. unitName: ele.unitName || '份',
  527. unitPrice: ele.unitPrice,
  528. property: 0,
  529. seckillGoodsId: Number(ele.seckillGoodsId) || 0
  530. })
  531. }
  532. })
  533. ;(this.itemInfoList || []).forEach(ele => {
  534. const count = Number(ele.refundCount) || 0
  535. const remain = Number(ele.num) - Number(ele.refundNum || 0)
  536. if (count > remain) {
  537. this.$msg(ele.name + '超过可退数量')
  538. hasError = true
  539. return
  540. }
  541. if (count > 0) {
  542. selectProduct.push({
  543. productId: ele.itemId,
  544. name: ele.name || '',
  545. num: count,
  546. unitType: ele.unitType || 0,
  547. unitName: ele.unitName || '',
  548. unitPrice: ele.unitPrice,
  549. property: 1
  550. })
  551. }
  552. })
  553. return { selectProduct, hasError }
  554. },
  555. askSubmit() {
  556. if (this.submitting) {
  557. return
  558. }
  559. let selectProduct = []
  560. if (this.refundType == 1) {
  561. const built = this.buildProduct()
  562. if (built.hasError) {
  563. return
  564. }
  565. selectProduct = built.selectProduct
  566. if (this.$util.isEmpty(selectProduct)) {
  567. this.$msg('请选择要退的商品')
  568. return
  569. }
  570. }
  571. if (!(Number(this.refundMoney) > 0) && !this.allowZeroCashRefund) {
  572. this.$msg('退款金额必须大于0')
  573. return
  574. }
  575. if (Number(this.refundMoney) > Number(this.couldRefundPrice)) {
  576. this.$msg('退款金额超过可退金额')
  577. return
  578. }
  579. const money = Number(this.refundMoney) || 0
  580. let title = '确认提交'
  581. let content = money > 0
  582. ? '申请退款 ¥' + this.refundMoney + ',提交后需商家审核'
  583. : '订单实付为0,提交后将申请退回红包,需商家审核'
  584. // 按支付方式补充去向说明(对齐采购售后确认弹窗)
  585. if (money > 0) {
  586. if (Number(this.orderInfo.onlinePay) == 2) {
  587. content = '此单线上付款,审核通过后钱将原路退回。申请退款 ¥' + this.refundMoney + '?'
  588. } else if (Number(this.orderInfo.payWay) == 2) {
  589. content = '此单余额付款,审核通过后钱将退回余额。申请退款 ¥' + this.refundMoney + '?'
  590. } else if (Number(this.orderInfo.payWay) == 3 || Number(this.orderInfo.debt) == 1) {
  591. content = '此单挂账,审核通过后挂账金额会减少。申请退款 ¥' + this.refundMoney + '?'
  592. } else {
  593. title = '特别注意'
  594. content = '此单线下付款,审核通过后需商家确认退回方式。申请退款 ¥' + this.refundMoney + '?'
  595. }
  596. }
  597. uni.showModal({
  598. title: title,
  599. content: content,
  600. success: res => {
  601. if (res.confirm) {
  602. this.doSubmit(selectProduct)
  603. }
  604. }
  605. })
  606. },
  607. doSubmit(selectProduct) {
  608. this.submitting = true
  609. uni.showLoading({ mask: true, title: '提交中' })
  610. const params = {
  611. id: this.option.id,
  612. price: this.refundMoney,
  613. remark: this.remark,
  614. refundType: this.refundType,
  615. product: JSON.stringify(selectProduct || [])
  616. }
  617. createRefund(params).then(res => {
  618. uni.hideLoading()
  619. this.submitting = false
  620. if (res.code == 1) {
  621. this.$msg(res.msg || '提交成功')
  622. this.init()
  623. }
  624. }).catch(() => {
  625. uni.hideLoading()
  626. this.submitting = false
  627. })
  628. },
  629. doCancel() {
  630. if (!this.apply || !this.apply.id) {
  631. return
  632. }
  633. uni.showModal({
  634. title: '提示',
  635. content: '确认撤销该售后申请?',
  636. success: res => {
  637. if (!res.confirm) {
  638. return
  639. }
  640. uni.showLoading({ mask: true })
  641. cancelRefund({ id: this.apply.id }).then(r => {
  642. uni.hideLoading()
  643. if (r.code == 1) {
  644. this.$msg('已撤销')
  645. this.apply = null
  646. this.init()
  647. }
  648. }).catch(() => {
  649. uni.hideLoading()
  650. })
  651. }
  652. })
  653. }
  654. }
  655. }
  656. </script>
  657. <style lang="scss" scoped>
  658. .refund-page {
  659. min-height: 100vh;
  660. background: #f5f6f8;
  661. padding: 20upx 0 200upx;
  662. }
  663. .tip-bar {
  664. margin: 0 20upx 20upx;
  665. padding: 20upx;
  666. background: #fff5f5;
  667. border: 1upx solid #ffd6dc;
  668. border-radius: 12upx;
  669. color: $mainColor;
  670. font-size: 24upx;
  671. line-height: 1.5;
  672. }
  673. /* 支付方式去向提示 */
  674. .tip-section {
  675. margin: 0 20upx 20upx;
  676. padding: 20upx;
  677. border-radius: 12upx;
  678. .tip-text {
  679. display: block;
  680. font-size: 28upx;
  681. line-height: 1.5;
  682. font-weight: 500;
  683. &.online-tip {
  684. background: rgba(51, 133, 255, 0.1);
  685. color: #3385ff;
  686. padding: 16upx 20upx;
  687. border-radius: 8upx;
  688. }
  689. &.debt-tip {
  690. background: rgba(230, 126, 34, 0.12);
  691. color: #e67e22;
  692. padding: 16upx 20upx;
  693. border-radius: 8upx;
  694. }
  695. &.offline-tip {
  696. background: rgba(255, 77, 109, 0.1);
  697. color: #ff4d6d;
  698. padding: 16upx 20upx;
  699. border-radius: 8upx;
  700. }
  701. }
  702. }
  703. .card-section {
  704. background: #fff;
  705. margin: 0 20upx 20upx;
  706. border-radius: 16upx;
  707. box-shadow: 0 2upx 12upx rgba(0, 0, 0, 0.06);
  708. overflow: hidden;
  709. }
  710. .section-title {
  711. padding: 30upx 30upx 20upx;
  712. border-bottom: 1upx solid #f0f0f0;
  713. .title-text {
  714. font-size: 32upx;
  715. font-weight: 600;
  716. color: #333;
  717. }
  718. }
  719. .refund-type-buttons {
  720. padding: 30upx;
  721. display: flex;
  722. .type-btn {
  723. flex: 1;
  724. height: 80upx;
  725. line-height: 80upx;
  726. border-radius: 40upx;
  727. font-size: 28upx;
  728. background: #f8f9fa;
  729. color: #666;
  730. border: 1upx solid #ddd;
  731. margin-right: 24upx;
  732. &:last-child {
  733. margin-right: 0;
  734. }
  735. &.active {
  736. background: linear-gradient(135deg, #ff8fa3, #ff4d6d);
  737. color: #fff;
  738. border-color: transparent;
  739. }
  740. }
  741. }
  742. .product-list-compact {
  743. padding: 0 20upx 20upx;
  744. margin-top: 10upx;
  745. }
  746. .product-row {
  747. display: flex;
  748. align-items: center;
  749. justify-content: space-between;
  750. padding: 20upx;
  751. margin-top: 12upx;
  752. background: #fafbfc;
  753. border-radius: 8upx;
  754. border: 1upx solid #eef0f2;
  755. &:first-child {
  756. margin-top: 0;
  757. }
  758. }
  759. .product-basic-info {
  760. flex: 1;
  761. margin-right: 16upx;
  762. .product-name-compact {
  763. font-size: 30upx;
  764. font-weight: 600;
  765. color: #333;
  766. display: block;
  767. margin-bottom: 8upx;
  768. overflow: hidden;
  769. text-overflow: ellipsis;
  770. white-space: nowrap;
  771. max-width: 380upx;
  772. }
  773. .product-meta {
  774. display: flex;
  775. flex-wrap: wrap;
  776. .stock-info {
  777. font-size: 24upx;
  778. color: #666;
  779. background: #f5f5f5;
  780. padding: 4upx 8upx;
  781. border-radius: 4upx;
  782. margin-right: 12upx;
  783. }
  784. .activity-info {
  785. font-size: 24upx;
  786. color: $mainColor;
  787. background: rgba(255, 40, 66, 0.08);
  788. padding: 4upx 8upx;
  789. border-radius: 4upx;
  790. margin-right: 12upx;
  791. }
  792. .available-info {
  793. font-size: 24upx;
  794. color: $mainColor;
  795. background: rgba(255, 40, 66, 0.08);
  796. padding: 4upx 8upx;
  797. border-radius: 4upx;
  798. }
  799. }
  800. }
  801. .refund-control {
  802. .input-item {
  803. display: flex;
  804. align-items: center;
  805. .input-label {
  806. font-size: 24upx;
  807. color: #666;
  808. margin-right: 8upx;
  809. }
  810. .unit-label {
  811. font-size: 24upx;
  812. color: #666;
  813. margin-left: 8upx;
  814. }
  815. }
  816. .refund-input-compact {
  817. width: 100upx;
  818. height: 60upx;
  819. background: #fff;
  820. border: 1upx solid #ddd;
  821. border-radius: 6upx;
  822. text-align: center;
  823. font-size: 26upx;
  824. color: #333;
  825. &:focus {
  826. border-color: $mainColor;
  827. }
  828. }
  829. }
  830. .amount-info {
  831. padding: 20upx 30upx 30upx;
  832. }
  833. .amount-row {
  834. display: flex;
  835. justify-content: space-between;
  836. align-items: center;
  837. padding: 18upx 0;
  838. border-bottom: 1upx solid #f0f0f0;
  839. &:last-child {
  840. border-bottom: none;
  841. }
  842. .amount-label {
  843. font-size: 28upx;
  844. color: #666;
  845. &.required::after {
  846. content: '*';
  847. color: $mainColor;
  848. margin-left: 4upx;
  849. }
  850. }
  851. .amount-value {
  852. font-size: 30upx;
  853. font-weight: 600;
  854. color: #333;
  855. &.available {
  856. color: $mainColor;
  857. }
  858. &.refund-money {
  859. color: $mainColor;
  860. font-size: 36upx;
  861. }
  862. }
  863. }
  864. .amount-hint {
  865. font-size: 22upx;
  866. color: #999;
  867. margin-top: 8upx;
  868. line-height: 1.4;
  869. }
  870. .remark-container {
  871. padding: 20upx 30upx 30upx;
  872. }
  873. .remark-textarea {
  874. width: 100%;
  875. height: 140upx;
  876. background: #fafbfc;
  877. border: 1upx solid #ddd;
  878. border-radius: 8upx;
  879. padding: 16upx;
  880. font-size: 28upx;
  881. color: #333;
  882. box-sizing: border-box;
  883. }
  884. .status-block {
  885. padding: 30upx;
  886. .status-tag {
  887. display: inline-block;
  888. padding: 8upx 20upx;
  889. border-radius: 8upx;
  890. font-size: 26upx;
  891. margin-bottom: 24upx;
  892. &.st-0 {
  893. background: #fff7e6;
  894. color: #fa8c16;
  895. }
  896. &.st-1 {
  897. background: rgba(255, 40, 66, 0.1);
  898. color: $mainColor;
  899. }
  900. &.st-2 {
  901. background: #fff1f0;
  902. color: #ff4757;
  903. }
  904. &.st-3 {
  905. background: #f5f5f5;
  906. color: #999;
  907. }
  908. }
  909. .status-row {
  910. display: flex;
  911. justify-content: space-between;
  912. padding: 14upx 0;
  913. font-size: 28upx;
  914. .label {
  915. color: #666;
  916. }
  917. .price {
  918. color: $mainColor;
  919. font-weight: 600;
  920. font-size: 32upx;
  921. }
  922. .value {
  923. color: #333;
  924. max-width: 70%;
  925. text-align: right;
  926. &.reject {
  927. color: #ff4757;
  928. }
  929. }
  930. }
  931. }
  932. .empty-tip {
  933. padding: 60upx 30upx;
  934. text-align: center;
  935. color: #999;
  936. font-size: 28upx;
  937. .sub {
  938. display: block;
  939. margin-top: 16upx;
  940. font-size: 24upx;
  941. color: $mainColor;
  942. }
  943. }
  944. .bottom-actions {
  945. z-index: 39;
  946. position: fixed;
  947. bottom: 0;
  948. left: 0;
  949. right: 0;
  950. background: #fff;
  951. padding: 24upx 30upx;
  952. padding-bottom: calc(24upx + env(safe-area-inset-bottom));
  953. border-top: 1upx solid #eee;
  954. display: flex;
  955. box-shadow: 0 -4upx 12upx rgba(0, 0, 0, 0.06);
  956. }
  957. .action-btn {
  958. flex: 1;
  959. height: 88upx;
  960. line-height: 88upx;
  961. border-radius: 44upx;
  962. font-size: 32upx;
  963. font-weight: 600;
  964. border: none;
  965. margin-right: 24upx;
  966. &:last-child {
  967. margin-right: 0;
  968. }
  969. &.cancel-btn {
  970. background: #f8f9fa;
  971. color: #666;
  972. border: 1upx solid #ddd;
  973. }
  974. &.confirm-btn {
  975. background: linear-gradient(135deg, #ff8fa3, #ff4d6d);
  976. color: #fff;
  977. box-shadow: 0 4upx 12upx rgba(255, 77, 109, 0.3);
  978. }
  979. }
  980. </style>