refundOrder.vue 12 KB

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