order-list.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="order-list">
  3. <view class="order-item" v-for="order in orders" :key="order.id">
  4. <view class="order-header">
  5. <image class="user-avatar" :src="order.user.avatar" mode="aspectFill" />
  6. <view class="order-info">
  7. <view class="order-number">订单编号:{{ order.transCode }}</view>
  8. <view class="order-remark">备注:{{ order.orderRemark||"" }}</view>
  9. <view class="order-remark">当前状态:{{ order.orderState||"" }}</view>
  10. </view>
  11. </view>
  12. <view class="order-details">
  13. <view class="order-detail-row">
  14. <text class="label">下单时间:</text>
  15. <text>{{ order.timeOrder||"" }}</text>
  16. </view>
  17. <view class="order-detail-row">
  18. <text class="label">数量:</text>
  19. <text>{{ order.orderProductsLists.length }}</text>
  20. </view>
  21. <view class="order-detail-row">
  22. <text class="label">实付:</text>
  23. <text class="order-price">¥{{ order.originPay }}</text>
  24. </view>
  25. </view>
  26. <view class="order-actions">
  27. <van-button size="small" type="primary" @click="handleOrderDetail(order)">查看详情</van-button>
  28. <!-- <van-button size="small" type="danger" @click="handleOrderAction(order)">{{ getActionText(order.orderState) }}</van-button>-->
  29. <van-button size="small" plain type="info" @click="handleReorder(order)">再来一单</van-button>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. props: {
  37. orders: {
  38. type: Array,
  39. required: true
  40. }
  41. },
  42. methods: {
  43. handleOrderDetail(order) {
  44. console.log(this.orders)
  45. console.log(`查看订单详情: ${order.transCode}`);
  46. },
  47. handleOrderAction(order) {
  48. const action = this.getActionText(order.orderState);
  49. console.log(`执行操作: ${action} - 订单编号: ${order.transCode}`);
  50. },
  51. handleReorder(order) {
  52. // console.log(`跳转到商店页面: `);
  53. // 在这里编写跳转到相应商店页面的逻辑
  54. uni.navigateTo({
  55. url: `/subpkg/shopdetail/shopdetail?shopID=${order.storeId}`
  56. })
  57. },
  58. getActionText(orderState) {
  59. switch (orderState) {
  60. case "待付款":
  61. return "立即付款";
  62. case "待收货":
  63. return "确认收货";
  64. case "退款/售后":
  65. return "申请退款";
  66. case "已完成":
  67. return "重新购买";
  68. default:
  69. return "暂无操作";
  70. }
  71. }
  72. }
  73. };
  74. </script>
  75. <style lang="scss">
  76. .order-list {
  77. .order-item {
  78. background-color: #fff;
  79. border-radius: 8px;
  80. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  81. padding: 12px;
  82. margin-bottom: 12px;
  83. .order-header {
  84. display: flex;
  85. align-items: center;
  86. margin-bottom: 8px;
  87. .user-avatar {
  88. width: 40px;
  89. height: 40px;
  90. border-radius: 50%;
  91. margin-right: 12px;
  92. }
  93. .order-info {
  94. flex: 1;
  95. .order-number {
  96. font-weight: bold;
  97. font-size: 14px;
  98. margin-bottom: 4px;
  99. }
  100. .order-remark {
  101. color: #666;
  102. font-size: 12px;
  103. overflow: hidden;
  104. text-overflow: ellipsis;
  105. white-space: nowrap;
  106. }
  107. }
  108. }
  109. .order-details {
  110. margin-bottom: 8px;
  111. .order-detail-row {
  112. display: flex;
  113. justify-content: space-between;
  114. margin-bottom: 4px;
  115. font-size: 12px;
  116. .label {
  117. color: #666;
  118. }
  119. .order-price {
  120. font-weight: bold;
  121. color: #ee0a24;
  122. }
  123. }
  124. }
  125. .order-actions {
  126. display: flex;
  127. justify-content: flex-end;
  128. .van-button {
  129. margin-left: 8px;
  130. font-size: 12px;
  131. padding: 0 8px;
  132. }
  133. }
  134. }
  135. }
  136. </style>