order-list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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="storeIconById[order.storeId]" 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. data (){
  43. return {
  44. storeIconById:{
  45. 1:"http://localhost:2441/files/1714889318659-scenes.png",
  46. 2:"http://localhost:2441/files/1714889474353-head2.jpg"
  47. }
  48. }
  49. },
  50. methods: {
  51. handleOrderDetail(order) {
  52. console.log(this.orders)
  53. console.log(`查看订单详情: ${order.transCode}`);
  54. },
  55. handleOrderAction(order) {
  56. const action = this.getActionText(order.orderState);
  57. console.log(`执行操作: ${action} - 订单编号: ${order.transCode}`);
  58. },
  59. handleReorder(order) {
  60. // console.log(`跳转到商店页面: `);
  61. // 在这里编写跳转到相应商店页面的逻辑
  62. uni.navigateTo({
  63. url: `/subpkg/shopdetail/shopdetail?shopID=${order.storeId}`
  64. })
  65. },
  66. getActionText(orderState) {
  67. switch (orderState) {
  68. case "待付款":
  69. return "立即付款";
  70. case "待收货":
  71. return "确认收货";
  72. case "退款/售后":
  73. return "申请退款";
  74. case "已完成":
  75. return "重新购买";
  76. default:
  77. return "暂无操作";
  78. }
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="scss">
  84. .order-list {
  85. .order-item {
  86. background-color: #fff;
  87. border-radius: 8px;
  88. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  89. padding: 12px;
  90. margin-bottom: 12px;
  91. .order-header {
  92. display: flex;
  93. align-items: center;
  94. margin-bottom: 8px;
  95. .user-avatar {
  96. width: 40px;
  97. height: 40px;
  98. border-radius: 50%;
  99. margin-right: 12px;
  100. }
  101. .order-info {
  102. flex: 1;
  103. .order-number {
  104. font-weight: bold;
  105. font-size: 14px;
  106. margin-bottom: 4px;
  107. }
  108. .order-remark {
  109. color: #666;
  110. font-size: 12px;
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. }
  115. }
  116. }
  117. .order-details {
  118. margin-bottom: 8px;
  119. .order-detail-row {
  120. display: flex;
  121. justify-content: space-between;
  122. margin-bottom: 4px;
  123. font-size: 12px;
  124. .label {
  125. color: #666;
  126. }
  127. .order-price {
  128. font-weight: bold;
  129. color: #ee0a24;
  130. }
  131. }
  132. }
  133. .order-actions {
  134. display: flex;
  135. justify-content: flex-end;
  136. .van-button {
  137. margin-left: 8px;
  138. font-size: 12px;
  139. padding: 0 8px;
  140. }
  141. }
  142. }
  143. }
  144. </style>