applyRefund.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. <template>
  2. <view v-if="isShowPage">
  3. <!--mine/applyRefund/applyRefund.wxml-->
  4. <!-- 退货商品 -->
  5. <view class="shouhou txt99" v-if="deliverListss.length > 0 && multiple == 1">选择售后商品</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]" 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. <button open-type="contact" hover-class="none" class="r-contact"><image src="../../../static/pages/images/kfico1.png"></image>客服</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.vue';
  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. let balancePayMoney = data.balancePayMoney&&data.balancePayMoney > 0 ? data.balancePayMoney : 0
  394. this.allMoney = parseFloat(data.payMoney + balancePayMoney).toFixed(2);
  395. }
  396. this.isShowPage = true;
  397. }
  398. );
  399. },
  400. checkProduct(index, idx) {
  401. // debugger
  402. //选择商品
  403. const that = this;
  404. let d = {};
  405. if (index == -1) {
  406. // 全选
  407. // console.log("全选");
  408. const isAll = that.isAll;
  409. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  410. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  411. this.deliverListss[i].extendDTOList[k].isActive = !isAll;
  412. }
  413. }
  414. this.isAll = !isAll;
  415. } else {
  416. // 单选
  417. this.deliverListss[index].extendDTOList[idx].isActive = !this.deliverListss[index].extendDTOList[idx].isActive;
  418. }
  419. // console.log(this.products);
  420. if (index != -1) {
  421. this.isAll = this.merchantCheckProduct();
  422. }
  423. this.CalculationMoney(index, idx);
  424. },
  425. // 判断店铺的商品是否全部选择
  426. merchantCheckProduct() {
  427. let d = {}; // debugger
  428. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  429. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  430. if (!this.deliverListss[i].extendDTOList[k].isActive) {
  431. return false;
  432. }
  433. }
  434. }
  435. return true;
  436. },
  437. CalculationMoney() {
  438. //计算商品总价格
  439. let jsdMoney = 0;
  440. let nmoney = 0.0;
  441. let integral = 0;
  442. let arr = [];
  443. let obj = {};
  444. for (let i = 0, len = this.deliverListss.length; i < len; i++) {
  445. for (let k = 0, length = this.deliverListss[i].extendDTOList.length; k < length; k++) {
  446. var lst = this.deliverListss[i].extendDTOList[k];
  447. if (lst.isActive) {
  448. jsdMoney += lst.refundQuantity * lst.money;
  449. integral += lst.refundQuantity * lst.integral;
  450. // obj = {
  451. // id: lst.id,
  452. // quantity: lst.quantity,
  453. // // 单价
  454. // actualPrice: lst.actualPrice,
  455. // skuId: lst.skuId,
  456. // refundQuantity: lst.refundQuantity,
  457. // salePrice: lst.salePrice,
  458. // orderProductId: lst.orderProductId
  459. // };
  460. obj = {
  461. id: lst.productId,
  462. deliveryInformation: lst.deliverId, //出库单ID
  463. quantity: lst.shouldQuantity,
  464. skuId: lst.skuId,
  465. isOtc: lst.isOtc,
  466. pic: lst.pic,
  467. refundQuantity: lst.refundQuantity,
  468. // 单价
  469. actualPrice: lst.money,
  470. salePrice: lst.salePrice,
  471. orderProductId: lst.orderProductId
  472. };
  473. arr.push(obj);
  474. }
  475. }
  476. }
  477. // this.products
  478. // .filter(it => it.isActive)
  479. // .forEach(lst => {
  480. // jsdMoney += lst.refundQuantity * lst.money;
  481. // integral += lst.refundQuantity * lst.integral;
  482. // obj = {
  483. // id: lst.id,
  484. // quantity: lst.quantity,
  485. // // 单价
  486. // actualPrice: lst.actualPrice,
  487. // skuId: lst.skuId,
  488. // isOtc: lst.isOtc,
  489. // pic: lst.pic,
  490. // refundQuantity: lst.refundQuantity,
  491. // salePrice: lst.salePrice,
  492. // orderProductId: lst.orderProductId
  493. // };
  494. // arr.push(obj);
  495. // });
  496. nmoney = Number(jsdMoney);
  497. //得到可退金额,如果存在退差的情况
  498. if (this.difference && this.difference > 0) {
  499. //退差金额不为空并且》0;
  500. //用订单的实付金额-退差金额;判断需要退的金额是否大于可退金额;如果大,则需要-退差金额-正在退、或者已退金额
  501. var keMoney = this.getKeMoney(); //可退金额
  502. if (nmoney > keMoney) {
  503. nmoney = nmoney - this.difference;
  504. }
  505. }
  506. // //计算是否需要退邮费
  507. // if(this.expressFee&&this.expressFee>0){//订单是否存在邮费
  508. // }
  509. this.setData({
  510. allMoney: parseFloat(nmoney).toFixed(2) > 0 ? parseFloat(nmoney).toFixed(2) : 0,
  511. integral: integral,
  512. list: arr
  513. });
  514. },
  515. //获取已退、在退中金额
  516. getKeMoney() {
  517. //用订单的实付金额-退差金额;判断需要退的金额是否大于可退金额;如果大,则需要-退差金额-正在退、或者已退金额
  518. //32 审核失败 42退款失败 49取消售后
  519. var list = this.orderRefundList.filter(it => it.refundState != 32 && it.refundState != 42 && it.refundState != 49);
  520. var refundMoney = 0;
  521. for (var i = 0; i < list.length; i++) {
  522. refundMoney = refundMoney + list[i].refundMoney;
  523. }
  524. var keMoney = parseFloat(this.money - this.difference - refundMoney).toFixed(2); //可退金额
  525. return keMoney;
  526. },
  527. jianQuantity(index, idx) {
  528. const page = this.deliverListss[index].extendDTOList[idx];
  529. if (page.refundQuantity <= 1) return false;
  530. this.deliverListss[index].extendDTOList[idx].refundQuantity = parseInt(page.refundQuantity) - 1;
  531. this.CalculationMoney(index, idx);
  532. },
  533. jiaQuantity(index, idx) {
  534. const page = this.deliverListss[index].extendDTOList[idx];
  535. let q = parseInt(page.refundQuantity) + 1;
  536. if (page.shouldQuantity > 0) {
  537. if (page.refundStock > 0) {
  538. if (q > page.shouldQuantity - page.refundStock) return req.msg('非常的抱歉,不能超过可退数量');
  539. else {
  540. q = parseInt(page.refundQuantity) + 1;
  541. }
  542. } else {
  543. if (q > page.shouldQuantity) return req.msg('非常的抱歉,不能超过可退数量');
  544. else {
  545. q = parseInt(page.refundQuantity) + 1;
  546. }
  547. }
  548. }
  549. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  550. this.CalculationMoney(index, idx);
  551. },
  552. // 获取输入的值
  553. getNum(event) {
  554. const index = event.currentTarget.dataset.index;
  555. const idx = event.currentTarget.dataset.idx;
  556. const page = this.deliverListss[index].extendDTOList[idx];
  557. let q = event.detail.value;
  558. if (page.refundStock > 0) {
  559. if (q > page.shouldQuantity - page.refundStock) {
  560. req.msg('非常的抱歉,不能超过可退数量');
  561. q = page.shouldQuantity - page.refundStock;
  562. } else {
  563. q = event.detail.value;
  564. }
  565. } else {
  566. if (q > page.shouldQuantity) {
  567. req.msg('非常的抱歉,不能超过可退数量');
  568. q = page.shouldQuantity;
  569. } else {
  570. q = event.detail.value;
  571. }
  572. }
  573. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  574. this.CalculationMoney(index, idx);
  575. return q;
  576. },
  577. minNum(event) {
  578. const index = event.currentTarget.dataset.index;
  579. const idx = event.currentTarget.dataset.idx;
  580. const page = this.deliverListss[index].extendDTOList[idx];
  581. let that = this;
  582. if (event.detail.value == '') {
  583. let q = 1;
  584. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  585. } else {
  586. let q = parseInt(event.detail.value);
  587. if (page.refundStock > 0) {
  588. if (q > page.shouldQuantity - page.refundStock) {
  589. req.msg('非常的抱歉,不能超过可退数量');
  590. q = page.shouldQuantity - page.refundStock;
  591. }
  592. } else {
  593. if (q > page.shouldQuantity) {
  594. req.msg('非常的抱歉,不能超过可退数量');
  595. q = page.shouldQuantity;
  596. }
  597. }
  598. this.deliverListss[index].extendDTOList[idx].refundQuantity = q;
  599. that.CalculationMoney(index, idx);
  600. return q;
  601. }
  602. },
  603. // 获取退款原因
  604. getRefund(event) {
  605. this.setData({
  606. isShow: true,
  607. type: event.currentTarget.dataset.isrefund
  608. });
  609. },
  610. hidePopup() {
  611. this.setData({
  612. isShow: false
  613. });
  614. },
  615. getValue: function(e) {
  616. // console.log(e);
  617. if (this.type == 1) {
  618. this.setData({
  619. refund: e.detail
  620. });
  621. }
  622. if (this.type == 2) {
  623. this.setData({
  624. huo: e.detail
  625. });
  626. }
  627. if (this.type == 3) {
  628. this.setData({
  629. start: e.detail
  630. });
  631. } // console.log(e.detail);
  632. },
  633. getIndex: function(e) {
  634. if (this.type == 1) {
  635. this.setData({
  636. refundIndex: e.detail
  637. });
  638. }
  639. if (this.type == 2) {
  640. this.setData({
  641. huoIndex: e.detail
  642. });
  643. }
  644. if (this.type == 3) {
  645. this.setData({
  646. startIndex: e.detail
  647. });
  648. }
  649. // console.log(e.detail);
  650. },
  651. // 获取退款说明
  652. getShuoming(event) {
  653. let shuoming = '';
  654. shuoming = event.detail.value;
  655. this.setData({
  656. shuoming: shuoming
  657. });
  658. // console.log(this.shuoming);
  659. },
  660. //上传图片
  661. uploadAvatar() {
  662. let that = this;
  663. uni.chooseImage({
  664. count: 3,
  665. sizeType: ['original', 'compressed'],
  666. sourceType: ['album', 'camera'],
  667. success: function({ tempFilePaths }) {
  668. var promise = Promise.all(
  669. tempFilePaths.map((tempFilePath, index) => {
  670. return new Promise(function(resolve, reject) {
  671. req.loadIng('上传中');
  672. req.uploadFile('/api/upload', tempFilePath, res => {
  673. // console.log(res);
  674. that.setData({
  675. credentialsUrl: that.credentialsUrl.concat(res.src)
  676. });
  677. uni.showToast({
  678. title: '上传成功',
  679. icon: 'success',
  680. duration: 2000
  681. });
  682. // console.log(that.avatar);
  683. });
  684. });
  685. })
  686. );
  687. promise
  688. .then(function(results) {
  689. // console.log(results);
  690. })
  691. .catch(function(err) {
  692. // console.log(err);
  693. });
  694. }
  695. }); // wx.chooseImage({
  696. // count: 3,
  697. // sizeType: ['original', 'compressed'],
  698. // sourceType: ['album', 'camera'],
  699. // success(res) {
  700. // console.log(res.tempFilePaths)
  701. // req.uploadFile('/api/upload', res.tempFilePaths, res => {
  702. // req.msg('图片上传成功');
  703. // that.setData({
  704. // avatar: that.data.avatar.concat(res.src)
  705. // })
  706. // console.log(that.data.avatar)
  707. // })
  708. // }
  709. // })
  710. },
  711. // 删除图片
  712. cleanimage(event) {
  713. let index = event.currentTarget.dataset.index;
  714. let arr = this.credentialsUrl;
  715. arr.splice(index, 1);
  716. this.setData({
  717. credentialsUrl: arr
  718. });
  719. },
  720. save: util.throttle(function() {
  721. let that = this;
  722. requsetmessage.refund().then(res => {
  723. // console.log("退款", res);
  724. that.saveRefund();
  725. });
  726. }, 1500),
  727. saveRefund() {
  728. console.log('数据>>>>>>>>>>', this.list);
  729. let parameter = {
  730. refundType: this.isrefund,
  731. orderId: this.id,
  732. imgUrl: this.credentialsUrl.toString(),
  733. remarks: this.shuoming,
  734. refundReason: this.refundIndex
  735. };
  736. // if (this.multiple == 1 && this.orderType != 11) {
  737. if (this.multiple == 1) {
  738. if (this.list.length < 1) {
  739. return req.msg('请您选择退款商品');
  740. } else {
  741. //遍历组装数据
  742. var dataList = [];
  743. // [
  744. // {"refundMoney":"100",
  745. // "deliverId":"1000",
  746. // "refundProductList":[]
  747. // }
  748. // ]
  749. for (var i = 0; i < this.list.length; i++) {
  750. if (dataList.length == 0) {
  751. var obj = {
  752. refundMoney: parseFloat(this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(2),
  753. deliverId: this.list[i].deliveryInformation,
  754. refundProductList: []
  755. };
  756. this.list[i].isAdd = true;
  757. obj.refundProductList.push(this.list[i]);
  758. dataList.push(obj);
  759. } else {
  760. for (var k = 0; k < dataList.length; k++) {
  761. if (dataList[k].deliverId == this.list[i].deliveryInformation) {
  762. //检验是否被添加过了
  763. if (!this.list[i].isAdd) {
  764. dataList[k].refundMoney = parseFloat(parseFloat(dataList[k].refundMoney) + this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(
  765. 2
  766. );
  767. this.list[i].isAdd = true;
  768. dataList[k].refundProductList.push(this.list[i]);
  769. }
  770. } else {
  771. if (!this.list[i].isAdd) {
  772. var obj = {
  773. refundMoney: parseFloat(this.list[i].actualPrice * this.list[i].refundQuantity).toFixed(2),
  774. deliverId: this.list[i].deliveryInformation,
  775. refundProductList: []
  776. };
  777. this.list[i].isAdd = true;
  778. obj.refundProductList.push(this.list[i]);
  779. dataList.push(obj);
  780. }
  781. }
  782. }
  783. }
  784. }
  785. parameter.jsonStr = JSON.stringify(dataList);
  786. console.log('>>>>>', parameter.jsonStr);
  787. }
  788. parameter.refundMoney = this.allMoney;
  789. } else {
  790. parameter.refundMoney = this.payMoney;
  791. if (this.balancePayMoney && this.balancePayMoney > 0) {
  792. parameter.refundMoney = parseFloat(this.payMoney + this.balancePayMoney).toFixed(2);
  793. }
  794. }
  795. if (this.isrefund == 2) {
  796. parameter.refundGoodState = this.startIndex;
  797. parameter.refundMethod = this.huoIndex;
  798. if (this.refundMethod != 5) {
  799. if (!parameter.refundGoodState) {
  800. return req.msg('请您填写货物状态');
  801. }
  802. }
  803. if (!parameter.refundMethod) {
  804. return req.msg('请您填写退货方式');
  805. }
  806. }
  807. if (this.refundMethod != 5) {
  808. if (!parameter.refundReason) {
  809. return req.msg('请您填写退款原因');
  810. }
  811. }
  812. //退货时,是必须强制需要提交照片
  813. // if ((!this.avatar || this.avatar.length == 0)&&this.isrefund==2) {
  814. // return req.msg('请上传凭证照片');
  815. // }
  816. if(this.credentialsUrl){
  817. parameter.imgUrl = this.credentialsUrl.toString();
  818. }
  819. parameter.apiType = 1; //等于1时走新的退款流程;未传的走老退款流程
  820. req.postRequest('/api/orderRefund/save', parameter, data => {
  821. // uni.redirectTo({
  822. // url: '/mine/refund/refundDetails/refundDetails?id=' + data[0] + '&isrefund=' + this.isrefund
  823. // });
  824. req.msg('售后申请提交成功');
  825. setTimeout(function() {
  826. uni.navigateBack();
  827. }, 2000);
  828. });
  829. },
  830. upData() {
  831. let parameter = {
  832. refundType: this.isrefund,
  833. id: this.id
  834. };
  835. parameter.refundMethod = this.huoIndex;
  836. if (this.huoIndex == 1) {
  837. parameter.RefundState = 35;
  838. } else {
  839. parameter.RefundState = 36;
  840. }
  841. req.putRequest('/api/orderRefund/update', parameter, data => {
  842. uni.navigateBack();
  843. });
  844. }
  845. }
  846. };
  847. </script>
  848. <style>
  849. @import './applyRefund.css';
  850. </style>