buy-order-item.vue 9.5 KB

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