buy-order-item.vue 13 KB

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