473 lines
13 KiB
Vue
473 lines
13 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 }"
|
||
>
|
||
<view class="corner-badge" v-if="props.source === 0 && cornerText">
|
||
<view class="corner-badge__bg"></view>
|
||
<view class="corner-badge__text">{{ cornerText }}</view>
|
||
</view>
|
||
<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&&false">
|
||
<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-row al-flex-end m-t-14" v-if="props.source === 0">
|
||
<view class="price-stock-row w100">
|
||
<view class="c13 size38 weight900">
|
||
<text class="size28">¥</text
|
||
>{{ fen2yuan(props.data.discountedPrice ? props.data.discountedPrice : props.data.price) }}
|
||
</view>
|
||
<!-- <text class="size20 c_999">存量:{{ props.data.stocks }}</text> -->
|
||
</view>
|
||
</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 footer-row">
|
||
<view
|
||
class="countdown-wrap"
|
||
v-if="props.source === 0"
|
||
:style="{ opacity: show ? 0 : 1 }"
|
||
>
|
||
<view class="size24 countdown-label">
|
||
距离<text>本场{{ timeText }}</text
|
||
>仅剩
|
||
</view>
|
||
<uni-countdown
|
||
color="#FFFFFF"
|
||
background-color="transparent"
|
||
border-color="transparent"
|
||
:show-day="false"
|
||
:hour="hour"
|
||
:minute="minute"
|
||
:second="second"
|
||
@timeup="timeup"
|
||
></uni-countdown>
|
||
</view>
|
||
<view class="flex-row al-flex-end" v-else>
|
||
<view class="c13 size28 weight900"
|
||
>¥
|
||
<text class="size38" v-if="props.source == 1">{{ fen2yuan(props.data.price) }}</text>
|
||
<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 !== '开始'" class="spec-btn-wrap">
|
||
<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>
|
||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||
import { ref, getCurrentInstance, defineProps, watch, computed } from 'vue';
|
||
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
|
||
import * as api from '@/sheep/api/ai/index';
|
||
|
||
const { proxy } = getCurrentInstance();
|
||
|
||
const props = defineProps({
|
||
data: {
|
||
type: Object,
|
||
default() {
|
||
return {};
|
||
},
|
||
},
|
||
source: {
|
||
//0选品广场 1我的店铺 3订单
|
||
type: Number,
|
||
default: 0,
|
||
},
|
||
idName: {
|
||
type: String,
|
||
default: 'id',
|
||
},
|
||
});
|
||
|
||
const cornerText = computed(() => {
|
||
const raw = String(props?.data?.shoppingPlazaName || '').trim();
|
||
if (!raw) return '';
|
||
return raw;
|
||
});
|
||
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: #fff;
|
||
border-radius: 12rpx;
|
||
padding: 24rpx 20rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.image {
|
||
position: relative;
|
||
width: 248rpx;
|
||
height: 248rpx;
|
||
border-radius: 8rpx;
|
||
overflow: hidden;
|
||
|
||
image {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
.corner-badge {
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
width: 0;
|
||
height: 0;
|
||
z-index: 2;
|
||
}
|
||
|
||
.corner-badge__bg {
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
width: 64rpx;
|
||
height: 64rpx;
|
||
background: linear-gradient(135deg, #9eb7ff 0%, #2556ec 100%);
|
||
clip-path: polygon(0 0, 100% 0, 0 100%);
|
||
}
|
||
|
||
.corner-badge__text {
|
||
position: absolute;
|
||
left: 6rpx;
|
||
top: 6rpx;
|
||
width: 35rpx;
|
||
max-height: 52rpx;
|
||
font-size: 14rpx;
|
||
line-height: 18rpx;
|
||
color: #ffffff;
|
||
font-weight: 700;
|
||
transform-origin: 0 0;
|
||
white-space: normal;
|
||
word-break: break-all;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.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;
|
||
background: linear-gradient(
|
||
to bottom right,
|
||
var(--countdown-grad-start) 0%,
|
||
var(--countdown-grad-end) 100%
|
||
) !important;
|
||
border: 0 !important;
|
||
}
|
||
|
||
:deep(.uni-countdown__splitor) {
|
||
color: var(--countdown-grad-end) !important;
|
||
}
|
||
|
||
.card {
|
||
border-radius: 16rpx;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.footer-row {
|
||
align-items: center;
|
||
}
|
||
|
||
.countdown-wrap {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.countdown-label {
|
||
line-height: 34rpx;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
.spec-btn-wrap {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.price-stock-row {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
}
|
||
</style>
|