refund.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <style lang="scss" scoped>
  2. .app-content{
  3. height: calc(100vh - 30upx * 2);
  4. padding: 30upx;
  5. background: #FFFFFF;
  6. font-size: 30upx;
  7. .radioBtn{
  8. width: 30upx;
  9. height: 30upx;
  10. margin-right: 10upx;
  11. border: 1upx solid #ddd;
  12. border-radius: 50%;
  13. &.active{
  14. position: relative;
  15. border: 1upx solid #3385ff;
  16. &:after{
  17. content: '';
  18. position: absolute;
  19. width: 18upx;
  20. height: 18upx;
  21. background: #3385ff;
  22. border-radius: 50%;
  23. }
  24. }
  25. }
  26. .refund-item-list{
  27. display: flex;
  28. padding-bottom: 30upx;
  29. border-bottom: 1upx solid #dddddd;
  30. .refund-label{
  31. width: 200upx;
  32. text{color: red;}
  33. }
  34. .list{
  35. margin-bottom: 10upx;
  36. .list-title{
  37. height: 60upx;
  38. padding-bottom: 20upx;
  39. .product-name{
  40. overflow: hidden;
  41. text-overflow:ellipsis;
  42. white-space: nowrap;
  43. width:310upx;
  44. margin-right:20upx;
  45. }
  46. }
  47. .list-val{
  48. input{
  49. width: 150upx;
  50. border: 1upx solid #ddd;
  51. }
  52. text{
  53. padding: 0 30upx;
  54. }
  55. }
  56. }
  57. }
  58. .refund-item{
  59. display: flex;
  60. padding: 18upx 0;
  61. .refund-label{
  62. width: 200upx;
  63. text{
  64. color: red;
  65. }
  66. }
  67. input{
  68. border: 1upx solid #ddd;
  69. }
  70. textarea{
  71. width: calc(100% - 210upx);
  72. height:150upx;
  73. border: 1upx solid #ddd;
  74. }
  75. }
  76. .btn-box{
  77. .btn{
  78. width: 200upx;
  79. height: 60upx;
  80. border: 1upx solid #666666;
  81. border-radius: 10upx;
  82. &.active{
  83. background: #3385ff;
  84. color: #fff;
  85. border: 1upx solid #3385ff;
  86. }
  87. }
  88. }
  89. }
  90. </style>
  91. <template>
  92. <view class="app-content">
  93. <view class="flex refund-item">
  94. <view class="refund-label">退款方式:</view>
  95. <view class="flex list">
  96. <view class="flex" @tap="refundType=1" ><view class="flex-center radioBtn" :class="refundType==1?'active':''"></view>退货并退款</view>
  97. <view style="margin-left: 20upx" class="flex" @tap="refundType=2"><view class="flex-center radioBtn" :class="refundType==1?'':'active'"></view>仅退款</view>
  98. </view>
  99. </view>
  100. <view class="refund-item-list" v-if="refundType==1">
  101. <view class="refund-label"><text></text>选择商品:</view>
  102. <view>
  103. <view class="list" v-for="(res,i) in product" :key="i">
  104. <view class="flex list-title" >
  105. <text class="product-name">{{res.name}}</text> {{ `${parseFloat(res.num)}` }}扎 {{`¥${parseFloat(res.price)}`}}
  106. </view>
  107. <view class="flex list-val">
  108. <input type="number" @blur="inputFun" v-model="res.big"><text>扎</text>
  109. <input type="number" @blur="inputFun" v-model="res.small"><text>支</text>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <view class="flex refund-item">
  115. <view class="refund-label">订单原价:</view>
  116. <view class="list">¥{{parseFloat(orderInfo.prePrice)||0}}</view>
  117. </view>
  118. <view class="flex refund-item" v-if="orderInfo.discountType == 4">
  119. <view class="refund-label">红包优惠:</view>
  120. <view class="list">
  121. <text style="color:red;margin-right:20upx;">-¥{{parseFloat(orderInfo.discountAmount) || 0}}</text>
  122. <text v-if="parseFloat(orderInfo.realPrice) == parseFloat(refundMoney)" style="color:red;">红包将退还客户</text>
  123. </view>
  124. </view>
  125. <view class="flex refund-item">
  126. <view class="refund-label">实付金额:</view>
  127. <view class="list">¥{{parseFloat(orderInfo.realPrice)||0}}</view>
  128. </view>
  129. <view class="flex refund-item">
  130. <view class="refund-label"><text></text>退款金额:</view>
  131. <input type="digit" v-model="refundMoney">
  132. </view>
  133. <view class="refund-item">
  134. <view class="refund-label">备注:</view>
  135. <textarea v-model="remark" />
  136. </view>
  137. <view class="refund-item">
  138. <view style="color:#CCCCCC;">每个订单只能发起一次退款</view>
  139. </view>
  140. <view class="flex-center btn-box" style="margin-bottom:50upx;margin-top:20upx;">
  141. <view class="flex-center btn" @tap="retreatPage">取消</view>
  142. <view class="flex-center btn active" @tap="refundFun" style="margin-left: 50upx">确定</view>
  143. </view>
  144. </view>
  145. </template>
  146. <script>
  147. import stepStatus from "./components/stepStatus";
  148. import TuiListCell from "@/components/plugin/list-cell";
  149. import { getDetail,refund } from "@/api/order/index";
  150. import { ORDER_STATUS } from "@/utils/declare";
  151. export default {
  152. name: "orderDetail",
  153. components: {
  154. stepStatus,
  155. TuiListCell
  156. },
  157. data() {
  158. return {
  159. ORDER_STATUS,
  160. isMonitor:true,
  161. product:[],
  162. refundMoney:0,
  163. refundType:1,
  164. remark:'',
  165. refundPrice:0,
  166. orderInfo:{},
  167. discount:1
  168. };
  169. },
  170. onShow() {
  171. },
  172. computed:{
  173. },
  174. watch:{
  175. product: {
  176. handler(newVal) {
  177. if(this.refundType == 2){
  178. return
  179. }
  180. this.refundPrice = 0
  181. if(!this.$util.isEmpty(newVal)){
  182. newVal.forEach(ele=>{
  183. let unitPrice = ele.unitPrice;
  184. let big = ele.big * unitPrice;
  185. let small = (ele.small * ele.smallUnitPrice).toFixed(2);
  186. this.refundPrice = (Number(this.refundPrice) + big + Number(small)).toFixed(2);
  187. })
  188. }
  189. let mayRefundMoney = parseFloat((this.refundPrice * this.discount).toFixed(2))
  190. if(Number(mayRefundMoney) > Number(this.orderInfo.realPrice)){
  191. mayRefundMoney = parseFloat(this.orderInfo.realPrice)
  192. }
  193. this.refundMoney = Number(mayRefundMoney) == 0 ? null : Number(mayRefundMoney)
  194. },
  195. deep: true
  196. }
  197. },
  198. methods: {
  199. retreatPage(){
  200. uni.navigateBack({delta: 1});
  201. },
  202. refundFun(){
  203. let product = [];
  204. let hasError = false;
  205. let that = this
  206. this.product.forEach(ele=>{
  207. if(ele.big>0||ele.small>0){
  208. product.push({"productId":ele.productId,"bigNum":ele.big?ele.big:0,"smallNum":ele.small?ele.small:0});
  209. }
  210. if(!this.$util.isEmpty(ele.big) && ele.big <= 0){
  211. uni.showToast({title:'数量填写有误',icon:'none'})
  212. hasError = true;
  213. return;
  214. }
  215. if(!this.$util.isEmpty(ele.small) && ele.small <= 0){
  216. uni.showToast({title:'数量填写有误',icon:'none'})
  217. hasError = true
  218. return;
  219. }
  220. })
  221. if(hasError){
  222. return
  223. }
  224. if(this.refundMoney<=0){
  225. uni.showToast({title:'退款金额不能小于0',icon:'none'});return;
  226. }
  227. if(this.$util.isEmpty(product)&&this.refundType==1){
  228. uni.showToast({title:'请选择商品',icon:'none'})
  229. return;
  230. }
  231. let parameter = {id:this.option.id,product:JSON.stringify(product),price:this.refundMoney,remark:this.remark,refundType:this.refundType,getOriginalItem:1};
  232. that.$util.confirmModal({content:'确认退款?'},() => {
  233. uni.showLoading({title: "提交中",mask:true})
  234. refund(parameter).then(res => {
  235. if(res.code == 1){
  236. uni.hideLoading()
  237. uni.navigateTo({url:'/common/success',query:{titleType:1}})
  238. }
  239. })
  240. })
  241. },
  242. inputFun(e){
  243. this.product.forEach(ele=>{
  244. if(Number(ele.big)>Number(ele.bigNum)){
  245. uni.showToast({title:'不能大于总数量',icon:'none'})
  246. ele.big = ele.bigNum;
  247. }
  248. if(Number(ele.small)>Number(ele.smallNum)){
  249. uni.showToast({title:'不能大于总数量',icon:'none'})
  250. ele.small = ele.smallNum;
  251. }
  252. })
  253. },
  254. selectProduct(index){
  255. this.product[index].isActive = !this.product[index].isActive;
  256. },
  257. async init() {
  258. const res = await getDetail({
  259. id: this.option.id,getOriginalItem:1
  260. });
  261. this.orderInfo = res.data
  262. this.discount = parseFloat((this.orderInfo.realPrice / this.orderInfo.prePrice).toFixed(2))
  263. this.product = res.data.product.map(ele=>{
  264. return {...ele,isActive:false,big:null,small:null}
  265. })
  266. },
  267. }
  268. };
  269. </script>