123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- <template>
- <view class="item ske-loading">
- <view class="order-list-top">
- <view class="top-l" @click.stop="go(`/another-tf/another-user/shop/shop-detail?shopId=${data.shopId}`)">
- <image :src="data.shopLogo" class="shop-img" />
- <text class="shop-name">{{ data.shopName }}</text>
- <tui-icon name="arrowright" :size="25" color="#999999"></tui-icon>
- </view>
- <view class="order-status">
- {{ data.returnType ? '退款中' : orderTypeEnum[data.state] || '--' }}
- </view>
- </view>
- <view class="order-info-box" @click="go(`/another-tf/another-serve/orderDetails/index?orderId=${data.orderId}`)">
- <view class="order-info">
- <view v-for="(skuItem, skuIndex) in data.skus" :key="skuIndex" class="order-info-item">
- <image :src="skuItem.image" class="product-img default-img" />
- <view class="info-box">
- <text class="product-name">{{ skuItem.productName && skuItem.productName }}</text>
- <view class="product-sku">{{ skuItem.value && skuItem.value }}</view>
- <view class="price-sku-box">
- <view class="box-h flex-items-plus">
- <text class="product-price">
- <text class="fuhao">
- ¥
- </text>
- {{ skuItem.price && skuItem.price }}
- </text>
- <text class="product-num">x {{ skuItem.number && skuItem.number }}</text>
- </view>
- <view v-if="showOperate">
- <view
- v-if="[3, 4].includes(data.state) && (data.orderType === 1)" class="evaluate"
- @click.stop="go(`/another-tf/another-user/product-logistics/index?orderId=${data.orderId}&skuId=${skuItem.skuId}`)"
- >
- 查看物流
- </view>
- <view
- v-if="[4, 10].includes(data.state) && (skuItem.commentId === 0)" class="evaluate2"
- @click.stop="go(`/another-tf/another-serve/evaluate/index?orderId=${data.orderId}&skuId=${skuItem.skuId}`)"
- >
- 立即评价
- </view>
- <view
- v-if="[4, 10].includes(data.state) && (skuItem.commentId !== 0) && (data.skus[0].ifAdd !== 1)" class="evaluate2"
- @click.stop="handleAddEvaluate(skuItem)"
- >
- 追加评价
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="total-price-box">
- <template v-if="data.orderPrice !== undefined || data.discountPrice !== undefined">
- 总价¥{{
- (data.orderPrice + data.logisticsPrice).toFixed(2)
- }},优惠¥{{ data.discountPrice }}
- <span v-if="data.price > 0">
- ,{{ data.state === 1 ? '应付¥' : '实付¥' }}{{ data.price }}
- </span>
- </template>
- </view>
- </view>
- <view v-if="showOperate" class="btnBox flex-items" :class="{ flexSpBetween: data.state === 5 || data.state === 9 }">
- <tui-icon
- v-if="data.state === 5 || data.state === 9" name="delete" :size="14" color="#333333"
- @click.stop="handleDeleteOrder(data)"
- ></tui-icon>
- <view class="order-btn-box">
- <text
- v-for="buttonItem in getOrderOptionButtonObj(data)" :key="buttonItem.name" class="btn"
- :class="[ buttonItem.className ]" @click.stop="handleOrderOptionButtonEvent(buttonItem)"
- >
- {{ buttonItem.name }}
- </text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { orderTypeEnum } from '../../../components/ATFOrderInfo/config'
- import { deleteShopOrderApi, cancelShopOrderApi, updateOrderConfirmApi, getProductDetailsByIdApi } from '../../../api/anotherTFInterface'
- import { T_SKU_ITEM_DTO_LIST } from '../../../constant'
- export default {
- name: 'BusinessOrder',
- props: {
- data: {
- type: Object,
- required: true
- },
- showOperate: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- orderTypeEnum
- }
- },
- watch: {
- },
- methods: {
- handleDeleteOrder(orderItem) {
- uni.showModal({
- title: '温馨提示',
- content: '您确定要删除该订单吗?',
- confirmText: '确定删除',
- cancelText: '点错了',
- success: async ({ confirm }) => {
- if (confirm) {
- uni.showLoading()
- const { orderId } = orderItem
- try {
- await deleteShopOrderApi({ orderId })
- uni.showToast({
- icon: 'none',
- title: '删除成功'
- })
- this.$emit('refresh')
- } finally {
- uni.hideLoading()
- }
- }
- }
- })
- },
- handleAddEvaluate(skuItem) {
- uni.navigateTo({
- url: '/another-tf/another-serve/addEvaluate/index?type=1',
- success: () => {
- uni.$emit('sendAddEvaluateMsg', { addCommentVOData: this.data, commentId: skuItem.commentId })
- }
- })
- },
- getOrderOptionButtonObj(orderItem) {
- const { state, returnType, afterState, skus = [], collageId, paymentState, orderType } = orderItem
- const orderNeedBtnList = [] // 订单应有的btn
- // 取消订单
- if ([1, 6, 8].includes(state)) {
- orderNeedBtnList.push({
- name: '取消订单',
- className: 'l',
- functionName: 'handleCancelOrder',
- functionParams: [ orderItem ]
- })
- }
- // 立即付款
- if ([1, 8].includes(state)) {
- orderNeedBtnList.push({
- name: '立即付款',
- className: 'r',
- functionName: 'handlePayOrder',
- functionParams: [ orderItem ]
- })
- }
- // 申请售后
- if ([2, 3, 4, 9, 10].includes(state) && [0, 6].includes(Number(afterState)) && (skus[0].ifAdd !== 1) && skus.some((i) => i.classifyId != 1439)) {
- orderNeedBtnList.push({
- name: '申请售后',
- className: 'l',
- functionName: 'goAfterSalesService',
- functionParams: [ orderItem ]
- })
- }
- // 退款详情
- if ([ 1 ].includes(returnType)) {
- orderNeedBtnList.push({
- name: '退款详情',
- className: 'l',
- functionName: 'goRefundDetail',
- functionParams: [ orderItem ]
- })
- }
- // 查看物流
- if ([3, 4].includes(state) && (orderType === 2)) { // orderType:1半子,2商城
- orderNeedBtnList.push({
- name: '查看物流',
- className: 'l',
- functionName: 'goLogisticsInformation',
- functionParams: [ orderItem ]
- })
- }
- // 确认收货
- if ([ 3 ].includes(state)) {
- orderNeedBtnList.push({
- name: '确认收货',
- className: 'r',
- functionName: 'handleConfirmReceipt',
- functionParams: [ orderItem ]
- })
- }
- // 邀请拼单
- if ([ 6 ].includes(state)) {
- orderNeedBtnList.push({
- name: '邀请拼单',
- className: 'r',
- functionName: 'goSpellGroup',
- functionParams: [ orderItem ]
- })
- }
- // 再次开团 | 再次购买
- if ([ 5 ].includes(state)) {
- orderNeedBtnList.push({
- name: collageId !== 0 ? '再次开团' : '再次购买',
- className: 'r',
- functionName: 'handleBuyAgainEvent',
- functionParams: [ orderItem ]
- })
- }
- return orderNeedBtnList
- },
- handleOrderOptionButtonEvent(buttonItem) {
- const { functionName, functionParams } = buttonItem
- if (this[functionName]) {
- this[functionName](...functionParams)
- } else {
- throw new Error(`${buttonItem.name}的function在本VM中不存在`)
- }
- },
- handleCancelOrder(orderItem) {
- const modalOptions = {
- title: '温馨提示',
- content: '您确定要取消该订单吗?',
- confirmText: '确定取消',
- cancelText: '点错了',
- success: async (res) => {
- if (res.confirm) {
- uni.showLoading()
- try {
- await cancelShopOrderApi({
- orderId: orderItem.orderId
- })
- this.$emit('refresh')
- uni.showToast({
- icon: 'none',
- title: '取消成功'
- })
- } finally {
- uni.hideLoading()
- }
- }
- }
- }
- uni.showModal(modalOptions)
- },
- handlePayOrder(orderItem) {
- const { orderPrice, collageId, orderId, shopId } = orderItem
- this.$emit('pay-order', {
- showPayPopup: true,
- pricePay: orderPrice,
- shopId,
- payInfo: {
- collageId,
- money: orderPrice,
- orderId,
- type: 2
- }
- })
- },
- goAfterSalesService(orderItem) {
- this.go(`/another-tf/another-serve/afterSaleApply/index?orderId=${orderItem.orderId}`)
- },
- goLogisticsInformation(orderItem) {
- this.go(`/another-tf/another-serve/logisticsInfo/index?express=${orderItem.express}&deliverFormid=${orderItem.deliverFormid}`)
- },
- handleConfirmReceipt(orderItem) {
- uni.showModal({
- title: '温馨提示',
- content: '确定您已经收到货物,否则会造成财产损失',
- confirmText: '确定收到',
- cancelText: '点错了',
- success: (res) => {
- if (res.confirm) {
- uni.showLoading({
- title: '确认中...'
- })
- updateOrderConfirmApi({
- orderId: orderItem.orderId
- }).then((result) => {
- uni.hideLoading()
- uni.showToast({
- title: '确认成功'
- })
- this.$emit('refresh')
- })
- .catch((e) => {
- uni.hideLoading()
- })
- }
- }
- })
- },
- goRefundDetail(orderItem) {
- this.go(`/another-tf/another-serve/refundDetails/index?item=${JSON.stringify(orderItem)}`)
- },
- goSpellGroup(orderItem) {
- 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}`)
- },
- handleBuyAgainEvent(orderItem) {
- // 判断拼团ID是否为0
- if (orderItem.collageId) {
- // 拼团直接跳回商品详情
- this.go(`/another-tf/another-serve/goodsDetails/index?shopId=${orderItem.shopId}&productId=${orderItem.skus[0].productId}&skuId=${orderItem.skus[0].skuId}`)
- } else {
- // 跳转详情
- this.handleGoBuyAgain(orderItem)
- }
- },
- async handleGoBuyAgain(orderItem) {
- // 循环sku,获取商品详情,并且判断库存
- const postAjax = []
- orderItem.skus.forEach((skuItem) => {
- postAjax.push(this.queryProductDetail(skuItem))
- })
- // 并发执行
- const skuDetailList = await Promise.all(postAjax)
- const canNotBuyNameList = []
- // 判断库存
- skuDetailList.forEach((skuDetail) => {
- for (const skuDetailSkuMapKey in skuDetail.map) {
- // 判断此SKU是否存在于传进来的item
- const findSku = orderItem.skus.find((skuItem) => skuItem.skuId === skuDetail.map[skuDetailSkuMapKey].skuId)
- if (findSku) {
- if (findSku.number > skuDetail.map[skuDetailSkuMapKey].stockNumber) {
- canNotBuyNameList.push(findSku.productName)
- }
- }
- }
- })
- // 如果有库存不足
- if (canNotBuyNameList.length > 0) return this.$showToast(canNotBuyNameList.join(',') + ' 库存不足')
- // 制造数据
- uni.setStorageSync(T_SKU_ITEM_DTO_LIST, [ {
- ifWork: orderItem.ifWork,
- shopId: orderItem.shopId,
- shopName: orderItem.shopName,
- shopDiscountId: orderItem.shopDiscountId,
- shopSeckillId: orderItem.shopSeckillId,
- skus: orderItem.skus
- } ])
- this.go('/another-tf/another-serve/orderConfirm/index?type=1')
- },
- async queryProductDetail(skuItem) {
- uni.showLoading({
- title: '加载中...',
- mask: true
- })
- const res = await getProductDetailsByIdApi({
- shopId: skuItem.shopId,
- productId: skuItem.productId,
- skuId: skuItem.skuId,
- terminal: 1
- })
- uni.hideLoading()
- return res.data
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .item {
- margin-bottom: 20rpx;
- background: #fff;
- border-radius: 10rpx;
- .order-list-top {
- height: 96rpx;
- padding: 0 30rpx;
- box-sizing: border-box;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- border-bottom: 1px solid #eee;
- .top-l {
- display: flex;
- flex-direction: row;
- align-items: center;
- .shop-img {
- width: 36rpx;
- height: 36rpx;
- margin-right: 10rpx;
- }
- .shop-name {
- font-size: 30rpx;
- color: #333;
- font-weight: bold;
- }
- }
- .order-status {
- font-size: 32upx;
- color: #C5AA7B;
- font-weight: 400;
- }
- }
- .order-info-box {
- padding: 0 30upx;
- box-sizing: border-box;
- .order-info {
- border-bottom: 1px solid #eee;
- .order-info-item {
- display: flex;
- flex-direction: row;
- padding: 20upx 0;
- .product-img {
- width: 180upx;
- height: 180upx;
- margin-right: 30upx;
- }
- .info-box {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .product-name {
- font-size: 26upx;
- color: #333;
- height: 68upx;
- line-height: 34upx;
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-all;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- }
- .product-sku {
- font-size: 24upx;
- color: #999;
- }
- .price-sku-box {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .product-price {
- font-size: 28upx;
- color: #333;
- font-weight: 400;
- .fuhao {
- font-size: 28upx;
- }
- }
- .product-num {
- display: inline-view;
- font-size: 28upx;
- margin-left: 20upx;
- color: #999;
- }
- .evaluate {
- height: 56upx;
- text-align: center;
- line-height: 56upx;
- font-size: 26upx;
- padding: 0 30upx;
- color: #C5AA7B;
- background: #333333;
- }
- .evaluate2 {
- height: 56upx;
- margin-top: 6upx;
- text-align: center;
- line-height: 56upx;
- font-size: 26upx;
- padding: 0 30upx;
- background: #333333;
- color: #C5AA7B;
- }
- }
- }
- }
- .total-price-box {
- font-size: 26upx;
- color: #333;
- text-align: right;
- padding: 30upx 0;
- }
- }
- .btnBox {
- width: 100%;
- justify-content: flex-end;
- .order-btn-box {
- padding: 20upx 0;
- display: flex;
- flex-direction: row;
- justify-content: flex-end;
- .btn {
- display: inline-view;
- width: 150upx;
- height: 56upx;
- text-align: center;
- line-height: 56upx;
- font-size: 26upx;
- color: #333;
- margin-left: 20upx;
- }
- .btn.l {
- border: 2rpx solid #333333;
- color: #333;
- }
- .btn.r {
- border: 2rpx solid #C5AA7B;
- color: #C5AA7B;
- }
- }
- }
- .flexSpBetween {
- justify-content: space-between;
- }
- }
- }
- </style>
|