389 lines
10 KiB
Vue
389 lines
10 KiB
Vue
<template>
|
|
<view class="flex-row card" @click="goDetail(props.data)">
|
|
<view
|
|
class="image m-r-16 shrink"
|
|
:class="{ w_180: props.source === 3, h_180: props.source === 3 }"
|
|
>
|
|
<image :src="props.data.picUrl" mode="scaleToFill" />
|
|
</view>
|
|
<view class="flex1 flex-column ju-between">
|
|
<view>
|
|
<view class="lineTwo size28 f500 m-b-14">
|
|
{{ props.source === 3 || props.source === 1 ? props.data.spuName : props.data.name }}
|
|
</view>
|
|
<view class="flex-center m-t-14 m-b-14" v-if="props.source === 0">
|
|
<view class="flex1 m-r-28 progressCard card1">
|
|
<view class="progress"></view>
|
|
<view
|
|
class="progress1"
|
|
:style="{
|
|
width:
|
|
Math.ceil(
|
|
(props.data.sales / (props.data.stocks + props.data.sales)) * 100,
|
|
).toFixed(0) + '%',
|
|
}"
|
|
></view>
|
|
<view class="progressText size20 line28"
|
|
>{{
|
|
Math.ceil(
|
|
(props.data.sales / (props.data.stocks + props.data.sales)) * 100,
|
|
).toFixed(0)
|
|
}}%</view
|
|
>
|
|
</view>
|
|
<view class="stockText size24">存量:{{ props.data.stocks }}</view>
|
|
</view>
|
|
<view
|
|
class="flex-center ju-flex-start"
|
|
v-if="props.source === 0"
|
|
:style="{ opacity: show ? 0 : 1 }"
|
|
>
|
|
<view class="size24 m-r-10">
|
|
距离<span class="c15">本场{{ timeText }}</span
|
|
>仅剩
|
|
</view>
|
|
<uni-countdown
|
|
color="#FFFFFF"
|
|
background-color="#FF393A"
|
|
border-color="#FF393A"
|
|
:show-day="false"
|
|
:hour="hour"
|
|
:minute="minute"
|
|
:second="second"
|
|
@timeup="timeup"
|
|
></uni-countdown>
|
|
</view>
|
|
</view>
|
|
<view class="flex-center ju-flex-start">
|
|
<view class="ai-button3 w_110 line38 h_38 radius8 m-t-8 m-b-14 m-r-20" v-if="props.source === 1">
|
|
{{ formatOrderStatus(props.data) }}
|
|
</view>
|
|
<view class="ai-button3 w_92 line38 h_38 radius8 m-t-8 m-b-14" v-if="props.source === 1"
|
|
:class="{'c12 border12':!props.data?.items1[0]?.saleStatus}">
|
|
{{ props.data?.items1[0]?.saleStatus ? '已上架' : '已下架' }}
|
|
</view>
|
|
</view>
|
|
<view>
|
|
<view class="m-b-12 size24 h_52" v-for="(item, i) in props.data.skuArr" :key="i">
|
|
<view
|
|
class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16"
|
|
v-if="item?.properties"
|
|
>
|
|
<view class="lineOne c19">
|
|
{{ item?.properties.length > 1 ? item?.propertyText : item?.properties[0].valueName }}
|
|
</view>
|
|
<view class="flex-center">
|
|
<view class="c19">x{{ item.count }}</view>
|
|
<view class="size28 m-l-12 weight900"
|
|
>¥<span class="">{{
|
|
fen2yuan(item.discountedPrice ? item.discountedPrice : item.price)
|
|
}}</span>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="flex-row ju-between">
|
|
<view class="flex-row al-flex-end">
|
|
<view class="c13 size28 weight900"
|
|
>¥
|
|
<span class="size38" v-if="props.source == 1">{{ fen2yuan(props.data.price) }}</span>
|
|
<span class="size38" v-else-if="props.source == 3">{{
|
|
fen2yuan(
|
|
props.data.discountedTotalPrice
|
|
? props.data.discountedTotalPrice
|
|
: props.data.totalPrice,
|
|
)
|
|
}}</span>
|
|
<span class="size38" v-else>
|
|
{{
|
|
fen2yuan(props.data.discountedPrice ? props.data.discountedPrice : props.data.price)
|
|
}}
|
|
</span>
|
|
</view>
|
|
<!-- <view class="through c12 m-l-8 size20" v-if="!props.source"
|
|
>¥{{
|
|
fen2yuan(
|
|
props.data.discountedPrice
|
|
? props.data.price
|
|
: props.data.totalPrice,
|
|
)
|
|
}}</view
|
|
> -->
|
|
<view class="through c12 m-l-8 size20" v-if="props.source == 3"
|
|
>¥{{
|
|
fen2yuan(props.data.discountedTotalPrice ? props.data.price : props.data.totalPrice)
|
|
}}</view
|
|
>
|
|
</view>
|
|
<view v-if="props.source === 0 && timeText !== '开始'">
|
|
<uni-badge :text="props.data.cartCount" absolute="rightTop" :offset="[8, 3]">
|
|
<view class="ai-button1 w_144" style="color: #fff" @click.stop="addCar">选规格</view>
|
|
</uni-badge>
|
|
</view>
|
|
</view>
|
|
<view v-if="props.source === 1" class="flex-center ju-flex-end m-t-12">
|
|
<view
|
|
class="ai-button3 w_144 m-r-10"
|
|
@click.stop="delayShipment(props.data)"
|
|
v-if="props.data.status === 10"
|
|
>延迟发货</view
|
|
>
|
|
<view
|
|
class="ai-button3 w_144 m-r-10"
|
|
@click.stop="nowShipment(props.data)"
|
|
v-if="props.data.status === 50"
|
|
>立即发货
|
|
</view>
|
|
<view class="ai-button3 w_144" @click.stop="goInfo">查看订单</view>
|
|
<view class="ai-button1 w_144 m-l-16" v-if="props.data.status === 20" @click.stop="confirm"
|
|
>确认收货</view
|
|
>
|
|
<view class="ai-button1 w_144 m-l-16" v-if="props.data.status === 0" @click.stop="goPay"
|
|
>去支付</view
|
|
>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
|
import { ref, onMounted, getCurrentInstance, defineProps, watch } from 'vue';
|
|
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
|
|
import * as api from '@/sheep/api/ai/index';
|
|
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
|
const props = defineProps({
|
|
data: {
|
|
type: Object,
|
|
default() {
|
|
return {};
|
|
},
|
|
},
|
|
source: {
|
|
//0选品广场 1我的店铺 3订单
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
idName: {
|
|
type: String,
|
|
default: 'id',
|
|
},
|
|
});
|
|
let timeText = ref('结束');
|
|
let hour = ref(0);
|
|
let minute = ref(0);
|
|
let second = ref(0);
|
|
let show = ref(false);
|
|
const timeup = () => {
|
|
show.value = true;
|
|
timeChange();
|
|
};
|
|
const timeChange = () => {
|
|
show.value = false;
|
|
let data = props.data;
|
|
let endTime = data.endTime;
|
|
let startTime = data.startTime;
|
|
// 当前时间戳
|
|
let currentTime = Date.now();
|
|
let time = null;
|
|
if (currentTime < startTime) {
|
|
timeText.value = '开始';
|
|
time = startTime - currentTime;
|
|
} else if (currentTime > startTime && currentTime < endTime) {
|
|
timeText.value = '结束';
|
|
time = endTime - currentTime;
|
|
} else {
|
|
show.value = true;
|
|
timeText.value = '已结束';
|
|
}
|
|
if (time) {
|
|
hour.value = Math.floor(time / 1000 / 60 / 60);
|
|
minute.value = Math.floor(time / 1000 / 60) % 60;
|
|
second.value = Math.floor(time / 1000) % 60;
|
|
}
|
|
};
|
|
|
|
watch(
|
|
() => props.data,
|
|
() => {
|
|
timeChange();
|
|
},
|
|
{
|
|
immediate: true,
|
|
deep: true,
|
|
},
|
|
);
|
|
//延迟发货
|
|
function delayShipment(e) {
|
|
uni.showModal({
|
|
title: '延迟发货',
|
|
content: '请您确认是否暂时不需要发货,确认后该产品将为您安排延迟发货',
|
|
confirmColor: '#FA7E31',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
api
|
|
.aiDelayedShipment({
|
|
id: e.orderId,
|
|
status: 50,
|
|
})
|
|
.then((res) => {
|
|
if (res.code === 0) {
|
|
proxy.$emit('shipment');
|
|
}
|
|
});
|
|
} else if (res.cancel) {
|
|
}
|
|
},
|
|
});
|
|
}
|
|
//立即发货
|
|
function nowShipment(e) {
|
|
uni.showModal({
|
|
title: '立即发货',
|
|
content: '请您确认是否需要立即发货,确认后将尽快为您安排发货',
|
|
confirmColor: '#FA7E31',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
api
|
|
.aiPendingShipment({
|
|
id: e.orderId,
|
|
status: 10,
|
|
})
|
|
.then((res) => {
|
|
if (res.code === 0) {
|
|
proxy.$emit('shipment');
|
|
}
|
|
});
|
|
}
|
|
},
|
|
});
|
|
}
|
|
function getPrice(source, data) {
|
|
// console.log(source, data);
|
|
if (source === 3) {
|
|
return props.data.totalPrice;
|
|
} else if (source === 1) {
|
|
return props.data.payPrice;
|
|
} else {
|
|
return props.data.price;
|
|
}
|
|
}
|
|
const addCar = () => {
|
|
proxy.$emit('addCar', props.data);
|
|
};
|
|
const goInfo = () => {
|
|
let id = props.data.orderId;
|
|
// if (props.source === 1) {
|
|
// id = props.data.spu.id;
|
|
// }
|
|
proxy.utils.go('/pages/AI/orderInfo', {
|
|
id: id,
|
|
});
|
|
};
|
|
// 确认收货
|
|
const confirm = () => {
|
|
api
|
|
.confirmReceive({
|
|
id: props.data.orderId,
|
|
})
|
|
.then(() => {
|
|
proxy.$emit('update');
|
|
});
|
|
};
|
|
// 去支付
|
|
const goPay = () => {
|
|
proxy.utils.go('/pages/AI/cashierDesk', {
|
|
id: props.data.orderId,
|
|
payOrderId: props.data.spuId,
|
|
});
|
|
};
|
|
|
|
function goDetail(e) {
|
|
if (props.source == 3) return;
|
|
proxy.utils.go('/pages/AI/comDetails', {
|
|
id: e[props.idName],
|
|
shopId: e.shoppingPlazaId || e.roundTimeId,
|
|
});
|
|
}
|
|
</script>
|
|
<style scoped lang="scss">
|
|
.card {
|
|
background: #ffefe5;
|
|
border-radius: 12rpx;
|
|
padding: 24rpx 20rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.image {
|
|
width: 248rpx;
|
|
height: 248rpx;
|
|
border-radius: 8rpx;
|
|
overflow: hidden;
|
|
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.stockText {
|
|
color: #000;
|
|
}
|
|
|
|
.progressCard {
|
|
position: relative;
|
|
height: 28rpx;
|
|
overflow: hidden;
|
|
|
|
.progress,
|
|
.progress1 {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 28rpx;
|
|
background-color: #7a7995;
|
|
opacity: 0.3;
|
|
border-radius: 40rpx;
|
|
}
|
|
|
|
.progressText {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 14rpx;
|
|
}
|
|
|
|
.progress {
|
|
}
|
|
|
|
.progress1 {
|
|
width: 0%;
|
|
background: linear-gradient(90deg, #f7772e 0%, #ee0a24 98%),
|
|
linear-gradient(96deg, #f7772e 10%, #ee0a24 126%), #fa7e31;
|
|
}
|
|
}
|
|
|
|
:deep(.uni-badge) {
|
|
z-index: 1;
|
|
}
|
|
|
|
:deep(.uni-countdown__number) {
|
|
font-size: 20rpx !important;
|
|
width: 32rpx !important;
|
|
height: 32rpx !important;
|
|
line-height: 32rpx !important;
|
|
}
|
|
|
|
:deep(.uni-countdown__splitor) {
|
|
color: #ff393a !important;
|
|
}
|
|
|
|
.card {
|
|
border-radius: 16rpx;
|
|
overflow: hidden;
|
|
}
|
|
</style>
|