apply_refund.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="apply-refund">
  3. <view class="goods bg-white m-t-20">
  4. <view class="flex">
  5. <u-image width="160rpx" height="160rpx" border-radius="6rpx" lazy-load :src="goods.image" />
  6. <view class="goods-info">
  7. <view class="line-2">{{goods.goods_name}}</view>
  8. <view class="xs muted m-t-10">{{goods.spec_value}}</view>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="opt-box m-t-20 bg-white">
  13. <view v-show="!hiddenOpt">
  14. <view class="opt-item flex row-between border-line" @tap="onlyRefund">
  15. <view>
  16. <view class="lg">仅退款</view>
  17. <view class="muted xs m-t-10">未收到货,与卖家协商同意无需退货只需退款</view>
  18. </view>
  19. <u-icon class="m-l-10" name="arrow-right" size="28" />
  20. </view>
  21. <view class="opt-item flex row-between" @tap="allRefunds">
  22. <view>
  23. <view class="lg">退货退款</view>
  24. <view class="muted xs m-t-10">已收到货,需退还收到的实物</view>
  25. </view>
  26. <u-icon class="m-l-10" name="arrow-right" size="28" />
  27. </view>
  28. </view>
  29. <view v-show="hiddenOpt">
  30. <view class="refund-info flex row-between m-t-20">
  31. <view class="lable">数量</view>
  32. <view>{{goods.goods_num}}</view>
  33. </view>
  34. <view class="refund-info flex row-between">
  35. <view class="lable">退款金额</view>
  36. <price-format :color="colorConfig.primary" :price="goods.total_pay_price" />
  37. </view>
  38. <view class="refund-info flex row-between" @tap="showPop=true">
  39. <view class="lable">退款原因</view>
  40. <view class="flex">
  41. <text :class="{muted: !reasonString}">{{reasonString ? reasonString : '请选择' }}</text>
  42. <u-icon class="m-l-10" name="arrow-right" size="28" />
  43. </view>
  44. </view>
  45. <view class="refund-info flex col-top">
  46. <view class="label">备注说明</view>
  47. <view class="flex-1" style="background-color: #F8F8F8;">
  48. <u-input v-model="remark" type="textarea" placeholder="请描述申请售后的具体原因,100字以内" :border="false"
  49. :height="160" />
  50. </view>
  51. </view>
  52. <view class="upload bg-white">
  53. <view class="title flex row-between">
  54. <view>上传凭证</view>
  55. <view class="muted">(选填,最多可上传1张)</view>
  56. </view>
  57. <u-upload ref="uUpload" :show-progress="false" :header="{token: $store.getters.token}"
  58. :max-count="1" width="160" height="160" :action="action" upload-text="上传图片"
  59. @on-success="onSuccess" @on-remove="onRemove" />
  60. </view>
  61. </view>
  62. </view>
  63. <button v-show="hiddenOpt" class="btn br60" type="primary" size="lg" @tap="onSubmit">申请退款</button>
  64. <u-select v-model="showPop" mode="single-column" value-name="index" label-name="name" :list="reason"
  65. @confirm="confirmSelect"></u-select>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. refundOptType
  71. } from "@/utils/type";
  72. import {
  73. baseURL
  74. } from '@/config/app';
  75. import {
  76. getGoodsInfo,
  77. applyAfterSale,
  78. applyAgain
  79. } from "@/api/user";
  80. import {
  81. uploadFile,
  82. trottle
  83. } from '@/utils/tools.js';
  84. export default {
  85. data() {
  86. return {
  87. action: baseURL + '/api/file/formimage',
  88. hiddenOpt: false,
  89. optTyle: refundOptType.ONLY_REFUND,
  90. goods: {},
  91. reason: [],
  92. showPop: false,
  93. reasonString: '',
  94. fileList: [],
  95. remark: ""
  96. };
  97. },
  98. onLoad(options) {
  99. const {
  100. order_id,
  101. item_id,
  102. after_sale_id
  103. } = this.$Route.query
  104. this.orderId = order_id;
  105. this.itemId = item_id;
  106. this.afterSaleId = after_sale_id;
  107. this.getGoodsInfoFun();
  108. this.onSubmit = trottle(this.onSubmit, 1000, this)
  109. },
  110. methods: {
  111. confirmSelect(e) {
  112. this.reasonString = e[0].label
  113. },
  114. onlyRefund() {
  115. this.optTyle = refundOptType.ONLY_REFUND
  116. this.hiddenOpt = true
  117. },
  118. allRefunds() {
  119. this.optTyle = refundOptType.REFUNDS;
  120. this.hiddenOpt = true;
  121. },
  122. onSuccess(e) {
  123. this.fileList.push(e.data.base_uri)
  124. },
  125. onRemove(index) {
  126. this.fileList.splice(index, 1)
  127. console.log(index)
  128. },
  129. async onSubmit() {
  130. const {
  131. reason,
  132. reasonString,
  133. optTyle,
  134. remark,
  135. fileList
  136. } = this;
  137. if (!reasonString) {
  138. return this.$toast({
  139. title: '请选择退款原因'
  140. });
  141. }
  142. const params = {
  143. reason: reasonString,
  144. refund_type: optTyle,
  145. remark: remark,
  146. img: fileList.length ? fileList[0] : ''
  147. };
  148. if (this.afterSaleId) {
  149. params.id = this.afterSaleId
  150. } else {
  151. params.item_id = this.itemId
  152. params.order_id = this.orderId
  153. }
  154. const {
  155. data,
  156. code,
  157. msg
  158. } = this.afterSaleId ? await applyAgain(params) : await applyAfterSale(params)
  159. if (code == 1) {
  160. this.$toast({
  161. title: msg
  162. });
  163. uni.$emit("refreshsale")
  164. setTimeout(() => {
  165. this.$Router.replace({
  166. path: '/bundle/pages/after_sales_detail/after_sales_detail',
  167. query: {
  168. id: data.after_sale_id
  169. }
  170. })
  171. }, 1000)
  172. }
  173. },
  174. getGoodsInfoFun() {
  175. let {
  176. orderId,
  177. itemId
  178. } = this;
  179. getGoodsInfo({
  180. order_id: orderId,
  181. item_id: itemId
  182. }).then(res => {
  183. if (res.code == 1) {
  184. this.goods = res.data.goods;
  185. this.reason = res.data.reason.map((item, index) => ({
  186. name: item,
  187. index
  188. }));
  189. }
  190. });
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss">
  196. .apply-refund {
  197. padding-bottom: 50rpx;
  198. .goods {
  199. padding: 20rpx 24rpx;
  200. .goods-info {
  201. margin-left: 24rpx;
  202. flex: 1;
  203. }
  204. }
  205. }
  206. .opt-box {
  207. .opt-item {
  208. padding: 20rpx 20rpx 30rpx;
  209. }
  210. }
  211. .apply-refund {
  212. .refund-info {
  213. padding: 24rpx 20rpx;
  214. border-bottom: $-solid-border;
  215. .label {
  216. width: 140rpx;
  217. margin-top: 19rpx;
  218. }
  219. textarea {
  220. flex: 1;
  221. height: 172rpx;
  222. border-radius: 10rpx;
  223. padding: 20rpx;
  224. box-sizing: border-box;
  225. }
  226. }
  227. .upload {
  228. padding: 0 20rpx 30rpx;
  229. .title {
  230. padding: 24rpx 0;
  231. }
  232. }
  233. .btn {
  234. margin: 30rpx 26rpx
  235. }
  236. }
  237. </style>