OrderList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="order-list__box">
  3. <div class="tabs-content">
  4. <a-tabs v-model:activeKey="mainData.tabIndex" @change="changeTab">
  5. <a-tab-pane v-for="(item, index) in mainData.tabs" :key="index" :tab="item.name" />
  6. </a-tabs>
  7. </div>
  8. <div v-if="mainData.list.length > 0" class="list-container">
  9. <div v-for="(item, index) in mainData.list" :key="index">
  10. <div class="item" @click="toOrderDetail(item.orderId, item.orderRefundId)">
  11. <!-- 普通订单 -->
  12. <div v-if="tabCurrent != 'REFUND'">
  13. <div class="top">
  14. <div class="left">{{ item.orderId }}</div>
  15. <div class="right">{{ statusFilter(item) }}</div>
  16. </div>
  17. <div v-for="(goodsItem, goodsIndex) in item.orderDetails" :key="goodsIndex">
  18. <div class="goods" :class="'goods' + goodsIndex">
  19. <img :src="goodsItem.imgUrl" />
  20. <div class="main">
  21. <div class="left">
  22. <div class="name ellipsis-2">{{ goodsItem.goodsName }}</div>
  23. <div class="des">{{ goodsItem.goodsSpecValue }}</div>
  24. </div>
  25. <div class="right">
  26. <div class="price">¥{{ formatPriceText(goodsItem.price) }}</div>
  27. <div class="num">x{{ goodsItem.num }}</div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="total">
  33. <div class="left">{{ item.createTime }}</div>
  34. <div class="right">共{{ item.totalNum }}件 订单总额:<span>¥{{ formatPriceText(item.payAmount) }}</span></div>
  35. </div>
  36. </div>
  37. <!-- 售后订单 -->
  38. <div v-if="tabCurrent == 'REFUND'">
  39. <div class="top">
  40. <div class="left">{{ item.orderId }}</div>
  41. <div class="right">{{ statusFilter2(item.orderStatus) }}</div>
  42. </div>
  43. <!-- 拒绝申请 -->
  44. <div v-if="item.examineStatus === 'FAIL'">
  45. <div v-for="(goodsItem, goodsIndex) in item.orderDetails" :key="goodsIndex">
  46. <div class="goods" :class="'goods' + goodsIndex">
  47. <image :src="goodsItem.imgUrl" mode="aspectFill"></image>
  48. <div class="main">
  49. <div class="left">
  50. <div class="name ellipsis-2">{{ goodsItem.goodsName }}</div>
  51. <div class="des">{{ goodsItem.goodsSpecValue }}</div>
  52. </div>
  53. <div class="right">
  54. <div class="price">¥{{ formatPriceText(goodsItem.price) }}</div>
  55. <div class="num">x{{ goodsItem.refundNum }}</div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="total">
  61. <div class="left">{{ item.createTime }}</div>
  62. <div class="right">共{{ item.totalNum }}件 {{ item.orderStatus == 'NOPAY' ? '应付' : '实付' }}总额:<span>¥{{
  63. formatPriceText(item.payAmount) }}</span></div>
  64. </div>
  65. </div>
  66. <!-- 其他 -->
  67. <div v-else>
  68. <div v-for="(goodsItem, goodsIndex) in item.orderDetails" :key="goodsIndex">
  69. <div class="goods" :class="'goods' + goodsIndex" v-if="goodsItem.refund">
  70. <image :src="goodsItem.imgUrl" mode="aspectFill"></image>
  71. <div class="main">
  72. <div class="left">
  73. <div class="name ellipsis-2">{{ goodsItem.goodsName }}</div>
  74. <div class="des">{{ goodsItem.goodsSpecValue }}</div>
  75. </div>
  76. <div class="right">
  77. <div class="price">¥{{ formatPriceText(goodsItem.price) }}</div>
  78. <div class="num">x{{ goodsItem.refundNum }}</div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="total">
  84. <div class="left">{{ item.createTime }}</div>
  85. <div class="right">共{{ getRefundNum(item.orderDetails) }}件
  86. {{ item.orderStatus == 'OVER' ? '实退' : '应退' }}总额:<span>¥{{ formatPriceText(item.refundAmount)
  87. }}</span>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <div v-if="item.isShareOrder">
  93. <div class="btn-group btn-group2">
  94. <div class="tips">分销订单</div>
  95. <div class="btns">
  96. <div class="button gray">查看订单</div>
  97. </div>
  98. </div>
  99. </div>
  100. <div v-else>
  101. <!-- 按钮:待付款 -->
  102. <div class="btn-group btn-group2" v-if="item.orderStatus == 'NOPAY'">
  103. <div class="tips">请在30分钟内付款</div>
  104. <div class="btns">
  105. <div class="button red">立即付款</div>
  106. </div>
  107. </div>
  108. <!-- 按钮:待发货 -->
  109. <!-- <div class="btn-group" v-if="item.orderStatus == 'DFH'">
  110. </div> -->
  111. <!-- 按钮:待服务 -->
  112. <!-- <div class="btn-group" v-if="item.orderStatus == 'YFH'">
  113. </div> -->
  114. <!-- 按钮:待评价 -->
  115. <!-- <div class="btn-group" v-if="item.orderStatus == 'OVER' && tabCurrent != 'REFUND'">
  116. </div> -->
  117. <!-- 按钮:超时未支付 -->
  118. <div class="btn-group" v-if="item.orderStatus == 'TIMEOUT'">
  119. <div class="button gray">查看订单</div>
  120. </div>
  121. <!-- 按钮:售后中 -->
  122. <div class="btn-group" v-if="item.orderStatus == 'REFUND'">
  123. <div class="button gray">查看订单</div>
  124. </div>
  125. <!-- 按钮:售后中 待商家处理 -->
  126. <div class="btn-group" v-if="item.orderStatus == 'DSJCL'">
  127. <div class="button gray" @click="toReturnDetail(item.orderRefundId)">售后详情</div>
  128. </div>
  129. <!-- 按钮:售后中 待买家处理 -->
  130. <div class="btn-group" v-if="item.orderStatus == 'DMJCL'">
  131. <div class="button red" @click="toReturnDetail(item.orderRefundId)" v-if="item.examineStatus == 'OK'">
  132. 提交资料
  133. </div>
  134. <div class="button white" @click="toApplyReturn(item.orderId)" v-if="item.examineStatus == 'FAIL'">
  135. 重新申请
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. <a-flex v-if="mainData.total > mainData.list.length" align="center" justify="center">
  142. <a-button type="link" @click="handleLoadMore">点击查看更多订单</a-button>
  143. </a-flex>
  144. </div>
  145. <div v-else class="list-container">
  146. <a-empty />
  147. </div>
  148. </div>
  149. </template>
  150. <script setup lang="js">
  151. import { onMounted, reactive, computed } from 'vue';
  152. import { message, Modal } from 'ant-design-vue';
  153. import {
  154. cancelOrder,
  155. ackComplete,
  156. remindNotice,
  157. getMyOrderList
  158. } from '@/api/order';
  159. import { useUserStore } from '@/store/user';
  160. const props = defineProps({
  161. type: {
  162. type: String,
  163. default: ''
  164. }
  165. })
  166. const emits = defineEmits(['view-detail']);
  167. const userStore = useUserStore();
  168. const tabCurrent = computed(() => mainData.tabs[mainData.tabIndex].key);
  169. const mainData = reactive({
  170. tabs: [
  171. { key: '', name: '全部' },
  172. { key: 'NOPAY', name: '待付款' },
  173. { key: 'DQR', name: '待确认' },
  174. { key: 'DJH', name: '待拣货' },
  175. { key: 'JHZ', name: '拣货中' },
  176. { key: 'DFH', name: '待发货' },
  177. { key: 'DPS', name: '待配送' },
  178. { key: 'PSDQ', name: '配送待取' },
  179. { key: 'PSZ', name: '配送中' },
  180. { key: 'OVER', name: '已完成' },
  181. { key: 'CLOSE', name: '已关闭' }
  182. ],
  183. tabIndex: 0,
  184. list: [],
  185. pageNo: 1,
  186. total: 0,
  187. canRemindShipment: true
  188. })
  189. const statusFilter = item => {
  190. const statusMap = {
  191. DQR: '待确认',
  192. NOPAY: '待付款',
  193. DJH: '待拣货',
  194. JHZ: '拣货中',
  195. DFH: '待发货',
  196. DTK: '待退款',
  197. DPS: '待配送',
  198. PSZ: '配送中',
  199. OVER: '已完成',
  200. CLOSE: '已关闭',
  201. REFUND: '售后/退款',
  202. TIMEOUT: '超时未支付'
  203. }
  204. if (item.orderStatus == 'OVER' && item.commentService) {
  205. return '已完成'
  206. } else {
  207. return statusMap[item.orderStatus]
  208. }
  209. }
  210. const statusFilter2 = (val) => {
  211. const statusMap = {
  212. DSJCL: '待商家处理',
  213. DSJSH: '待商家收货',
  214. DMJCL: '待买家处理',
  215. OVER: '退款成功',
  216. CANCEL: '已取消'
  217. }
  218. return statusMap[val]
  219. }
  220. const getRefundNum = (orderDetails) => {
  221. let refundNum = 0
  222. orderDetails.forEach(item => {
  223. if (item.refund) {
  224. refundNum = refundNum + item.refundNum
  225. }
  226. })
  227. return refundNum
  228. }
  229. const changeTab = tabIndex => {
  230. mainData.tabIndex = tabIndex;
  231. resetParams();
  232. fetchOrderList();
  233. }
  234. const resetParams = () => {
  235. mainData.list = []
  236. mainData.pageNo = 1
  237. mainData.total = 0
  238. }
  239. const fetchOrderList = async () => {
  240. const orderStatus = mainData.tabs[mainData.tabIndex].key || ''
  241. const res = await getMyOrderList({
  242. pageNo: mainData.pageNo,
  243. pageSize: 10,
  244. orderStatus: orderStatus,
  245. userId: userStore.userInfo?.userId || ''
  246. })
  247. mainData.list = mainData.list.concat(res.data?.records || []);
  248. mainData.total = res.data?.total || 0;
  249. }
  250. const handleLoadMore = () => {
  251. mainData.pageNo += 1;
  252. fetchOrderList();
  253. }
  254. // 申请退款
  255. const toApplyReturn = (orderId) => {
  256. // url: '/packageMine/pages/order/return/apply?orderId=' + orderId
  257. }
  258. // 去订单详情
  259. const toOrderDetail = (orderId = '', orderRefundId = '') => {
  260. emits('view-detail', { orderId, orderRefundId })
  261. }
  262. // 去售后详情
  263. const toReturnDetail = (orderRefundId) => {
  264. // this.$navToPage({
  265. // url: '/packageMine/pages/order/return/detail?orderRefundId=' + orderRefundId
  266. // })
  267. }
  268. // 提醒发货
  269. const remindShipment = (orderId) => {
  270. mainData.canRemindShipment = false
  271. setTimeout(() => {
  272. mainData.canRemindShipment = true
  273. }, 3000)
  274. remindNotice({
  275. orderId: orderId,
  276. userId: userStore.userInfo?.userId || ''
  277. }).then(() => {
  278. message.success('提醒发货成功')
  279. })
  280. }
  281. // 取消订单
  282. const handleCancelOrder = orderId => {
  283. cancelOrder({
  284. orderId: orderId
  285. }).then(() => {
  286. resetParams()
  287. fetchOrderList()
  288. message.success('取消成功')
  289. })
  290. }
  291. // 服务完成
  292. const confirmReceipt = orderId => {
  293. Modal.confirm({
  294. title: '完成服务',
  295. content: '请确认是否已完成服务?',
  296. onOk() {
  297. ackComplete({
  298. orderId: orderId
  299. }).then(() => {
  300. message.success('完成服务成功')
  301. })
  302. }
  303. })
  304. }
  305. const formatPriceText = price => {
  306. if (!price) return '0.00'
  307. price = Number(price)
  308. return price.toFixed(2)
  309. }
  310. onMounted(() => {
  311. mainData.tabIndex = mainData.tabs.findIndex(item => item.key === props.type);
  312. if (mainData.tabIndex < 0) {
  313. mainData.tabIndex = 0;
  314. }
  315. fetchOrderList()
  316. })
  317. </script>
  318. <style lang="less" scoped>
  319. .order-list__box {
  320. .tab-container {
  321. background: #ffffff;
  322. }
  323. .list-container {
  324. .item {
  325. padding-bottom: 10px;
  326. border-bottom: 1px solid @border-color;
  327. .top {
  328. display: flex;
  329. justify-content: space-between;
  330. align-items: center;
  331. padding: 10px 0;
  332. .left {
  333. font-size: 14px;
  334. font-weight: 500;
  335. }
  336. .right {
  337. font-size: 14px;
  338. }
  339. }
  340. .goods {
  341. display: flex;
  342. justify-content: space-between;
  343. margin-top: 10px;
  344. img {
  345. width: 70px;
  346. height: 70px;
  347. object-fit: cover;
  348. }
  349. &.goods0 {
  350. margin-top: 0;
  351. }
  352. image {
  353. width: 70px;
  354. height: 70px;
  355. display: div;
  356. flex-shrink: 0;
  357. margin-right: 10px;
  358. }
  359. .main {
  360. margin-left: 10px;
  361. flex: 1;
  362. display: flex;
  363. justify-content: space-between;
  364. .left {
  365. .name {
  366. font-size: 14px;
  367. color: #333333;
  368. line-height: 18px;
  369. }
  370. .des {
  371. font-size: 14px;
  372. color: #999999;
  373. margin-top: 5px;
  374. }
  375. }
  376. .right {
  377. flex-shrink: 0;
  378. margin-left: 10px;
  379. text-align: right;
  380. .price {
  381. font-size: 14px;
  382. color: #333333;
  383. line-height: 14px;
  384. font-weight: 600;
  385. margin-top: 3;
  386. }
  387. .num {
  388. font-size: 14px;
  389. color: #999999;
  390. line-height: 14px;
  391. margin-top: 8px;
  392. }
  393. }
  394. }
  395. }
  396. .total {
  397. display: flex;
  398. justify-content: space-between;
  399. height: 25px;
  400. align-items: center;
  401. .left {
  402. font-size: 12px;
  403. color: #666666;
  404. }
  405. .right {
  406. font-size: 12;
  407. color: #666666;
  408. text {
  409. color: #ff577e;
  410. ;
  411. font-size: 16px;
  412. font-weight: 600;
  413. margin-left: 4px;
  414. }
  415. }
  416. }
  417. .btn-group {
  418. border-top: 1px solid #eaeaea;
  419. height: 50px;
  420. display: flex;
  421. justify-content: flex-end;
  422. align-items: center;
  423. &.btn-group2 {
  424. justify-content: space-between;
  425. .tips {
  426. font-size: 14px;
  427. color: #ff577e;
  428. }
  429. .btns {
  430. display: flex;
  431. }
  432. }
  433. .button {
  434. width: 70px;
  435. height: 24px;
  436. border-radius: 24px;
  437. text-align: center;
  438. line-height: 24px;
  439. font-size: 12px;
  440. margin-left: 10px;
  441. flex-shrink: 0;
  442. &:first-child {
  443. margin-left: 0;
  444. }
  445. &.gray {
  446. color: #999999;
  447. border: 1px solid #999999;
  448. }
  449. &.white {
  450. }
  451. &.red {
  452. }
  453. }
  454. }
  455. }
  456. }
  457. }
  458. </style>