refund.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.itemNum)}` }}{{res.bigUnit}}</text>
  21. <text class="product-price">{{`${parseFloat(res.bigPrice)}`}}元/{{res.bigUnit}}</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.bigUnit}}</text>
  26. <text style="color:green;margin-left:20upx;">可退{{Number(res.itemNum)-Number(res.refundNum)}}{{res.bigUnit}}</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 class="flex-center btn-box" style="margin-bottom:50upx;margin-top:20upx;">
  55. <view class="flex-center btn" @tap="cancelRefund">取消</view>
  56. <view class="flex-center btn active" @tap="confirmRefund" style="margin-left: 80upx">确定</view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import TuiListCell from "@/components/plugin/list-cell";
  62. import { getPurchaseDetailApi } from "@/api/purchase";
  63. import { createOrder } from "@/api/cg-refund"
  64. export default {
  65. name: "refund",
  66. components: {
  67. TuiListCell
  68. },
  69. data() {
  70. return {
  71. product:[],
  72. refundMoney:0,
  73. refundType:1,
  74. remark:'',
  75. orderInfo:{},
  76. couldRefundPrice:0
  77. };
  78. },
  79. onShow() {
  80. },
  81. computed:{
  82. refundPrice(){
  83. let price = 0
  84. if(this.product){
  85. for (const item of this.product) {
  86. if(Number(item.refundCount)>0){
  87. let currentPrice = Number(item.refundCount)*Number(item.bigPrice)
  88. currentPrice.toFixed(2)
  89. price = Number(price) + Number(currentPrice)
  90. price.toFixed(2)
  91. }
  92. }
  93. }
  94. price = parseFloat(price.toFixed(2))
  95. this.refundMoney = price
  96. return price
  97. }
  98. },
  99. watch:{
  100. },
  101. methods: {
  102. cancelRefund(){
  103. uni.navigateBack({delta: 1});
  104. },
  105. confirmRefund(){
  106. let hasError = false
  107. let product = []
  108. let that = this
  109. this.product.forEach(ele=>{
  110. let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
  111. let currentNum = ele.itemNum ? Number(ele.itemNum) : 0
  112. let hasRefundNum = ele.refundNum ? Number(ele.refundNum) : 0
  113. let couldRefundNum = Number(currentNum) - Number(hasRefundNum)
  114. if(Number(currentRefundCont) > Number(couldRefundNum)){
  115. uni.showToast({title:ele.name+'超过可退数量',icon:'none'})
  116. hasError = true;
  117. return false
  118. }
  119. if(Number(ele.refundCount)>0){
  120. product.push({
  121. productId:ele.productId,
  122. num:ele.refundCount,
  123. unitType:0,
  124. unitName:ele.bigUnit,
  125. unitPrice:ele.bigPrice
  126. })
  127. }
  128. })
  129. if(hasError){
  130. return
  131. }
  132. if(this.$util.isEmpty(product)&&this.refundType==1){
  133. uni.showToast({title:'请选择花材',icon:'none'})
  134. return;
  135. }
  136. let refundParams = {
  137. id:this.orderInfo.id,
  138. product:JSON.stringify(product),
  139. price:this.refundMoney,
  140. remark:this.remark,
  141. refundType:this.refundType
  142. };
  143. that.$util.confirmModal({content:'确认申请?'},() => {
  144. uni.showLoading({title: "提交中",mask:true})
  145. createOrder(refundParams).then(res => {
  146. if(res.code == 1){
  147. uni.hideLoading()
  148. that.$util.pageTo({url:'/pagesPurchase/refundSuccess',type:2})
  149. }
  150. })
  151. })
  152. },
  153. async init() {
  154. const res = await getPurchaseDetailApi(this.option.orderSn)
  155. this.orderInfo = res.data
  156. this.couldRefundPrice = Number(res.data.orderPrice) - Number(res.data.tkPrice)
  157. this.couldRefundPrice = this.couldRefundPrice.toFixed(2)
  158. this.couldRefundPrice = parseFloat(this.couldRefundPrice)
  159. this.product = res.data.itemInfo.map(ele=>{
  160. return {...ele,refundCount:null}
  161. })
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss" scoped>
  167. .app-content{
  168. height: calc(100vh - 30upx * 2);
  169. padding: 30upx;
  170. background: #FFFFFF;
  171. font-size: 30upx;
  172. .radioBtn{
  173. width: 30upx;
  174. height: 30upx;
  175. margin-right: 10upx;
  176. border: 1upx solid #ddd;
  177. border-radius: 50%;
  178. &.active{
  179. position: relative;
  180. border: 1upx solid #3385ff;
  181. &:after{
  182. content: '';
  183. position: absolute;
  184. width: 18upx;
  185. height: 18upx;
  186. background: #3385ff;
  187. border-radius: 50%;
  188. }
  189. }
  190. }
  191. .refund-item-list{
  192. display: flex;
  193. padding-bottom: 30upx;
  194. padding-top: 30upx;
  195. border-top: 1upx solid #e6e4e4;
  196. border-bottom: 1upx solid #e6e4e4;
  197. .refund-label{
  198. width: 200upx;
  199. color:#666666;
  200. font-size:26upx;
  201. text{color: red;}
  202. }
  203. .list{
  204. margin-bottom: 10upx;
  205. .list-title{
  206. height: 60upx;
  207. padding-bottom: 20upx;
  208. font-size:26upx;
  209. font-weight:bold;
  210. .product-name{
  211. overflow: hidden;
  212. text-overflow:ellipsis;
  213. white-space: nowrap;
  214. width:190upx;
  215. }
  216. .product-price{
  217. overflow: hidden;
  218. text-overflow:ellipsis;
  219. white-space: nowrap;
  220. width:130upx;
  221. margin-left:10upx;
  222. }
  223. .product-num{
  224. width:90upx;
  225. overflow: hidden;
  226. text-overflow:ellipsis;
  227. white-space: nowrap;
  228. margin-left:10upx;
  229. }
  230. }
  231. .list-val{
  232. input{
  233. width: 200upx;
  234. border: 1upx solid #ddd;
  235. text-align: center;
  236. font-weight: normal;
  237. }
  238. }
  239. }
  240. }
  241. .refund-item{
  242. display: flex;
  243. padding: 18upx 0;
  244. .refund-label{
  245. width: 200upx;
  246. color:#666666;
  247. font-size:26upx;
  248. text{
  249. color: red;
  250. }
  251. }
  252. input{
  253. border: 1upx solid #ddd;
  254. }
  255. textarea{
  256. width: calc(100% - 210upx);
  257. height:150upx;
  258. border: 1upx solid #ddd;
  259. }
  260. }
  261. .btn-box{
  262. .btn{
  263. width: 220upx;
  264. height: 90upx;
  265. border: 1upx solid #666666;
  266. border-radius: 10upx;
  267. color:#666666;
  268. &.active{
  269. background: #3385ff;
  270. color: #fff;
  271. border: 1upx solid #3385ff;
  272. }
  273. }
  274. }
  275. }
  276. </style>