index.vue 9.3 KB

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