index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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'></image>
  8. </view>
  9. <view class='text acea-row row-between'>
  10. <view class='name line2'>{{item.productInfo.store_name}}</view>
  11. <view class='money'>
  12. <view>¥{{item.truePrice}}</view>
  13. <view class='num'>x{{item.cart_num}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class='list'>
  18. <view class='item acea-row row-between-wrapper'>
  19. <view>退货件数</view>
  20. <view class='num' v-if="refundCartInfo.length !== 1 || refund_total_num == 1">
  21. {{refund_total_num}}
  22. </view>
  23. <picker v-else class='num' @change="returnGoodsNum" :value="refund_num_index" :range="refundNumData">
  24. <view class="picker acea-row row-between-wrapper">
  25. <view class='reason'>{{refundNumData[refund_num_index]}}</view>
  26. <text class='iconfont icon-jiantou'></text>
  27. </view>
  28. </picker>
  29. <!-- <input type="number" v-model="refund_num" @input="inputNumber" v-else /> -->
  30. </view>
  31. <!-- <view class='item acea-row row-between-wrapper'>
  32. <view>退款金额</view>
  33. <view class='num' v-if="refundCartInfo.length !== 1">¥{{refund_pay_price.toFixed(2)}}</view>
  34. <view class='num' v-else>¥{{refund_Money.toFixed(2)}}
  35. </view>
  36. </view> -->
  37. <view class='item acea-row row-between-wrapper'
  38. v-if="status && status._type !== 1 && !productType">
  39. <view>退款类型</view>
  40. <picker class='num' @change="returnGoodsChange" :value="returnGoods" :range="returnGoodsData">
  41. <view class="picker acea-row row-between-wrapper">
  42. <view class='reason'>{{returnGoodsData[returnGoods]}}</view>
  43. <text class='iconfont icon-jiantou'></text>
  44. </view>
  45. </picker>
  46. </view>
  47. <view class='item acea-row row-between-wrapper'>
  48. <view>退款原因</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>备注说明</view>
  58. <textarea placeholder='填写备注信息,100字以内' class='num' name="refund_reason_wap_explain"
  59. placeholder-class='填写备注信息,100字以内'></textarea>
  60. </view>
  61. <view class='item acea-row row-between'>
  62. <view class='title acea-row row-between-wrapper'>
  63. <view>上传凭证</view>
  64. <view class='tip'>( 最多可上传3张 )</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>上传凭证</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <button class='returnBnt bg-color' form-type="submit">申请退款</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. import colors from '@/mixins/color.js';
  99. export default {
  100. components: {},
  101. mixins: [colors],
  102. data() {
  103. return {
  104. id:0,
  105. cartIds:[],
  106. refund_reason_wap_img: [],
  107. status: {},
  108. RefundArray: [],
  109. refundCartInfo: [],
  110. returnGoodsData: ['仅退款', '退货并退款'],
  111. refund_total_num: 0,
  112. index: 0,
  113. returnGoods: 0,
  114. orderId: 0,
  115. refundNumData: [],
  116. refund_num_index: 0,
  117. productType: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. this.productType = parseInt(options.productType) || 0;
  136. if(options.cartIds){
  137. this.cartIds = JSON.parse(options.cartIds) || []
  138. }
  139. if (this.isLogin) {
  140. this.refundGoodsInfo();
  141. this.getRefundReason();
  142. } else {
  143. toLogin();
  144. }
  145. },
  146. onShow() {
  147. uni.removeStorageSync('form_type_cart');
  148. },
  149. methods: {
  150. refundGoodsInfo(){
  151. postRefundGoods({id:this.id,cart_ids:this.cartIds}).then(res=>{
  152. let data = res.data;
  153. this.status = data._status;
  154. this.refundCartInfo = data.cartInfo;
  155. this.refundCartInfo.forEach(item=>{
  156. this.refund_total_num = this.$util.$h.Add(this.refund_total_num, item.cart_num)
  157. })
  158. this.refundNumData = Array(this.refund_total_num).fill(0).map((e, i) => i + 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: '请输入备注说明'
  205. });
  206. let cartInfo = this.refundCartInfo;
  207. if(cartInfo.length === 1){
  208. this.cartIds = [
  209. {
  210. cart_id:cartInfo[0].id,
  211. cart_num: this.refund_num_index + 1
  212. }
  213. ]
  214. }
  215. returnGoodsSubmit(this.id, {
  216. text: that.RefundArray[that.index] || '',
  217. refund_reason_wap_explain: value.refund_reason_wap_explain,
  218. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  219. refund_type: this.returnGoods ? 2 : 1,
  220. uni: that.orderId,
  221. cart_ids: this.cartIds
  222. }).then(res => {
  223. return this.$util.Tips({
  224. title: '申请成功',
  225. icon: 'success'
  226. }, {
  227. tab: 5,
  228. url: '/pages/users/user_return_list/index?isT=1'
  229. });
  230. }).catch(err => {
  231. return this.$util.Tips({
  232. title: err
  233. });
  234. })
  235. },
  236. bindPickerChange(e) {
  237. this.$set(this, 'index', e.detail.value);
  238. },
  239. returnGoodsChange(e) {
  240. this.$set(this, 'returnGoods', e.detail.value);
  241. },
  242. returnGoodsNum(e) {
  243. this.$set(this, 'refund_num_index', Number(e.detail.value));
  244. }
  245. }
  246. }
  247. </script>
  248. <style scoped lang="scss">
  249. .apply-return .list {
  250. background-color: #fff;
  251. margin-top: 18rpx;
  252. }
  253. .apply-return .list .item {
  254. margin-left: 30rpx;
  255. padding-right: 30rpx;
  256. min-height: 90rpx;
  257. border-bottom: 1rpx solid #eee;
  258. font-size: 30rpx;
  259. color: #333;
  260. }
  261. .apply-return .list .item .num {
  262. color: #282828;
  263. width: 427rpx;
  264. text-align: right;
  265. }
  266. .apply-return .list .item .num .picker .reason {
  267. width: 385rpx;
  268. }
  269. .apply-return .list .item .num .picker .iconfont {
  270. color: #666;
  271. font-size: 30rpx;
  272. margin-top: 2rpx;
  273. }
  274. .apply-return .list .item.textarea {
  275. padding: 30rpx 30rpx 30rpx 0;
  276. }
  277. .apply-return .list .item textarea {
  278. height: 100rpx;
  279. font-size: 30rpx;
  280. }
  281. .apply-return .list .item .placeholder {
  282. color: #bbb;
  283. }
  284. .apply-return .list .item .title {
  285. height: 95rpx;
  286. width: 100%;
  287. }
  288. .apply-return .list .item .title .tip {
  289. font-size: 30rpx;
  290. color: #bbb;
  291. }
  292. .apply-return .list .item .upload {
  293. padding-bottom: 36rpx;
  294. }
  295. .apply-return .list .item .upload .pictrue {
  296. margin: 22rpx 23rpx 0 0;
  297. width: 156rpx;
  298. height: 156rpx;
  299. position: relative;
  300. font-size: 24rpx;
  301. color: #bbb;
  302. }
  303. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  304. margin-right: 0;
  305. }
  306. .apply-return .list .item .upload .pictrue image {
  307. width: 100%;
  308. height: 100%;
  309. border-radius: 3rpx;
  310. }
  311. .apply-return .list .item .upload .pictrue .icon-guanbi1 {
  312. position: absolute;
  313. font-size: 45rpx;
  314. top: -10rpx;
  315. right: -10rpx;
  316. }
  317. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  318. color: #bfbfbf;
  319. font-size: 50rpx;
  320. }
  321. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  322. border: 1rpx solid #ddd;
  323. box-sizing: border-box;
  324. }
  325. .apply-return .returnBnt {
  326. font-size: 32rpx;
  327. color: #fff;
  328. width: 690rpx;
  329. height: 86rpx;
  330. border-radius: 50rpx;
  331. text-align: center;
  332. line-height: 86rpx;
  333. margin: 43rpx auto;
  334. }
  335. .goodsStyle .text .name {
  336. align-self: flex-start;
  337. }
  338. .list /deep/ .uni-input-input {
  339. text-align: right;
  340. }
  341. </style>