OrderItem.vue 8.4 KB

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