buy-order-item.vue 14 KB

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