index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="subRefund">
  4. <view class='apply-return'>
  5. <view class='goodsStyle acea-row row-between' v-for="(item,index) in refundCartInfo" :key="index">
  6. <view class='pictrue'>
  7. <image :src='item.productInfo.attrInfo?item.productInfo.attrInfo.image:item.productInfo.image'>
  8. </image>
  9. </view>
  10. <view class='text acea-row row-between'>
  11. <view class='name line2'>{{item.productInfo.store_name}}</view>
  12. <view class='money'>
  13. <view>
  14. {{$t(`¥`)}}{{(parseFloat(item.truePrice)+parseFloat(item.postage_price/item.cart_num)).toFixed(2)}}
  15. </view>
  16. <view class='num'>x{{item.cart_num}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class='list'>
  21. <view class='item acea-row row-between-wrapper'>
  22. <view>{{$t(`退货件数`)}}</view>
  23. <view class='num' v-if="refundCartInfo.length !== 1 || refund_total_num == 1">
  24. {{refund_total_num}}
  25. </view>
  26. <picker v-else class='num' @change="returnGoodsNum" :value="refund_num_index"
  27. :range="refundNumData">
  28. <view class="picker acea-row row-between-wrapper">
  29. <view class='reason'>{{refundNumData[refund_num_index]}}</view>
  30. <text class='iconfont icon-jiantou'></text>
  31. </view>
  32. </picker>
  33. </view>
  34. <view class='item acea-row row-between-wrapper' v-if="status && status._type !== 1">
  35. <view>{{$t(`退款类型`)}}</view>
  36. <picker v-if="status._is_back" class='num' @change="returnGoodsChange" :value="returnGoods"
  37. :range="returnGoodsData">
  38. <view class="picker acea-row row-between-wrapper">
  39. <view class='reason'>{{returnGoodsData[returnGoods]}}</view>
  40. <text class='iconfont icon-jiantou'></text>
  41. </view>
  42. </picker>
  43. <view class="" v-else>
  44. 仅退款
  45. </view>
  46. </view>
  47. <view class='item acea-row row-between-wrapper'>
  48. <view>{{$t(`退款原因`)}}</view>
  49. <picker class='num' @change="bindPickerChange" :value="index" :range="RefundArray">
  50. <view class="picker acea-row row-between-wrapper">
  51. <view class='reason'>{{RefundArray[index]}}</view>
  52. <text class='iconfont icon-jiantou'></text>
  53. </view>
  54. </picker>
  55. </view>
  56. <view class='item textarea acea-row row-between'>
  57. <view>{{$t(`备注说明`)}}</view>
  58. <textarea :placeholder='$t(`填写备注信息,100字以内`)' class='num' name="refund_reason_wap_explain"
  59. :placeholder-class='$t(`填写备注信息,100字以内`)'></textarea>
  60. </view>
  61. <view class='item acea-row row-between upload'>
  62. <view class='title acea-row row-between-wrapper'>
  63. <view>{{$t(`上传图片`)}}</view>
  64. <view class='tip'></view>
  65. </view>
  66. <view class='upload acea-row row-middle'>
  67. <view class='pictrue' v-for="(item,index) in refund_reason_wap_img" :key="index">
  68. <image :src='item'></image>
  69. <view class='iconfont icon-guanbi1 font-num' @tap='DelPic(index)'></view>
  70. </view>
  71. <view class='pictrue acea-row row-center-wrapper row-column' @tap='uploadpic'
  72. v-if="refund_reason_wap_img.length < 3">
  73. <text class='iconfont icon-icon25201'></text>
  74. <view>{{$t(`上传图片`)}}</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <button class='returnBnt bg-color' form-type="submit">{{$t(`申请退款`)}}</button>
  80. </view>
  81. </form>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. ordeRefundReason,
  87. orderRefundVerify,
  88. getOrderDetail,
  89. returnGoodsSubmit,
  90. postRefundGoods
  91. } from '@/api/order.js';
  92. import {
  93. toLogin
  94. } from '@/libs/login.js';
  95. import {
  96. mapGetters
  97. } from "vuex";
  98. // #ifdef MP
  99. import authorize from '@/components/Authorize';
  100. // #endif
  101. import colors from '@/mixins/color.js';
  102. export default {
  103. components: {
  104. // #ifdef MP
  105. authorize
  106. // #endif
  107. },
  108. mixins: [colors],
  109. data() {
  110. return {
  111. id: 0,
  112. cartIds: [],
  113. refund_reason_wap_img: [],
  114. status: {},
  115. RefundArray: [],
  116. refundCartInfo: [],
  117. returnGoodsData: [this.$t(`仅退款`), this.$t(`退货并退款`)],
  118. refund_total_num: 0,
  119. index: 0,
  120. returnGoods: 0,
  121. orderId: 0,
  122. refundNumData: [],
  123. refund_num_index: 0,
  124. isRes: false
  125. };
  126. },
  127. computed: mapGetters(['isLogin']),
  128. watch: {
  129. isLogin: {
  130. handler: function(newV, oldV) {
  131. if (newV) {
  132. this.refundGoodsInfo();
  133. this.getRefundReason();
  134. }
  135. },
  136. deep: true
  137. }
  138. },
  139. onLoad(options) {
  140. this.orderId = options.orderId;
  141. this.id = options.id;
  142. if (options.cartIds) {
  143. this.cartIds = JSON.parse(options.cartIds) || []
  144. }
  145. if (this.isLogin) {
  146. this.refundGoodsInfo();
  147. this.getRefundReason();
  148. } else {
  149. toLogin();
  150. }
  151. },
  152. methods: {
  153. refundGoodsInfo() {
  154. postRefundGoods({
  155. id: this.id,
  156. cart_ids: this.cartIds
  157. }).then(res => {
  158. let data = res.data;
  159. this.status = data._status;
  160. this.refundCartInfo = data.cartInfo;
  161. this.refundCartInfo.forEach(item => {
  162. this.refund_total_num = this.$util.$h.Add(this.refund_total_num, item.cart_num)
  163. })
  164. this.refundNumData = Array(this.refund_total_num).fill(0).map((e, i) => i + 1)
  165. this.refundCartInfo.length === 1 ? this.refund_num_index = this.refundNumData.length - 1 : ''
  166. }).catch(err => {
  167. return this.$util.Tips({
  168. title: err
  169. });
  170. })
  171. },
  172. /**
  173. * 获取退款理由
  174. */
  175. getRefundReason: function() {
  176. let that = this;
  177. ordeRefundReason().then(res => {
  178. that.$set(that, 'RefundArray', res.data);
  179. })
  180. },
  181. /**
  182. * 删除图片
  183. *
  184. */
  185. DelPic: function(e) {
  186. let index = e,
  187. that = this,
  188. pic = this.refund_reason_wap_img[index];
  189. that.refund_reason_wap_img.splice(index, 1);
  190. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  191. },
  192. /**
  193. * 上传文件
  194. *
  195. */
  196. uploadpic: function() {
  197. let that = this;
  198. this.$util.uploadImageOne('upload/image', function(res) {
  199. that.refund_reason_wap_img.push(res.data.url);
  200. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  201. });
  202. },
  203. /**
  204. * 申请退货
  205. */
  206. subRefund: function(e) {
  207. if (this.isRes) return
  208. uni.showLoading({
  209. title: this.$t(`申请中`)
  210. });
  211. let that = this,
  212. value = e.detail.value;
  213. //收集form表单
  214. if (!value.refund_reason_wap_explain) return this.$util.Tips({
  215. title: this.$t(`请输入备注`)
  216. });
  217. let cartInfo = this.refundCartInfo;
  218. if (cartInfo.length === 1) {
  219. this.cartIds = [{
  220. cart_id: cartInfo[0].id,
  221. cart_num: this.refund_num_index + 1
  222. }]
  223. }
  224. this.isRes = true
  225. returnGoodsSubmit(this.id, {
  226. text: that.RefundArray[that.index] || '',
  227. refund_reason_wap_explain: value.refund_reason_wap_explain,
  228. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  229. refund_type: this.returnGoods == 1 ? 2 : 1,
  230. uni: that.orderId,
  231. cart_ids: this.cartIds
  232. }).then(res => {
  233. uni.hideLoading();
  234. this.isRes = false
  235. return this.$util.Tips({
  236. title: this.$t(`申请成功`),
  237. icon: 'success'
  238. }, {
  239. tab: 5,
  240. url: '/pages/users/user_return_list/index?isT=1'
  241. });
  242. }).catch(err => {
  243. uni.hideLoading();
  244. this.isRes = false
  245. return this.$util.Tips({
  246. title: err
  247. });
  248. })
  249. },
  250. bindPickerChange(e) {
  251. this.$set(this, 'index', e.detail.value);
  252. },
  253. returnGoodsChange(e) {
  254. this.$set(this, 'returnGoods', e.detail.value);
  255. },
  256. returnGoodsNum(e) {
  257. this.$set(this, 'refund_num_index', Number(e.detail.value));
  258. }
  259. }
  260. }
  261. </script>
  262. <style scoped lang="scss">
  263. .apply-return .list {
  264. background-color: #fff;
  265. margin-top: 18rpx;
  266. }
  267. .apply-return .list .item {
  268. margin-left: 30rpx;
  269. padding-right: 30rpx;
  270. min-height: 90rpx;
  271. border-bottom: 1rpx solid #eee;
  272. font-size: 30rpx;
  273. color: #333;
  274. }
  275. .apply-return .list .item .num {
  276. color: #282828;
  277. width: 427rpx;
  278. text-align: right;
  279. }
  280. .apply-return .list .item .num .picker .reason {
  281. width: 385rpx;
  282. }
  283. .apply-return .list .item .num .picker .iconfont {
  284. color: #666;
  285. font-size: 30rpx;
  286. margin-top: 2rpx;
  287. }
  288. .apply-return .list .item.textarea {
  289. padding: 30rpx 30rpx 30rpx 0;
  290. }
  291. .apply-return .list .item textarea {
  292. height: 100rpx;
  293. font-size: 30rpx;
  294. }
  295. .apply-return .list .item .placeholder {
  296. color: #bbb;
  297. }
  298. .apply-return .list .item .title {
  299. height: 95rpx;
  300. width: 100%;
  301. }
  302. .apply-return .list .item .title .tip {
  303. font-size: 30rpx;
  304. color: #bbb;
  305. }
  306. .apply-return .list .item .upload {
  307. padding-bottom: 36rpx;
  308. }
  309. .apply-return .list .item .upload .pictrue {
  310. margin: 22rpx 23rpx 0 0;
  311. width: 156rpx;
  312. height: 156rpx;
  313. position: relative;
  314. font-size: 24rpx;
  315. color: #bbb;
  316. }
  317. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  318. margin-right: 0;
  319. }
  320. .apply-return .list .item .upload .pictrue image {
  321. width: 100%;
  322. height: 100%;
  323. border-radius: 3rpx;
  324. }
  325. .apply-return .list .item .upload .pictrue .icon-guanbi1 {
  326. position: absolute;
  327. font-size: 45rpx;
  328. top: -10rpx;
  329. right: -10rpx;
  330. }
  331. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  332. color: #bfbfbf;
  333. font-size: 50rpx;
  334. }
  335. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  336. border: 1rpx solid #ddd;
  337. box-sizing: border-box;
  338. }
  339. .apply-return .returnBnt {
  340. font-size: 32rpx;
  341. color: #fff;
  342. width: 690rpx;
  343. height: 86rpx;
  344. border-radius: 50rpx;
  345. text-align: center;
  346. line-height: 86rpx;
  347. margin: 43rpx auto;
  348. }
  349. .goodsStyle .text .name {
  350. align-self: flex-start;
  351. }
  352. .list /deep/ .uni-input-input {
  353. text-align: right;
  354. }
  355. .acea-row {
  356. flex-wrap: nowrap;
  357. }
  358. .upload {
  359. flex-wrap: wrap;
  360. }
  361. </style>