index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. let that = this,
  201. value = e.detail.value;
  202. //收集form表单
  203. if (!value.refund_reason_wap_explain) return this.$util.Tips({
  204. title: this.$t(`请输入备注`)
  205. });
  206. let cartInfo = this.refundCartInfo;
  207. if (cartInfo.length === 1) {
  208. this.cartIds = [{
  209. cart_id: cartInfo[0].id,
  210. cart_num: this.refund_num_index + 1
  211. }]
  212. }
  213. returnGoodsSubmit(this.id, {
  214. text: that.RefundArray[that.index] || '',
  215. refund_reason_wap_explain: value.refund_reason_wap_explain,
  216. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  217. refund_type: this.returnGoods ? 2 : 1,
  218. uni: that.orderId,
  219. cart_ids: this.cartIds
  220. }).then(res => {
  221. return this.$util.Tips({
  222. title: this.$t(`申请成功`),
  223. icon: 'success'
  224. }, {
  225. tab: 5,
  226. url: '/pages/users/user_return_list/index?isT=1'
  227. });
  228. }).catch(err => {
  229. return this.$util.Tips({
  230. title: err
  231. });
  232. })
  233. },
  234. bindPickerChange(e) {
  235. this.$set(this, 'index', e.detail.value);
  236. },
  237. returnGoodsChange(e) {
  238. this.$set(this, 'returnGoods', e.detail.value);
  239. },
  240. returnGoodsNum(e) {
  241. this.$set(this, 'refund_num_index', Number(e.detail.value));
  242. }
  243. }
  244. }
  245. </script>
  246. <style scoped lang="scss">
  247. .apply-return .list {
  248. background-color: #fff;
  249. margin-top: 18rpx;
  250. }
  251. .apply-return .list .item {
  252. margin-left: 30rpx;
  253. padding-right: 30rpx;
  254. min-height: 90rpx;
  255. border-bottom: 1rpx solid #eee;
  256. font-size: 30rpx;
  257. color: #333;
  258. }
  259. .apply-return .list .item .num {
  260. color: #282828;
  261. width: 427rpx;
  262. text-align: right;
  263. }
  264. .apply-return .list .item .num .picker .reason {
  265. width: 385rpx;
  266. }
  267. .apply-return .list .item .num .picker .iconfont {
  268. color: #666;
  269. font-size: 30rpx;
  270. margin-top: 2rpx;
  271. }
  272. .apply-return .list .item.textarea {
  273. padding: 30rpx 30rpx 30rpx 0;
  274. }
  275. .apply-return .list .item textarea {
  276. height: 100rpx;
  277. font-size: 30rpx;
  278. }
  279. .apply-return .list .item .placeholder {
  280. color: #bbb;
  281. }
  282. .apply-return .list .item .title {
  283. height: 95rpx;
  284. width: 100%;
  285. }
  286. .apply-return .list .item .title .tip {
  287. font-size: 30rpx;
  288. color: #bbb;
  289. }
  290. .apply-return .list .item .upload {
  291. padding-bottom: 36rpx;
  292. }
  293. .apply-return .list .item .upload .pictrue {
  294. margin: 22rpx 23rpx 0 0;
  295. width: 156rpx;
  296. height: 156rpx;
  297. position: relative;
  298. font-size: 24rpx;
  299. color: #bbb;
  300. }
  301. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  302. margin-right: 0;
  303. }
  304. .apply-return .list .item .upload .pictrue image {
  305. width: 100%;
  306. height: 100%;
  307. border-radius: 3rpx;
  308. }
  309. .apply-return .list .item .upload .pictrue .icon-guanbi1 {
  310. position: absolute;
  311. font-size: 45rpx;
  312. top: -10rpx;
  313. right: -10rpx;
  314. }
  315. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  316. color: #bfbfbf;
  317. font-size: 50rpx;
  318. }
  319. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  320. border: 1rpx solid #ddd;
  321. box-sizing: border-box;
  322. }
  323. .apply-return .returnBnt {
  324. font-size: 32rpx;
  325. color: #fff;
  326. width: 690rpx;
  327. height: 86rpx;
  328. border-radius: 50rpx;
  329. text-align: center;
  330. line-height: 86rpx;
  331. margin: 43rpx auto;
  332. }
  333. .goodsStyle .text .name {
  334. align-self: flex-start;
  335. }
  336. .list /deep/ .uni-input-input {
  337. text-align: right;
  338. }
  339. .acea-row {
  340. flex-wrap: nowrap;
  341. }
  342. .upload {
  343. flex-wrap: wrap;
  344. }
  345. </style>