refund.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <!-- 售后提交 -->
  2. <template>
  3. <view class="apply-return">
  4. <!-- 申请售后 -->
  5. <view class="container" v-if="selected">
  6. <view class="goodsStyle acea-row row-between"
  7. v-for="cart in selectProduct"
  8. :key="cart.id"
  9. >
  10. <view class="pictrue">
  11. <image :src="JSON.parse(cart.img)[0].url" class="image"/>
  12. </view>
  13. <view class="text acea-row row-between">
  14. <view class="name line2">{{ cart.productTitle }}</view>
  15. <view class="money">
  16. <view>
  17. ¥{{ cart.price }}
  18. </view>
  19. <view class="num">x{{ cart.num }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="list">
  24. <view v-if="serviceType === 1" class="item acea-row row-between-wrapper">
  25. <view>退货件数</view>
  26. <view class="num">{{ totalNum || 0 }}</view>
  27. </view>
  28. <view class="item acea-row row-between-wrapper">
  29. <view>退款金额</view>
  30. <view class="num currency-input-row">
  31. <text class="currency-symbol">¥</text>
  32. <input class="currency-input" type="number" v-model.number="totalMoney"
  33. placeholder="请输入退款金额" />
  34. </view>
  35. </view>
  36. <picker :value="reason" :range="reasonList" @change="changeReason">
  37. <view class="item acea-row row-between-wrapper">
  38. <view>退款原因</view>
  39. <view class="num">{{ reason }}</view>
  40. <text class="iconfont icon-jiantou"></text>
  41. </view>
  42. </picker>
  43. <view class="item textarea acea-row row-between">
  44. <view>备注说明</view>
  45. <textarea class="num"
  46. placeholder="填写备注信息,100字以内"
  47. v-model="refund_reason_wap_explain"
  48. ></textarea>
  49. </view>
  50. </view>
  51. <view v-if="serviceType === 0"
  52. class="returnBnt bg-color-red"
  53. @click="submit"
  54. >申请退款
  55. </view>
  56. <view v-if="serviceType === 1"
  57. class="returnBnt bg-color-red"
  58. @click="submit"
  59. >申请退货
  60. </view>
  61. </view>
  62. <!-- 选择商品 -->
  63. <view class="selectProduct" v-else>
  64. <view class="selectContainer"
  65. v-for="(cart, index) in selectProduct"
  66. :key="cart.id"
  67. >
  68. <view class="checkbox-wrapper">
  69. <checkbox-group @change="switchSelect(index)">
  70. <label class="well-check">
  71. <checkbox color="#eb3729" value :checked="cart.checked"></checkbox>
  72. </label>
  73. </checkbox-group>
  74. </view>
  75. <view class="pictrue">
  76. <image :src="JSON.parse(cart.img)[0].url" class="image"/>
  77. </view>
  78. <view class="content">
  79. <view class="title">{{ cart.productTitle || '' }}</view>
  80. <view class="skus">
  81. <view class="sku">
  82. {{ cart.productAttrTitle || '' }}
  83. </view>
  84. <view class="num">x{{ cart.num || 0 }}</view>
  85. </view>
  86. <view class="money">
  87. <view>
  88. {{ cart.price }}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="choose">
  94. <view class="checkTotal">
  95. <checkbox-group @change="allChecked">
  96. <label class="well-check">
  97. <checkbox
  98. color="#eb3729"
  99. value="allSelect"
  100. :checked="isAllSelect"
  101. ></checkbox>
  102. <text class="checkAll">全选 ({{ cartCount || 0 }})</text>
  103. </label>
  104. </checkbox-group>
  105. <view class="total">
  106. <view class="proTotal">
  107. {{ totalNum || 0 }}件商品
  108. </view>
  109. <view class="moneyTotal">
  110. 合计 ¥ {{ orderInfo.totalPrice || 0 }}
  111. </view>
  112. </view>
  113. </view>
  114. <view class="typeBtn">
  115. <view class="button def" @click="chooseType(0)">确认</view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. export default {
  123. name: "goodsReturn",
  124. data() {
  125. return {
  126. id: 0,
  127. selected: false,
  128. orderInfo: {},
  129. rebackList: [],
  130. reasonList: ['收货地址填错了', '与描述不符', '信息填错了,重新拍', '收到商品损坏了', '未按预定时间发货', '其它原因'],
  131. reason: "",
  132. refund_reason_wap_explain: '',
  133. refund_reason_wap_img: [],
  134. serviceType: null,
  135. // 选中售后商品
  136. selectProduct: [],
  137. productParamList: [],
  138. totalNum: 0,
  139. totalMoney: 0,
  140. isAllSelect: false,
  141. cartCount: 0,
  142. };
  143. },
  144. onLoad(option) {
  145. const that = this
  146. uni.showLoading({
  147. title: '正在加载'
  148. })
  149. that.$api.request('get', 'order/app/getOrderDetail', {
  150. orderId: option.id
  151. }, failres => {
  152. uni.hideLoading()
  153. that.$api.msg(failres.msg)
  154. }).then(res => {
  155. uni.hideLoading()
  156. that.orderInfo = res.data
  157. that.selectProduct = res.data.productList
  158. that.totalNum = 0
  159. that.orderInfo.productList.forEach(item => {
  160. that.totalNum = item.num + that.totalNum
  161. item.imgs = []
  162. })
  163. })
  164. },
  165. methods: {
  166. changeReason(e) {
  167. this.reason = this.reasonList[e.mp.detail.value];
  168. },
  169. imageuploaded(res) {
  170. if (res.status !== 200) {
  171. uni.showToast({
  172. title: err.msg || err.response.data.msg || err.response.data.message,
  173. icon: 'none',
  174. duration: 2000
  175. });
  176. return
  177. }
  178. this.refund_reason_wap_img.push(res.data.url);
  179. },
  180. getAfterSalesMoney() {
  181. this.$api.request('post', 'order/app/storeAfterSales/getRefundAmount', {
  182. orderCode: this.orderInfo.orderId,
  183. productParamList: this.productParamList
  184. }).then(res => {
  185. this.totalMoney = res.data
  186. }
  187. )
  188. },
  189. getOrderDetail() {
  190. uni.showLoading({
  191. title: '正在查询商品',
  192. duration: 2000,
  193. })
  194. orderDetail(this.id)
  195. .then(res => {
  196. this.orderInfo = res.data;
  197. this.selectProduct = res.data.cartInfo.map(item => {
  198. item.checked = false
  199. return item
  200. })
  201. if (res.data.cartInfo.length === 0) {
  202. uni.showToast({
  203. title: "订单无可售后商品",
  204. icon: 'none',
  205. duration: 2000
  206. });
  207. return
  208. }
  209. uni.hideLoading()
  210. })
  211. .catch(err => {
  212. uni.hideLoading()
  213. // uni.showToast({
  214. // title: err.msg || err.response.data.msg|| err.response.data.message,
  215. // icon: 'none',
  216. // duration: 2000
  217. // });
  218. });
  219. },
  220. getRefundReason() {
  221. getRefundReason().then(res => {
  222. this.reasonList = res.data;
  223. });
  224. },
  225. // 选择退款商品
  226. switchSelect(index) {
  227. let isAll = true
  228. this.selectProduct[index].checked = !this.selectProduct[index].checked
  229. this.selectProduct.forEach(item => {
  230. if (!item.checked) {
  231. isAll = false
  232. }
  233. })
  234. this.isAllSelect = isAll
  235. this.cartCount = this.selectProduct.filter(item => item.checked).length
  236. },
  237. // 全选
  238. allChecked() {
  239. this.isAllSelect = !this.isAllSelect
  240. this.selectProduct.forEach(item => {
  241. item.checked = this.isAllSelect
  242. })
  243. this.cartCount = this.selectProduct.filter(item => item.checked).length
  244. },
  245. // 选择退款类型
  246. chooseType(val) {
  247. if (!this.cartCount) {
  248. uni.showToast({
  249. title: "请至少选择一个商品",
  250. icon: 'none',
  251. duration: 2000
  252. });
  253. } else {
  254. this.selectProduct = this.selectProduct.map(item => {
  255. if (item.checked) {
  256. this.productParamList.push({
  257. productId: item.productId
  258. })
  259. return item
  260. }
  261. }).filter(r => r)
  262. this.selected = true;
  263. this.serviceType = val;
  264. this.getAfterSalesMoney();
  265. }
  266. },
  267. submit() {
  268. const refund_reason_wap_explain = this.refund_reason_wap_explain;
  269. if (!this.reason) {
  270. uni.showToast({
  271. title: "请选择退款原因",
  272. icon: 'none',
  273. duration: 2000
  274. });
  275. return
  276. }
  277. this.$api.request('post', 'order/app/storeAfterSales/applyForAfterSales', {
  278. orderCode: this.orderInfo.orderId,
  279. serviceType: this.serviceType,
  280. reasonForApplication: this.reason,
  281. applicationInstructions: refund_reason_wap_explain,
  282. applicationDescriptionPicture: this.refund_reason_wap_img.join(","),
  283. productParamList: this.productParamList
  284. }).then(res => {
  285. if (res.code === 200) {
  286. uni.showToast({
  287. title: res.msg,
  288. icon: "success",
  289. duration: 2000
  290. });
  291. setTimeout(() => {
  292. uni.navigateTo({
  293. url: "/pages/refund/index"
  294. })
  295. }, 1500)
  296. }
  297. })
  298. .catch(err => {
  299. uni.showToast({
  300. title: err.msg || err.response.data.msg || err.response.data.message,
  301. icon: 'none',
  302. duration: 2000
  303. });
  304. });
  305. }
  306. }
  307. };
  308. </script>
  309. <style lang="scss" scoped>
  310. .apply-return {
  311. .selectProduct {
  312. margin-bottom: 180rpx;
  313. .selectContainer {
  314. padding: 20rpx 32rpx;
  315. background-color: #FFF;
  316. display: flex;
  317. align-items: center;
  318. .pictrue {
  319. .image {
  320. width: 180rpx;
  321. height: 180rpx;
  322. }
  323. }
  324. .content {
  325. width: 100%;
  326. height: 100%;
  327. margin-left: 16rpx;
  328. font-size: 24rpx;
  329. display: flex;
  330. flex-direction: column;
  331. justify-content: space-between;
  332. .title {
  333. width: 100%;
  334. height: 80rpx;
  335. text-overflow: ellipsis;
  336. font-size: 28rpx;
  337. }
  338. .skus {
  339. display: flex;
  340. justify-content: space-between;
  341. color: #999999;
  342. }
  343. .money {
  344. margin-top: 10rpx;
  345. display: flex;
  346. view {
  347. color: #EB3729;
  348. }
  349. }
  350. }
  351. }
  352. .choose {
  353. width: 100%;
  354. padding: 20rpx 30rpx;
  355. background-color: #FFF;
  356. position: fixed;
  357. bottom: 0;
  358. height: 180rpx;
  359. .checkTotal {
  360. height: 80rpx;
  361. font-size: 28rpx;
  362. border-bottom: 2rpx solid #F3F4F5;
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. .total {
  367. display: flex;
  368. .proTotal {
  369. color: #666;
  370. }
  371. .moneyTotal {
  372. color: #333;
  373. margin-left: 30rpx;
  374. }
  375. }
  376. }
  377. .typeBtn {
  378. margin-top: 10rpx;
  379. display: flex;
  380. justify-content: flex-end;
  381. align-items: center;
  382. .button {
  383. width: 160rpx;
  384. height: 60rpx;
  385. margin: 0 10rpx;
  386. line-height: 60rpx;
  387. text-align: center;
  388. font-size: 24rpx;
  389. border-radius: 180rpx;
  390. }
  391. .def {
  392. color: #AAAAAA;
  393. border: 2rpx solid #DDDDDD;
  394. }
  395. .greenBtn {
  396. color: #FFF;
  397. background-color: #EB3729;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. /**/
  404. .goodsStyle {
  405. background-color: #fff;
  406. padding: 0.22 * 100rpx 0.3 * 100rpx;
  407. }
  408. .goodsStyle .pictrue {
  409. width: 1.2 * 100rpx;
  410. height: 1.2 * 100rpx;
  411. }
  412. .goodsStyle .pictrue .image {
  413. width: 100%;
  414. height: 100%;
  415. border-radius: 0.06 * 100rpx;
  416. }
  417. .goodsStyle .text {
  418. width: 5.45 * 100rpx;
  419. font-size: 0.28 * 100rpx;
  420. color: #999;
  421. }
  422. .goodsStyle .text .name {
  423. width: 3.6 * 100rpx;
  424. color: #282828;
  425. }
  426. .goodsStyle .text .money {
  427. text-align: right;
  428. }
  429. .goodsStyle .text .money .num {
  430. margin-top: 0.07 * 100rpx;
  431. }
  432. /* layout */
  433. .acea-row {
  434. display: flex;
  435. flex-wrap: wrap;
  436. /* 辅助类 */
  437. }
  438. .acea-row.row-between {
  439. justify-content: space-between;
  440. }
  441. /*申请退货*/
  442. .apply-return .list {
  443. background-color: #fff;
  444. margin-top: 0.18 * 100rpx;
  445. }
  446. .apply-return .list .item {
  447. margin-left: 0.3 * 100rpx;
  448. padding-right: 0.3 * 100rpx;
  449. min-height: 0.9 * 100rpx;
  450. border-bottom: 1px solid #eee;
  451. font-size: 0.3 * 100rpx;
  452. color: #333;
  453. }
  454. .apply-return .list .item .num {
  455. color: #282828;
  456. flex: 1;
  457. text-align: right;
  458. position: relative;
  459. }
  460. .apply-return .list .item .num .picker {
  461. text-align: right;
  462. }
  463. .apply-return .list .item .num .iconfont {
  464. color: #666;
  465. font-size: 0.3 * 100rpx;
  466. position: absolute;
  467. right: 0;
  468. top: 50%;
  469. transform: translateY(-50%);
  470. }
  471. .apply-return .list .item.textarea {
  472. padding: 0.3 * 100rpx 0.3 * 100rpx 0.3 * 100rpx 0;
  473. }
  474. .apply-return .list .item textarea {
  475. height: 1 * 100rpx;
  476. font-size: 0.3 * 100rpx;
  477. }
  478. .apply-return .list .item textarea::placeholder {
  479. color: #bbb;
  480. }
  481. .apply-return .list .item .title {
  482. height: 0.95 * 100rpx;
  483. width: 100%;
  484. }
  485. .apply-return .list .item .title .tip {
  486. font-size: 0.3 * 100rpx;
  487. color: #bbb;
  488. }
  489. .apply-return .list .item .upload {
  490. padding-bottom: 0.36 * 100rpx;
  491. }
  492. .apply-return .list .item .upload .pictrue {
  493. margin: 0.22 * 100rpx 0.23 * 100rpx 0 0;
  494. width: 1.56 * 100rpx;
  495. height: 1.56 * 100rpx;
  496. position: relative;
  497. font-size: 0.24 * 100rpx;
  498. color: #bbb;
  499. border: 1px solid #bbb;
  500. }
  501. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  502. margin-right: 0;
  503. }
  504. .apply-return .list .item .upload .pictrue image {
  505. width: 100%;
  506. height: 100%;
  507. border-radius: 0.03 * 100rpx;
  508. }
  509. .apply-return .list .item .upload .pictrue .icon-guanbi1 {
  510. position: absolute;
  511. font-size: 0.45 * 100rpx;
  512. top: -0.1 * 100rpx;
  513. right: -0.1 * 100rpx;
  514. width: 0.45 * 100rpx;
  515. height: 0.45 * 100rpx;
  516. line-height: 0.45 * 100rpx;
  517. }
  518. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  519. color: #bfbfbf;
  520. font-size: 0.5 * 100rpx;
  521. width: 0.5 * 100rpx;
  522. height: 0.6 * 100rpx;
  523. line-height: 0.6 * 100rpx;
  524. }
  525. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  526. border: 1px solid #ddd;
  527. }
  528. .apply-return .returnBnt {
  529. font-size: 0.32 * 100rpx;
  530. color: #fff;
  531. width: 6.9 * 100rpx;
  532. height: 0.86 * 100rpx;
  533. border-radius: 0.5 * 100rpx;
  534. text-align: center;
  535. line-height: 0.86 * 100rpx;
  536. margin: 0.43 * 100rpx auto;
  537. }
  538. .acea-row.row-between-wrapper {
  539. align-items: center;
  540. justify-content: space-between;
  541. }
  542. .bg-color-red {
  543. background-color: #eb3729 !important;
  544. }
  545. .currency-input-row {
  546. display: flex;
  547. align-items: center;
  548. width: 100%;
  549. max-width: 400px;
  550. justify-content: flex-end; /* 内容靠右 */
  551. }
  552. .currency-symbol {
  553. border-radius: 6px;
  554. margin-right: 10px;
  555. }
  556. .currency-input {
  557. border: 1px solid #ddd;
  558. border-radius: 6px;
  559. font-size: 1rem;
  560. width: 150px;
  561. text-align: center; /* 输入值居中 */
  562. transition: border-color 0.3s;
  563. }
  564. </style>