buy-order-item.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="buy-order-item" @click="goToDetail">
  3. <!-- 订单头部:订单号和状态 -->
  4. <view class="order-header">
  5. <text class="order-no">订单号:{{ order.orderId }}</text>
  6. <text class="order-status">{{ getStatusText(order) }}</text>
  7. </view>
  8. <!-- 商品信息 -->
  9. <view class="goods-list">
  10. <scroll-view scroll-x class="goods-scroll">
  11. <view class="goods-wrapper">
  12. <image v-for="(cover, index) in order.detailCoverList" :key="index" :src="cover || defaultCover"
  13. mode="aspectFill" class="goods-cover"></image>
  14. </view>
  15. </scroll-view>
  16. </view>
  17. <!-- 价格汇总 -->
  18. <view class="order-total">
  19. <text>共{{ order.totalNum }}本</text>
  20. <text class="ml-20">实付款 ¥{{ order.payMoney || 0 }}</text>
  21. </view>
  22. <!-- 操作按钮 -->
  23. <view class="action-box">
  24. <!-- 待付款 -->
  25. <template v-if="order.status == '1' && order.cancelStatus == '0'">
  26. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('address')">修改地址</u-button>
  27. <u-button size="mini" shape="circle" type="error" plain :custom-style="btnStyle" @click.stop="handleAction('cancel')">取消订单</u-button>
  28. <u-button size="mini" shape="circle" :custom-style="themeBtnStyle" @click.stop="handleAction('pay')">付款</u-button>
  29. </template>
  30. <!-- 待发货 -->
  31. <template v-else-if="order.status == '2' && order.refundStatus == '1' && order.cancelStatus == '0'">
  32. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('address')">修改地址</u-button>
  33. <u-button size="mini" shape="circle" type="error" plain :custom-style="btnStyle" @click.stop="handleAction('refund')">申请售后</u-button>
  34. <u-button size="mini" shape="circle" type="warning" plain :custom-style="btnStyle" @click.stop="handleAction('remind')">催发货</u-button>
  35. </template>
  36. <!-- 待收货 -->
  37. <template v-else-if="order.status == '3' && order.refundStatus == '1' && order.cancelStatus == '0'">
  38. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('extend')">延长收货</u-button>
  39. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('invoice')">申请开票</u-button>
  40. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('complaint')">投诉</u-button>
  41. <u-button size="mini" shape="circle" type="primary" plain :custom-style="btnStyle" @click.stop="handleAction('logistics')">查看物流</u-button>
  42. <u-button size="mini" shape="circle" :custom-style="themeBtnStyle" @click.stop="handleAction('confirm')">确认收货</u-button>
  43. </template>
  44. <!-- 已完成 -->
  45. <template v-else-if="order.status == '4' && order.refundStatus == '1' && order.cancelStatus == '0'">
  46. <u-button size="mini" shape="circle" :custom-style="themeBtnStyle" @click.stop="handleAction('addToCart')">加入购物车</u-button>
  47. <u-button size="mini" shape="circle" type="primary" plain :custom-style="btnStyle" @click.stop="handleAction('rebuy')">再买一单</u-button>
  48. <u-button size="mini" shape="circle" type="primary" plain :custom-style="btnStyle" @click.stop="handleAction('evaluate')">评价</u-button>
  49. <u-button size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleAction('more', ['applyAfterSales', 'logistics', 'invoice'])">更多</u-button>
  50. </template>
  51. <!-- 退款/售后 -->
  52. <template v-else-if="order.refundStatus != '1'">
  53. <u-button size="mini" shape="circle" type="primary" plain :custom-style="btnStyle" @click.stop="handleAction('moneyWhere')">钱款去向</u-button>
  54. <u-button size="mini" shape="circle" type="primary" plain :custom-style="btnStyle" @click.stop="handleAction('detail')">查看详情</u-button>
  55. </template>
  56. <!-- 已取消 -->
  57. <template v-else-if="order.cancelStatus == '1'">
  58. <u-button size="mini" shape="circle" type="error" plain :custom-style="btnStyle" @click.stop="handleAction('delete')">删除订单</u-button>
  59. <u-button size="mini" shape="circle" :custom-style="themeBtnStyle" @click.stop="handleAction('addToCart')">加入购物车</u-button>
  60. </template>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. props: {
  67. order: {
  68. type: Object,
  69. required: true
  70. }
  71. },
  72. data() {
  73. return {
  74. defaultCover: 'https://uviewui.com/album/1.jpg',
  75. btnStyle: {
  76. marginLeft: '20rpx',
  77. width: '150rpx',
  78. height: '60rpx',
  79. lineHeight: '60rpx',
  80. padding: '0',
  81. fontSize:'26rpx',
  82. },
  83. themeBtnStyle: {
  84. marginLeft: '20rpx',
  85. width: '160rpx',
  86. height: '60rpx',
  87. lineHeight: '60rpx',
  88. padding: '0',
  89. backgroundColor: '#38C148',
  90. color: '#fff',
  91. fontSize:'26rpx',
  92. }
  93. }
  94. },
  95. methods: {
  96. goToDetail() {
  97. uni.navigateTo({
  98. url: `/pages-car/pages/order-detail?orderId=${this.order.orderId}`
  99. })
  100. },
  101. getStatusText(order) {
  102. if (order.cancelStatus == '1') return '已取消';
  103. if (order.refundStatus == '2') return '退款中';
  104. if (order.refundStatus == '3') return '已退款';
  105. const map = {
  106. '1': '待付款',
  107. '2': '待发货',
  108. '3': '待收货',
  109. '4': '已完成'
  110. }
  111. return map[order.status] || '未知状态'
  112. },
  113. handleAction(type, data) {
  114. this.$emit('action', { type, order: this.order, data })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .buy-order-item {
  121. background-color: #fff;
  122. border-radius: 16rpx;
  123. padding: 30rpx 20rpx;
  124. margin-bottom: 20rpx;
  125. .order-header {
  126. display: flex;
  127. justify-content: space-between;
  128. margin-bottom: 20rpx;
  129. font-size: 28rpx;
  130. .order-no {
  131. color: #333;
  132. font-weight: 500;
  133. }
  134. .order-status {
  135. color: #999;
  136. }
  137. }
  138. .goods-list {
  139. margin-bottom: 20rpx;
  140. .goods-scroll {
  141. width: 100%;
  142. white-space: nowrap;
  143. }
  144. .goods-wrapper {
  145. display: flex;
  146. }
  147. .goods-cover {
  148. width: 140rpx;
  149. height: 170rpx;
  150. border-radius: 8rpx;
  151. margin-right: 20rpx;
  152. background-color: #eee;
  153. display: inline-block;
  154. }
  155. }
  156. .order-total {
  157. text-align: right;
  158. font-size: 26rpx;
  159. color: #333;
  160. margin-bottom: 20rpx;
  161. .ml-20 {
  162. margin-left: 20rpx;
  163. font-weight: 500;
  164. }
  165. }
  166. .action-box {
  167. display: flex;
  168. justify-content: flex-end;
  169. align-items: center;
  170. flex-wrap: wrap; // 防止按钮过多换行问题
  171. u-button {
  172. margin-bottom: 10rpx; // 如果换行,增加间距
  173. }
  174. .status-desc {
  175. font-size: 26rpx;
  176. color: #999;
  177. }
  178. }
  179. }
  180. </style>