aftersale.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <view class="container">
  3. <view class="order-goods">
  4. <view class="h">退款商品</view>
  5. <view class="goods">
  6. <view class="item" v-for="(item, index) in orderGoods" :key="index">
  7. <view class="img">
  8. <image :src="item.picUrl"></image>
  9. </view>
  10. <view class="info">
  11. <view class="t">
  12. <text class="name">{{ item.goodsName }}</text>
  13. <text class="number">x{{ item.number }}</text>
  14. </view>
  15. <view class="attr">{{ item.specifications }}</view>
  16. <view class="price">单价:¥{{ item.price }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- <van-cell-group title="订单明细">
  22. <van-cell title="商品总价" value=" ¥{{orderInfo.goodsPrice}}元" />
  23. <van-cell title=" 优惠" value="-¥{{orderInfo.couponPrice}}元" />
  24. <van-cell title="订单实付" value=" ¥{{orderInfo.actualPrice}}元" />
  25. </van-cell-group> -->
  26. <view class="card">
  27. <view class="module-title">订单明细</view>
  28. <view class="tt-cell">
  29. <view>商品总价</view>
  30. <view>¥{{ orderInfo.goodsPrice }}元</view>
  31. </view>
  32. <view class="tt-cell">
  33. <view>优 惠</view>
  34. <view>-¥{{ orderInfo.couponPrice }}元</view>
  35. </view>
  36. <view class="tt-cell">
  37. <view>订单实付</view>
  38. <view>-¥{{ orderInfo.actualPrice }}元</view>
  39. </view>
  40. </view>
  41. <!-- <van-cell-group title="操作">
  42. <van-field value="{{ aftersale.typeDesc }}" label="退款类型" readonly="readonly" placeholder="请选择" input-align="right" required clickable bind:tap="showTypePicker" />
  43. <van-field value="{{ aftersale.reason }}" label="退款原因" placeholder="请输入" bind:change="onReasonChange" input-align="right" required clearable />
  44. <van-field label="退款说明" value="{{ aftersale.comment }}" placeholder="请输入" type="textarea" input-align="right" autosize />
  45. <van-cell title="退款金额" value="¥{{ aftersale.amount }}元" label="不可修改,即订单实付- 运费" required />
  46. <van-cell title="上传凭证" label="最多上传三张">
  47. <van-uploader file-list="{{ fileList }}" bind:after-read="afterRead" bind:delete="deleteImage" max-count="3" preview-size="50px" />
  48. </van-cell>
  49. </van-cell-group> -->
  50. <view class="card">
  51. <view class="module-title">退款信息</view>
  52. <!-- <view class="refund-tips">
  53. 退款发起时间距离服务时间小于(含)24小时,将收取60元退改费
  54. </view> -->
  55. <picker :value="index" :range="columns" @change="bindPickerChange">
  56. <view class="tt-cell">
  57. <view>
  58. <text class="need">*</text>
  59. 退款类型
  60. </view>
  61. <view>{{ aftersale.typeDesc }} ></view>
  62. </view>
  63. </picker>
  64. <view class="tt-cell">
  65. <view>
  66. <text class="need">*</text>
  67. 退款原因
  68. </view>
  69. <input :value="aftersale.reason" placeholder="请输入" placeholder-style="font-size:26rpx;color:#999;" @input="onReasonChange" />
  70. </view>
  71. <view class="comment-wrapper">
  72. <view class="tt-cell comment-cell">
  73. <view>退款说明</view>
  74. <input :value="aftersale.comment" placeholder="请输入" placeholder-style="font-size:26rpx;color:#999;" @input="onCommentChange" />
  75. </view>
  76. </view>
  77. <view class="tt-cell">
  78. <view>
  79. <text class="need">*</text>
  80. 退款金额
  81. </view>
  82. <view>¥{{ aftersale.amount }}元</view>
  83. </view>
  84. <view class="comment-tips">不可更改,即订单实付</view>
  85. <view class="upload-text">上传凭证</view>
  86. <view class="comment-tips">最多上传3张</view>
  87. <!-- 图片上传 -->
  88. <view class="upload-wrapper">
  89. <view class="img-item" v-for="(item, index) in imgList" :key="index">
  90. <image mode="aspectFill" :src="item" class="user-upload" @tap="previewImg" :data-img="item"></image>
  91. <image class="close-img" mode="aspectFill" src="/static/images/icon-close.png" @tap="delImg" :data-index="index"></image>
  92. </view>
  93. <view class="upload" @tap="uploadImg">
  94. <image mode="aspectFill" src="/static/images/icon-add.png"></image>
  95. <view>上传照片</view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="submit-btn" @tap="submit">申请售后</view>
  100. <!-- <van-button type="danger" bind:click="submit" block>申请售后</van-button> -->
  101. <!-- <van-popup show="{{showPicker}}" position="bottom">
  102. <van-picker show-toolbar columns="{{columns}}" bind:cancel="onCancel" bind:confirm="onConfirm" />
  103. </van-popup> -->
  104. </view>
  105. </template>
  106. <script>
  107. var util = require('../../../utils/util.js');
  108. var api = require('../../../config/api.js');
  109. export default {
  110. data() {
  111. return {
  112. index: '',
  113. orderId: 0,
  114. orderInfo: {
  115. goodsPrice: '',
  116. couponPrice: '',
  117. actualPrice: ''
  118. },
  119. orderGoods: [],
  120. aftersale: {
  121. pictures: [],
  122. typeDesc: '请选择',
  123. reason: '',
  124. amount: '',
  125. orderId: '',
  126. comment: '',
  127. type: ''
  128. },
  129. columns: ['地址约错', '约不到想要的服务时间', '活动/优惠未享受', '服务质量问题'],
  130. contentLength: 0,
  131. fileList: [],
  132. imgList: [],
  133. refundTypes: '',
  134. showPicker: false,
  135. type: ''
  136. };
  137. },
  138. onLoad: function (options) {
  139. // 页面初始化 options为页面跳转所带来的参数
  140. this.setData({
  141. orderId: options.id
  142. });
  143. this.getOrderDetail();
  144. this.getRefudnType();
  145. this.getAmount();
  146. },
  147. onReady: function () {
  148. // 页面渲染完成
  149. },
  150. onShow: function () {
  151. // 页面显示
  152. },
  153. onHide: function () {
  154. // 页面隐藏
  155. },
  156. onUnload: function () {
  157. // 页面关闭
  158. },
  159. methods: {
  160. getRefudnType() {
  161. let that = this;
  162. util.request(api.AftersaleRefundType).then(function (res) {
  163. if (res.errno === 0) {
  164. that.setData({
  165. refundTypes: res.data,
  166. columns: res.data.map((obj) => obj.name)
  167. });
  168. console.info(that.refundTypes);
  169. }
  170. });
  171. },
  172. getAmount: function () {
  173. util.request(api.AftersaleAmount, {
  174. orderId: this.orderId
  175. }).then((res) => {
  176. if (res.errno === 0) {
  177. console.log(res.data);
  178. this.setData({
  179. 'aftersale.amount': res.data.refundAmount
  180. });
  181. }
  182. });
  183. },
  184. getOrderDetail: function () {
  185. uni.showLoading({
  186. title: '加载中'
  187. });
  188. setTimeout(function () {
  189. uni.hideLoading();
  190. }, 2000);
  191. let that = this;
  192. util.request(api.OrderDetail, {
  193. orderId: that.orderId
  194. }).then(function (res) {
  195. if (res.errno === 0) {
  196. console.log(res.data);
  197. that.setData({
  198. orderInfo: res.data.orderInfo,
  199. orderGoods: res.data.orderGoods,
  200. 'aftersale.orderId': that.orderId
  201. // 'aftersale.amount': res.data.orderInfo.actualPrice - res.data.orderInfo.freightPrice
  202. });
  203. }
  204. uni.hideLoading();
  205. });
  206. },
  207. deleteImage(event) {
  208. const { fileList = [] } = this;
  209. fileList.splice(event.detail.index, 1);
  210. this.setData({
  211. fileList: fileList
  212. });
  213. let urls = [];
  214. fileList.forEach(function (e) {
  215. urls.push(e.url);
  216. });
  217. this.setData({
  218. 'aftersale.pictures': urls
  219. });
  220. },
  221. afterRead(event) {
  222. const { file } = event.detail;
  223. let that = this;
  224. const uploadTask = uni.uploadFile({
  225. url: api.StorageUpload,
  226. filePath: file.path,
  227. name: 'file',
  228. success: function (res) {
  229. var _res = JSON.parse(res.data);
  230. if (_res.errno === 0) {
  231. var url = _res.data.url;
  232. that.aftersale.pictures.push(url);
  233. const { fileList = [] } = that;
  234. fileList.push({
  235. ...file,
  236. url: url
  237. });
  238. that.setData({
  239. fileList: fileList
  240. });
  241. }
  242. },
  243. fail: function (e) {
  244. uni.showModal({
  245. title: '错误',
  246. content: '上传失败',
  247. showCancel: false
  248. });
  249. }
  250. });
  251. },
  252. previewImage: function (e) {
  253. uni.previewImage({
  254. current: e.currentTarget.id,
  255. // 当前显示图片的http链接
  256. urls: this.files // 需要预览的图片http链接列表
  257. });
  258. },
  259. contentInput: function (e) {
  260. this.setData({
  261. contentLength: e.detail.cursor,
  262. 'aftersale.comment': e.detail.value
  263. });
  264. },
  265. onReasonChange: function (e) {
  266. console.log(e);
  267. this.setData({
  268. 'aftersale.reason': e.detail.value
  269. });
  270. },
  271. onCommentChange: function (e) {
  272. console.log(e);
  273. this.setData({
  274. 'aftersale.comment': e.detail.value
  275. });
  276. },
  277. showTypePicker: function () {
  278. this.setData({
  279. showPicker: true
  280. });
  281. },
  282. onCancel: function () {
  283. this.setData({
  284. showPicker: false
  285. });
  286. },
  287. bindPickerChange: function (event) {
  288. console.log(event);
  289. this.setData({
  290. 'aftersale.type': event.detail.value,
  291. 'aftersale.typeDesc': this.columns[event.detail.value]
  292. });
  293. },
  294. submit: function () {
  295. let that = this;
  296. if (that.aftersale.type == undefined) {
  297. util.showErrorToast('请选择退款类型');
  298. return false;
  299. }
  300. let name = that.aftersale.typeDesc;
  301. let vals = this.refundTypes.filter((item) => item.name == name);
  302. that.setData({
  303. type: vals[0].id
  304. });
  305. console.log(that.aftersale);
  306. if (that.aftersale.reason == '') {
  307. util.showErrorToast('请输入退款原因');
  308. return false;
  309. }
  310. uni.showLoading({
  311. title: '提交中...',
  312. mask: true,
  313. success: function () {}
  314. });
  315. this.setData({
  316. 'aftersale.pictures': this.imgList
  317. });
  318. util.request(api.AftersaleSubmit, that.aftersale, 'POST').then(function (res) {
  319. uni.hideLoading();
  320. if (res.errno === 0) {
  321. uni.showToast({
  322. title: '申请售后成功',
  323. icon: 'success',
  324. duration: 2000,
  325. complete: function () {
  326. uni.redirectTo({
  327. url: '/pages/ucenter/aftersaleList/aftersaleList'
  328. });
  329. }
  330. });
  331. } else {
  332. util.showErrorToast(res.errmsg);
  333. }
  334. });
  335. },
  336. previewImg(e) {
  337. let img = e.currentTarget.dataset.img;
  338. let imgs = this.imgList;
  339. uni.previewImage({
  340. current: img,
  341. // 当前显示图片的http链接
  342. urls: imgs // 需要预览的图片http链接列表
  343. });
  344. },
  345. delImg(e) {
  346. let imgs = this.imgList;
  347. let index = e.currentTarget.dataset.index;
  348. imgs.splice(index, 1);
  349. this.setData({
  350. imgList: imgs
  351. });
  352. },
  353. uploadImg() {
  354. if (this.imgList.length >= 3) {
  355. uni.showToast({
  356. title: '最多上传3张图片',
  357. icon: 'none',
  358. duration: 2000
  359. });
  360. return false;
  361. }
  362. let that = this;
  363. let count = 3 - that.imgList.length;
  364. uni.chooseImage({
  365. count: count,
  366. sizeType: ['original', 'compressed'],
  367. sourceType: ['album', 'camera'],
  368. success: function (res) {
  369. console.log(res);
  370. let tempFilePaths = res.tempFilePaths;
  371. uni.showLoading({
  372. title: '上传中...'
  373. });
  374. for (let i = 0; i < tempFilePaths.length; i++) {
  375. let imgs = that.imgList;
  376. if (imgs.length >= 3) {
  377. that.setData({
  378. imgList: imgs
  379. });
  380. return false;
  381. } else {
  382. uni.uploadFile({
  383. url: api.StorageUpload,
  384. filePath: tempFilePaths[i],
  385. name: 'file',
  386. success(res) {
  387. console.log(res);
  388. let data = JSON.parse(res.data);
  389. if (data.errno == 0) {
  390. imgs.push(data.data.url);
  391. that.setData({
  392. imgList: imgs
  393. });
  394. } else {
  395. console.log('上传失败');
  396. }
  397. }
  398. });
  399. }
  400. }
  401. uni.hideLoading();
  402. }
  403. });
  404. }
  405. }
  406. };
  407. </script>
  408. <style>
  409. page {
  410. /* height: 100%; */
  411. width: 100%;
  412. background: #f4f4f4;
  413. padding: 0 0 80rpx;
  414. }
  415. .container {
  416. padding: 0 30rpx;
  417. }
  418. .order-goods {
  419. margin-top: 30rpx;
  420. background: #fff;
  421. border-radius: 10rpx;
  422. width: 690rpx;
  423. padding: 30rpx 20rpx;
  424. }
  425. .order-goods .h {
  426. height: 30rpx;
  427. line-height: 30rpx;
  428. margin-bottom: 30rpx;
  429. font-size: 30rpx;
  430. color: #333;
  431. }
  432. .order-goods .h .label {
  433. float: left;
  434. font-size: 30rpx;
  435. color: #333;
  436. }
  437. .order-goods .h .status {
  438. float: right;
  439. font-size: 30rpx;
  440. color: #b4282d;
  441. }
  442. .order-goods .item {
  443. display: flex;
  444. align-items: center;
  445. height: 190rpx;
  446. }
  447. .order-goods .item:last-child {
  448. border-bottom: none;
  449. }
  450. .order-goods .item .img {
  451. height: 190rpx;
  452. width: 190rpx;
  453. background: #f4f4f4;
  454. margin-right: 20rpx;
  455. border-radius: 10rpx;
  456. }
  457. .order-goods .item .img image {
  458. height: 190rpx;
  459. border-radius: 10rpx;
  460. width: 190rpx;
  461. }
  462. .order-goods .item .info {
  463. flex: 1;
  464. height: 190rpx;
  465. }
  466. .order-goods .item .t {
  467. margin-top: 10rpx;
  468. /* height: 33rpx; */
  469. line-height: 34rpx;
  470. margin-bottom: 30rpx;
  471. display: flex;
  472. justify-content: space-between;
  473. }
  474. .order-goods .item .t .name {
  475. max-height: 68rpx;
  476. line-height: 34rpx;
  477. color: #333;
  478. font-size: 30rpx;
  479. width: 360rpx;
  480. margin-right: 40rpx;
  481. /* text-overflow: ellipsis;
  482. white-space: nowrap;*/
  483. overflow: hidden;
  484. }
  485. .order-goods .item .t .number {
  486. line-height: 36rpx;
  487. color: #666;
  488. font-size: 26rpx;
  489. }
  490. .order-goods .item .attr {
  491. height: 26rpx;
  492. line-height: 26rpx;
  493. color: #666;
  494. font-size: 26rpx;
  495. }
  496. .order-goods .item .price {
  497. height: 26rpx;
  498. line-height: 26rpx;
  499. color: #666;
  500. font-size: 26rpx;
  501. margin-top: 16rpx;
  502. }
  503. .module-title {
  504. height: 80rpx;
  505. padding: 0 8rpx;
  506. line-height: 80rpx;
  507. font-size: 30rpx;
  508. color: #333;
  509. border-bottom: 1rpx solid #efefef;
  510. }
  511. .tt-cell {
  512. display: flex;
  513. padding: 0 4rpx 0 8rpx;
  514. align-items: center;
  515. justify-content: space-between;
  516. background: #fff;
  517. height: 68rpx;
  518. /* border-bottom:2rpx solid #ebedf0; */
  519. }
  520. .tt-cell view {
  521. font-size: 30rpx;
  522. color: #333;
  523. }
  524. .tt-cell view:last-child {
  525. color: #999;
  526. font-size: 26rpx;
  527. }
  528. .tt-cell input {
  529. text-align: right;
  530. }
  531. .need {
  532. color: red;
  533. }
  534. .comment-wrapper {
  535. /* border-bottom:2rpx solid #ebedf0; */
  536. }
  537. .tt-cell.comment-cell {
  538. border: none;
  539. }
  540. .tt-cell.comment-cell view {
  541. padding-left: 14rpx;
  542. }
  543. .comment-tips {
  544. padding-left: 22rpx;
  545. height: 50rpx;
  546. line-height: 30rpx;
  547. color: #777;
  548. font-size: 20rpx;
  549. background: #fff;
  550. }
  551. .submit-btn {
  552. text-align: center;
  553. color: #fff;
  554. margin: 120rpx 0 60rpx;
  555. width: 690rpx;
  556. height: 100rpx;
  557. line-height: 100rpx;
  558. background: #00b9ff;
  559. border-radius: 100rpx;
  560. font-size: 30rpx;
  561. }
  562. .upload-text {
  563. height: 88rpx;
  564. line-height: 88rpx;
  565. padding-left: 22rpx;
  566. background: #fff;
  567. }
  568. .upload-wrapper {
  569. /* margin:18rpx -20rpx 56rpx 0; */
  570. display: flex;
  571. flex-wrap: wrap;
  572. background: #fff;
  573. padding: 0 24rpx 40rpx;
  574. }
  575. .upload {
  576. width: 160rpx;
  577. height: 160rpx;
  578. background: #fafafa;
  579. border-radius: 4rpx;
  580. border: 1rpx solid #d9d9d9;
  581. display: flex;
  582. align-items: center;
  583. flex-direction: column;
  584. justify-content: center;
  585. margin-right: 16rpx;
  586. box-sizing: border-box;
  587. }
  588. .upload image {
  589. width: 38rpx;
  590. height: 38rpx;
  591. margin-bottom: 22rpx;
  592. }
  593. .upload view {
  594. font-weight: 400;
  595. color: #c5c3c3;
  596. line-height: 48rpx;
  597. font-size: 26rpx;
  598. }
  599. .img-item {
  600. width: 160rpx;
  601. height: 160rpx;
  602. background: #fff;
  603. border-radius: 2rpx;
  604. border: 1rpx solid #d9d9d9;
  605. margin: 0 20rpx 24rpx 0;
  606. padding: 8rpx;
  607. position: relative;
  608. box-sizing: border-box;
  609. }
  610. .img-item .user-upload {
  611. width: 144rpx;
  612. height: 144rpx;
  613. }
  614. .img-item .close-img {
  615. width: 28rpx;
  616. height: 28rpx;
  617. position: absolute;
  618. top: 0;
  619. right: 0;
  620. }
  621. .refund-tips {
  622. color: #ee0a24;
  623. font-size: 22rpx;
  624. line-height: 40rpx;
  625. padding-left: 8rpx;
  626. margin: 4rpx 0 8rpx;
  627. }
  628. .card {
  629. background: #fff;
  630. border-radius: 10rpx;
  631. margin-top: 20rpx;
  632. padding: 0 20rpx 20rpx;
  633. }
  634. .tt-cell input {
  635. flex: 1;
  636. font-size: 26rpx;
  637. color: #666;
  638. }
  639. </style>