order-item.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="order-item" @click="goToDetail">
  3. <!-- 订单头部 -->
  4. <view class="order-header">
  5. <text class="common-text-2 font-30">卖书编号:{{ 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 mb-20">
  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" 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. isReturn: {
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. data() {
  42. return {
  43. statusTextMap: {
  44. 'pending_review': '待初审',
  45. 'cancelled': '已取消',
  46. 'pending_audit': '待审核',
  47. },
  48. statusColorMap: {
  49. 'pending_review': '#FF5B5B',
  50. 'cancelled': '#999999',
  51. 'pending_audit': '#FF5B5B',
  52. },
  53. customStyle: {
  54. height: '60rpx',
  55. borderRadius: '10rpx',
  56. width: '170rpx',
  57. fontSize: '28rpx',
  58. }
  59. }
  60. },
  61. methods: {
  62. getActions(status) {
  63. const actionMap = {
  64. 'pending_review': [
  65. { text: '取消交易', type: 'info', plain: true, action: 'cancel' },
  66. { text: '投诉上报', type: 'primary', plain: true, action: 'report' },
  67. { text: '修改地址', type: 'primary', plain: false, action: 'editAddress' }
  68. ],
  69. 'pending_audit': [
  70. { text: '提醒审核', type: 'primary', plain: false, action: 'remind' }
  71. ]
  72. }
  73. return actionMap[status] || []
  74. },
  75. goToDetail() {
  76. if (this.isReturn) {
  77. uni.navigateTo({
  78. url: `/pages-mine/pages/apply?id=${this.order.orderNo}`
  79. })
  80. } else {
  81. uni.navigateTo({
  82. url: `/pages-mine/pages/order-detail?id=${this.order.orderNo}`
  83. })
  84. }
  85. },
  86. handleAction(action) {
  87. this.$emit(action, this.order)
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .order-item {
  94. background: #FFFFFF;
  95. border-radius: 12rpx;
  96. padding: 30rpx;
  97. margin-bottom: 20rpx;
  98. .order-header {
  99. display: flex;
  100. justify-content: space-between;
  101. align-items: center;
  102. .order-status {
  103. font-size: 28rpx;
  104. }
  105. }
  106. // 修改图片滚动区域样式
  107. .book-scroll {
  108. width: 100%;
  109. white-space: nowrap;
  110. margin: 30rpx 0 20rpx 0;
  111. .book-list {
  112. display: inline-flex;
  113. padding-right: 20rpx; // 为最后一张图片添加右边距
  114. gap: 20rpx;
  115. .book-cover {
  116. width: 132rpx;
  117. height: 185rpx;
  118. border-radius: 10rpx;
  119. flex-shrink: 0; // 防止图片被压缩
  120. }
  121. }
  122. }
  123. .order-actions {
  124. display: flex;
  125. justify-content: flex-end;
  126. gap: 12rpx;
  127. margin-top: 30rpx;
  128. }
  129. }
  130. // 隐藏滚动条
  131. ::-webkit-scrollbar {
  132. display: none;
  133. width: 0;
  134. height: 0;
  135. color: transparent;
  136. }
  137. </style>