OrderItem.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="card">
  3. <view class="card-header">
  4. <text class="waybill-number">运单号:{{ orderDetail.externalWaybillNo }}</text>
  5. <image src="/static/img/copy.png" @click="copyWaybillNumber"></image>
  6. </view>
  7. <view class="content">
  8. <!-- 左侧寄件人信息 -->
  9. <view class="sender-info">
  10. <view class="city-tag">{{ orderDetail.senderCity }}</view>
  11. <view class="name">{{ orderDetail.senderName }}</view>
  12. </view>
  13. <view class="translate">
  14. <view class="status">{{ getStatusText(orderDetail.orderStatus) }}</view>
  15. <image v-if="orderDetail.orderStatus == 5" src="/static/img/translte-1.png"></image>
  16. <image v-else src="/static/img/translte-2.png"></image>
  17. </view>
  18. <!-- 右侧收件人信息 -->
  19. <view class="receiver-info">
  20. <view class="city-tag">{{ orderDetail.receiverCity }}</view>
  21. <view class="name">{{ orderDetail.receiverName }}</view>
  22. </view>
  23. </view>
  24. <!-- 状态信息 -->
  25. <view class="section-continer" v-if="false">
  26. <view class="timeline">
  27. <view class="dot">
  28. <view class="timeline-dot dot-active"></view>
  29. </view>
  30. <view class="timeline-line line-active"></view>
  31. </view>
  32. <view class="status-section">
  33. <view class="status-badge status-collected">已代收</view>
  34. <view class="status-detail">
  35. 快件已投递至【北京海淀区北京大学菜鸟驿北京海淀区北京大学菜鸟驿北京海淀区北京大学菜鸟驿北京海淀区北京大学菜鸟驿】
  36. </view>
  37. <view class="status-time">2026-01-11 17:32:32</view>
  38. </view>
  39. </view>
  40. <!-- 操作按钮 -->
  41. <view class="action-buttons">
  42. <view v-if="orderDetail.orderStatus > 1 && orderDetail.orderStatus != 6" class="action-btn" @click="showExpressTrack">
  43. <text class="btn-text">物流轨迹</text>
  44. </view>
  45. <view class="action-btn" @click="showOrderInfo">
  46. <text class="btn-text">运单详情</text>
  47. </view>
  48. <view v-if="orderDetail.orderStatus == 1" @click="cancel" class="action-btn btn-cancel">
  49. <text class="btn-text">运单取消</text>
  50. </view>
  51. </view>
  52. <!-- 物流轨迹弹框 -->
  53. <TrackPopup v-model:showPopup="showTrackPopup" :expressData="expressData" />
  54. </view>
  55. </template>
  56. <script setup>
  57. import {
  58. ref,
  59. defineProps,
  60. defineEmits
  61. } from 'vue'
  62. import {
  63. cancelOrder
  64. } from '@/api/order.js'
  65. import TrackPopup from './TrackPopup.vue'
  66. const emit = defineEmits(['success'])
  67. const props = defineProps({
  68. isGrab: {
  69. type: Boolean,
  70. default: false
  71. },
  72. orderDetail: {
  73. type: Object,
  74. default: () => ({})
  75. }
  76. })
  77. // 控制弹框显示
  78. const showTrackPopup = ref(false)
  79. const expressData = ref({
  80. company: '顺丰速运',
  81. number: 'JDVA401410370033',
  82. status: '待取件'
  83. })
  84. // 显示物流轨迹弹框
  85. const showExpressTrack = () => {
  86. // 这里可以调用API获取物流信息
  87. // 暂时使用模拟数据
  88. showTrackPopup.value = true
  89. }
  90. const showOrderInfo = () => {
  91. uni.navigateTo({
  92. url: `/pages/order/order_detail?waybillId=${props.orderDetail.waybillId}`
  93. })
  94. }
  95. // 复制运单号
  96. const copyWaybillNumber = () => {
  97. uni.setClipboardData({
  98. data: props.orderDetail.externalWaybillNo,
  99. success: () => {
  100. uni.showToast({
  101. title: '运单号已复制',
  102. icon: 'success'
  103. })
  104. }
  105. })
  106. }
  107. // 取消订单
  108. const cancel = async () => {
  109. let res = await cancelOrder({
  110. waybillId: props.orderDetail.waybillId,
  111. cancelReason: "取消",
  112. externalWaybillNo: props.orderDetail.externalWaybillNo,
  113. orderType: props.orderDetail.orderType,
  114. productCode: props.orderDetail.productCode,
  115. waybillNo: props.orderDetail.waybillNo,
  116. })
  117. if (res.code == 200) {
  118. uni.showToast({
  119. title: res.msg,
  120. icon: 'success'
  121. })
  122. emit('success')
  123. }
  124. }
  125. // 获取订单状态
  126. const getStatusText = (orderStatus) => {
  127. let txt = ''
  128. switch (orderStatus) {
  129. case 1:
  130. txt = '待揽件'
  131. break;
  132. case 2:
  133. txt = '已揽件'
  134. break;
  135. case 3:
  136. txt = '运输中'
  137. break;
  138. case 4:
  139. txt = '派送中'
  140. break;
  141. case 5:
  142. txt = '已签收'
  143. break;
  144. case 6:
  145. txt = '已取消'
  146. break;
  147. default:
  148. break;
  149. }
  150. return txt;
  151. }
  152. </script>
  153. <style scoped lang="less">
  154. .card {
  155. background-color: #fff;
  156. border-radius: 32rpx;
  157. margin-bottom: 20rpx;
  158. padding: 20rpx;
  159. .card-header {
  160. height: 45rpx;
  161. margin-bottom: 20rpx;
  162. display: flex;
  163. align-items: center;
  164. .waybill-number {
  165. height: 100%;
  166. line-height: 45rpx;
  167. font-size: 28rpx;
  168. color: #333;
  169. font-weight: 500;
  170. }
  171. image {
  172. width: 50rpx;
  173. height: 50rpx;
  174. padding: 10rpx;
  175. margin-left: 8rpx;
  176. flex-shrink: 0;
  177. }
  178. }
  179. .content {
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. margin-bottom: 20rpx;
  184. .sender-info,
  185. .receiver-info {
  186. flex: 1;
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. min-width: 0;
  191. /* 防止flex子元素溢出 */
  192. .city-tag {
  193. max-width: 250rpx;
  194. height: 52rpx;
  195. font-size: 36rpx;
  196. color: #333333;
  197. line-height: 52rpx;
  198. font-weight: bold;
  199. overflow: hidden;
  200. text-overflow: ellipsis;
  201. white-space: nowrap;
  202. }
  203. .name {
  204. max-width: 250rpx;
  205. height: 44rpx;
  206. font-weight: 400;
  207. font-size: 28rpx;
  208. color: #333333;
  209. line-height: 44rpx;
  210. margin-top: 8rpx;
  211. overflow: hidden;
  212. text-overflow: ellipsis;
  213. white-space: nowrap;
  214. }
  215. }
  216. .translate {
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. justify-content: center;
  221. width: 160rpx;
  222. flex-shrink: 0;
  223. .status {
  224. height: 44rpx;
  225. font-weight: 400;
  226. font-size: 28rpx;
  227. color: #333333;
  228. line-height: 44rpx;
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. white-space: nowrap;
  232. max-width: 100%;
  233. }
  234. image {
  235. height: 28rpx;
  236. width: 160rpx;
  237. margin-top: 8rpx;
  238. flex-shrink: 0;
  239. }
  240. }
  241. }
  242. .section-continer {
  243. display: flex;
  244. background-color: #F5F7FA;
  245. border-radius: 16rpx;
  246. padding: 20rpx;
  247. margin-bottom: 20rpx;
  248. .timeline {
  249. display: flex;
  250. flex-direction: column;
  251. align-items: center;
  252. width: 34rpx;
  253. margin-right: 20rpx;
  254. flex-shrink: 0;
  255. .dot {
  256. width: 34rpx;
  257. height: 34rpx;
  258. border-radius: 50%;
  259. background-color: #C1D5FF;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. flex-shrink: 0;
  264. }
  265. .timeline-dot {
  266. width: 18rpx;
  267. height: 18rpx;
  268. border-radius: 50%;
  269. &.dot-active {
  270. background-color: #1B64F0;
  271. }
  272. }
  273. .timeline-line {
  274. flex: 1;
  275. width: 4rpx;
  276. box-sizing: border-box;
  277. margin-top: 10rpx;
  278. &.line-active {
  279. border-left: 4rpx dashed #1B64F0;
  280. }
  281. }
  282. }
  283. .status-section {
  284. flex: 1;
  285. min-width: 0;
  286. .status-badge {
  287. margin-bottom: 8rpx;
  288. height: 48rpx;
  289. font-weight: 400;
  290. font-size: 32rpx;
  291. color: #333333;
  292. line-height: 48rpx;
  293. overflow: hidden;
  294. text-overflow: ellipsis;
  295. white-space: nowrap;
  296. }
  297. .status-detail {
  298. font-weight: 400;
  299. font-size: 28rpx;
  300. color: #333333;
  301. line-height: 44rpx;
  302. margin-top: 8rpx;
  303. overflow: hidden;
  304. text-overflow: ellipsis;
  305. white-space: nowrap;
  306. }
  307. .status-time {
  308. margin-top: 8rpx;
  309. height: 40rpx;
  310. font-weight: 400;
  311. font-size: 24rpx;
  312. color: #999999;
  313. line-height: 40rpx;
  314. overflow: hidden;
  315. text-overflow: ellipsis;
  316. white-space: nowrap;
  317. }
  318. }
  319. }
  320. .action-buttons {
  321. margin-top: 20rpx;
  322. display: flex;
  323. justify-content: flex-end;
  324. .action-btn {
  325. display: flex;
  326. justify-content: center;
  327. align-items: center;
  328. width: 160rpx;
  329. height: 60rpx;
  330. border-radius: 80rpx;
  331. border: 2rpx solid #F1F3F8;
  332. margin-left: 20rpx;
  333. &:first-child {
  334. margin-left: 0;
  335. }
  336. &:last-child {
  337. margin-right: 0;
  338. }
  339. .btn-text {
  340. font-size: 28rpx;
  341. color: #333;
  342. overflow: hidden;
  343. text-overflow: ellipsis;
  344. white-space: nowrap;
  345. }
  346. &.btn-cancel {
  347. background-color: #fff5f5;
  348. .btn-text {
  349. color: #ff6b6b;
  350. }
  351. }
  352. /* 添加点击效果 */
  353. &:active {
  354. opacity: 0.7;
  355. }
  356. }
  357. }
  358. }
  359. </style>