buy-order-item.vue 13 KB

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