applicationDrawback.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <view class="container">
  3. <view class="bg-fff u-mt20 u-p30" v-if="keystatus == 1">
  4. <view
  5. class="goodsItem u-flex-center mb20"
  6. v-for="value in list"
  7. :key="value.id"
  8. >
  9. <image
  10. :src="value.productCover"
  11. v-if="value.productCover"
  12. class="u-goods200 u-ml15"
  13. mode=""
  14. ></image>
  15. <view class="u-flex1 u-flex-column-start rightText u-ml30">
  16. <view class="u-text2 u-1A1A1A u-font28">{{ value.productTitle }}</view>
  17. <view class="bottext u-flex-column-start u-flex1">
  18. <text class="u-font22 u-999" v-if="value.skuSetName"
  19. >规格: {{ value.skuSetName }}</text
  20. >
  21. <view class="u-flex-center botPrice">
  22. <view class="u-FF0000 u-font32" v-if="value.exchange"
  23. >{{ value.singlePoint }} 积分</view
  24. >
  25. <view class="u-FF0000 u-font32" v-else>
  26. <rich-text
  27. :nodes="$mUtil.priceBigSmall(value.realPrice)"
  28. ></rich-text>
  29. </view>
  30. <text class="u-font26 u-666 u-ml15" v-if="value.productNum"
  31. >x {{ value.productNum }}</text
  32. >
  33. <text class="u-font26 u-666 u-ml15" v-if="value.number"
  34. >x {{ value.number }}</text
  35. >
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="bg-fff u-mt20 u-p30" v-if="keystatus == 2 || keystatus == 3">
  42. <view class="goodsItem u-flex-center">
  43. <image
  44. :src="value.productCover"
  45. v-if="value.productCover"
  46. class="u-goods200 u-ml15"
  47. mode=""
  48. ></image>
  49. <view class="u-flex1 u-flex-column-start rightText u-ml30">
  50. <view class="u-text2 u-1A1A1A u-font28">{{ value.productTitle }}</view>
  51. <view class="bottext u-flex-column-start u-flex1">
  52. <text class="u-font22 u-999" v-if="value.skuSetName"
  53. >规格: {{ value.skuSetName }}</text
  54. >
  55. <view class="u-flex-center botPrice">
  56. <view class="u-FF0000 u-font32" v-if="value.singlePoint && value.singlePoint * 1"
  57. >{{ value.singlePoint }} 积分</view
  58. >
  59. <view class="u-FF0000 u-font32" v-else>
  60. <rich-text
  61. :nodes="$mUtil.priceBigSmall(value.realPrice)"
  62. ></rich-text>
  63. </view>
  64. <text class="u-font26 u-666 u-ml15" v-if="value.productNum"
  65. >x {{ value.productNum }}</text
  66. >
  67. <text class="u-font26 u-666 u-ml15" v-if="value.number"
  68. >x {{ value.number }}</text
  69. >
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="u-bg-fff u-mt20">
  76. <view class="u-plr30">
  77. <picker
  78. @change="pickerChange($event, 'industry')"
  79. :value="applicationTypeIndex"
  80. range-key="name"
  81. :range="applicationTypeList"
  82. v-if="applicationTypeList.length > 0"
  83. >
  84. <view class="u-flex-center-sb u-border-one-one ht104">
  85. <view class="u-1A1A1A">售后类型</view>
  86. <view class="u-flex">
  87. <view class="uni-input ml38 u-4D4D4D">{{
  88. applicationTypeList[applicationTypeIndex].name
  89. }}</view>
  90. <view class="iconfont u-666">&#xe6c7;</view>
  91. </view>
  92. </view>
  93. </picker>
  94. <picker
  95. @change="pickerChangeres($event, 'industry')"
  96. :value="applicationIndex"
  97. range-key="name"
  98. :range="applicationList"
  99. v-if="applicationList.length > 0"
  100. >
  101. <view class="u-flex-center-sb u-border-one-one ht104">
  102. <view class="u-1A1A1A">售后原因</view>
  103. <view class="u-flex">
  104. <view class="uni-input ml38 u-4D4D4D">{{
  105. applicationList[applicationIndex].name
  106. }}</view>
  107. <view class="iconfont u-666">&#xe6c7;</view>
  108. </view>
  109. </view>
  110. </picker>
  111. <view
  112. class="u-flex-center-sb u-border-one-one ht104"
  113. v-if="keystatus == 2"
  114. >
  115. <view class="u-1A1A1A">数量</view>
  116. <view class="rightAddRes u-flex-center">
  117. <text class="btnTag" @click="resNum">-</text>
  118. <text class="u-flex1 centertext u-font28 u-999">{{ num }}</text>
  119. <text class="btnTag" @click="addNum">+</text>
  120. </view>
  121. </view>
  122. <view class="u-flex-center-sb u-border-one-one ht104">
  123. <view class="u-1A1A1A">退款金额</view>
  124. <!-- <view class="u-FF0000 u-font32 u-bold"><rich-text :nodes="$mUtil.priceBigSmall(12.2)" ></rich-text></view> -->
  125. <input
  126. type="digit"
  127. :value="money"
  128. maxlength="10"
  129. @input="onchangeInput"
  130. class="u-FF0000 u-font32 u-flex1 u-text-right"
  131. />
  132. </view>
  133. <view
  134. class="u-flex-center-sb u-border-one-one ht104"
  135. v-if="ableRefundPoint > 0"
  136. >
  137. <view class="u-1A1A1A">退款积分</view>
  138. <view class="u-FF0000 u-font32">{{ ableRefundPoint }}</view>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="u-bg-fff u-plr30 apply">
  143. <view class="u-060606">退款备注</view>
  144. <view class="u-mt25">
  145. <textarea
  146. placeholder="请您详细填写申请说明"
  147. @input="onchangeText"
  148. maxlength="45"
  149. ></textarea>
  150. </view>
  151. <view class="u-mt30 u-060606">上传凭证</view>
  152. <view class="u-mt25">
  153. <uploadImg
  154. :imgCount="3"
  155. :uploadImgCount="1"
  156. v-model="imgArray"
  157. ></uploadImg>
  158. </view>
  159. </view>
  160. <view class="btn" @click="submitApply"
  161. ><button class="u-btn-two">提交审核</button></view
  162. >
  163. </view>
  164. </template>
  165. <script setup>
  166. import { ref, reactive } from "vue";
  167. import { onLoad } from "@dcloudio/uni-app";
  168. import {
  169. ableRefundMoney_Api,
  170. ableRefundMoneyMain_Api,
  171. childOrder_Api,
  172. applyOrder_Api,
  173. } from "@/api/order.js";
  174. const applicationTypeIndex = ref(0);
  175. const applicationIndex = ref(0);
  176. const applicationTypeList = ref([]); //申请类型
  177. const applicationList = ref([
  178. {
  179. code: 1,
  180. name: "多拍、错拍、不想要",
  181. },
  182. {
  183. code: 1,
  184. name: "不喜欢、效果不好",
  185. },
  186. {
  187. code: 1,
  188. name: "商品成分描述不符",
  189. },
  190. {
  191. code: 1,
  192. name: "其他",
  193. },
  194. ]); //申请类型
  195. const imgArray = ref([]); //图片列表
  196. const value = ref({});
  197. const keystatus = ref(1); //1未发货,退款,2收到货退款/退货
  198. const parentOrderId = ref(null);
  199. const orderId = ref(null);
  200. const list = ref([]);
  201. const money = ref(0);
  202. const moneyold = ref(0);
  203. const num = ref(0);
  204. const number = ref(0);
  205. const flag = ref(true);
  206. const reason = ref("");
  207. const caption = ref("");
  208. const ableRefundPoint = ref(0);
  209. const type = ref(null);
  210. // 页面加载
  211. onLoad((option) => {
  212. let goodslist = uni.getStorageSync("blackgoodsList");
  213. // 注意:在Vue3中,this.config.title需要替换为其他方式设置标题
  214. // 这里我们忽略标题设置,因为在实际应用中可能通过路由参数传递
  215. if (option.id) {
  216. orderId.value = option.id;
  217. }
  218. if (option.orderId) {
  219. parentOrderId.value = option.orderId;
  220. }
  221. if (option.type) {
  222. type.value = option.type;
  223. }
  224. if (option.keystatus) {
  225. keystatus.value = option.keystatus;
  226. if (option.keystatus == 2 || option.keystatus == 3) {
  227. //子订单
  228. if (goodslist) {
  229. goodslist.forEach((item) => {
  230. if (item.orderDetailId == option.id) {
  231. value.value = item;
  232. getChildOrder(option.orderId, option.id, item.number);
  233. // getAddNumber(option.orderId, option.id, item.number);
  234. }
  235. });
  236. }
  237. if (option.keystatus == 2) {
  238. applicationTypeList.value = [
  239. {
  240. i: 0,
  241. name: "退款",
  242. },
  243. {
  244. i: 1,
  245. name: "退货退款",
  246. },
  247. ];
  248. reason.value = applicationList.value[applicationIndex.value].name;
  249. }
  250. } else {
  251. //主订单
  252. if (goodslist) {
  253. list.value = goodslist;
  254. }
  255. mainOrder(option.orderId);
  256. applicationTypeList.value = [
  257. {
  258. i: 0,
  259. name: "退款",
  260. },
  261. ];
  262. reason.value = applicationList.value[applicationIndex.value].name;
  263. }
  264. }
  265. });
  266. // 输入框变化处理
  267. const onchangeText = (e) => {
  268. if (e) {
  269. caption.value = e.detail.value;
  270. }
  271. };
  272. const onchangeInput = (e) => {
  273. if (e) {
  274. money.value = e.detail.value;
  275. }
  276. };
  277. // 图片上传结果处理
  278. const resultUrl = (e) => {
  279. imgArray.value = e;
  280. };
  281. // 提交申请
  282. const submitApply = () => {
  283. let that = {
  284. keystatus: keystatus.value,
  285. parentOrderId: parentOrderId.value,
  286. orderId: orderId.value || parentOrderId.value,
  287. applicationTypeIndex: applicationTypeIndex.value,
  288. reason: reason.value,
  289. caption: caption.value,
  290. imgArray: imgArray.value,
  291. money: money.value,
  292. moneyold: moneyold.value,
  293. num: num.value,
  294. ableRefundPoint: ableRefundPoint.value,
  295. };
  296. if (that.money * 1 > that.moneyold * 1) {
  297. uni.$uv.toast("退款金额不能大于" + that.moneyold);
  298. return false;
  299. }
  300. if (that.keystatus == 1) {
  301. let data = {
  302. parentOrderId: parentOrderId.value,
  303. orderId: that.parentOrderId,
  304. rightsCargoStatus: 0, //0未收货,1已收货
  305. rightsType: 5, //5仅退款,10退款退货
  306. reason: that.reason,
  307. caption: that.caption,
  308. voucherImages: that.imgArray,
  309. refundMoney: that.money,
  310. refundPoint: that.ableRefundPoint,
  311. isAllRights: true
  312. };
  313. console.log(data)
  314. applyOrder_Api(data).then((res) => {
  315. if (res && res.code == 200) {
  316. uni.$uv.toast("申请成功");
  317. setTimeout(() => {
  318. uni.navigateBack();
  319. }, 1000);
  320. }
  321. });
  322. } else {
  323. let data = {
  324. orderId: that.parentOrderId,
  325. childOrderId: that.orderId,
  326. rightsCargoStatus: 1, //0未收货,1已收货
  327. rightsType: that.applicationTypeIndex == 0 ? 5 : 10, //5仅退款,10退款退货
  328. reason: that.reason,
  329. caption: that.caption,
  330. refundMoney: that.money,
  331. refundNum: that.num,
  332. refundPoint: that.ableRefundPoint,
  333. };
  334. childOrder_Api(data).then((res) => {
  335. if (res && res.code == 200) {
  336. uni.$uv.toast("申请成功");
  337. setTimeout(() => {
  338. // uni.reLaunch({
  339. // url: '/pages/order/mallOrder/orderList'
  340. // });
  341. uni.navigateBack();
  342. }, 1000);
  343. }
  344. });
  345. }
  346. };
  347. // 减数量
  348. const resNum = () => {
  349. if (num.value * 1 > 1) {
  350. flag.value = false;
  351. num.value--;
  352. getAddNumber(parentOrderId.value, orderId.value, num.value);
  353. }
  354. };
  355. // 加数量
  356. const addNum = () => {
  357. console.log(number.value);
  358. if (num.value < number.value) {
  359. flag.value = false;
  360. num.value++;
  361. getAddNumber(parentOrderId.value, orderId.value, num.value);
  362. }
  363. };
  364. // 主订单可以最多可以退多少钱
  365. const mainOrder = (id) => {
  366. let data = {
  367. orderId: id,
  368. };
  369. ableRefundMoneyMain_Api(data).then((res) => {
  370. if (res && res.code == 200) {
  371. money.value = res.data.ableRefundMoney;
  372. moneyold.value = res.data.ableRefundMoney;
  373. ableRefundPoint.value = res.data.ableRefundPoint;
  374. // num.value = res.data.goods_num
  375. // number.value = res.data.goods_num
  376. }
  377. });
  378. };
  379. // 子订单可以最多可以退多少钱
  380. const getChildOrder = (id, childid, nums) => {
  381. let data = {
  382. orderId: id,
  383. childOrderId: childid,
  384. refundNum: nums,
  385. };
  386. ableRefundMoney_Api(data).then((res) => {
  387. if (res && res.code == 200) {
  388. money.value = res.data.ableRefundMoney;
  389. moneyold.value = res.data.ableRefundMoney;
  390. ableRefundPoint.value = res.data.ableRefundPoint;
  391. number.value = res.data.productNum;
  392. if (flag.value) {
  393. num.value = res.data.productNum;
  394. }
  395. }
  396. });
  397. };
  398. const getAddNumber = (id, childid, nums) => {
  399. let data = {
  400. orderId: id,
  401. childOrderId: childid,
  402. refundNum: nums,
  403. };
  404. ableRefundMoney_Api(data).then((res) => {
  405. if (res && res.code == 200) {
  406. money.value = res.data.ableRefundMoney;
  407. moneyold.value = res.data.ableRefundMoney;
  408. ableRefundPoint.value = res.data.ableRefundPoint;
  409. if (flag.value) {
  410. num.value = res.data.productNum;
  411. }
  412. }
  413. });
  414. };
  415. const pickerChange = (e, val) => {
  416. // console.log('applicationTypeList.value', applicationTypeList.value);
  417. // console.log('e.target.val', e);
  418. applicationTypeIndex.value = e.detail.value;
  419. };
  420. const pickerChangeres = (e, val) => {
  421. applicationIndex.value = e.detail.value;
  422. reason.value = applicationList.value[e.detail.value].name;
  423. };
  424. </script>
  425. <style lang="scss">
  426. page {
  427. background-color: #fafafa;
  428. }
  429. .bg-fff {
  430. background-color: #fff;
  431. }
  432. .ml38 {
  433. margin-left: 38rpx;
  434. }
  435. .mb20 {
  436. margin-bottom: 20rpx;
  437. }
  438. .ht104 {
  439. height: 104rpx;
  440. line-height: 104rpx;
  441. }
  442. .rightAddRes {
  443. width: 172rpx;
  444. height: 50rpx;
  445. border-radius: 8rpx;
  446. border: 1px solid #e5e5e5;
  447. .centertext {
  448. text-align: center;
  449. }
  450. .btnTag {
  451. width: 50rpx;
  452. height: 50rpx;
  453. line-height: 50rpx;
  454. text-align: center;
  455. background-color: #dedede;
  456. font-size: 46rpx;
  457. color: #888;
  458. }
  459. }
  460. .p-tlbr30 {
  461. padding: 30rpx;
  462. }
  463. textarea {
  464. width: 100%;
  465. height: 210rpx;
  466. opacity: 0.66;
  467. border: 1rpx solid #e6e6e6;
  468. border-radius: 8rpx;
  469. padding-left: 22rpx;
  470. padding-top: 14rpx;
  471. box-sizing: border-box;
  472. }
  473. .apply {
  474. padding-top: 34rpx;
  475. padding-bottom: 42rpx;
  476. }
  477. .btn {
  478. padding: 70rpx 30rpx;
  479. button {
  480. // background: #fa6138;
  481. color: #ffffff;
  482. }
  483. }
  484. </style>