BusinessOrder.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <view class="item ske-loading">
  3. <view class="order-list-top">
  4. <view class="top-l" @click.stop="go(`/another-tf/another-user/shop/shop-detail?shopId=${data.shopId}`)">
  5. <image :src="data.shopLogo" class="shop-img" />
  6. <text class="shop-name">{{ data.shopName }}</text>
  7. <tui-icon name="arrowright" :size="25" color="#999999"></tui-icon>
  8. </view>
  9. <view class="order-status">
  10. {{ data.returnType ? '退款中' : orderTypeEnum[data.state] || '--' }}
  11. </view>
  12. </view>
  13. <view class="order-info-box" @click="go(`/another-tf/another-serve/orderDetails/index?orderId=${data.orderId}`)">
  14. <view class="order-info">
  15. <view v-for="(skuItem, skuIndex) in data.skus" :key="skuIndex" class="order-info-item">
  16. <image :src="skuItem.image" class="product-img default-img" />
  17. <view class="info-box">
  18. <text class="product-name">{{ skuItem.productName && skuItem.productName }}</text>
  19. <view class="product-sku">{{ skuItem.value && skuItem.value }}</view>
  20. <view class="price-sku-box">
  21. <view class="box-h flex-items-plus">
  22. <text class="product-price">
  23. <text class="fuhao">
  24. </text>
  25. {{ skuItem.price && skuItem.price }}
  26. </text>
  27. <text class="product-num">x {{ skuItem.number && skuItem.number }}</text>
  28. </view>
  29. <view v-if="showOperate">
  30. <view
  31. v-if="[3, 4].includes(data.state) && (data.orderType === 1)" class="evaluate"
  32. @click.stop="go(`/another-tf/another-user/product-logistics/index?orderId=${data.orderId}&skuId=${skuItem.skuId}`)"
  33. >
  34. 查看物流
  35. </view>
  36. <view
  37. v-if="[4, 10].includes(data.state) && (skuItem.commentId === 0)" class="evaluate2"
  38. @click.stop="go(`/another-tf/another-serve/evaluate/index?orderId=${data.orderId}&skuId=${skuItem.skuId}`)"
  39. >
  40. 立即评价
  41. </view>
  42. <view
  43. v-if="[4, 10].includes(data.state) && (skuItem.commentId !== 0) && (data.skus[0].ifAdd !== 1)" class="evaluate2"
  44. @click.stop="handleAddEvaluate(skuItem)"
  45. >
  46. 追加评价
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="total-price-box">
  53. <template v-if="data.orderPrice !== undefined || data.discountPrice !== undefined">
  54. 总价¥{{
  55. (data.orderPrice + data.logisticsPrice).toFixed(2)
  56. }},优惠¥{{ data.discountPrice }}
  57. <span v-if="data.price > 0">
  58. ,{{ data.state === 1 ? '应付¥' : '实付¥' }}{{ data.price }}
  59. </span>
  60. </template>
  61. </view>
  62. </view>
  63. <view v-if="showOperate" class="btnBox flex-items" :class="{ flexSpBetween: data.state === 5 || data.state === 9 }">
  64. <tui-icon
  65. v-if="data.state === 5 || data.state === 9" name="delete" :size="14" color="#333333"
  66. @click.stop="handleDeleteOrder(data)"
  67. ></tui-icon>
  68. <view class="order-btn-box">
  69. <text
  70. v-for="buttonItem in getOrderOptionButtonObj(data)" :key="buttonItem.name" class="btn"
  71. :class="[ buttonItem.className ]" @click.stop="handleOrderOptionButtonEvent(buttonItem)"
  72. >
  73. {{ buttonItem.name }}
  74. </text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { orderTypeEnum } from '../../../components/ATFOrderInfo/config'
  82. import { deleteShopOrderApi, cancelShopOrderApi, updateOrderConfirmApi, getProductDetailsByIdApi } from '../../../api/anotherTFInterface'
  83. import { T_SKU_ITEM_DTO_LIST } from '../../../constant'
  84. export default {
  85. name: 'BusinessOrder',
  86. props: {
  87. data: {
  88. type: Object,
  89. required: true
  90. },
  91. showOperate: {
  92. type: Boolean,
  93. default: true
  94. }
  95. },
  96. data() {
  97. return {
  98. orderTypeEnum
  99. }
  100. },
  101. watch: {
  102. },
  103. methods: {
  104. handleDeleteOrder(orderItem) {
  105. uni.showModal({
  106. title: '温馨提示',
  107. content: '您确定要删除该订单吗?',
  108. confirmText: '确定删除',
  109. cancelText: '点错了',
  110. success: async ({ confirm }) => {
  111. if (confirm) {
  112. uni.showLoading()
  113. const { orderId } = orderItem
  114. try {
  115. await deleteShopOrderApi({ orderId })
  116. uni.showToast({
  117. icon: 'none',
  118. title: '删除成功'
  119. })
  120. this.$emit('refresh')
  121. } finally {
  122. uni.hideLoading()
  123. }
  124. }
  125. }
  126. })
  127. },
  128. handleAddEvaluate(skuItem) {
  129. uni.navigateTo({
  130. url: '/another-tf/another-serve/addEvaluate/index?type=1',
  131. success: () => {
  132. uni.$emit('sendAddEvaluateMsg', { addCommentVOData: this.data, commentId: skuItem.commentId })
  133. }
  134. })
  135. },
  136. getOrderOptionButtonObj(orderItem) {
  137. const { state, returnType, afterState, skus = [], collageId, paymentState, orderType } = orderItem
  138. const orderNeedBtnList = [] // 订单应有的btn
  139. // 取消订单
  140. if ([1, 6, 8].includes(state)) {
  141. orderNeedBtnList.push({
  142. name: '取消订单',
  143. className: 'l',
  144. functionName: 'handleCancelOrder',
  145. functionParams: [ orderItem ]
  146. })
  147. }
  148. // 立即付款
  149. if ([1, 8].includes(state)) {
  150. orderNeedBtnList.push({
  151. name: '立即付款',
  152. className: 'r',
  153. functionName: 'handlePayOrder',
  154. functionParams: [ orderItem ]
  155. })
  156. }
  157. // 申请售后
  158. if ([2, 3, 4, 9, 10].includes(state) && [0, 6].includes(Number(afterState)) && (skus[0].ifAdd !== 1) && skus.some((i) => i.classifyId != 1439)) {
  159. orderNeedBtnList.push({
  160. name: '申请售后',
  161. className: 'l',
  162. functionName: 'goAfterSalesService',
  163. functionParams: [ orderItem ]
  164. })
  165. }
  166. // 退款详情
  167. if ([ 1 ].includes(returnType)) {
  168. orderNeedBtnList.push({
  169. name: '退款详情',
  170. className: 'l',
  171. functionName: 'goRefundDetail',
  172. functionParams: [ orderItem ]
  173. })
  174. }
  175. // 查看物流
  176. if ([3, 4].includes(state) && (orderType === 2)) { // orderType:1半子,2商城
  177. orderNeedBtnList.push({
  178. name: '查看物流',
  179. className: 'l',
  180. functionName: 'goLogisticsInformation',
  181. functionParams: [ orderItem ]
  182. })
  183. }
  184. // 确认收货
  185. if ([ 3 ].includes(state)) {
  186. orderNeedBtnList.push({
  187. name: '确认收货',
  188. className: 'r',
  189. functionName: 'handleConfirmReceipt',
  190. functionParams: [ orderItem ]
  191. })
  192. }
  193. // 邀请拼单
  194. if ([ 6 ].includes(state)) {
  195. orderNeedBtnList.push({
  196. name: '邀请拼单',
  197. className: 'r',
  198. functionName: 'goSpellGroup',
  199. functionParams: [ orderItem ]
  200. })
  201. }
  202. // 再次开团 | 再次购买
  203. if ([ 5 ].includes(state)) {
  204. orderNeedBtnList.push({
  205. name: collageId !== 0 ? '再次开团' : '再次购买',
  206. className: 'r',
  207. functionName: 'handleBuyAgainEvent',
  208. functionParams: [ orderItem ]
  209. })
  210. }
  211. return orderNeedBtnList
  212. },
  213. handleOrderOptionButtonEvent(buttonItem) {
  214. const { functionName, functionParams } = buttonItem
  215. if (this[functionName]) {
  216. this[functionName](...functionParams)
  217. } else {
  218. throw new Error(`${buttonItem.name}的function在本VM中不存在`)
  219. }
  220. },
  221. handleCancelOrder(orderItem) {
  222. const modalOptions = {
  223. title: '温馨提示',
  224. content: '您确定要取消该订单吗?',
  225. confirmText: '确定取消',
  226. cancelText: '点错了',
  227. success: async (res) => {
  228. if (res.confirm) {
  229. uni.showLoading()
  230. try {
  231. await cancelShopOrderApi({
  232. orderId: orderItem.orderId
  233. })
  234. this.$emit('refresh')
  235. uni.showToast({
  236. icon: 'none',
  237. title: '取消成功'
  238. })
  239. } finally {
  240. uni.hideLoading()
  241. }
  242. }
  243. }
  244. }
  245. uni.showModal(modalOptions)
  246. },
  247. handlePayOrder(orderItem) {
  248. const { orderPrice, collageId, orderId, shopId } = orderItem
  249. this.$emit('pay-order', {
  250. showPayPopup: true,
  251. pricePay: orderPrice,
  252. shopId,
  253. payInfo: {
  254. collageId,
  255. money: orderPrice,
  256. orderId,
  257. type: 2
  258. }
  259. })
  260. },
  261. goAfterSalesService(orderItem) {
  262. this.go(`/another-tf/another-serve/afterSaleApply/index?orderId=${orderItem.orderId}`)
  263. },
  264. goLogisticsInformation(orderItem) {
  265. this.go(`/another-tf/another-serve/logisticsInfo/index?express=${orderItem.express}&deliverFormid=${orderItem.deliverFormid}`)
  266. },
  267. handleConfirmReceipt(orderItem) {
  268. uni.showModal({
  269. title: '温馨提示',
  270. content: '确定您已经收到货物,否则会造成财产损失',
  271. confirmText: '确定收到',
  272. cancelText: '点错了',
  273. success: (res) => {
  274. if (res.confirm) {
  275. uni.showLoading({
  276. title: '确认中...'
  277. })
  278. updateOrderConfirmApi({
  279. orderId: orderItem.orderId
  280. }).then((result) => {
  281. uni.hideLoading()
  282. uni.showToast({
  283. title: '确认成功'
  284. })
  285. this.$emit('refresh')
  286. })
  287. .catch((e) => {
  288. uni.hideLoading()
  289. })
  290. }
  291. }
  292. })
  293. },
  294. goRefundDetail(orderItem) {
  295. this.go(`/another-tf/another-serve/refundDetails/index?item=${JSON.stringify(orderItem)}`)
  296. },
  297. goSpellGroup(orderItem) {
  298. this.go(`/another-tf/another-serve/inviteSpell/index?collageId=${orderItem.collageId}&orderId=${orderItem.orderId}&type=1&productId=${orderItem.skus[0].productId}&skuId=${orderItem.skus[0].skuId}&shopGroupWorkId=${orderItem.shopGroupWorkId}`)
  299. },
  300. handleBuyAgainEvent(orderItem) {
  301. // 判断拼团ID是否为0
  302. if (orderItem.collageId) {
  303. // 拼团直接跳回商品详情
  304. this.go(`/another-tf/another-serve/goodsDetails/index?shopId=${orderItem.shopId}&productId=${orderItem.skus[0].productId}&skuId=${orderItem.skus[0].skuId}`)
  305. } else {
  306. // 跳转详情
  307. this.handleGoBuyAgain(orderItem)
  308. }
  309. },
  310. async handleGoBuyAgain(orderItem) {
  311. // 循环sku,获取商品详情,并且判断库存
  312. const postAjax = []
  313. orderItem.skus.forEach((skuItem) => {
  314. postAjax.push(this.queryProductDetail(skuItem))
  315. })
  316. // 并发执行
  317. const skuDetailList = await Promise.all(postAjax)
  318. const canNotBuyNameList = []
  319. // 判断库存
  320. skuDetailList.forEach((skuDetail) => {
  321. for (const skuDetailSkuMapKey in skuDetail.map) {
  322. // 判断此SKU是否存在于传进来的item
  323. const findSku = orderItem.skus.find((skuItem) => skuItem.skuId === skuDetail.map[skuDetailSkuMapKey].skuId)
  324. if (findSku) {
  325. if (findSku.number > skuDetail.map[skuDetailSkuMapKey].stockNumber) {
  326. canNotBuyNameList.push(findSku.productName)
  327. }
  328. }
  329. }
  330. })
  331. // 如果有库存不足
  332. if (canNotBuyNameList.length > 0) return this.$showToast(canNotBuyNameList.join(',') + ' 库存不足')
  333. // 制造数据
  334. uni.setStorageSync(T_SKU_ITEM_DTO_LIST, [ {
  335. ifWork: orderItem.ifWork,
  336. shopId: orderItem.shopId,
  337. shopName: orderItem.shopName,
  338. shopDiscountId: orderItem.shopDiscountId,
  339. shopSeckillId: orderItem.shopSeckillId,
  340. skus: orderItem.skus
  341. } ])
  342. this.go('/another-tf/another-serve/orderConfirm/index?type=1')
  343. },
  344. async queryProductDetail(skuItem) {
  345. uni.showLoading({
  346. title: '加载中...',
  347. mask: true
  348. })
  349. const res = await getProductDetailsByIdApi({
  350. shopId: skuItem.shopId,
  351. productId: skuItem.productId,
  352. skuId: skuItem.skuId,
  353. terminal: 1
  354. })
  355. uni.hideLoading()
  356. return res.data
  357. }
  358. }
  359. }
  360. </script>
  361. <style lang="less" scoped>
  362. .item {
  363. margin-bottom: 20rpx;
  364. background: #fff;
  365. border-radius: 10rpx;
  366. .order-list-top {
  367. height: 96rpx;
  368. padding: 0 30rpx;
  369. box-sizing: border-box;
  370. display: flex;
  371. flex-direction: row;
  372. align-items: center;
  373. justify-content: space-between;
  374. border-bottom: 1px solid #eee;
  375. .top-l {
  376. display: flex;
  377. flex-direction: row;
  378. align-items: center;
  379. .shop-img {
  380. width: 36rpx;
  381. height: 36rpx;
  382. margin-right: 10rpx;
  383. }
  384. .shop-name {
  385. font-size: 30rpx;
  386. color: #333;
  387. font-weight: bold;
  388. }
  389. }
  390. .order-status {
  391. font-size: 32upx;
  392. color: #C5AA7B;
  393. font-weight: 400;
  394. }
  395. }
  396. .order-info-box {
  397. padding: 0 30upx;
  398. box-sizing: border-box;
  399. .order-info {
  400. border-bottom: 1px solid #eee;
  401. .order-info-item {
  402. display: flex;
  403. flex-direction: row;
  404. padding: 20upx 0;
  405. .product-img {
  406. width: 180upx;
  407. height: 180upx;
  408. margin-right: 30upx;
  409. }
  410. .info-box {
  411. flex: 1;
  412. display: flex;
  413. flex-direction: column;
  414. justify-content: space-between;
  415. .product-name {
  416. font-size: 26upx;
  417. color: #333;
  418. height: 68upx;
  419. line-height: 34upx;
  420. display: -webkit-box;
  421. overflow: hidden;
  422. text-overflow: ellipsis;
  423. word-break: break-all;
  424. -webkit-box-orient: vertical;
  425. -webkit-line-clamp: 2;
  426. }
  427. .product-sku {
  428. font-size: 24upx;
  429. color: #999;
  430. }
  431. .price-sku-box {
  432. display: flex;
  433. flex-direction: row;
  434. justify-content: space-between;
  435. .product-price {
  436. font-size: 28upx;
  437. color: #333;
  438. font-weight: 400;
  439. .fuhao {
  440. font-size: 28upx;
  441. }
  442. }
  443. .product-num {
  444. display: inline-view;
  445. font-size: 28upx;
  446. margin-left: 20upx;
  447. color: #999;
  448. }
  449. .evaluate {
  450. height: 56upx;
  451. text-align: center;
  452. line-height: 56upx;
  453. font-size: 26upx;
  454. padding: 0 30upx;
  455. color: #C5AA7B;
  456. background: #333333;
  457. }
  458. .evaluate2 {
  459. height: 56upx;
  460. margin-top: 6upx;
  461. text-align: center;
  462. line-height: 56upx;
  463. font-size: 26upx;
  464. padding: 0 30upx;
  465. background: #333333;
  466. color: #C5AA7B;
  467. }
  468. }
  469. }
  470. }
  471. .total-price-box {
  472. font-size: 26upx;
  473. color: #333;
  474. text-align: right;
  475. padding: 30upx 0;
  476. }
  477. }
  478. .btnBox {
  479. width: 100%;
  480. justify-content: flex-end;
  481. .order-btn-box {
  482. padding: 20upx 0;
  483. display: flex;
  484. flex-direction: row;
  485. justify-content: flex-end;
  486. .btn {
  487. display: inline-view;
  488. width: 150upx;
  489. height: 56upx;
  490. text-align: center;
  491. line-height: 56upx;
  492. font-size: 26upx;
  493. color: #333;
  494. margin-left: 20upx;
  495. }
  496. .btn.l {
  497. border: 2rpx solid #333333;
  498. color: #333;
  499. }
  500. .btn.r {
  501. border: 2rpx solid #C5AA7B;
  502. color: #C5AA7B;
  503. }
  504. }
  505. }
  506. .flexSpBetween {
  507. justify-content: space-between;
  508. }
  509. }
  510. }
  511. </style>