order-item.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="order-item" @click="goToDetail">
  3. <!-- 订单头部 -->
  4. <view class="order-header">
  5. <text class="common-text-2">卖书编号:{{ order.orderNo }}</text>
  6. <text class="order-status" :style="{ color: statusColorMap[order.status] }">{{ statusTextMap[order.status]
  7. }}</text>
  8. </view>
  9. <!-- 书籍列表 - 改为横向滚动 -->
  10. <scroll-view scroll-x class="book-scroll" :show-scrollbar="false" enhanced>
  11. <view class="book-list">
  12. <image v-for="(book, index) in order.books" :key="index" :src="book.cover" class="book-cover"
  13. mode="aspectFill" />
  14. </view>
  15. </scroll-view>
  16. <!-- 订单信息 -->
  17. <view class="flex-a flex-j-b">
  18. <text class="common-text">提交时间:{{ order.submitTime }}</text>
  19. <text class="common-title">共{{ order.books.length }}本</text>
  20. </view>
  21. <!-- 底部按钮 -->
  22. <view class="order-actions mt-20" v-if="getActions(order.status).length > 0">
  23. <u-button v-for="(action, index) in getActions(order.status)" :key="index" :type="action.type" size="mini"
  24. :plain="action.plain" class="action-btn" @click.stop="handleAction(action.action)" :customStyle="customStyle">{{ action.text }}</u-button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'order-item',
  31. props: {
  32. order: {
  33. type: Object,
  34. required: true
  35. }
  36. },
  37. data() {
  38. return {
  39. statusTextMap: {
  40. 'pending_review': '待初审',
  41. 'cancelled': '已取消',
  42. 'pending_audit': '待审核',
  43. },
  44. statusColorMap: {
  45. 'pending_review': '#FF5B5B',
  46. 'cancelled': '#999999',
  47. 'pending_audit': '#FF5B5B',
  48. },
  49. customStyle: {
  50. height: '60rpx',
  51. borderRadius: '10rpx',
  52. width: '170rpx',
  53. fontSize: '28rpx',
  54. }
  55. }
  56. },
  57. methods: {
  58. getActions(status) {
  59. const actionMap = {
  60. 'pending_review': [
  61. { text: '取消交易', type: 'info', plain: true, action: 'cancel' },
  62. { text: '投诉上报', type: 'primary', plain: true, action: 'report' },
  63. { text: '修改地址', type: 'primary', plain: false, action: 'editAddress' }
  64. ],
  65. 'pending_audit': [
  66. { text: '提醒审核', type: 'primary', plain: false, action: 'remind' }
  67. ]
  68. }
  69. return actionMap[status] || []
  70. },
  71. goToDetail() {
  72. uni.navigateTo({
  73. url: `/pages/order/detail?id=${this.order.orderNo}`
  74. })
  75. },
  76. handleAction(action) {
  77. this.$emit(action, this.order)
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .order-item {
  84. background: #FFFFFF;
  85. border-radius: 12rpx;
  86. padding: 30rpx;
  87. margin-bottom: 20rpx;
  88. .order-header {
  89. display: flex;
  90. justify-content: space-between;
  91. align-items: center;
  92. .order-status {
  93. font-size: 28rpx;
  94. }
  95. }
  96. // 修改图片滚动区域样式
  97. .book-scroll {
  98. width: 100%;
  99. white-space: nowrap;
  100. margin: 30rpx 0 20rpx 0;
  101. .book-list {
  102. display: inline-flex;
  103. padding-right: 20rpx; // 为最后一张图片添加右边距
  104. gap: 20rpx;
  105. .book-cover {
  106. width: 132rpx;
  107. height: 185rpx;
  108. border-radius: 10rpx;
  109. flex-shrink: 0; // 防止图片被压缩
  110. }
  111. }
  112. }
  113. .order-actions {
  114. display: flex;
  115. justify-content: flex-end;
  116. gap: 12rpx;
  117. margin-top: 30rpx;
  118. }
  119. }
  120. // 隐藏滚动条
  121. ::-webkit-scrollbar {
  122. display: none;
  123. width: 0;
  124. height: 0;
  125. color: transparent;
  126. }
  127. </style>