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