applyRefund.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. <template>
  2. <view v-if="isShowPage">
  3. <!--mine/applyRefund/applyRefund.wxml-->
  4. <!-- 退货商品 -->
  5. <view class="shouhou txt99">选择售后商品</view>
  6. <!-- && orderType != 11 -->
  7. <view class="list3_1" v-if="deliverListss.length > 0 && multiple == 1">
  8. <view class="list3_2" v-for="(items, indx) in deliverListss" :key="indx">
  9. <!-- <view class="shouhou txt99">{{ items.supplierName ? items.supplierName : merchantName + '自营' }}</view> -->
  10. <!-- <view class="shouhou txt99">{{ merchantName}}</view> -->
  11. <block v-for="(item, idx) in items.extendDTOList" :key="idx">
  12. <view class="li">
  13. <view class="checkbox" :data-store="item.store" @tap="checkProduct(indx, idx)">
  14. <image :src="item.isActive ? '/static/pages/images/gou_h.png' : '/static/pages/images/gou.png'" class="check"></image>
  15. </view>
  16. <view class="info dflex flex">
  17. <view class="cimgs" :data-id="item.productId" @tap="checkProduct(indx, idx)">
  18. <image :src="item.pic + '?x-oss-process=style/w160'" class="cimg"></image>
  19. <image src="/static/pages/images/jishida.png" class="type" v-if="item.isJs"></image>
  20. </view>
  21. <view class="zhinfo">
  22. <view :class="'zhtit ' + (item.store <= 0 || item.isInvalid ? 'color999' : '')" :data-id="item.productId">{{ item.productName }}</view>
  23. <view v-if="item.specs && item.specs != 'DEFAULT_SKU'" class="guigecontent">
  24. 规格:
  25. <text v-for="(itemGuige, index2) in JSON.parse(item.specs)" :key="index2" class="guige" decode="true">{{ itemGuige.value }}&nbsp;</text>
  26. </view>
  27. <view class="jiage">
  28. <view class="zhjia" :data-id="item.productId" v-if="!integralshop">
  29. <text>¥</text>
  30. {{ item.money }}
  31. </view>
  32. <view class="integral" v-if="integralshop">
  33. <text class="intnum">{{ item.integral }}积分</text>
  34. <text class="money">+¥{{ item.money }}</text>
  35. </view>
  36. <block v-if="item.shouldQuantity - item.refundStock > 1">
  37. <view class="num">
  38. <view class="jian" @tap="jianQuantity(indx, idx)">-</view>
  39. <input class="nums" :value="item.refundQuantity" type="number" @input="getNum" @blur="minNum" :data-index="indx" :data-idx="idx" />
  40. <view class="jian" @tap="jiaQuantity(indx, idx)">+</view>
  41. </view>
  42. </block>
  43. <block v-else>
  44. <view class="">×{{ item.shouldQuantity }}</view>
  45. </block>
  46. </view>
  47. <view class="tabe dflex">
  48. <text>可退数量:{{ item.shouldQuantity - item.refundStock }}</text>
  49. <text v-if="item.refundStock">已退数量:{{ item.refundStock }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </block>
  55. </view>
  56. <view class="all" data-index="-1" @tap="checkProduct(-1, -1)" v-if="showAll">
  57. <image :src="isAll ? '/static/pages/images/gou_h.png' : '/static/pages/images/gou.png'" class="check"></image>
  58. 全选
  59. </view>
  60. </view>
  61. <!-- 退款并退货 退款原因-->
  62. <view class="list1">
  63. <view class="dpname bt1" v-if="isrefund == 2 && refundMethod != 5" @tap="getRefund" data-isrefund="3">
  64. <view class="txt99">货物状态</view>
  65. <view class="fne">
  66. <text>{{ start ? start : '请选择' }}</text>
  67. <image src="/static/pages/images/more.png" class="right"></image>
  68. </view>
  69. </view>
  70. <view class="dpname" @tap="getRefund" data-isrefund="1" v-if="refundMethod != 5">
  71. <view class="txt99">退款原因</view>
  72. <view class="fne">
  73. <text>{{ refund ? refund : '请选择' }}</text>
  74. <image src="/static/pages/images/more.png" class="right"></image>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 退款无需退货 商品列表-->
  79. <!-- <view class="list">
  80. <view class="li" wx:for="{{products}}" wx:key="item" bindtap="toDetail" data-id="{{item.id}}">
  81. <view class="cimgs">
  82. <image src="{{item.pic}}" mode="aspectFit" class="cimg"></image>
  83. <image src="/pages/images/jishida.png" mode="aspectFit" class="type" wx:if="{{orderType == 5}}"></image>
  84. <image src="/pages/images/tuangou.png" mode="aspectFit" class="type" wx:if="{{orderType == 2}}"></image>
  85. </view>
  86. <view class="zhinfo">
  87. <view class="zhtit">{{item.title}}</view>
  88. <view wx:if="{{item.propertiesList}}" class="guigecontent">规格:
  89. <text wx:for="{{item.propertiesList}}" wx:for-item="itemGuige" class="guige" decode="{{true}}">{{itemGuige.value}}&nbsp;
  90. </text>
  91. </view>
  92. <view class="jiage">
  93. <view class="zhjia"><text class="money">¥</text><text class="size">{{item.salePrice}}</text></view>
  94. <view class="num">×{{item.quantity}}</view>
  95. </view>
  96. </view>
  97. </view>
  98. </view> -->
  99. <!-- 退款并退货 退货列表-->
  100. <!-- <view class="cart">
  101. <view class="dian1 dflex">
  102. <view class="flex">选择退货商品</view>
  103. </view>
  104. <view class="list1">
  105. <block wx:for="{{products}}" wx:key="index">
  106. <view class="li">
  107. <view class="checkbox" data-index="{{0}}" data-idx="{{index}}" bindtap="checkProduct">
  108. <image src="{{item.isActive ? '/pages/images/gou_h.png' : '/pages/images/gou.png'}}" class="check"></image>
  109. </view>
  110. <view class="info dflex flex">
  111. <view class="cimgs" bindtap="toDetail" data-id="{{item.productId}}">
  112. <image src="{{item.pic}}" mode="aspectFit" class="cimg"></image>
  113. </view>
  114. <view class="zhinfo">
  115. <view class="zhtit" bindtap="toDetail" data-id="{{item.productId}}">{{item.title}}</view>
  116. <view class="jiagecont">
  117. <text class="money">¥</text><text class="size">88.00</text>
  118. </view>
  119. <view class="jiage">
  120. <view class="zhjia" bindtap="" data-id="">购买数量:1</view>
  121. <view class="num">
  122. <view class="jian" bindtap="" data-index="{{0}}" data-idx="{{index}}">-</view>
  123. <text class="nums">{{item.quantity}}</text>
  124. <view class="jian" bindtap="" data-index="{{0}}" data-idx="{{index}}">+</view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </block>
  131. <view class="dian dflex">
  132. <image src="{{isJsdAll ? '/pages/images/gou_h.png' : '/pages/images/gou.png'}}" class="check" data-index="-2" bindtap="checkProduct"></image>
  133. <view class="flex">全选</view>
  134. </view>
  135. </view>
  136. </view> -->
  137. <!-- 退款无需退货 退款原因-->
  138. <!-- 换货 换货原因-->
  139. <!-- <view class="list1">
  140. <view class="dpname">
  141. <view>换货原因</view>
  142. <view class="fne">
  143. <text>请选择</text>
  144. <image src="/pages/images/more.png" class="right"></image>
  145. </view>
  146. </view>
  147. </view> -->
  148. <!-- 退款金额 -->
  149. <view class="list1">
  150. <view :class="'dpname2 dflex ' + (isrefund == 1 ? '' : bt1)" v-if="refundMethod != 5">
  151. <view class="txt99">退款金额:</view>
  152. <view>
  153. <text class="money">¥</text>
  154. <text class="size">{{ allMoney ? allMoney : '0' }}</text>
  155. </view>
  156. </view>
  157. <!-- <view class="dpname2 dflex {{isrefund==1?'':bt1}}" wx:if="{{refundMethod!=5&&balancePayMoney>0}}">
  158. <view class="txt99">退款余额:</view>
  159. <view><text class="money">¥</text><text class="size">{{balancePayMoney}}</text></view>
  160. </view> -->
  161. <view :class="'dpname2 dflex ' + (isrefund == 1 ? '' : bt1)" v-if="refundMethod != 5 && orderType == 11">
  162. <view class="txt99">退款积分:</view>
  163. <view>
  164. <text class="money"></text>
  165. <text class="size">{{ integral }}</text>
  166. </view>
  167. </view>
  168. <view class="dpname" v-if="isrefund == 2" @tap="getRefund" data-isrefund="2">
  169. <view class="txt99">退货方式</view>
  170. <view class="fne">
  171. <text>{{ huo ? huo : '请选择' }}</text>
  172. <image src="/static/pages/images/more.png" class="right"></image>
  173. </view>
  174. </view>
  175. </view>
  176. <!-- 退款并退货 退货方式 -->
  177. <!-- <view class="list1">
  178. <view class="dpname">
  179. <view>退货方式</view>
  180. <view class="fne">
  181. <text>请选择</text>
  182. <image src="/pages/images/more.png" class="right"></image>
  183. </view>
  184. </view>
  185. <view class="dpname3">
  186. <view>收货地址</view>
  187. <view class="addcont">
  188. <text>通小御 </text>
  189. <text>12568595625</text>
  190. </view>
  191. <view class="fne">
  192. <image src="/pages/images/more.png" class="bist"></image>
  193. </view>
  194. </view>
  195. <view class="address">
  196. <text>湖南省长沙市岳麓区湖南省长沙市岳麓区</text>
  197. <view>湖南省长沙市岳麓区湖南省长沙市</view>
  198. </view>
  199. </view> -->
  200. <!--退款说明 -->
  201. <view class="list2" v-if="refundMethod != 5">
  202. <view class="dpname dflex">
  203. <view class="sm txt99">退款说明:</view>
  204. <view class="dflex shouming">
  205. <input type="text" @input="getShuoming" placeholder="选填" />
  206. <image src="/mine/static/mine/images/bi.png"></image>
  207. </view>
  208. </view>
  209. <!-- 上传凭证 -->
  210. <view class="li1"><view class="txt99">上传凭证</view></view>
  211. <view class="dflex">
  212. <view v-for="(item, index) in credentialsUrl" :key="index" class="pz">
  213. <image :src="credentialsUrl[index]" mode="aspectFill" class="scpz"></image>
  214. <image src="/mine/static/mine/images/imagecuo.png" class="cuo" @tap="cleanimage" :data-index="index"></image>
  215. </view>
  216. <image src="/mine/static/mine/images/scpz.png" class="scpz" @tap="uploadAvatar" v-if="credentialsUrl.length < 3"></image>
  217. </view>
  218. </view>
  219. <view class="r-des">
  220. <rich-text v-if="refundExplainDesc" :nodes="refundExplainDesc"></rich-text>
  221. </view>
  222. <!-- 提交申请 -->
  223. <view class="btn-bot ddflex">
  224. <contact-button img-url="../../static/pages/images/kfico1.png" class-name="r-contact" button-text="客服"></contact-button>
  225. <view class="btn fflex" @tap="save" v-if="refundMethod != 5">提交申请</view>
  226. <view :class="'btn fflex ' + (refundMethod == 5 ? 'refund' : '')" v-if="refundMethod == 5" @tap="upData">提交</view>
  227. </view>
  228. <block v-if="isShow"><refund-popup :refund-type="type" @hidePopup="hidePopup" @getValue="getValue" @getIndex="getIndex" :isrefund="isrefund"></refund-popup></block>
  229. </view>
  230. </template>
  231. <script>
  232. // mine/applyRefund/applyRefund.js
  233. const app = getApp();
  234. const req = require('../../../utils/request.js');
  235. const util = require('../../../utils/util.js');
  236. const requsetmessage = require('../../../utils/requestmessage.js');
  237. import refundPopup from '../../../components/refund-popup/index';
  238. // state : 1 未付款 2 待确认 3 待发货 4 待提货 5 配送中 6 已签收 7 订单完成
  239. // 8 订单取消 9 退货中 10 完成退货 11 支付失败 15 进行中
  240. // 售后状态
  241. // 30 售后待审核 32 售后审核失败 35 商品待退回 36 商品退回中
  242. // 39 退款申请 40 退款待支付 41 退款中 42 退款失败
  243. // 43 退款成功
  244. // 处方订单
  245. // 20 未开方 21 开方中 22 开方失败 25 待审方
  246. // 26 审方中 27 审方失败,
  247. // 49 用户取消售后
  248. export default {
  249. data() {
  250. return {
  251. isShowPage: false,
  252. ids: '',
  253. pageList: [],
  254. count: 0,
  255. money: 0,
  256. isShow: true,
  257. credentialsUrl: [],
  258. id: '',
  259. isrefund: '',
  260. refundMethod: '',
  261. allMoney: '',
  262. type: '',
  263. refund: '',
  264. huo: '',
  265. start: '',
  266. refundIndex: '',
  267. huoIndex: '',
  268. startIndex: '',
  269. shuoming: '',
  270. isAll: false,
  271. products: [],
  272. list: [],
  273. multiple: '0',
  274. deliverListss: '',
  275. refundExplainDesc: '',
  276. showAll: false
  277. };
  278. },
  279. components: {
  280. refundPopup
  281. },
  282. props: {},
  283. /**
  284. * 生命周期函数--监听页面加载
  285. * options.isrefund=1为退款
  286. * options.isrefund=2为退货
  287. */
  288. onLoad: function(options) {
  289. // console.log(options);
  290. this.setData({
  291. id: options.id,
  292. isrefund: options.isrefund,
  293. refundMethod: options.refundMethod
  294. });
  295. if (req.getStorage('configRes')) {
  296. let about = JSON.parse(req.getStorage('configRes'));
  297. if (!about.is_open_multiple_refund) {
  298. this.multiple = '0';
  299. } else {
  300. this.multiple = about.is_open_multiple_refund;
  301. }
  302. // console.log(this.multiple, "about")
  303. }
  304. this.refundMethod = options.refundMethod;
  305. let title = '';
  306. if (options.isrefund == 2) {
  307. title = '我要退货';
  308. } else {
  309. title = '我要退款';
  310. }
  311. uni.setNavigationBarTitle({
  312. title: title
  313. });
  314. this.setData({
  315. isShow: false
  316. });
  317. if (this.refundMethod == 5) {
  318. this.isShowPage = true;
  319. }
  320. this.getRefundExplain();
  321. if (this.refundMethod != 5) {
  322. this.getOrderDet();
  323. }
  324. },
  325. /**
  326. * 生命周期函数--监听页面显示
  327. */
  328. onShow: function() {
  329. },
  330. methods: {
  331. getRefundExplain() {
  332. req.getRequest(
  333. '/api/params/value',
  334. {
  335. type: 'refund_explain_desc'
  336. },
  337. data => {
  338. this.refundExplainDesc = data;
  339. }
  340. );
  341. },
  342. // 获取退款详情
  343. getOrderDet() {
  344. req.getRequest(
  345. '/api/order/detail',
  346. {
  347. id: this.id
  348. },
  349. data => {
  350. // if (this.multiple == 1 && data.orderType != 11) {
  351. this.setData(data);
  352. console.log('this.multiple==',this.multiple)
  353. if (this.multiple == 1) {
  354. for (var i = 0; i < data.deliverList.length; i++) {
  355. data.deliverList[i].extendDTOList.map(el => {
  356. el.refundQuantity = 1;
  357. return el;
  358. });
  359. data.deliverList[i].extendDTOList = data.deliverList[i].extendDTOList.filter(it => it.shouldQuantity - (it.refundStock ? it.refundStock : 0) > 0);
  360. }
  361. // console.log('可退数据000>>>>', data.deliverList);
  362. // && it.isRefundStock == 1
  363. this.deliverListss = data.deliverList.filter(it => it.extendDTOList.length > 0 && it.isRefundStock == 1);
  364. console.log('可退数据000>>>>', this.deliverListss);
  365. if(this.deliverListss&&this.deliverListss.length >0){
  366. if(this.deliverListss&&this.deliverListss.length == 1){
  367. // this.checkProduct(0,0);
  368. // this.showAll = false;
  369. // }else{
  370. this.deliverListss.map((it,index)=>{
  371. if(index == 0){
  372. if(it.extendDTOList&&it.extendDTOList.length == 1){
  373. this.checkProduct(0,0)
  374. }
  375. }
  376. if(it.extendDTOList&&it.extendDTOList.length > 1){
  377. this.showAll = true;
  378. }else{
  379. this.showAll = false;
  380. }
  381. })
  382. }else{
  383. this.showAll = true;
  384. }
  385. }
  386. // console.log('可退数据111>>>>', JSON.stringify(this.deliverListss));
  387. // data.products.map(el => {
  388. // el.refundQuantity = 1;
  389. // return el;
  390. // });
  391. // data.products = data.products.filter(it => it.quantity - (it.refundStock ? it.refundStock : 0) > 0);
  392. } else {
  393. if (data.balancePayMoney && data.balancePayMoney > 0) {
  394. this.allMoney = parseFloat(data.payMoney + data.balancePayMoney).toFixed(2);
  395. }
  396. }
  397. this.isShowPage = true;
  398. }
  399. );
  400. },
  401. checkProduct(index, idx) {
  402. // debugger
  403. //选择商品
  404. const that = this;
  405. let d = {};
  406. if (index == -1) {
  407. // 全选
  408. // console.log("全选");
  409. const isAll = that.isAll;
  410. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  411. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  412. this.deliverListss[i].extendDTOList[k].isActive = !isAll;
  413. }
  414. }
  415. this.isAll = !isAll;
  416. } else {
  417. // 单选
  418. this.deliverListss[index].extendDTOList[idx].isActive = !this.deliverListss[index].extendDTOList[idx].isActive;
  419. }
  420. // console.log(this.products);
  421. if (index != -1) {
  422. this.isAll = this.merchantCheckProduct();
  423. }
  424. this.CalculationMoney(index, idx);
  425. },
  426. // 判断店铺的商品是否全部选择
  427. merchantCheckProduct() {
  428. let d = {}; // debugger
  429. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  430. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  431. if (!this.deliverListss[i].extendDTOList[k].isActive) {
  432. return false;
  433. }
  434. }
  435. }
  436. return true;
  437. },
  438. CalculationMoney() {
  439. //计算商品总价格
  440. let jsdMoney = 0;
  441. let nmoney = 0.0;
  442. let integral = 0;
  443. let arr = [];
  444. let obj = {};
  445. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  446. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  447. var lst = this.deliverListss[i].extendDTOList[k];
  448. if (lst.isActive) {
  449. jsdMoney += lst.refundQuantity * lst.money;
  450. integral += lst.refundQuantity * lst.integral;
  451. // obj = {
  452. // id: lst.id,
  453. // quantity: lst.quantity,
  454. // // 单价
  455. // actualPrice: lst.actualPrice,
  456. // skuId: lst.skuId,
  457. // refundQuantity: lst.refundQuantity,
  458. // salePrice: lst.salePrice,
  459. // orderProductId: lst.orderProductId
  460. // };
  461. obj = {
  462. id: lst.productId,
  463. deliveryInformation: lst.deliverId, //出库单ID
  464. quantity: lst.shouldQuantity,
  465. skuId: lst.skuId,
  466. isOtc: lst.isOtc,
  467. pic: lst.pic,
  468. refundQuantity: lst.refundQuantity,
  469. // 单价
  470. actualPrice: lst.money,
  471. salePrice: lst.salePrice,
  472. orderProductId: lst.orderProductId
  473. };
  474. arr.push(obj);
  475. }
  476. }
  477. }
  478. // this.products
  479. // .filter(it => it.isActive)
  480. // .forEach(lst => {
  481. // jsdMoney += lst.refundQuantity * lst.money;
  482. // integral += lst.refundQuantity * lst.integral;
  483. // obj = {
  484. // id: lst.id,
  485. // quantity: lst.quantity,
  486. // // 单价
  487. // actualPrice: lst.actualPrice,
  488. // skuId: lst.skuId,
  489. // isOtc: lst.isOtc,
  490. // pic: lst.pic,
  491. // refundQuantity: lst.refundQuantity,
  492. // salePrice: lst.salePrice,
  493. // orderProductId: lst.orderProductId
  494. // };
  495. // arr.push(obj);
  496. // });
  497. nmoney = Number(jsdMoney);
  498. //得到可退金额,如果存在退差的情况
  499. if (this.difference && this.difference > 0) {
  500. //退差金额不为空并且》0;
  501. //用订单的实付金额-退差金额;判断需要退的金额是否大于可退金额;如果大,则需要-退差金额-正在退、或者已退金额
  502. var keMoney = this.getKeMoney(); //可退金额
  503. if (nmoney > keMoney) {
  504. nmoney = nmoney - this.difference;
  505. }
  506. }
  507. // //计算是否需要退邮费
  508. // if(this.expressFee&&this.expressFee>0){//订单是否存在邮费
  509. // }
  510. this.setData({
  511. allMoney: parseFloat(nmoney).toFixed(2) > 0 ? parseFloat(nmoney).toFixed(2) : 0,
  512. integral: integral,
  513. list: arr
  514. });
  515. },
  516. //获取已退、在退中金额
  517. getKeMoney() {
  518. //用订单的实付金额-退差金额;判断需要退的金额是否大于可退金额;如果大,则需要-退差金额-正在退、或者已退金额
  519. //32 审核失败 42退款失败 49取消售后
  520. var list = this.orderRefundList.filter(it => it.refundState != 32 && it.refundState != 42 && it.refundState != 49);
  521. var refundMoney = 0;
  522. for (var i = 0; i < list.length; i++) {
  523. refundMoney = refundMoney + list[i].refundMoney;
  524. }
  525. var keMoney = parseFloat(this.money - this.difference - refundMoney).toFixed(2); //可退金额
  526. return keMoney;
  527. },
  528. jianQuantity(index, idx) {
  529. const page = this.deliverListss[index].extendDTOList[idx];
  530. if (page.refundQuantity <= 1) return false;
  531. this.deliverListss[index].extendDTOList[idx].refundQuantity = parseInt(page.refundQuantity) - 1;
  532. this.CalculationMoney(index, idx);
  533. },
  534. jiaQuantity(index, idx) {
  535. const page = this.deliverListss[index].extendDTOList[idx];
  536. let q = parseInt(page.refundQuantity) + 1;
  537. if (page.shouldQuantity > 0) {
  538. if (page.refundStock > 0) {
  539. if (q > page.shouldQuantity - page.refundStock) return req.msg('非常的抱歉,不能超过可退数量');
  540. else {
  541. q = parseInt(page.refundQuantity) + 1;
  542. }
  543. } else {
  544. if (q > page.shouldQuantity) return req.msg('非常的抱歉,不能超过可退数量');
  545. else {
  546. q = parseInt(page.refundQuantity) + 1;
  547. }
  548. }
  549. }
  550. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  551. this.CalculationMoney(index, idx);
  552. },
  553. // 获取输入的值
  554. getNum(event) {
  555. const index = event.currentTarget.dataset.index;
  556. const idx = event.currentTarget.dataset.idx;
  557. const page = this.deliverListss[index].extendDTOList[idx];
  558. let q = event.detail.value;
  559. if (page.refundStock > 0) {
  560. if (q > page.shouldQuantity - page.refundStock) {
  561. req.msg('非常的抱歉,不能超过可退数量');
  562. q = page.shouldQuantity - page.refundStock;
  563. } else {
  564. q = event.detail.value;
  565. }
  566. } else {
  567. if (q > page.shouldQuantity) {
  568. req.msg('非常的抱歉,不能超过可退数量');
  569. q = page.shouldQuantity;
  570. } else {
  571. q = event.detail.value;
  572. }
  573. }
  574. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  575. this.CalculationMoney(index, idx);
  576. return q;
  577. },
  578. minNum(event) {
  579. const index = event.currentTarget.dataset.index;
  580. const idx = event.currentTarget.dataset.idx;
  581. const page = this.deliverListss[index].extendDTOList[idx];
  582. let that = this;
  583. if (event.detail.value == '') {
  584. let q = 1;
  585. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  586. } else {
  587. let q = parseInt(event.detail.value);
  588. if (page.refundStock > 0) {
  589. if (q > page.shouldQuantity - page.refundStock) {
  590. req.msg('非常的抱歉,不能超过可退数量');
  591. q = page.shouldQuantity - page.refundStock;
  592. }
  593. } else {
  594. if (q > page.shouldQuantity) {
  595. req.msg('非常的抱歉,不能超过可退数量');
  596. q = page.shouldQuantity;
  597. }
  598. }
  599. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  600. that.CalculationMoney(index, idx);
  601. return q;
  602. }
  603. },
  604. // 获取退款原因
  605. getRefund(event) {
  606. this.setData({
  607. isShow: true,
  608. type: event.currentTarget.dataset.isrefund
  609. });
  610. },
  611. hidePopup() {
  612. this.setData({
  613. isShow: false
  614. });
  615. },
  616. getValue: function(e) {
  617. // console.log(e);
  618. if (this.type == 1) {
  619. this.setData({
  620. refund: e.detail
  621. });
  622. }
  623. if (this.type == 2) {
  624. this.setData({
  625. huo: e.detail
  626. });
  627. }
  628. if (this.type == 3) {
  629. this.setData({
  630. start: e.detail
  631. });
  632. } // console.log(e.detail);
  633. },
  634. getIndex: function(e) {
  635. if (this.type == 1) {
  636. this.setData({
  637. refundIndex: e.detail
  638. });
  639. }
  640. if (this.type == 2) {
  641. this.setData({
  642. huoIndex: e.detail
  643. });
  644. }
  645. if (this.type == 3) {
  646. this.setData({
  647. startIndex: e.detail
  648. });
  649. }
  650. // console.log(e.detail);
  651. },
  652. // 获取退款说明
  653. getShuoming(event) {
  654. let shuoming = '';
  655. shuoming = event.detail.value;
  656. this.setData({
  657. shuoming: shuoming
  658. });
  659. // console.log(this.shuoming);
  660. },
  661. //上传图片
  662. uploadAvatar() {
  663. let that = this;
  664. uni.chooseImage({
  665. count: 3,
  666. sizeType: ['original', 'compressed'],
  667. sourceType: ['album', 'camera'],
  668. success: function({ tempFilePaths }) {
  669. var promise = Promise.all(
  670. tempFilePaths.map((tempFilePath, index) => {
  671. return new Promise(function(resolve, reject) {
  672. req.loadIng('上传中');
  673. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  674. // console.log(res);
  675. that.setData({
  676. credentialsUrl: that.credentialsUrl.concat(res.src)
  677. });
  678. uni.showToast({
  679. title: '上传成功',
  680. icon: 'success',
  681. duration: 2000
  682. });
  683. // console.log(that.avatar);
  684. });
  685. });
  686. })
  687. );
  688. promise
  689. .then(function(results) {
  690. // console.log(results);
  691. })
  692. .catch(function(err) {
  693. // console.log(err);
  694. });
  695. }
  696. }); // wx.chooseImage({
  697. // count: 3,
  698. // sizeType: ['original', 'compressed'],
  699. // sourceType: ['album', 'camera'],
  700. // success(res) {
  701. // console.log(res.tempFilePaths)
  702. // req.uploadFile('/api/upload', res.tempFilePaths, res => {
  703. // req.msg('图片上传成功');
  704. // that.setData({
  705. // avatar: that.data.avatar.concat(res.src)
  706. // })
  707. // console.log(that.data.avatar)
  708. // })
  709. // }
  710. // })
  711. },
  712. // 删除图片
  713. cleanimage(event) {
  714. let index = event.currentTarget.dataset.index;
  715. let arr = this.credentialsUrl;
  716. arr.splice(index, 1);
  717. this.setData({
  718. credentialsUrl: arr
  719. });
  720. },
  721. save: util.throttle(function() {
  722. let that = this;
  723. requsetmessage.refund().then(res => {
  724. // console.log("退款", res);
  725. that.saveRefund();
  726. });
  727. }, 1500),
  728. saveRefund() {
  729. console.log('数据>>>>>>>>>>', this.list);
  730. let parameter = {
  731. refundType: this.isrefund,
  732. orderId: this.id,
  733. imgUrl: this.credentialsUrl.toString(),
  734. remarks: this.shuoming,
  735. refundReason: this.refundIndex
  736. };
  737. // if (this.multiple == 1 && this.orderType != 11) {
  738. if (this.multiple == 1) {
  739. if (this.list.length < 1) {
  740. return req.msg('请您选择退款商品');
  741. } else {
  742. //遍历组装数据
  743. var dataList = [];
  744. // [
  745. // {"refundMoney":"100",
  746. // "deliverId":"1000",
  747. // "refundProductList":[]
  748. // }
  749. // ]
  750. for (var i = 0; i < this.list.length; i++) {
  751. if (dataList.length == 0) {
  752. var obj = {
  753. refundMoney: parseFloat(this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(2),
  754. deliverId: this.list[i].deliveryInformation,
  755. refundProductList: []
  756. };
  757. this.list[i].isAdd = true;
  758. obj.refundProductList.push(this.list[i]);
  759. dataList.push(obj);
  760. } else {
  761. for (var k = 0; k < dataList.length; k++) {
  762. if (dataList[k].deliverId == this.list[i].deliveryInformation) {
  763. //检验是否被添加过了
  764. if (!this.list[i].isAdd) {
  765. dataList[k].refundMoney = parseFloat(parseFloat(dataList[k].refundMoney) + this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(
  766. 2
  767. );
  768. this.list[i].isAdd = true;
  769. dataList[k].refundProductList.push(this.list[i]);
  770. }
  771. } else {
  772. if (!this.list[i].isAdd) {
  773. var obj = {
  774. refundMoney: parseFloat(this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(2),
  775. deliverId: this.list[i].deliveryInformation,
  776. refundProductList: []
  777. };
  778. this.list[i].isAdd = true;
  779. obj.refundProductList.push(this.list[i]);
  780. dataList.push(obj);
  781. }
  782. }
  783. }
  784. }
  785. }
  786. parameter.jsonStr = JSON.stringify(dataList);
  787. console.log('>>>>>', parameter.jsonStr);
  788. }
  789. parameter.refundMoney = this.allMoney;
  790. } else {
  791. parameter.refundMoney = this.payMoney;
  792. if (this.balancePayMoney && this.balancePayMoney > 0) {
  793. parameter.refundMoney = parseFloat(this.payMoney + this.balancePayMoney).toFixed(2);
  794. }
  795. }
  796. if (this.isrefund == 2) {
  797. parameter.refundGoodState = this.startIndex;
  798. parameter.refundMethod = this.huoIndex;
  799. if (this.refundMethod != 5) {
  800. if (!parameter.refundGoodState) {
  801. return req.msg('请您填写货物状态');
  802. }
  803. }
  804. if (!parameter.refundMethod) {
  805. return req.msg('请您填写退货方式');
  806. }
  807. }
  808. if (this.refundMethod != 5) {
  809. if (!parameter.refundReason) {
  810. return req.msg('请您填写退款原因');
  811. }
  812. }
  813. //退货时,是必须强制需要提交照片
  814. // if ((!this.avatar || this.avatar.length == 0)&&this.isrefund==2) {
  815. // return req.msg('请上传凭证照片');
  816. // }
  817. if(this.credentialsUrl){
  818. parameter.imgUrl = this.credentialsUrl.toString();
  819. }
  820. parameter.apiType = 1; //等于1时走新的退款流程;未传的走老退款流程
  821. req.postRequest('/api/orderRefund/save', parameter, data => {
  822. // uni.redirectTo({
  823. // url: '/mine/refund/refundDetails/refundDetails?id=' + data[0] + '&isrefund=' + this.isrefund
  824. // });
  825. req.msg('售后申请提交成功');
  826. setTimeout(function() {
  827. uni.navigateBack();
  828. }, 2000);
  829. });
  830. },
  831. upData() {
  832. let parameter = {
  833. refundType: this.isrefund,
  834. id: this.id
  835. };
  836. parameter.refundMethod = this.huoIndex;
  837. if (this.huoIndex == 1) {
  838. parameter.RefundState = 35;
  839. } else {
  840. parameter.RefundState = 36;
  841. }
  842. req.putRequest('/api/orderRefund/update', parameter, data => {
  843. uni.navigateBack();
  844. });
  845. }
  846. }
  847. };
  848. </script>
  849. <style>
  850. @import './applyRefund.css';
  851. </style>