OrderItem.vue 8.1 KB

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