refund.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <app-layout>
  3. <view v-if="is_show" class="refund-box">
  4. <view class='goods-box'>
  5. <app-jump-button :url="`/pages/goods/goods?id=${refundDetail.goods_id}`">
  6. <app-order-goods-info style="width:100%;" :goods='refundDetail.goods_info'></app-order-goods-info>
  7. </app-jump-button>
  8. </view>
  9. <view class='tab-box' v-if="switchBool">
  10. <app-switch-tab :currentIndex="type" :list='tabList' @tabEvent='tabClick'></app-switch-tab>
  11. </view>
  12. <form class='form-box'>
  13. <view class='dir-left-nowrap remark-box'>
  14. <view class='box-grow-0 label'>
  15. {{type == 0 ? '退款' : '换货'}}原因
  16. </view>
  17. <view class='box-grow-1'>
  18. <app-textarea
  19. padding-y="0"
  20. padding-x="20"
  21. v-model="remark"
  22. font-size="32"
  23. :show-border="false"
  24. :placeholder="`请输入${type == 0 ? '退款' : '换货'}原因`">
  25. </app-textarea>
  26. </view>
  27. </view>
  28. <block v-if='type == 0'>
  29. <view class='dir-left-nowrap price-box'>
  30. <view>退款金额</view>
  31. <input v-model="refund_price" name='refund_price'
  32. placeholder-style="color:#aaa"
  33. :placeholder="`最多可退款${refundDetail.refund_price}`" class='price'/>
  34. </view>
  35. </block>
  36. <view class='image-box'>
  37. <view class="label">上传凭证</view>
  38. <app-upload-image
  39. backgroundColor="#fff"
  40. @imageEvent='imageEvent'
  41. :maxNum='maxNum'>
  42. </app-upload-image>
  43. </view>
  44. <view>
  45. <app-jump-button>
  46. <view @click="formSubmit" class="btn main-center cross-center">提交</view>
  47. </app-jump-button>
  48. </view>
  49. </form>
  50. </view>
  51. </app-layout>
  52. </template>
  53. <script>
  54. import appSwitchTab from "../../../components/basic-component/app-switch-tab/app-switch-tab.vue";
  55. import appOrderGoodsInfo from "../../../components/page-component/app-order-goods-info/app-order-goods-info.vue";
  56. import appUploadImage from "../../../components/basic-component/app-upload-image/app-upload-image.vue";
  57. import appTextarea from "../../../components/basic-component/app-textarea/app-textarea.vue";
  58. export default {
  59. components: {
  60. "app-textarea": appTextarea,
  61. "app-order-goods-info": appOrderGoodsInfo,
  62. "app-switch-tab": appSwitchTab,
  63. 'app-upload-image': appUploadImage
  64. },
  65. data() {
  66. return {
  67. id: 0,
  68. refundDetail: {},
  69. tabList: [
  70. {
  71. 'name': '退货退款'
  72. },
  73. {
  74. 'name': '换货'
  75. },
  76. ],
  77. type: 0, // 售后类型
  78. maxNum: 6, // 图片上传最大数量
  79. imageList: [],
  80. is_show: false,
  81. switchBool: true,
  82. }
  83. },
  84. methods: {
  85. tabClick(e) {
  86. this.type = e.currentIndex;
  87. },
  88. getRefundDetail() {
  89. let self = this;
  90. self.$showLoading();
  91. self.$request({
  92. url: this.$api.order.apply_refund,
  93. data: {
  94. id: self.id,
  95. }
  96. }).then(response => {
  97. self.$hideLoading();
  98. self.is_show = true;
  99. if (response.code === 0) {
  100. self.refundDetail = response.data.detail;
  101. } else {
  102. uni.showModal({
  103. title: '',
  104. content: response.msg,
  105. showCancel: false,
  106. });
  107. }
  108. }).catch(() => {
  109. self.$hideLoading();
  110. });
  111. },
  112. formSubmit() {
  113. let self = this;
  114. this.$subscribe(this.refundDetail.template_message_list).then(response => {
  115. self.submitAction();
  116. }).catch(res => {
  117. self.submitAction();
  118. });
  119. },
  120. submitAction() {
  121. let self = this;
  122. if (!self.remark) {
  123. let text = self.type == 0 ? '退款' : '换货';
  124. uni.showModal({
  125. title: '',
  126. content: '请填写' + text + '原因',
  127. showCancel: false,
  128. });
  129. return;
  130. }
  131. let refundPrice = self.type == 0 ? self.refund_price : 0;
  132. if (self.type == 0 && !refundPrice || refundPrice < 0) {
  133. uni.showModal({
  134. title: '',
  135. content: '请填写退款金额',
  136. showCancel: false,
  137. });
  138. return;
  139. }
  140. uni.showLoading({
  141. title: '提交中'
  142. });
  143. self.$request({
  144. url: self.$api.order.refund_submit,
  145. method: "post",
  146. data: {
  147. id: self.id,
  148. type: self.type + 1,
  149. pic_list: JSON.stringify(self.imageList),
  150. refund_price: refundPrice,
  151. remark: this.remark,
  152. },
  153. }).then(response => {
  154. uni.hideLoading();
  155. if (response.code === 0) {
  156. uni.redirectTo({
  157. url: '/pages/order/refund/index'
  158. })
  159. } else {
  160. uni.showModal({
  161. title: '',
  162. content: response.msg,
  163. showCancel: false,
  164. });
  165. }
  166. }).catch(() => {
  167. uni.hideLoading();
  168. });
  169. },
  170. imageEvent(e) {
  171. this.imageList = e.imageList
  172. }
  173. },
  174. onLoad(options) {
  175. this.id = options.id;
  176. if (options.sign === 'gift') {
  177. this.type = 1;
  178. this.switchBool = false;
  179. }
  180. this.getRefundDetail();
  181. },
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .refund-box {
  186. position: absolute;
  187. width: 100%;
  188. height: 100%;
  189. }
  190. .goods-box {
  191. padding: 30#{rpx} 24#{rpx};
  192. border-top: 1#{rpx} solid #e3e3e3;
  193. background-color: #fff;
  194. margin-bottom: 20#{rpx};
  195. }
  196. .form-box .btn {
  197. background-color: #ff4544;
  198. color: #fff;
  199. margin-top: 100#{rpx};
  200. width: 90%;
  201. border-radius: 46#{rpx};
  202. height: 92#{rpx};
  203. }
  204. .form-box .remark-box {
  205. background-color: #fff;
  206. margin-top: 20#{rpx};
  207. padding: 20#{rpx};
  208. }
  209. .form-box .price-box {
  210. background-color: #fff;
  211. padding: 30#{rpx} 20#{rpx};
  212. margin-top: 20#{rpx};
  213. }
  214. .form-box .price-box .price {
  215. color: #ff4544;
  216. margin-left: 20#{rpx};
  217. }
  218. .form-box .image-box {
  219. padding: 20#{rpx};
  220. background-color: #fff;
  221. margin-top: 20#{rpx};
  222. .label {
  223. margin-bottom: 20#{rpx};
  224. color: $uni-important-color-black;
  225. font-size: $uni-font-size-general-one;
  226. }
  227. }
  228. </style>