buy-order-item.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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" 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" 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" 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 == '5')"
  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. hasPayOrderNo(payOrderNo) {
  125. return payOrderNo !== null && payOrderNo !== undefined && String(payOrderNo).trim() !== '';
  126. },
  127. openWechatConfirmReceive(order) {
  128. // #ifdef MP-WEIXIN
  129. if (typeof wx === 'undefined' || typeof wx.openBusinessView !== 'function') {
  130. return false;
  131. }
  132. wx.openBusinessView({
  133. businessType: 'weappOrderConfirm',
  134. extraData: {
  135. transaction_id: order.payOrderNo
  136. },
  137. success: () => {
  138. uni.showLoading({ title: '处理中' });
  139. this.$u.api.confirmReceiveAjax({ orderId: order.orderId }).then(res => {
  140. uni.hideLoading();
  141. if (res.code == 200) {
  142. uni.showToast({ title: '收货成功', icon: 'success' });
  143. this.$emit('refresh'); // 通知父组件刷新列表
  144. }
  145. }).catch(() => {
  146. uni.hideLoading();
  147. });
  148. },
  149. fail: (err) => {
  150. const errMsg = (err && err.errMsg) ? err.errMsg : '';
  151. if (errMsg.indexOf('cancel') > -1) return;
  152. uni.showToast({ title: '暂无法唤起微信确认收货', icon: 'none' });
  153. }
  154. });
  155. return true;
  156. // #endif
  157. return false;
  158. },
  159. goToDetail() {
  160. uni.navigateTo({
  161. url: `/pages-car/pages/order-detail?orderId=${this.order.orderId}`
  162. })
  163. },
  164. getStatusText(order) {
  165. //订单状态:1-待付款 2-待发货 3-待收货 4-用户已签收 5-已完成 6-已取消
  166. const map = {
  167. '1': '待付款',
  168. '2': '待发货',
  169. '3': '待收货',
  170. '4': '用户已签收',
  171. '5': '已完成',
  172. '6': '已取消',
  173. }
  174. return map[order.status] || '未知状态'
  175. },
  176. handleAction(type, data) {
  177. if (type === 'complaint') {
  178. uni.setStorageSync('tempComplaintOrder', data);
  179. uni.navigateTo({
  180. url: `/pages-car/pages/complaint?orderId=${data.orderId}`
  181. });
  182. return;
  183. }
  184. if (type === 'detail') {
  185. uni.navigateTo({
  186. url: `/pages-car/pages/order-detail?orderId=${data.orderId}`
  187. });
  188. return;
  189. }
  190. if (type === 'confirm') {
  191. if (data.showConfirmShop == 1 && this.hasPayOrderNo(data.payOrderNo) && this.openWechatConfirmReceive(data)) {
  192. return;
  193. }
  194. uni.showModal({
  195. title: '提示',
  196. content: '是否确认收货?',
  197. success: (res) => {
  198. if (res.confirm) {
  199. uni.showLoading({ title: '处理中' });
  200. this.$u.api.confirmReceiveAjax({ orderId: data.orderId }).then(res => {
  201. uni.hideLoading();
  202. if (res.code == 200) {
  203. uni.showToast({ title: '收货成功', icon: 'success' });
  204. this.$emit('refresh'); // 通知父组件刷新列表
  205. }
  206. });
  207. }
  208. }
  209. });
  210. return;
  211. }
  212. console.log('handleAction', type, data)
  213. this.$emit('action', { type, order: data })
  214. },
  215. handleMoreAction() {
  216. // 收集更多按钮下的操作
  217. const actions = [];
  218. if (this.order.showAfterSales == 1) actions.push('applyAfterSales');
  219. if (this.order.showCheckExpress == 1) actions.push('logistics');
  220. if (this.order.showApplyInvoice == 1) actions.push('invoice');
  221. this.$emit('action', { type: 'more', order: this.order, data: actions })
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .buy-order-item {
  228. background-color: #fff;
  229. border-radius: 16rpx;
  230. padding: 30rpx 20rpx;
  231. margin-bottom: 20rpx;
  232. .order-header {
  233. display: flex;
  234. justify-content: space-between;
  235. margin-bottom: 20rpx;
  236. font-size: 28rpx;
  237. .order-no {
  238. color: #333;
  239. font-weight: 500;
  240. }
  241. .order-status {
  242. color: #999;
  243. }
  244. .refund-status {
  245. color: #FF4D4F;
  246. }
  247. }
  248. .goods-list {
  249. margin-bottom: 20rpx;
  250. .goods-scroll {
  251. white-space: nowrap;
  252. width: 100%;
  253. .goods-wrapper {
  254. display: flex;
  255. }
  256. .goods-cover {
  257. width: 140rpx;
  258. height: 140rpx;
  259. margin-right: 20rpx;
  260. border-radius: 8rpx;
  261. flex-shrink: 0;
  262. }
  263. }
  264. .single-book {
  265. display: flex;
  266. .book-cover {
  267. width: 140rpx;
  268. height: 140rpx;
  269. margin-right: 10rpx;
  270. border-radius: 8rpx;
  271. flex-shrink: 0;
  272. }
  273. .book-info {
  274. flex: 1;
  275. display: flex;
  276. flex-direction: column;
  277. justify-content: space-between;
  278. .info-top {
  279. display: flex;
  280. justify-content: space-between;
  281. .book-name {
  282. flex: 1;
  283. font-size: 28rpx;
  284. color: #333;
  285. font-weight: bold;
  286. margin-right: 30rpx;
  287. }
  288. .price-box {
  289. text-align: right;
  290. display: flex;
  291. flex-direction: column;
  292. align-items: flex-end;
  293. .price {
  294. font-size: 28rpx;
  295. color: #333;
  296. font-weight: 500;
  297. }
  298. .num {
  299. font-size: 24rpx;
  300. color: #999;
  301. margin-top: 6rpx;
  302. }
  303. }
  304. }
  305. .book-sku {
  306. background: rgb(56, 193, 72, 0.1);
  307. color: #333;
  308. font-size: 24rpx;
  309. padding: 4rpx 12rpx;
  310. border-radius: 4rpx;
  311. align-self: flex-start;
  312. margin-top: 10rpx;
  313. }
  314. }
  315. }
  316. }
  317. .order-total {
  318. text-align: right;
  319. font-size: 26rpx;
  320. color: #333;
  321. margin-bottom: 20rpx;
  322. .ml-20 {
  323. margin-left: 20rpx;
  324. font-weight: 500;
  325. }
  326. }
  327. .action-box {
  328. display: flex;
  329. justify-content: flex-end;
  330. align-items: center;
  331. flex-wrap: wrap; // 防止按钮过多换行问题
  332. u-button {
  333. margin-bottom: 10rpx; // 如果换行,增加间距
  334. }
  335. .status-desc {
  336. font-size: 26rpx;
  337. color: #999;
  338. }
  339. }
  340. }
  341. </style>