orderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <view class="container">
  3. <!-- 加载中 -->
  4. <view v-if="loading" class="loading-wrapper">
  5. <text>加载中...</text>
  6. </view>
  7. <!-- 订单详情 -->
  8. <view v-else-if="order">
  9. <!-- 订单状态 -->
  10. <view class="card status-card">
  11. <view class="status-left">
  12. <view class="status-icon-wrapper" :class="getStatusClass(order.status)">
  13. <text class="status-icon">✓</text>
  14. </view>
  15. <text class="status-text">{{ order.statusText || getStatusText(order.status) }}</text>
  16. </view>
  17. <text class="invoice-status">未开票</text>
  18. </view>
  19. <!-- 订单明细 -->
  20. <view class="card detail-card">
  21. <view class="card-header">
  22. <text class="card-title">订单明细</text>
  23. </view>
  24. <view v-for="(product, index) in order.products" :key="index" class="product-item">
  25. <view class="product-image">
  26. <image v-if="product.image" :src="product.image" mode="aspectFill" lazy-load></image>
  27. <view v-else class="image-placeholder"></view>
  28. </view>
  29. <view class="product-info">
  30. <text class="product-name">{{ product.name }}</text>
  31. <text class="product-price">销售单价 ¥{{ product.price.toFixed(2) }}</text>
  32. </view>
  33. <text class="product-quantity">x{{ product.quantity }}</text>
  34. </view>
  35. <view v-if="order.discountAmount && order.discountAmount > 0" class="amount-row discount-row">
  36. <text class="amount-label">优惠金额</text>
  37. <view class="amount-value-wrapper">
  38. <text class="amount-prefix">-¥</text>
  39. <text class="amount-discount">{{ order.discountAmount.toFixed(2) }}</text>
  40. </view>
  41. </view>
  42. <view class="amount-row">
  43. <text class="amount-label">实付款</text>
  44. <view class="amount-value-wrapper">
  45. <text class="amount-prefix">合计</text>
  46. <text class="amount-symbol">¥</text>
  47. <text class="amount-integer">{{ (order.paidAmount || order.totalAmount || 0).toFixed(2) }}</text>
  48. </view>
  49. </view>
  50. <!-- 退款历史记录 -->
  51. <view v-if="order.refunds && order.refunds.length > 0" class="refund-history">
  52. <view class="history-title">退款记录</view>
  53. <view v-for="(record, index) in order.refunds" :key="index" class="history-item">
  54. <view class="history-timeline">
  55. <view :class="['timeline-dot', record.status === 'REFUNDED' ? 'success' : record.status === 'REJECTED' ? 'rejected' : 'pending']"></view>
  56. <view v-if="index < order.refunds.length - 1" class="timeline-line"></view>
  57. </view>
  58. <view class="history-content">
  59. <view class="history-header">
  60. <text :class="['history-status', record.status === 'REFUNDED' ? 'success' : record.status === 'REJECTED' ? 'rejected' : 'pending']">
  61. {{ record.status === 'REFUNDED' ? '已退款' : record.status === 'REJECTED' ? '已拒绝' : '审核中' }}
  62. </text>
  63. <text class="history-amount">¥{{ (record.refundAmount || 0).toFixed(2) }}</text>
  64. </view>
  65. <view class="history-meta">
  66. <text class="history-time">{{ record.createTime }}</text>
  67. </view>
  68. <text v-if="record.reason" class="history-reason">原因:{{ record.reason }}</text>
  69. <text v-if="record.remark && record.status === 'REJECTED'" class="history-reject-reason">拒绝原因:{{ record.remark }}</text>
  70. <!-- 退款商品 -->
  71. <view v-if="record.items && record.items.length > 0" class="history-items">
  72. <view v-for="(item, i) in record.items" :key="i" class="history-item-row">
  73. <text class="item-name">{{ item.productName }}</text>
  74. <text class="item-meta">×{{ item.quantity }} ¥{{ (item.refundAmount || 0).toFixed(2) }}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="card-footer-actions">
  81. <button v-if="canRefund(order) && order.refundStatus !== 'PENDING'" class="action-btn-outline" @click="applyRefund">申请退款</button>
  82. </view>
  83. </view>
  84. <!-- 订单信息 -->
  85. <view class="card info-card">
  86. <view class="card-header">
  87. <text class="card-title">订单信息</text>
  88. </view>
  89. <view class="info-list">
  90. <view class="info-row" v-if="order.orderName">
  91. <text class="info-label">订单名称</text>
  92. <text class="info-value">{{ order.orderName }}</text>
  93. </view>
  94. <view class="info-row">
  95. <text class="info-label">订单编号</text>
  96. <view class="info-value-group">
  97. <text class="info-value">{{ order.orderNo }}</text>
  98. <view class="copy-btn" @click="copyText(order.orderNo)">
  99. <view class="copy-icon-box"></view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="info-row" v-if="order.hahaOrderNo">
  104. <text class="info-label">哈哈订单号</text>
  105. <view class="info-value-group">
  106. <text class="info-value">{{ order.hahaOrderNo }}</text>
  107. <view class="copy-btn" @click="copyText(order.hahaOrderNo)">
  108. <view class="copy-icon-box"></view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="info-row">
  113. <text class="info-label">下单时间</text>
  114. <text class="info-value">{{ formatTime(order.createTime) }}</text>
  115. </view>
  116. <view class="info-row" v-if="order.payTime">
  117. <text class="info-label">支付时间</text>
  118. <text class="info-value">{{ formatTime(order.payTime) }}</text>
  119. </view>
  120. <view class="info-row">
  121. <text class="info-label">支付方式</text>
  122. <text class="info-value">微信</text>
  123. </view>
  124. <view class="info-row" v-if="order.storeName">
  125. <text class="info-label">门店</text>
  126. <text class="info-value">{{ order.storeName }}</text>
  127. </view>
  128. <view class="info-row">
  129. <text class="info-label">设备编号</text>
  130. <text class="info-value">{{ order.deviceId }}</text>
  131. </view>
  132. <view class="info-row" v-if="order.confidence">
  133. <text class="info-label">AI识别置信度</text>
  134. <text class="info-value">{{ (order.confidence * 100).toFixed(1) }}%</text>
  135. </view>
  136. <view class="info-row" v-if="order.videoUrl">
  137. <text class="info-label">识别视频</text>
  138. <view class="info-link" @click="viewVideo(order.videoUrl)">
  139. <text class="link-text">查看视频</text>
  140. <text class="link-arrow">></text>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 联系客服 -->
  147. <view class="footer-note">
  148. <CustomerServiceButton
  149. mode="link"
  150. :title="'订单 ' + (order?.orderNo || '')"
  151. :path="'/pages/orderDetail/orderDetail?orderId=' + String(order?.id || '')"
  152. >
  153. <text>如有疑问,请联系客服</text>
  154. </CustomerServiceButton>
  155. </view>
  156. </view>
  157. </template>
  158. <script setup lang="ts">
  159. import { ref, onMounted } from 'vue';
  160. import { getOrderDetail } from '../../api/order';
  161. import type { OrderInfo } from '../../api/order';
  162. import { checkAuth } from '../../utils/auth';
  163. import { getStatusText, canRefund } from '../../utils/order';
  164. import { logger } from '../../utils/logger';
  165. const order = ref<OrderInfo | null>(null);
  166. const loading = ref(true);
  167. const orderId = ref<string | null>(null);
  168. const getStatusClass = (status: number) => {
  169. if (status === 1) return 'status-success';
  170. if (status === 0) return 'status-pending';
  171. if (status === 2) return 'status-cancelled';
  172. return '';
  173. };
  174. const formatTime = (time: string | undefined) => {
  175. if (!time) return '-';
  176. if (typeof time === 'string' && time.includes('-')) {
  177. return time.replace('T', ' ').substring(0, 19);
  178. }
  179. return time;
  180. };
  181. const loadOrderDetail = async () => {
  182. if (!orderId.value) {
  183. uni.showToast({ title: '订单ID不存在', icon: 'none' });
  184. return;
  185. }
  186. loading.value = true;
  187. try {
  188. uni.showLoading({ title: '加载中...' });
  189. const orderDetail = await getOrderDetail({ orderId: orderId.value });
  190. order.value = orderDetail;
  191. uni.hideLoading();
  192. } catch (error: any) {
  193. uni.hideLoading();
  194. logger.error('加载订单详情失败:', error);
  195. setTimeout(() => {
  196. uni.navigateBack();
  197. }, 1500);
  198. } finally {
  199. loading.value = false;
  200. }
  201. };
  202. onMounted(() => {
  203. if (!checkAuth()) {
  204. return;
  205. }
  206. const pages = getCurrentPages();
  207. const currentPage = pages[pages.length - 1] as any;
  208. const options = currentPage.options || {};
  209. if (options.orderId) {
  210. orderId.value = String(options.orderId);
  211. loadOrderDetail();
  212. } else {
  213. uni.showToast({ title: '订单ID不存在', icon: 'none' });
  214. setTimeout(() => {
  215. uni.navigateBack();
  216. }, 1500);
  217. }
  218. });
  219. const applyRefund = () => {
  220. if (!order.value) return;
  221. uni.navigateTo({
  222. url: '/pages/refund/refund?orderId=' + String(order.value.id)
  223. });
  224. };
  225. const copyText = (text: string) => {
  226. uni.setClipboardData({
  227. data: text,
  228. success: () => {
  229. uni.showToast({ title: '复制成功', icon: 'success' });
  230. }
  231. });
  232. };
  233. const viewVideo = (url: string) => {
  234. uni.showToast({ title: '视频播放功能开发中', icon: 'none' });
  235. };
  236. </script>
  237. <style scoped lang="scss">
  238. .container {
  239. min-height: 100vh;
  240. background: linear-gradient(180deg, $color-primary-bg 0%, $color-bg-secondary 30%);
  241. padding: 24rpx;
  242. box-sizing: border-box;
  243. }
  244. .loading-wrapper {
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. min-height: 400rpx;
  249. font-size: 28rpx;
  250. color: $color-text-secondary;
  251. }
  252. /* 通用卡片样式 */
  253. .card {
  254. background-color: $color-bg-primary;
  255. border-radius: $radius-lg;
  256. padding: 32rpx;
  257. margin-bottom: 24rpx;
  258. box-shadow: $shadow-md;
  259. }
  260. /* 订单状态卡片 */
  261. .status-card {
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. }
  266. .status-left {
  267. display: flex;
  268. align-items: center;
  269. }
  270. .status-icon-wrapper {
  271. width: 56rpx;
  272. height: 56rpx;
  273. border-radius: 50%;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. margin-right: 20rpx;
  278. &.status-success {
  279. background: linear-gradient(135deg, $color-success, #43A047);
  280. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);
  281. }
  282. &.status-pending {
  283. background: linear-gradient(135deg, $color-warning, #F57C00);
  284. box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.3);
  285. }
  286. &.status-cancelled {
  287. background: linear-gradient(135deg, $color-text-secondary, #9E9E9E);
  288. box-shadow: 0 4rpx 12rpx rgba(140, 140, 140, 0.3);
  289. }
  290. }
  291. .status-icon {
  292. color: #ffffff;
  293. font-size: 32rpx;
  294. font-weight: bold;
  295. }
  296. .status-text {
  297. font-size: 34rpx;
  298. color: $color-text-primary;
  299. font-weight: 700;
  300. }
  301. .invoice-status {
  302. font-size: 24rpx;
  303. color: $color-error;
  304. padding: 6rpx 16rpx;
  305. background: rgba(244, 67, 54, 0.06);
  306. border-radius: 12rpx;
  307. }
  308. /* 订单明细卡片 */
  309. .detail-card {
  310. padding: 0;
  311. overflow: hidden;
  312. }
  313. .card-header {
  314. padding: 32rpx;
  315. border-bottom: 1rpx solid $color-bg-secondary;
  316. }
  317. .card-title {
  318. font-size: 32rpx;
  319. font-weight: 700;
  320. color: $color-text-primary;
  321. }
  322. .product-item {
  323. display: flex;
  324. padding: 32rpx;
  325. align-items: flex-start;
  326. &:active {
  327. background: $color-bg-secondary;
  328. }
  329. }
  330. .product-image {
  331. width: 140rpx;
  332. height: 140rpx;
  333. background: $color-bg-tertiary;
  334. border-radius: $radius-md;
  335. margin-right: 24rpx;
  336. overflow: hidden;
  337. image {
  338. width: 100%;
  339. height: 100%;
  340. border-radius: $radius-md;
  341. }
  342. }
  343. .image-placeholder {
  344. width: 100%;
  345. height: 100%;
  346. background: $color-bg-tertiary;
  347. border-radius: $radius-md;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. }
  352. .product-info {
  353. flex: 1;
  354. }
  355. .product-name {
  356. font-size: 30rpx;
  357. color: $color-text-primary;
  358. font-weight: 600;
  359. margin-bottom: 16rpx;
  360. display: block;
  361. line-height: 1.5;
  362. }
  363. .product-price {
  364. font-size: 26rpx;
  365. color: $color-text-secondary;
  366. }
  367. .product-quantity {
  368. font-size: 26rpx;
  369. color: $color-text-tertiary;
  370. margin-top: 60rpx;
  371. font-weight: 500;
  372. }
  373. .amount-row {
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. padding: 32rpx;
  378. border-top: 1rpx solid $color-bg-secondary;
  379. background: $color-bg-primary;
  380. }
  381. .discount-row {
  382. background: rgba(76, 175, 80, 0.04);
  383. border-top: none;
  384. padding: 24rpx 32rpx;
  385. }
  386. .amount-label {
  387. font-size: 28rpx;
  388. color: $color-text-secondary;
  389. }
  390. .amount-value-wrapper {
  391. display: flex;
  392. align-items: baseline;
  393. }
  394. .amount-prefix {
  395. font-size: 26rpx;
  396. color: $color-text-secondary;
  397. margin-right: 10rpx;
  398. }
  399. .amount-symbol {
  400. font-size: 28rpx;
  401. color: $color-warning;
  402. font-weight: 700;
  403. }
  404. .amount-integer {
  405. font-size: 40rpx;
  406. color: $color-warning;
  407. font-weight: 800;
  408. }
  409. .amount-discount {
  410. font-size: 32rpx;
  411. color: $color-success;
  412. font-weight: 700;
  413. }
  414. .refund-notice {
  415. display: flex;
  416. align-items: center;
  417. gap: 12rpx;
  418. margin: 0 $spacing-lg $spacing-xs;
  419. padding: 20rpx $spacing-md;
  420. border-radius: $radius-md;
  421. font-size: 26rpx;
  422. line-height: 1.5;
  423. .notice-dot {
  424. width: 14rpx;
  425. height: 14rpx;
  426. border-radius: 50%;
  427. flex-shrink: 0;
  428. }
  429. .notice-amount {
  430. font-weight: 700;
  431. }
  432. &.pending {
  433. background-color: $color-primary-bg;
  434. color: $color-primary-dark;
  435. .notice-dot {
  436. background-color: $color-warning;
  437. animation: notice-dot-pulse 1.5s ease-in-out infinite;
  438. }
  439. }
  440. &.partial {
  441. background-color: #E3F2FD;
  442. color: #1565C0;
  443. .notice-dot {
  444. background-color: $color-info;
  445. }
  446. }
  447. &.full {
  448. background-color: #E8F5E9;
  449. color: #2E7D32;
  450. .notice-dot {
  451. background-color: $color-success;
  452. }
  453. }
  454. }
  455. @keyframes notice-dot-pulse {
  456. 0%, 100% { opacity: 1; }
  457. 50% { opacity: 0.4; }
  458. }
  459. .card-footer-actions {
  460. display: flex;
  461. justify-content: flex-end;
  462. padding: 24rpx 32rpx 32rpx;
  463. gap: 16rpx;
  464. }
  465. .action-btn-outline {
  466. background-color: $color-bg-primary;
  467. border: 2rpx solid $color-border;
  468. border-radius: $radius-xl;
  469. font-size: 26rpx;
  470. color: $color-text-secondary;
  471. margin: 0;
  472. padding: 16rpx 32rpx;
  473. line-height: 1;
  474. &::after {
  475. border: none;
  476. }
  477. &:active {
  478. transform: scale(0.95);
  479. background-color: $color-bg-secondary;
  480. }
  481. }
  482. /* 退款历史记录 */
  483. .refund-history {
  484. padding: 0 $spacing-lg;
  485. margin-bottom: $spacing-md;
  486. }
  487. .history-title {
  488. font-size: 28rpx;
  489. font-weight: 600;
  490. color: $color-text-primary;
  491. margin-bottom: $spacing-md;
  492. }
  493. .history-item {
  494. display: flex;
  495. gap: $spacing-md;
  496. &:last-child .timeline-line {
  497. display: none;
  498. }
  499. }
  500. .history-timeline {
  501. display: flex;
  502. flex-direction: column;
  503. align-items: center;
  504. width: 40rpx;
  505. flex-shrink: 0;
  506. }
  507. .timeline-dot {
  508. width: 16rpx;
  509. height: 16rpx;
  510. border-radius: 50%;
  511. margin-top: 6rpx;
  512. flex-shrink: 0;
  513. &.success { background-color: $color-success; }
  514. &.rejected { background-color: $color-error; }
  515. &.pending { background-color: $color-warning; }
  516. }
  517. .timeline-line {
  518. width: 2rpx;
  519. flex: 1;
  520. min-height: 30rpx;
  521. background-color: $color-border;
  522. margin: 8rpx 0;
  523. }
  524. .history-content {
  525. flex: 1;
  526. padding-bottom: $spacing-md;
  527. min-width: 0;
  528. }
  529. .history-header {
  530. display: flex;
  531. justify-content: space-between;
  532. align-items: center;
  533. margin-bottom: 6rpx;
  534. }
  535. .history-status {
  536. font-size: 26rpx;
  537. font-weight: 500;
  538. &.success { color: $color-success; }
  539. &.rejected { color: $color-error; }
  540. &.pending { color: $color-warning; }
  541. }
  542. .history-amount {
  543. font-size: 28rpx;
  544. font-weight: 700;
  545. color: $color-text-primary;
  546. }
  547. .history-meta {
  548. margin-bottom: 4rpx;
  549. }
  550. .history-time {
  551. font-size: 22rpx;
  552. color: $color-text-tertiary;
  553. }
  554. .history-reason {
  555. display: block;
  556. font-size: 24rpx;
  557. color: $color-text-secondary;
  558. margin-top: 6rpx;
  559. line-height: 1.5;
  560. }
  561. .history-reject-reason {
  562. display: block;
  563. font-size: 24rpx;
  564. color: $color-error;
  565. margin-top: 6rpx;
  566. line-height: 1.5;
  567. }
  568. .history-items {
  569. margin-top: 12rpx;
  570. padding: 16rpx;
  571. background-color: $color-bg-secondary;
  572. border-radius: $radius-sm;
  573. }
  574. .history-item-row {
  575. display: flex;
  576. justify-content: space-between;
  577. align-items: center;
  578. padding: 6rpx 0;
  579. .item-name {
  580. font-size: 24rpx;
  581. color: $color-text-primary;
  582. flex: 1;
  583. overflow: hidden;
  584. text-overflow: ellipsis;
  585. white-space: nowrap;
  586. }
  587. .item-meta {
  588. font-size: 24rpx;
  589. color: $color-text-secondary;
  590. flex-shrink: 0;
  591. margin-left: 16rpx;
  592. }
  593. }
  594. /* 订单信息卡片 */
  595. .info-card {
  596. padding: 0;
  597. }
  598. .info-list {
  599. padding: 10rpx 32rpx 32rpx;
  600. }
  601. .info-row {
  602. display: flex;
  603. justify-content: space-between;
  604. align-items: center;
  605. padding: 28rpx 0;
  606. border-bottom: 1rpx solid $color-bg-secondary;
  607. &:active {
  608. background: $color-bg-secondary;
  609. }
  610. &:last-child {
  611. border-bottom: none;
  612. }
  613. }
  614. .info-label {
  615. font-size: 28rpx;
  616. color: $color-text-secondary;
  617. }
  618. .info-value-group {
  619. display: flex;
  620. align-items: center;
  621. }
  622. .info-value {
  623. font-size: 28rpx;
  624. color: $color-text-primary;
  625. font-weight: 500;
  626. }
  627. .copy-btn {
  628. margin-left: 12rpx;
  629. padding: 8rpx;
  630. &:active {
  631. transform: scale(0.9);
  632. }
  633. }
  634. .copy-icon-box {
  635. width: 28rpx;
  636. height: 32rpx;
  637. border: 3rpx solid $color-text-secondary;
  638. position: relative;
  639. border-radius: 4rpx;
  640. &::after {
  641. content: '';
  642. position: absolute;
  643. width: 20rpx;
  644. height: 24rpx;
  645. border: 3rpx solid $color-text-secondary;
  646. background-color: $color-bg-primary;
  647. top: -8rpx;
  648. right: -8rpx;
  649. border-radius: 4rpx;
  650. }
  651. }
  652. .info-link {
  653. display: flex;
  654. align-items: center;
  655. &:active {
  656. opacity: 0.6;
  657. }
  658. }
  659. .link-text {
  660. font-size: 28rpx;
  661. color: $color-warning;
  662. font-weight: 600;
  663. margin-right: 6rpx;
  664. }
  665. .link-arrow {
  666. font-size: 28rpx;
  667. color: $color-primary-dark;
  668. }
  669. /* 底部提示 */
  670. .footer-note {
  671. text-align: center;
  672. padding: 60rpx 0 40rpx;
  673. text {
  674. font-size: 24rpx;
  675. color: $color-text-tertiary;
  676. }
  677. }
  678. </style>