index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="subRefund">
  4. <view class='apply-return'>
  5. <view class="return">
  6. <view class='goodsStyle acea-row row-between' v-for="(item,index) in refundCartInfo" :key="index">
  7. <view class='pictrue'>
  8. <image class="w-136 h-136 rd-16rpx" :src="item.productInfo.image"></image>
  9. </view>
  10. <view class='text'>
  11. <view class="nameCon">
  12. <view class='name line2'>{{item.productInfo.store_name}}</view>
  13. </view>
  14. <view class="num">购买数量:{{item.cart_num}}</view>
  15. </view>
  16. </view>
  17. <view class="tips acea-row row-middle" v-if="refundNum">
  18. <text class="title">售后退款</text>
  19. <text>有{{refundCartInfo.length}}个商品已申请售后</text>
  20. </view>
  21. </view>
  22. <view class='list'>
  23. <view class='item acea-row row-between-wrapper'>
  24. <view>退款金额</view>
  25. <text class="text--w111-333 fs-36 Regular font-color"> -¥{{refund_price}}</text>
  26. </view>
  27. <view class='item acea-row row-between-wrapper'>
  28. <view>售后类型</view>
  29. <view v-if="status && status._type !== 1 && !productType" class="picker acea-row row-between-wrapper" @click="returnTypeTap">
  30. <view class='reason'>{{returnType}}</view>
  31. <text class='iconfont icon-ic_rightarrow'></text>
  32. </view>
  33. <view v-else class="num">仅退款(无需退货)</view>
  34. </view>
  35. <view class='item acea-row row-between-wrapper'>
  36. <view>退货件数</view>
  37. <view class='num' v-if="refundCartInfo.length !== 1 || refund_total_num == 1">
  38. {{refund_total_num}}
  39. </view>
  40. <picker v-else class='num' @change="returnGoodsNum" :value="refund_num_index" :range="refundNumData">
  41. <view class="picker acea-row row-between-wrapper">
  42. <view class='reason'>{{refundNumData[refund_num_index]}}</view>
  43. <text class='iconfont icon-ic_rightarrow'></text>
  44. </view>
  45. </picker>
  46. <!-- <input type="number" v-model="refund_num" @input="inputNumber" v-else /> -->
  47. </view>
  48. <view class='item acea-row row-between-wrapper' v-if="refundReason.RefundArray.length">
  49. <view>申请原因</view>
  50. <view class="num" @click="reasonTap">
  51. <view class="picker acea-row row-between-wrapper">
  52. <view class='reason'>{{refundItem}}</view>
  53. <text class='iconfont icon-ic_rightarrow'></text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="list">
  59. <view class='item textarea'>
  60. <view class="acea-row row-between-wrapper">
  61. <view>申请说明</view>
  62. <view class="fontNum">{{fontNum}}/100</view>
  63. </view>
  64. <textarea placeholder='必填,请您详细填写备注说明' placeholder-class="placeholder" maxlength=100 name="refund_reason_wap_explain" @input="sumfontnum"></textarea>
  65. </view>
  66. <view class='item acea-row row-between'>
  67. <view class='upload acea-row row-middle'>
  68. <view class='pictrue' v-for="(item,index) in refund_reason_wap_img" :key="index">
  69. <image :src='item' mode="aspectFill"></image>
  70. <view class='iconfont icon-ic_close' @tap='DelPic(index)'></view>
  71. </view>
  72. <view class='pictrue acea-row row-center-wrapper row-column' @tap='uploadpic'
  73. v-if="refund_reason_wap_img.length < 3">
  74. <image class="img" src="../static/ic_camera.png"></image>
  75. <view>上传凭证</view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view style="height: 140rpx;"></view>
  81. <view class="bntCon flex-center fixed-lb pb-safe">
  82. <button class='returnBnt bg-color' form-type="submit">申请退款</button>
  83. </view>
  84. </view>
  85. </form>
  86. <refundPopup :refundData='refundReason' @changeClose='changeClose' @selectInfo='selectInfo'></refundPopup>
  87. <refundPopup :refundData='returnGoods' @changeClose='changeGoodsClose' @selectInfo='selectGoodsInfo'></refundPopup>
  88. <!-- #ifdef MP -->
  89. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  90. <!-- #endif -->
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. ordeRefundReason,
  96. orderRefundVerify,
  97. getOrderDetail,
  98. returnGoodsSubmit,
  99. postRefundGoods
  100. } from '@/api/order.js';
  101. import {
  102. toLogin
  103. } from '@/libs/login.js';
  104. import {
  105. mapGetters
  106. } from "vuex";
  107. import refundPopup from '../components/refundPopup/index.vue'
  108. import colors from '@/mixins/color.js';
  109. export default {
  110. components: {
  111. refundPopup
  112. },
  113. mixins: [colors],
  114. data() {
  115. return {
  116. id:0,
  117. cartIds:[],
  118. refund_reason_wap_img: [],
  119. status: {},
  120. refundCartInfo: [],
  121. refund_total_num: 0,
  122. orderId: 0,
  123. refundNumData: [],
  124. refund_num_index: 0,
  125. productType:0,
  126. isShowAuth: false,
  127. refund_price:0,
  128. fontNum:0,
  129. maxPrice:0,
  130. refundNum:0,
  131. refundItem:'',
  132. refundReason:{
  133. RefundArray: [],
  134. show:false
  135. },
  136. returnType:'',
  137. returnGoods:{
  138. RefundArray: ['仅退款(无需退货)', '退货退款(快递退回)','退货退款(到店退货)'],
  139. show:false
  140. },
  141. returnGoodsIndex:0,
  142. delivery_type:0
  143. };
  144. },
  145. computed: {
  146. ...mapGetters(['isLogin']),
  147. inputWid() {
  148. return function(value) {
  149. if (value == '') {
  150. return '300rpx';
  151. } else {
  152. console.log(String(value).length)
  153. return String(value).length * 16 + 'rpx';
  154. }
  155. };
  156. }
  157. },
  158. watch: {
  159. isLogin: {
  160. handler: function(newV, oldV) {
  161. if (newV) {
  162. //#ifndef MP
  163. this.refundGoodsInfo();
  164. this.getRefundReason();
  165. //#endif
  166. }
  167. },
  168. deep: true
  169. }
  170. },
  171. onLoad(options) {
  172. this.returnType = this.returnGoods.RefundArray[0];
  173. this.orderId = options.orderId;
  174. this.id = options.id;
  175. this.store_id = options.store_id;
  176. this.productType = parseInt(options.productType) || 0;
  177. if(options.cartIds){
  178. this.cartIds = JSON.parse(options.cartIds) || []
  179. }
  180. if (options.store_id == 0) {
  181. this.returnGoods.RefundArray.pop()
  182. }
  183. if (this.isLogin) {
  184. this.refundGoodsInfo();
  185. this.getRefundReason();
  186. } else {
  187. toLogin()
  188. }
  189. },
  190. onShow() {
  191. uni.removeStorageSync('form_type_cart');
  192. },
  193. methods: {
  194. onLoadFun(){
  195. this.refundGoodsInfo();
  196. this.getRefundReason();
  197. this.isShowAuth = false
  198. },
  199. // 授权关闭
  200. authColse: function(e) {
  201. this.isShowAuth = e
  202. },
  203. reasonTap(){
  204. this.refundReason.show = true;
  205. },
  206. changeClose(){
  207. this.refundReason.show = false;
  208. },
  209. selectInfo(e){
  210. this.refundItem = this.refundReason.RefundArray[e];
  211. this.changeClose();
  212. },
  213. returnTypeTap(){
  214. this.returnGoods.show = true;
  215. },
  216. changeGoodsClose(){
  217. this.returnGoods.show = false;
  218. },
  219. selectGoodsInfo(e){
  220. this.returnGoodsIndex = e;
  221. this.returnType = this.returnGoods.RefundArray[e];
  222. this.changeGoodsClose();
  223. },
  224. // 最大限制金额
  225. replaceInput(e){
  226. if(e.detail.value>=this.maxPrice){
  227. setTimeout(()=>{
  228. this.refund_price = this.maxPrice
  229. },0)
  230. }
  231. },
  232. // 限制文本框字数
  233. sumfontnum(e) {
  234. this.fontNum = e.detail.value.length
  235. },
  236. refundGoodsInfo(){
  237. postRefundGoods({id:this.id,cart_ids:this.cartIds}).then(res=>{
  238. let data = res.data;
  239. this.status = data._status;
  240. this.refundCartInfo = data.cartInfo;
  241. this.refundNum = data.refund_num;
  242. let refundPrice = 0
  243. this.refundCartInfo.forEach(item=>{
  244. this.refund_total_num = this.$util.$h.Add(this.refund_total_num, item.cart_num);
  245. let price = this.$util.$h.Add(this.refund_price, this.$util.$h.Mul(item.cart_num,item.truePrice));
  246. refundPrice = price
  247. })
  248. if(this.refundCartInfo.length !== 1 || this.refund_total_num == 1){
  249. this.refund_price = refundPrice;
  250. this.maxPrice = refundPrice;
  251. }else{
  252. let truePrice = this.refundCartInfo[0].truePrice;
  253. this.refund_price = truePrice;
  254. this.maxPrice = truePrice;
  255. }
  256. this.refundNumData = Array(this.refund_total_num).fill(0).map((e, i) => i + 1)
  257. }).catch(err=>{
  258. return this.$util.Tips({
  259. title: err
  260. });
  261. })
  262. },
  263. /**
  264. * 获取退款理由
  265. */
  266. getRefundReason: function() {
  267. let that = this;
  268. ordeRefundReason().then(res => {
  269. that.$set(that.refundReason, 'RefundArray', res.data);
  270. this.refundItem = res.data[0];
  271. })
  272. },
  273. /**
  274. * 删除图片
  275. *
  276. */
  277. DelPic: function(e) {
  278. let index = e,
  279. that = this,
  280. pic = this.refund_reason_wap_img[index];
  281. that.refund_reason_wap_img.splice(index, 1);
  282. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  283. },
  284. /**
  285. * 上传文件
  286. *
  287. */
  288. uploadpic: function() {
  289. let that = this;
  290. this.$util.uploadImageOne('upload/image', function(res) {
  291. that.refund_reason_wap_img.push(res.data.url);
  292. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  293. });
  294. },
  295. /**
  296. * 申请退货
  297. */
  298. subRefund: function(e) {
  299. let that = this,
  300. value = e.detail.value;
  301. //收集form表单
  302. if (!value.refund_reason_wap_explain) return this.$util.Tips({
  303. title: '请输入申请说明'
  304. });
  305. let cartInfo = this.refundCartInfo;
  306. if(cartInfo.length === 1){
  307. this.cartIds = [
  308. {
  309. cart_id:cartInfo[0].id,
  310. cart_num: this.refund_num_index + 1
  311. }
  312. ]
  313. }
  314. returnGoodsSubmit(this.id, {
  315. text: that.refundItem || '',
  316. refund_reason_wap_explain: value.refund_reason_wap_explain,
  317. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  318. refund_type: parseInt(this.returnGoodsIndex)+1,
  319. uni: that.orderId,
  320. cart_ids: this.cartIds,
  321. refund_price: this.refund_price
  322. }).then(res => {
  323. return this.$util.Tips({
  324. title: '申请成功',
  325. icon: 'success'
  326. }, {
  327. tab: 5,
  328. url: '/pages/users/user_return_list/index?isT=1'
  329. });
  330. }).catch(err => {
  331. return this.$util.Tips({
  332. title: err
  333. });
  334. })
  335. },
  336. returnGoodsNum(e) {
  337. let num = Number(e.detail.value);
  338. this.$set(this, 'refund_num_index', num);
  339. let price = this.$util.$h.Mul(this.refundNumData[num],this.refundCartInfo[0].truePrice);
  340. this.refund_price = price;
  341. this.maxPrice = price;
  342. }
  343. }
  344. }
  345. </script>
  346. <style scoped lang="scss">
  347. .apply-return{
  348. .return{
  349. width: 710rpx;
  350. background: #FFFFFF;
  351. border-radius: 24rpx;
  352. margin: 20rpx auto 0 auto;
  353. padding-bottom: 32rpx;
  354. .tips{
  355. width: 662rpx;
  356. height: 72rpx;
  357. background: #F5F5F5;
  358. border-radius: 8rpx;
  359. margin: 32rpx auto 0 auto;
  360. padding: 0 20rpx;
  361. color: #999999;
  362. font-size: 26rpx;
  363. .title{
  364. color: #333333;
  365. margin-right: 20rpx;
  366. }
  367. }
  368. }
  369. .goodsStyle{
  370. padding: 32rpx 24rpx 0 24rpx;
  371. border-radius: 24rpx;
  372. .pictrue{
  373. width: 136rpx;
  374. height: 136rpx;
  375. border-radius: 16rpx;
  376. image{
  377. border-radius: 16rpx;
  378. }
  379. }
  380. .text{
  381. width: 504rpx;
  382. font-size: 24rpx;
  383. font-weight: 400;
  384. .nameCon{
  385. height: 104rpx;
  386. .name{
  387. font-size: 28rpx;
  388. color: #333;
  389. }
  390. }
  391. .num{
  392. color: #999999;
  393. }
  394. }
  395. }
  396. }
  397. .apply-return .list {
  398. background-color: #fff;
  399. width: 710rpx;
  400. border-radius: 16rpx;
  401. margin: 20rpx auto 0 auto;
  402. padding: 1rpx 24rpx 32rpx 24rpx;
  403. }
  404. .apply-return .list .item {
  405. font-size: 28rpx;
  406. color: #333;
  407. margin-top: 32rpx;
  408. .fontNum{
  409. font-size: 24rpx;
  410. color: #999;
  411. }
  412. .placeholder{
  413. font-size: 26rpx;
  414. color: #CCCCCC;
  415. }
  416. }
  417. .apply-return .list .item .num {
  418. color: #282828;
  419. width: 427rpx;
  420. text-align: right;
  421. .iconfont{
  422. color: #999;
  423. font-size: 30rpx;
  424. margin-left: 12rpx;
  425. }
  426. .label{
  427. color: var(--view-theme);
  428. font-size: 32rpx;
  429. }
  430. }
  431. .apply-return .list .item .num .picker .reason {
  432. width: 385rpx;
  433. }
  434. .apply-return .list .item .num .picker .iconfont {
  435. color: #999;
  436. font-size: 30rpx;
  437. margin-top: 2rpx;
  438. }
  439. .apply-return .list .item textarea {
  440. height: 166rpx;
  441. margin-top: 24rpx;
  442. font-size: 26rpx;
  443. }
  444. .apply-return .list .item .placeholder {
  445. color: #bbb;
  446. }
  447. .apply-return .list .item .title {
  448. height: 95rpx;
  449. width: 100%;
  450. }
  451. .apply-return .list .item .title .tip {
  452. font-size: 30rpx;
  453. color: #bbb;
  454. }
  455. .apply-return .list .item .upload .pictrue {
  456. margin: 22rpx 23rpx 0 0;
  457. width: 156rpx;
  458. height: 156rpx;
  459. position: relative;
  460. font-size: 24rpx;
  461. color: #bbb;
  462. border-radius: 16rpx;
  463. .img{
  464. width: 48rpx;
  465. height: 48rpx;
  466. margin-bottom: 8rpx;
  467. }
  468. }
  469. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  470. margin-right: 0;
  471. }
  472. .apply-return .list .item .upload .pictrue image {
  473. width: 100%;
  474. height: 100%;
  475. border-radius: 16rpx;
  476. }
  477. .apply-return .list .item .upload .pictrue .icon-ic_close {
  478. position: absolute;
  479. font-size: 24rpx;
  480. top: 0;
  481. right: 0;
  482. width: 32rpx;
  483. height: 32rpx;
  484. background: #999999;
  485. border-radius: 0 16rpx 0 16rpx;
  486. text-align: center;
  487. line-height: 32rpx;
  488. color: #fff;
  489. }
  490. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  491. color: #bfbfbf;
  492. font-size: 50rpx;
  493. }
  494. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  495. width: 148rpx;
  496. height: 148rpx;
  497. background: #F5F5F5;
  498. font-size: 24rpx;
  499. color: #333;
  500. }
  501. .apply-return .bntCon{
  502. width: 100%;
  503. height: 120rpx;
  504. background: #FFFFFF;
  505. }
  506. .apply-return .returnBnt {
  507. font-size: 28rpx;
  508. color: #fff;
  509. width: 710rpx;
  510. height: 80rpx;
  511. border-radius: 50rpx;
  512. text-align: center;
  513. line-height: 80rpx;
  514. }
  515. .goodsStyle .text .name {
  516. align-self: flex-start;
  517. }
  518. .list /deep/ .uni-input-input {
  519. text-align: right;
  520. color: var(--view-theme);
  521. font-weight: 400;
  522. font-size: 36rpx;
  523. max-width: 300rpx;
  524. font-family: 'Regular';
  525. }
  526. .Regular{
  527. font-family: 'Regular';
  528. }
  529. </style>