refundOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <!-- 药品列表 -->
  5. <view class="drug-list">
  6. <view class="item">
  7. <!-- 药品信息 -->
  8. <!-- <view v-if="order!=null&&order.isPackage!=1" class="drug-info" v-for="(item,index) in items" :key="index"> -->
  9. <view class="drug-info" v-for="(item,index) in items" :key="index">
  10. <view class="img-box">
  11. <image :src="JSON.parse(item.jsonInfo).image" mode="aspectFit"></image>
  12. </view>
  13. <view class="info">
  14. <view class="top">
  15. <view class="title ellipsis2">{{ JSON.parse(item.jsonInfo).productName}}</view>
  16. <view class="spec">{{JSON.parse(item.jsonInfo).sku}}</view>
  17. </view>
  18. <view class="price-num">
  19. <view class="price-box">
  20. <text class="unit">¥</text>
  21. <text class="price">{{JSON.parse(item.jsonInfo).price.toFixed(2)}}</text>
  22. </view>
  23. <view class="num">x{{item.num}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="order!=null&&order.isPackage==1&&packageJson!=null" class="drug-info">
  28. <view class="img-box">
  29. <image :src="packageJson.imgUrl" mode="aspectFit"></image>
  30. </view>
  31. <view class="info">
  32. <view class="top">
  33. <view class="title ellipsis2">
  34. <view class="tag">套餐</view>{{packageJson.title}}
  35. </view>
  36. <view class="spec">{{packageJson.descs}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 申请原因 -->
  43. <view class="reason-apply">
  44. <view class="title-box">
  45. <text class="label">退款金额</text>
  46. <input class="money" type="text" disabled v-model="refundAmount" placeholder="退款金额"
  47. placeholder-class="form-input" />
  48. </view>
  49. <view class="title-box">
  50. <text class="label">申请原因</text>
  51. <picker @change="reasonsChange" :value="reasons" range-key="dictLabel" :range="reasonsList">
  52. <view class="chose-box">
  53. <text class="text">{{reasons}}</text>
  54. <image src="https://kntobs.jnmyunl.com/shop/images/arrow_gray.png" mode=""></image>
  55. </view>
  56. </picker>
  57. </view>
  58. <view class="textarea-box">
  59. <textarea v-model="explains" placeholder="请描述申请售后服务的具体原因" placeholder-class="textarea-place" />
  60. </view>
  61. </view>
  62. <!-- 退回方式 -->
  63. <!-- <view class="return-method">
  64. <view class="title-box">
  65. <text class="text">退货方式</text>
  66. <text class="text">用户发货</text>
  67. </view>
  68. <view class="return-tips">
  69. <text class="text">请您在审核通过后7天内,将商品发货到指定点</text>
  70. </view>
  71. <view class="info-item">
  72. <text class="label">联系人</text>
  73. <text class="text">张三 1572325612</text>
  74. </view>
  75. <view class="info-item">
  76. <text class="label">发货地址</text>
  77. <text class="text">重庆市江北区建玛特商场5楼</text>
  78. </view>
  79. </view> -->
  80. <!-- 底部按钮 -->
  81. <view class="btn-box">
  82. <view class="sub-btn" @click="submit()">申请售后</view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. applyAfterSales,
  90. getMyStoreOrderItemByOrderId
  91. } from '@/api/storeAfterSales'
  92. export default {
  93. data() {
  94. return {
  95. packageJson:null,
  96. orderId: null,
  97. order: null,
  98. orderCode: null,
  99. items: [],
  100. type: null,
  101. reasonsList: [],
  102. reasons: "请选择",
  103. explains: "",
  104. orderitems: null
  105. // refundAmount:0.00,
  106. }
  107. },
  108. onLoad(option) {
  109. console.log(option);
  110. this.type = option.type;
  111. this.orderCode = option.orderCode;
  112. this.items = uni.getStorageSync('refundItems')
  113. const isPackage = option.isPackage || 0
  114. this.reasonsList = this.utils.getDict("storeAfterSalesReasons");
  115. this.orderId = option.orderId;
  116. if (isPackage == 1) {
  117. this.getMyStoreOrderItemByOrderId()
  118. }
  119. },
  120. computed: {
  121. refundAmount() {
  122. if(this.order&&this.order.isPackage ==1) {
  123. // return this.order.payMoney.toFixed(2)
  124. if (this.order.isPayRemain == 0) {
  125. return this.order.payMoney.toFixed(2)
  126. } else {
  127. return this.order.payPrice.toFixed(2)
  128. }
  129. } else {
  130. const counts = this.items.map(item => {
  131. return {
  132. ...item,
  133. price: JSON.parse(item.jsonInfo).price * item.num
  134. }
  135. });
  136. const count = counts.reduce((accumulator, item) => accumulator + item.price, 0);
  137. return count
  138. }
  139. }
  140. },
  141. methods: {
  142. getMyStoreOrderItemByOrderId() {
  143. var data = {
  144. orderId: this.orderId
  145. };
  146. getMyStoreOrderItemByOrderId(data).then(res => {
  147. if (res.code == 200) {
  148. this.order = res.order;
  149. this.orderitems = res.items
  150. this.packageJson = this.order&&this.order.isPackage ==1 ? JSON.parse(this.order.packageJson): null
  151. } else {
  152. uni.showToast({
  153. icon: 'none',
  154. title: "请求失败",
  155. });
  156. }
  157. });
  158. },
  159. reasonsChange(e) {
  160. console.log(e.detail.value)
  161. this.reasons = this.reasonsList[e.detail.value].dictLabel
  162. },
  163. submit() {
  164. if (this.reasons == "请选择") {
  165. uni.showToast({
  166. icon: 'none',
  167. title: '请选择原因'
  168. });
  169. return;
  170. }
  171. if (this.refundAmount < 0) {
  172. uni.showToast({
  173. icon: 'none',
  174. title: '请输入退款金额'
  175. });
  176. return;
  177. }
  178. const items = this.order&&this.order.isPackage ==1 ? this.orderitems : this.items
  179. var productIds = items.map(item => item.productId);
  180. var nums = items.map(item => item.num);
  181. var products = [];
  182. for (var i = 0; i < productIds.length; i++) {
  183. var item = {
  184. productId: productIds[i],
  185. num: nums[i]
  186. };
  187. products.push(item);
  188. }
  189. var data = {
  190. refundAmount: this.refundAmount,
  191. orderCode: this.orderCode,
  192. serviceType: this.type,
  193. reasons: this.reasons,
  194. explains: this.explains,
  195. productList: products
  196. };
  197. applyAfterSales(data).then(res => {
  198. if (res.code == 200) {
  199. uni.showToast({
  200. icon: 'success',
  201. title: '提交成功'
  202. });
  203. setTimeout(function() {
  204. uni.$emit('refreshOrder');
  205. uni.navigateBack({
  206. delta: 1
  207. })
  208. }, 500);
  209. } else {
  210. uni.showToast({
  211. icon: 'none',
  212. title: res.msg
  213. });
  214. }
  215. });
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .content {
  222. margin-bottom: 170upx;
  223. .inner {
  224. padding: 20upx;
  225. .drug-list {
  226. .item {
  227. background: #FFFFFF;
  228. border-radius: 16upx;
  229. margin-bottom: 20upx;
  230. padding: 0 30upx;
  231. .drug-info {
  232. display: flex;
  233. align-items: center;
  234. padding: 30upx 0;
  235. .img-box {
  236. width: 160upx;
  237. height: 160upx;
  238. margin-right: 30upx;
  239. image {
  240. width: 100%;
  241. height: 100%;
  242. }
  243. }
  244. .info {
  245. width: calc(100% - 160upx);
  246. height: 160upx;
  247. display: flex;
  248. flex-direction: column;
  249. justify-content: space-between;
  250. .top {
  251. .title {
  252. font-size: 28upx;
  253. font-family: PingFang SC;
  254. font-weight: 500;
  255. color: #111111;
  256. line-height: 1.4;
  257. .tag {
  258. display: inline-block;
  259. padding: 0 6upx;
  260. height: 30upx;
  261. background: linear-gradient(90deg, #66b2ef 0%, #2BC7B9 100%);
  262. border-radius: 4upx;
  263. margin-right: 10upx;
  264. font-size: 22upx;
  265. font-family: PingFang SC;
  266. font-weight: bold;
  267. color: #FFFFFF;
  268. line-height: 30upx;
  269. float: left;
  270. margin-top: 7upx;
  271. }
  272. }
  273. .spec {
  274. font-size: 24upx;
  275. font-family: PingFang SC;
  276. font-weight: 500;
  277. color: #999999;
  278. line-height: 1;
  279. margin-top: 14upx;
  280. }
  281. }
  282. .price-num {
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. .price-box {
  287. display: flex;
  288. align-items: flex-end;
  289. .unit {
  290. font-size: 24upx;
  291. font-family: PingFang SC;
  292. font-weight: 500;
  293. color: #111111;
  294. line-height: 1.2;
  295. margin-right: 5upx;
  296. }
  297. .price {
  298. font-size: 32upx;
  299. font-family: PingFang SC;
  300. font-weight: 500;
  301. color: #111111;
  302. line-height: 1;
  303. }
  304. }
  305. .num {
  306. font-size: 24upx;
  307. font-family: PingFang SC;
  308. font-weight: bold;
  309. color: #666666;
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. .reason-apply {
  317. margin-top: 20upx;
  318. background: #FFFFFF;
  319. border-radius: 16upx;
  320. padding: 0 30upx;
  321. .title-box {
  322. height: 86upx;
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. border-bottom: 1px solid #F0F0F0;
  327. .label {
  328. font-size: 30upx;
  329. font-family: PingFang SC;
  330. font-weight: bold;
  331. color: #333333;
  332. }
  333. .money {
  334. font-size: 24upx;
  335. font-family: PingFang SC;
  336. font-weight: 500;
  337. color: #999999;
  338. }
  339. .chose-box {
  340. display: flex;
  341. align-items: center;
  342. .text {
  343. font-size: 24upx;
  344. font-family: PingFang SC;
  345. font-weight: 500;
  346. color: #999999;
  347. }
  348. image {
  349. width: 14upx;
  350. height: 24upx;
  351. margin-left: 10upx;
  352. }
  353. }
  354. }
  355. .textarea-box {
  356. padding: 30upx 0;
  357. textarea {
  358. width: 100%;
  359. box-sizing: border-box;
  360. background: #F5F5F5;
  361. border-radius: 16upx;
  362. padding: 30upx 20upx;
  363. font-size: 24upx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #111111;
  367. }
  368. .textarea-place {
  369. font-size: 24upx;
  370. font-family: PingFang SC;
  371. font-weight: 500;
  372. color: #999999;
  373. }
  374. }
  375. }
  376. .return-method {
  377. background: #FFFFFF;
  378. border-radius: 16upx;
  379. margin-top: 20upx;
  380. padding: 0 30upx 40upx;
  381. .title-box {
  382. height: 86upx;
  383. display: flex;
  384. align-items: center;
  385. justify-content: space-between;
  386. border-bottom: 1px solid #F0F0F0;
  387. .text {
  388. font-size: 30upx;
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. color: #333333;
  392. }
  393. }
  394. .return-tips {
  395. margin-top: 30upx;
  396. margin-bottom: 30upx;
  397. height: 80upx;
  398. background: #FFF4E6;
  399. border-radius: 16upx;
  400. padding: 0 20upx;
  401. display: flex;
  402. align-items: center;
  403. .text {
  404. font-size: 24upx;
  405. font-family: PingFang SC;
  406. font-weight: 500;
  407. color: #EF8A07;
  408. }
  409. }
  410. .info-item {
  411. display: flex;
  412. align-items: center;
  413. justify-content: space-between;
  414. margin-bottom: 40upx;
  415. &:last-child {
  416. margin-bottom: 0;
  417. }
  418. .label {
  419. font-size: 26upx;
  420. font-family: PingFang SC;
  421. font-weight: 500;
  422. color: #666666;
  423. line-height: 1;
  424. }
  425. .text {
  426. font-size: 26upx;
  427. font-family: PingFang SC;
  428. font-weight: 500;
  429. color: #111111;
  430. line-height: 1;
  431. }
  432. .detail-box {
  433. display: flex;
  434. align-items: center;
  435. .price-box {
  436. display: flex;
  437. align-items: flex-end;
  438. margin-right: 18upx;
  439. .unit {
  440. font-size: 24upx;
  441. font-family: PingFang SC;
  442. font-weight: 500;
  443. color: #111111;
  444. line-height: 1.2;
  445. }
  446. .num {
  447. font-size: 32upx;
  448. font-family: PingFang SC;
  449. font-weight: bold;
  450. color: #111111;
  451. line-height: 1;
  452. }
  453. }
  454. .det-text {
  455. font-size: 26upx;
  456. font-family: PingFang SC;
  457. font-weight: 500;
  458. color: #111111;
  459. }
  460. image {
  461. width: 14upx;
  462. height: 24upx;
  463. margin-left: 10upx;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. .reson-box {
  470. padding: 0 10upx 60upx;
  471. .reson-item {
  472. width: 100%;
  473. height: 110upx;
  474. display: flex;
  475. align-items: center;
  476. justify-content: space-between;
  477. .title {
  478. font-size: 30upx;
  479. font-family: PingFang SC;
  480. font-weight: 500;
  481. color: #111111;
  482. }
  483. }
  484. }
  485. }
  486. .btn-box {
  487. height: 120upx;
  488. padding: 0 30upx;
  489. display: flex;
  490. align-items: center;
  491. justify-content: center;
  492. .sub-btn {
  493. width: 100%;
  494. height: 88upx;
  495. line-height: 88upx;
  496. text-align: center;
  497. font-size: 30upx;
  498. font-family: PingFang SC;
  499. font-weight: bold;
  500. color: #FFFFFF;
  501. background: #2BC7B9;
  502. border-radius: 44upx;
  503. }
  504. }
  505. input {
  506. text-align: right;
  507. }
  508. .form-input {
  509. font-size: 30upx;
  510. font-family: PingFang SC;
  511. font-weight: 500;
  512. color: #999999;
  513. text-align: right;
  514. }
  515. </style>