buy-order-item.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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" v-if="order.detailCoverList && order.detailCoverList.length > 0">
  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. <!-- 单本书样式 -->
  17. <view class="single-book" v-else>
  18. <image :src="order.bookCover || defaultCover" mode="aspectFit" class="book-cover"></image>
  19. <view class="book-info">
  20. <view class="info-top">
  21. <text class="book-name u-line-2">{{ order.bookName }}</text>
  22. <view class="price-box">
  23. <text class="price">¥ {{ order.bookPrice || '0.00' }}</text>
  24. <text class="num">x{{ order.bookNum }}</text>
  25. </view>
  26. </view>
  27. <view class="book-sku" v-if="order.bookConditionType">
  28. 品相:{{ order.bookConditionType | conditionText }}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 价格汇总 -->
  34. <view class="order-total">
  35. <text class="ml-20">总价 ¥{{ order.totalMoney || 0 }}</text>
  36. <text class="ml-20">实付款 ¥{{ order.payMoney || 0 }}</text>
  37. </view>
  38. <!-- 操作按钮 -->
  39. <view class="action-box">
  40. <!-- 付款 (未包含在Flags中,保留原逻辑: 待付款且未取消) -->
  41. <u-button v-if="order.status == '1' && order.cancelStatus == '0'" size="mini" shape="circle"
  42. :custom-style="themeBtnStyle" @click.stop="handleAction('pay', order)">付款</u-button>
  43. <!-- 确认收货 -->
  44. <u-button v-if="order.showConfirmShop == 1" size="mini" shape="circle" :custom-style="themeBtnStyle"
  45. @click.stop="handleAction('confirm', order)">确认收货</u-button>
  46. <!-- 加入购物车 -->
  47. <u-button v-if="order.showAddToCart == 1" size="mini" shape="circle" :custom-style="themeBtnStyle"
  48. @click.stop="handleAction('addToCart', order)">加入购物车</u-button>
  49. <!-- 再来一单 -->
  50. <u-button v-if="order.showBuyAgain == 1" size="mini" shape="circle" type="primary" plain
  51. :custom-style="btnStyle" @click.stop="handleAction('rebuy', order)">再买一单</u-button>
  52. <!-- 评价 -->
  53. <u-button v-if="order.showEvaluation == 1" size="mini" shape="circle" type="primary" plain
  54. :custom-style="btnStyle" @click.stop="handleAction('evaluate', order)">评价</u-button>
  55. <!-- 查看物流 -->
  56. <u-button v-if="order.showCheckExpress == 1 && order.status != '4'" size="mini" shape="circle"
  57. type="primary" plain :custom-style="btnStyle"
  58. @click.stop="handleAction('logistics', order)">查看物流</u-button>
  59. <!-- 延长收货 -->
  60. <u-button v-if="order.showExtendReceivingTime == 1" size="mini" shape="circle" plain
  61. :custom-style="btnStyle" @click.stop="handleAction('extend', order)">延长收货</u-button>
  62. <!-- 催发货 -->
  63. <u-button v-if="order.showUrge == 1" size="mini" shape="circle" type="warning" plain
  64. :custom-style="btnStyle" @click.stop="handleAction('remind', order)">催发货</u-button>
  65. <!-- 申请售后 -->
  66. <u-button v-if="order.showAfterSales == 1 && order.status != '4'" size="mini" shape="circle" type="error"
  67. plain :custom-style="btnStyle" @click.stop="handleAction('refund', order)">申请售后</u-button>
  68. <!-- 取消订单 (未包含在Flags中,保留原逻辑: 待付款且未取消) -->
  69. <u-button v-if="order.showCancel" size="mini" shape="circle" type="error" plain :custom-style="btnStyle"
  70. @click.stop="handleAction('cancel', order)">取消订单</u-button>
  71. <!-- 钱款去向 -->
  72. <u-button v-if="order.showMoneyDestination == 1" size="mini" shape="circle" type="primary" plain
  73. :custom-style="btnStyle" @click.stop="handleAction('moneyWhere', order)">钱款去向</u-button>
  74. <!-- 查看详情 -->
  75. <u-button v-if="order.showShowDetail == 1" size="mini" shape="circle" plain :custom-style="btnStyle"
  76. @click.stop="handleAction('detail', order)">查看详情</u-button>
  77. <!-- 申请开票 -->
  78. <u-button v-if="order.showApplyInvoice == 1 && order.status != '4'" size="mini" shape="circle" plain
  79. :custom-style="btnStyle" @click.stop="handleAction('invoice', order)">申请开票</u-button>
  80. <!-- 投诉 -->
  81. <u-button v-if="order.showComplaint == 1" size="mini" shape="circle" plain :custom-style="btnStyle"
  82. @click.stop="handleAction('complaint', order)">投诉</u-button>
  83. <!-- 修改地址 -->
  84. <u-button v-if="order.showModifyAddress == 1" size="mini" shape="circle" plain :custom-style="btnStyle"
  85. @click.stop="handleAction('address', order)">修改地址</u-button>
  86. <!-- 更多操作 (仅在已完成状态下显示) -->
  87. <u-button
  88. v-if="(order.showAfterSales == 1 || order.showCheckExpress == 1 || order.showApplyInvoice == 1) && order.status == '4'"
  89. size="mini" shape="circle" plain :custom-style="btnStyle" @click.stop="handleMoreAction">更多</u-button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. export default {
  95. props: {
  96. order: {
  97. type: Object,
  98. required: true
  99. }
  100. },
  101. data() {
  102. return {
  103. defaultCover: 'https://uviewui.com/album/1.jpg',
  104. btnStyle: {
  105. marginLeft: '20rpx',
  106. height: '60rpx',
  107. lineHeight: '60rpx',
  108. padding: '0 24rpx',
  109. fontSize: '26rpx',
  110. },
  111. themeBtnStyle: {
  112. marginLeft: '20rpx',
  113. height: '60rpx',
  114. lineHeight: '60rpx',
  115. padding: '0 30rpx',
  116. backgroundColor: '#38C148',
  117. color: '#fff',
  118. fontSize: '26rpx',
  119. }
  120. }
  121. },
  122. methods: {
  123. goToDetail() {
  124. uni.navigateTo({
  125. url: `/pages-car/pages/order-detail?orderId=${this.order.orderId}`
  126. })
  127. },
  128. getStatusText(order) {
  129. //订单状态:1-待付款 2-待发货 3-待收货 4-已完成 5-已取消 6-退款中 7-已退款
  130. const map = {
  131. '1': '待付款',
  132. '2': '待发货',
  133. '3': '待收货',
  134. '4': '已完成',
  135. '5': '已取消',
  136. '6': '退款中',
  137. '7': '已退款'
  138. }
  139. return map[order.status] || '未知状态'
  140. },
  141. handleAction(type, data) {
  142. if (type === 'complaint') {
  143. uni.setStorageSync('tempComplaintOrder', data);
  144. uni.navigateTo({
  145. url: `/pages-car/pages/complaint?orderId=${data.orderId}`
  146. });
  147. return;
  148. }
  149. if (type === 'detail') {
  150. // 跳转至退款详情页
  151. const id = this.order.refundOrderId;
  152. uni.navigateTo({
  153. url: `/pages-car/pages/refund-detail?refundOrderId=${id}`
  154. });
  155. return;
  156. }
  157. console.log('handleAction', type, data)
  158. this.$emit('action', { type, order: data })
  159. },
  160. handleMoreAction() {
  161. // 收集更多按钮下的操作
  162. const actions = [];
  163. if (this.order.showAfterSales == 1) actions.push('applyAfterSales');
  164. if (this.order.showCheckExpress == 1) actions.push('logistics');
  165. if (this.order.showApplyInvoice == 1) actions.push('invoice');
  166. this.$emit('action', { type: 'more', order: this.order, data: actions });
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .buy-order-item {
  173. background-color: #fff;
  174. border-radius: 16rpx;
  175. padding: 30rpx 20rpx;
  176. margin-bottom: 20rpx;
  177. .order-header {
  178. display: flex;
  179. justify-content: space-between;
  180. margin-bottom: 20rpx;
  181. font-size: 28rpx;
  182. .order-no {
  183. color: #333;
  184. font-weight: 500;
  185. }
  186. .order-status {
  187. color: #999;
  188. }
  189. }
  190. .goods-list {
  191. margin-bottom: 20rpx;
  192. .goods-scroll {
  193. white-space: nowrap;
  194. width: 100%;
  195. .goods-wrapper {
  196. display: flex;
  197. }
  198. .goods-cover {
  199. width: 140rpx;
  200. height: 140rpx;
  201. margin-right: 20rpx;
  202. border-radius: 8rpx;
  203. flex-shrink: 0;
  204. }
  205. }
  206. .single-book {
  207. display: flex;
  208. .book-cover {
  209. width: 140rpx;
  210. height: 140rpx;
  211. margin-right: 10rpx;
  212. border-radius: 8rpx;
  213. flex-shrink: 0;
  214. }
  215. .book-info {
  216. flex: 1;
  217. display: flex;
  218. flex-direction: column;
  219. justify-content: space-between;
  220. .info-top {
  221. display: flex;
  222. justify-content: space-between;
  223. .book-name {
  224. flex: 1;
  225. font-size: 28rpx;
  226. color: #333;
  227. font-weight: bold;
  228. margin-right: 30rpx;
  229. }
  230. .price-box {
  231. text-align: right;
  232. display: flex;
  233. flex-direction: column;
  234. align-items: flex-end;
  235. .price {
  236. font-size: 28rpx;
  237. color: #333;
  238. font-weight: 500;
  239. }
  240. .num {
  241. font-size: 24rpx;
  242. color: #999;
  243. margin-top: 6rpx;
  244. }
  245. }
  246. }
  247. .book-sku {
  248. background: rgb(56, 193, 72, 0.1);
  249. color: #333;
  250. font-size: 24rpx;
  251. padding: 4rpx 12rpx;
  252. border-radius: 4rpx;
  253. align-self: flex-start;
  254. margin-top: 10rpx;
  255. }
  256. }
  257. }
  258. }
  259. .order-total {
  260. text-align: right;
  261. font-size: 26rpx;
  262. color: #333;
  263. margin-bottom: 20rpx;
  264. .ml-20 {
  265. margin-left: 20rpx;
  266. font-weight: 500;
  267. }
  268. }
  269. .action-box {
  270. display: flex;
  271. justify-content: flex-end;
  272. align-items: center;
  273. flex-wrap: wrap; // 防止按钮过多换行问题
  274. u-button {
  275. margin-bottom: 10rpx; // 如果换行,增加间距
  276. }
  277. .status-desc {
  278. font-size: 26rpx;
  279. color: #999;
  280. }
  281. }
  282. }
  283. </style>