detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <!-- 导航栏 -->
  5. <Navbar fixed leftIconColor="var(--black)" title="店铺订单详情"> </Navbar>
  6. <!-- 订单状态 -->
  7. <view class="status-section">
  8. <view class="status-icon">
  9. <i class="icon-font" :class="getStatusIcon(orderDetail.status)"></i>
  10. </view>
  11. <view class="status-info">
  12. <view class="status-text">{{
  13. getStatusText(orderDetail.status)
  14. }}</view>
  15. <view class="status-desc">{{
  16. getStatusDesc(orderDetail.status)
  17. }}</view>
  18. </view>
  19. </view>
  20. <!-- 收货信息 -->
  21. <view class="address-section" v-if="orderDetail.address">
  22. <view class="section-header">
  23. <i class="icon-font icon-location"></i>
  24. <text>收货信息</text>
  25. </view>
  26. <view class="address-info">
  27. <view class="receiver">
  28. <text class="name">{{ orderDetail.address.name }}</text>
  29. <text class="phone">{{ orderDetail.address.phone }}</text>
  30. </view>
  31. <view class="address">{{ orderDetail.address.address }}</view>
  32. </view>
  33. </view>
  34. <!-- Tab导航 -->
  35. <view class="tab-section">
  36. <Tab :active="activeTab" :tabList="tabList" @confirm="onTabChange" />
  37. </view>
  38. <!-- 商品信息 -->
  39. <view class="products-section" v-if="activeTab === 0">
  40. <view class="section-header">
  41. <i class="icon-font icon-goods"></i>
  42. <text>商品信息</text>
  43. </view>
  44. <view class="product-list">
  45. <view
  46. v-for="(product, index) in orderDetail.goods"
  47. :key="index"
  48. class="product-item"
  49. >
  50. <view class="product-image">
  51. <image :src="product.image" mode="aspectFill" />
  52. </view>
  53. <view class="product-info">
  54. <view class="product-name">{{ product.name }}</view>
  55. <view class="product-spec" v-if="product.spec">{{
  56. product.spec
  57. }}</view>
  58. <view class="product-price">
  59. <text class="price">{{ formatCurrency(product.price) }}</text>
  60. <text class="quantity">x{{ product.quantity }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 订单信息 -->
  67. <view class="order-info-section">
  68. <view class="section-header">
  69. <i class="icon-font icon-order"></i>
  70. <text>订单信息</text>
  71. </view>
  72. <view class="info-list">
  73. <view class="info-item">
  74. <text class="label">订单号</text>
  75. <text class="value">{{ orderDetail.orderNo }}</text>
  76. </view>
  77. <view class="info-item">
  78. <text class="label">下单时间</text>
  79. <text class="value">{{ formatTime(orderDetail.createTime) }}</text>
  80. </view>
  81. <view class="info-item" v-if="orderDetail.payTime">
  82. <text class="label">支付时间</text>
  83. <text class="value">{{ formatTime(orderDetail.payTime) }}</text>
  84. </view>
  85. <view class="info-item" v-if="orderDetail.shipTime">
  86. <text class="label">发货时间</text>
  87. <text class="value">{{ formatTime(orderDetail.shipTime) }}</text>
  88. </view>
  89. <view class="info-item" v-if="orderDetail.completeTime">
  90. <text class="label">完成时间</text>
  91. <text class="value">{{
  92. formatTime(orderDetail.completeTime)
  93. }}</text>
  94. </view>
  95. <view class="info-item" v-if="orderDetail.remark">
  96. <text class="label">备注</text>
  97. <text class="value">{{ orderDetail.remark }}</text>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 金额明细 -->
  102. <view class="amount-section">
  103. <view class="section-header">
  104. <i class="icon-font icon-money"></i>
  105. <text>金额明细</text>
  106. </view>
  107. <view class="amount-list">
  108. <view class="amount-item">
  109. <text class="label">商品金额</text>
  110. <text class="value">{{ formatCurrency(orderDetail.goodsAmount) }}</text>
  111. </view>
  112. <view class="amount-item" v-if="orderDetail.shippingFee > 0">
  113. <text class="label">运费</text>
  114. <text class="value">{{ formatCurrency(orderDetail.shippingFee) }}</text>
  115. </view>
  116. <view class="amount-item" v-if="orderDetail.discountAmount > 0">
  117. <text class="label">优惠金额</text>
  118. <text class="value discount"
  119. >-{{ formatCurrency(orderDetail.discountAmount) }}</text
  120. >
  121. </view>
  122. <view class="amount-item total">
  123. <text class="label">实付金额</text>
  124. <text class="value">{{ formatCurrency(orderDetail.totalAmount) }}</text>
  125. </view>
  126. </view>
  127. </view>
  128. <!-- 物流信息 -->
  129. <view class="logistics-section" v-if="orderDetail.logistics">
  130. <view class="section-header">
  131. <i class="icon-font icon-truck"></i>
  132. <text>物流信息</text>
  133. </view>
  134. <view class="logistics-info">
  135. <view class="logistics-item">
  136. <text class="label">快递公司</text>
  137. <text class="value">{{ orderDetail.logistics.company }}</text>
  138. </view>
  139. <view class="logistics-item">
  140. <text class="label">快递单号</text>
  141. <text class="value">{{
  142. orderDetail.logistics.trackingNumber
  143. }}</text>
  144. </view>
  145. <view class="logistics-item" v-if="orderDetail.logistics.status">
  146. <text class="label">物流状态</text>
  147. <text class="value">{{ orderDetail.logistics.status }}</text>
  148. </view>
  149. </view>
  150. </view>
  151. <!-- 操作按钮 -->
  152. <!-- <view class="action-section" v-if="getActionButtons(orderDetail.status).length > 0">
  153. <view
  154. v-for="action in getActionButtons(orderDetail.status)"
  155. :key="action.type"
  156. class="action-btn"
  157. :class="action.class"
  158. @click="handleAction(action.type)"
  159. >
  160. {{ action.text }}
  161. </view>
  162. </view> -->
  163. </view>
  164. </Theme>
  165. </template>
  166. <script setup>
  167. import { ref, onMounted } from "vue";
  168. import Navbar from "@/components/navbar";
  169. import Tab from "@/components/tabs";
  170. import { t } from "@/locale";
  171. import { onLoad } from "@dcloudio/uni-app";
  172. import { Toast, formatCurrency } from "@/utils";
  173. import { SELLER_SELLER_DETAIL } from "@/api";
  174. // 订单详情数据
  175. const orderDetail = ref({});
  176. // Tab相关
  177. const tabList = ref(["商品信息", "订单详情"]);
  178. const activeTab = ref(0);
  179. // Tab切换
  180. const onTabChange = (index) => {
  181. activeTab.value = index;
  182. };
  183. // 获取订单详情
  184. const getOrderDetail = async (orderId) => {
  185. try {
  186. const res = await SELLER_SELLER_DETAIL(orderId);
  187. orderDetail.value = res.data;
  188. } catch (error) {
  189. Toast(error.msg);
  190. }
  191. };
  192. // 格式化时间
  193. const formatTime = (timestamp) => {
  194. if (!timestamp) return "";
  195. const date = new Date(timestamp);
  196. const year = date.getFullYear();
  197. const month = String(date.getMonth() + 1).padStart(2, "0");
  198. const day = String(date.getDate()).padStart(2, "0");
  199. const hours = String(date.getHours()).padStart(2, "0");
  200. const minutes = String(date.getMinutes()).padStart(2, "0");
  201. return `${year}-${month}-${day} ${hours}:${minutes}`;
  202. };
  203. // 获取状态文本
  204. const getStatusText = (status) => {
  205. const statusMap = {
  206. 0: "待付款",
  207. 100: "待发货",
  208. 200: "已发货",
  209. 300: "待发货",
  210. 400: "已完成",
  211. 500: "已取消",
  212. 600: "已退款",
  213. };
  214. return statusMap[status] || "未知状态";
  215. };
  216. // 获取状态描述
  217. const getStatusDesc = (status) => {
  218. const descMap = {
  219. 0: "等待买家付款",
  220. 100: "等待您发货",
  221. 200: "商品已发出",
  222. 300: "等待您发货",
  223. 400: "订单已完成",
  224. 500: "订单已取消",
  225. 600: "订单已退款",
  226. };
  227. return descMap[status] || "";
  228. };
  229. // 获取状态图标
  230. const getStatusIcon = (status) => {
  231. const iconMap = {
  232. 0: "icon-time",
  233. 100: "icon-package",
  234. 200: "icon-truck",
  235. 300: "icon-package",
  236. 400: "icon-check",
  237. 500: "icon-close",
  238. 600: "icon-refund",
  239. };
  240. return iconMap[status] || "icon-order";
  241. };
  242. // 获取操作按钮
  243. const getActionButtons = (status) => {
  244. const buttonMap = {
  245. 0: [], // 待付款 - 买家操作
  246. 100: [{ type: "ship", text: "发货", class: "btn-primary" }],
  247. 200: [], // 已发货 - 买家操作
  248. 300: [{ type: "ship", text: "发货", class: "btn-primary" }],
  249. 400: [], // 已完成
  250. 500: [], // 已取消
  251. 600: [], // 已退款
  252. };
  253. return buttonMap[status] || [];
  254. };
  255. // 处理操作
  256. const handleAction = (actionType) => {
  257. switch (actionType) {
  258. case "ship":
  259. // 发货
  260. Toast("发货功能待实现");
  261. break;
  262. case "cancel":
  263. // 取消订单
  264. Toast("取消订单功能待实现");
  265. break;
  266. case "refund":
  267. // 退款
  268. Toast("退款功能待实现");
  269. break;
  270. default:
  271. break;
  272. }
  273. };
  274. onLoad((options) => {
  275. if (options.id) {
  276. getOrderDetail(options.id);
  277. }
  278. });
  279. </script>
  280. <style lang="less" scoped>
  281. @import url("@/style.less");
  282. .wrap {
  283. min-height: 100vh;
  284. background: var(--bg);
  285. padding-bottom: 40rpx;
  286. .nav_title {
  287. color: var(--black);
  288. font-size: 36rpx;
  289. font-weight: bold;
  290. }
  291. .status-section {
  292. background: var(--light);
  293. padding: 40rpx 30rpx;
  294. margin-bottom: 20rpx;
  295. display: flex;
  296. align-items: center;
  297. gap: 30rpx;
  298. .status-icon {
  299. width: 100rpx;
  300. height: 100rpx;
  301. border-radius: 50%;
  302. background: var(--primary);
  303. display: flex;
  304. align-items: center;
  305. justify-content: center;
  306. .icon-font {
  307. font-size: 48rpx;
  308. color: var(--light);
  309. }
  310. }
  311. .status-info {
  312. flex: 1;
  313. .status-text {
  314. font-size: 32rpx;
  315. font-weight: bold;
  316. color: var(--black);
  317. margin-bottom: 8rpx;
  318. }
  319. .status-desc {
  320. font-size: 24rpx;
  321. color: var(--text-01);
  322. }
  323. }
  324. }
  325. .tab-section {
  326. background: var(--light);
  327. margin-bottom: 20rpx;
  328. padding: 0 30rpx;
  329. }
  330. .address-section,
  331. .products-section,
  332. .order-info-section,
  333. .amount-section,
  334. .logistics-section {
  335. background: var(--light);
  336. margin-bottom: 20rpx;
  337. padding: 30rpx;
  338. .section-header {
  339. display: flex;
  340. align-items: center;
  341. gap: 12rpx;
  342. margin-bottom: 24rpx;
  343. font-size: 28rpx;
  344. font-weight: bold;
  345. color: var(--black);
  346. .icon-font {
  347. font-size: 32rpx;
  348. color: var(--primary);
  349. }
  350. }
  351. }
  352. .address-info {
  353. .receiver {
  354. display: flex;
  355. align-items: center;
  356. gap: 20rpx;
  357. margin-bottom: 12rpx;
  358. .name {
  359. font-size: 28rpx;
  360. font-weight: bold;
  361. color: var(--black);
  362. }
  363. .phone {
  364. font-size: 24rpx;
  365. color: var(--text-01);
  366. }
  367. }
  368. .address {
  369. font-size: 26rpx;
  370. color: var(--text);
  371. line-height: 1.5;
  372. }
  373. }
  374. .product-list {
  375. .product-item {
  376. display: flex;
  377. gap: 20rpx;
  378. padding: 20rpx 0;
  379. border-bottom: 1rpx solid var(--border);
  380. &:last-child {
  381. border-bottom: none;
  382. }
  383. .product-image {
  384. width: 120rpx;
  385. height: 120rpx;
  386. border-radius: 12rpx;
  387. overflow: hidden;
  388. background: var(--bg);
  389. image {
  390. width: 100%;
  391. height: 100%;
  392. }
  393. }
  394. .product-info {
  395. flex: 1;
  396. display: flex;
  397. flex-direction: column;
  398. justify-content: space-between;
  399. .product-name {
  400. font-size: 28rpx;
  401. color: var(--black);
  402. line-height: 1.4;
  403. margin-bottom: 8rpx;
  404. overflow: hidden;
  405. text-overflow: ellipsis;
  406. display: -webkit-box;
  407. -webkit-line-clamp: 2;
  408. line-clamp: 2;
  409. -webkit-box-orient: vertical;
  410. }
  411. .product-spec {
  412. font-size: 24rpx;
  413. color: var(--text-01);
  414. margin-bottom: 8rpx;
  415. }
  416. .product-price {
  417. display: flex;
  418. justify-content: space-between;
  419. align-items: center;
  420. .price {
  421. font-size: 28rpx;
  422. font-weight: bold;
  423. color: var(--primary);
  424. }
  425. .quantity {
  426. font-size: 24rpx;
  427. color: var(--text-01);
  428. }
  429. }
  430. }
  431. }
  432. }
  433. .info-list,
  434. .amount-list,
  435. .logistics-info {
  436. .info-item,
  437. .amount-item,
  438. .logistics-item {
  439. display: flex;
  440. justify-content: space-between;
  441. align-items: center;
  442. padding: 16rpx 0;
  443. border-bottom: 1rpx solid var(--border);
  444. &:last-child {
  445. border-bottom: none;
  446. }
  447. .label {
  448. font-size: 26rpx;
  449. color: var(--text-01);
  450. }
  451. .value {
  452. font-size: 26rpx;
  453. color: var(--text);
  454. text-align: right;
  455. &.discount {
  456. color: var(--success);
  457. }
  458. }
  459. &.total {
  460. border-top: 2rpx solid var(--border);
  461. margin-top: 16rpx;
  462. padding-top: 20rpx;
  463. .label {
  464. font-size: 28rpx;
  465. font-weight: bold;
  466. color: var(--black);
  467. }
  468. .value {
  469. font-size: 32rpx;
  470. font-weight: bold;
  471. color: var(--primary);
  472. }
  473. }
  474. }
  475. }
  476. .action-section {
  477. position: fixed;
  478. bottom: 0;
  479. left: 0;
  480. right: 0;
  481. background: var(--light);
  482. padding: 20rpx 30rpx;
  483. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  484. border-top: 1rpx solid var(--border);
  485. display: flex;
  486. gap: 20rpx;
  487. justify-content: flex-end;
  488. .action-btn {
  489. padding: 20rpx 40rpx;
  490. border-radius: 40rpx;
  491. font-size: 28rpx;
  492. font-weight: bold;
  493. text-align: center;
  494. min-width: 120rpx;
  495. &.btn-primary {
  496. background: var(--primary);
  497. color: var(--light);
  498. }
  499. &.btn-secondary {
  500. background: var(--light);
  501. color: var(--black);
  502. border: 1rpx solid var(--border);
  503. }
  504. &.btn-danger {
  505. background: var(--danger);
  506. color: var(--light);
  507. }
  508. }
  509. }
  510. }
  511. </style>