refund.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="app-content">
  3. <view class="flex refund-item">
  4. <view class="refund-label">退款方式:</view>
  5. <view class="flex list">
  6. <view class="flex" @tap="refundType=1" >
  7. <view class="flex-center radioBtn" :class="refundType==1?'active':''">
  8. </view>退货并退款</view>
  9. <view style="margin-left: 30upx" class="flex" @tap="refundType=2">
  10. <view class="flex-center radioBtn" :class="refundType==1?'':'active'">
  11. </view>只退款</view>
  12. </view>
  13. </view>
  14. <view class="refund-item-list" v-if="refundType==1">
  15. <view class="refund-label"><text></text>选择商品:</view>
  16. <view>
  17. <view class="list" v-for="(res,i) in product" :key="i">
  18. <view class="flex list-title" >
  19. <text class="product-name">{{res.name}}</text>
  20. <text class="product-num">{{ `${parseFloat(res.xhNum)}` }}{{res.xhUnitName}}</text>
  21. <text class="product-price">{{`${parseFloat(res.xhUnitPrice)}`}}元/{{res.xhUnitName}}</text>
  22. </view>
  23. <view class="flex list-val" style="font-size:26upx;font-weight:bold;">
  24. <input type="number" placeholder="退货数" v-model="res.refundCount" placeholder-style="color:#CCCCCC" />
  25. <text style="margin-left:10upx;">{{res.xhUnitName}}</text>
  26. <text style="color:green;margin-left:20upx;">可退{{Number(res.xhNum)-Number(res.refundNum)}}{{res.xhUnitName}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="flex refund-item">
  32. <view class="refund-label">订单金额:</view>
  33. <view class="list">
  34. ¥{{parseFloat(orderInfo.orderPrice)||0}}
  35. <text style="margin-left:25upx;font-size:25upx;color:green;" v-if="Number(orderInfo.tkPrice)>0">已退¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</text>
  36. </view>
  37. </view>
  38. <view class="flex refund-item">
  39. <view class="refund-label">可退金额:</view>
  40. <view class="list">¥{{couldRefundPrice}}</view>
  41. </view>
  42. <view class="flex refund-item">
  43. <view class="refund-label">合计退款:</view>
  44. <view class="list">¥{{refundPrice}}</view>
  45. </view>
  46. <view class="flex refund-item">
  47. <view class="refund-label"><text></text>实际退款:</view>
  48. <input type="digit" v-model="refundMoney">
  49. </view>
  50. <view class="refund-item">
  51. <view class="refund-label">备注:</view>
  52. <textarea v-model="remark" />
  53. </view>
  54. <view style="padding:20upx 0 20upx 0;font-size:32upx;font-weight:bold;">
  55. <text v-if="orderInfo.onlinePay == 2" style="color:green;">此单线上付款,提交后,钱会原路自动退回给客户</text>
  56. <block v-else>
  57. <text v-if="Number(orderInfo.debtPrice)>0" style="color:#3385ff;">
  58. 此单为欠款单,提交后,欠款金额会自动减少
  59. </text>
  60. <text v-else style="color:red;">此单线下付款,提交后钱不会原路退回,请线下转账给客户</text>
  61. </block>
  62. </view>
  63. <view class="flex-center btn-box" style="margin-bottom:50upx;margin-top:20upx;padding-bottom:10upx;">
  64. <view class="flex-center btn" @tap="cancelRefund">取消</view>
  65. <view class="flex-center btn active" @tap="confirmRefund" style="margin-left: 80upx">确定</view>
  66. </view>
  67. <view style="font-size:32upx;z-index:9999;color:red;text-align:center;font-weight:bold;margin-bottom:30upx;"
  68. v-if="!$util.isEmpty(unClear)" @click="goClear(unClear)">
  69. <text>有一个待结账单 ¥{{unClear.actPrice?parseFloat(unClear.actPrice):0}}</text>
  70. <text style="font-weight:bold;margin-left:15upx;">查看</text>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import stepStatus from "./components/stepStatus";
  76. import TuiListCell from "@/components/plugin/list-cell";
  77. import { getDetail,refund } from "@/api/order/index";
  78. import { ORDER_STATUS } from "@/utils/declare";
  79. import { getUnClear } from "@/api/clear"
  80. export default {
  81. name: "orderDetail",
  82. components: {
  83. stepStatus,
  84. TuiListCell
  85. },
  86. data() {
  87. return {
  88. ORDER_STATUS,
  89. product:[],
  90. refundMoney:0,
  91. refundType:1,
  92. remark:'',
  93. orderInfo:{},
  94. couldRefundPrice:0,
  95. unClear:[]
  96. };
  97. },
  98. onShow() {
  99. },
  100. computed:{
  101. refundPrice(){
  102. let price = 0
  103. if(this.product){
  104. for (const item of this.product) {
  105. if(Number(item.refundCount)>0){
  106. let currentPrice = Number(item.refundCount)*Number(item.xhUnitPrice)
  107. currentPrice.toFixed(2)
  108. price = Number(price) + Number(currentPrice)
  109. price.toFixed(2)
  110. }
  111. }
  112. }
  113. price = parseFloat(price.toFixed(2))
  114. this.refundMoney = price
  115. return price
  116. }
  117. },
  118. watch:{
  119. },
  120. methods: {
  121. cancelRefund(){
  122. uni.navigateBack({delta: 1});
  123. },
  124. confirmRefund(){
  125. let hasError = false
  126. let product = []
  127. let that = this
  128. this.product.forEach(ele=>{
  129. let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
  130. let currentNum = ele.xhNum ? Number(ele.xhNum) : 0
  131. let hasRefundNum = ele.refundNum ? Number(ele.refundNum) : 0
  132. let couldRefundNum = Number(currentNum) - Number(hasRefundNum)
  133. if(Number(currentRefundCont) > Number(couldRefundNum)){
  134. uni.showToast({title:ele.name+'超过可退数量',icon:'none'})
  135. hasError = true;
  136. return false
  137. }
  138. if(Number(ele.refundCount)>0){
  139. product.push({
  140. "productId":ele.productId,
  141. "num":ele.refundCount,
  142. "unitType":ele.unitType,
  143. unitName:ele.xhUnitName,
  144. unitType:ele.xhUnitType,
  145. unitPrice:ele.xhUnitPrice
  146. })
  147. }
  148. })
  149. if(hasError){
  150. return
  151. }
  152. if(this.$util.isEmpty(product)&&this.refundType==1){
  153. uni.showToast({title:'请选择商品',icon:'none'})
  154. return;
  155. }
  156. let refundParams = {
  157. id:this.option.id,
  158. product:JSON.stringify(product),
  159. price:this.refundMoney,
  160. remark:this.remark,
  161. refundType:this.refundType,
  162. getOriginalItem:1
  163. };
  164. that.$util.confirmModal({content:'确认退款?'},() => {
  165. uni.showLoading({title: "提交中",mask:true})
  166. refund(refundParams).then(res => {
  167. if(res.code == 1){
  168. uni.hideLoading()
  169. if(res.data.error && res.data.error == 'hasUnClearOrder'){
  170. that.needCancelRemind(res.data.clearId)
  171. }else{
  172. this.$util.pageTo({url: '/pagesOrder/refundSuccess?id='+res.data.id,type:2})
  173. }
  174. }
  175. })
  176. })
  177. },
  178. needCancelRemind(id){
  179. let that = this
  180. that.$util.confirmModal({content:'有结账单取消了才能退款?',okText:'去取消',cancelText:'不操作'},() => {
  181. that.$util.pageTo({url: '/admin/clear/customInfo?id='+id})
  182. })
  183. },
  184. async init() {
  185. //getOriginalItem 取原有的花材结构(小菊的花材结构有变化)
  186. const res = await getDetail({ id: this.option.id,getOriginalItem:1 })
  187. this.orderInfo = res.data
  188. this.couldRefundPrice = Number(res.data.orderPrice) - Number(res.data.tkPrice)
  189. this.couldRefundPrice = this.couldRefundPrice.toFixed(2)
  190. this.couldRefundPrice = parseFloat(this.couldRefundPrice)
  191. this.product = res.data.product.map(ele=>{
  192. return {...ele,refundCount:null}
  193. })
  194. let customId = res.data.customId ? res.data.customId : 0
  195. if(Number(customId)>0){
  196. getUnClear({customId:customId}).then(res=>{
  197. if(res.code == 1){
  198. this.unClear = res.data.info
  199. }
  200. })
  201. }
  202. },
  203. goClear(item){
  204. this.$util.pageTo({url:'/admin/clear/customInfo?id='+item.id})
  205. },
  206. }
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. .app-content{
  211. height: calc(100vh - 30upx * 2);
  212. padding: 30upx;
  213. background: #FFFFFF;
  214. font-size: 30upx;
  215. .radioBtn{
  216. width: 30upx;
  217. height: 30upx;
  218. margin-right: 10upx;
  219. border: 1upx solid #ddd;
  220. border-radius: 50%;
  221. &.active{
  222. position: relative;
  223. border: 1upx solid #3385ff;
  224. &:after{
  225. content: '';
  226. position: absolute;
  227. width: 18upx;
  228. height: 18upx;
  229. background: #3385ff;
  230. border-radius: 50%;
  231. }
  232. }
  233. }
  234. .refund-item-list{
  235. display: flex;
  236. padding-bottom: 30upx;
  237. padding-top: 30upx;
  238. border-top: 1upx solid #e6e4e4;
  239. border-bottom: 1upx solid #e6e4e4;
  240. .refund-label{
  241. width: 200upx;
  242. color:#666666;
  243. font-size:26upx;
  244. text{color: red;}
  245. }
  246. .list{
  247. margin-bottom: 10upx;
  248. .list-title{
  249. height: 60upx;
  250. padding-bottom: 20upx;
  251. font-size:26upx;
  252. font-weight:bold;
  253. .product-name{
  254. overflow: hidden;
  255. text-overflow:ellipsis;
  256. white-space: nowrap;
  257. width:190upx;
  258. }
  259. .product-price{
  260. overflow: hidden;
  261. text-overflow:ellipsis;
  262. white-space: nowrap;
  263. width:130upx;
  264. margin-left:10upx;
  265. }
  266. .product-num{
  267. width:90upx;
  268. overflow: hidden;
  269. text-overflow:ellipsis;
  270. white-space: nowrap;
  271. margin-left:10upx;
  272. }
  273. }
  274. .list-val{
  275. input{
  276. width: 200upx;
  277. border: 1upx solid #ddd;
  278. text-align: center;
  279. font-weight: normal;
  280. }
  281. }
  282. }
  283. }
  284. .refund-item{
  285. display: flex;
  286. padding: 18upx 0;
  287. .refund-label{
  288. width: 200upx;
  289. color:#666666;
  290. font-size:26upx;
  291. text{
  292. color: red;
  293. }
  294. }
  295. input{
  296. border: 1upx solid #ddd;
  297. }
  298. textarea{
  299. width: calc(100% - 210upx);
  300. height:150upx;
  301. border: 1upx solid #ddd;
  302. }
  303. }
  304. .btn-box{
  305. .btn{
  306. width: 220upx;
  307. height: 90upx;
  308. border: 1upx solid #666666;
  309. border-radius: 10upx;
  310. color:#666666;
  311. &.active{
  312. background: #3385ff;
  313. color: #fff;
  314. border: 1upx solid #3385ff;
  315. }
  316. }
  317. }
  318. }
  319. </style>