Files
kangyuan-mobile/pages/index/components/aistore_tab2.vue
T

259 lines
5.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="tab2-wrap p-x-32 p-b-300">
<view
class="shop-card m-b-24"
v-for="(v, i) in renderList"
:key="v.id || i"
@tap="toListRecord(v)"
>
<view class="shop-card-inner">
<view class="shop-card-top">
<view class="shop-name lineOne">{{ v.name }}</view>
</view>
<view class="meta-row flex-between">
<view class="progress-row">
<view class="progress-bar">
<view
class="progress"
:style="{ width: `${calcProgressPercent(v)}%` }"
></view>
<view class="progress-percent">{{ formatProgressPercent(v) }}%</view>
</view>
</view>
<view class="first-time"
>首次代理时间:{{ sheep.$helper.timeFormat(v.createTime, 'yy-mm-dd hh:MM:ss') }}</view
>
</view>
<view class="stats flex-between">
<view class="stat">
<view class="stat-head flex-between">
<view class="stat-title">店铺总收益</view>
<image class="stat-icon" src="/static/aiStore/earnings.png" mode="aspectFit" />
</view>
<view class="stat-value">¥{{ $fen2yuan(v.earnings) }}</view>
</view>
<view class="stat">
<view class="stat-head flex-between">
<view class="stat-title">绿色积分</view>
<image class="stat-icon" src="/static/aiStore/leaf.png" mode="aspectFit" />
</view>
<view class="stat-value leaf">{{ v.leaf || 0 }}</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed } from 'vue';
import sheep from '@/sheep';
const props = defineProps({
list: {
type: Array,
default: () => [],
},
source: {
type: Number,
default: 1,
},
});
const emit = defineEmits(['addCar', 'update', 'shipment']);
const renderList = computed(() => (Array.isArray(props.list) ? props.list : []));
const calcProgressPercent = (item) => {
const totalRevenue = Number(item?.totalRevenue ?? item?.earnings) || 0;
const userPayPrice = Number(item?.userPayPrice) || 0;
if (userPayPrice <= 0 || totalRevenue <= 0) return 0;
const pct = (totalRevenue / userPayPrice) * 100;
if (!Number.isFinite(pct)) return 0;
return Math.max(0, Math.min(100, pct));
};
const formatProgressPercent = (item) => {
return calcProgressPercent(item).toFixed(2);
};
const toListRecord = (item) => {
const skuId = item?.skuId ?? '';
const url =
'/pages/index/listRecord' +
`?skuId=${encodeURIComponent(String(skuId))}`;
uni.navigateTo({ url });
};
</script>
<style lang="scss" scoped>
.tab2-wrap {
box-sizing: border-box;
}
.shop-card {
background: #ffffff;
border-radius: 24rpx;
overflow: hidden;
box-shadow: 0 16rpx 40rpx rgba(25, 80, 215, 0.12);
}
.shop-card-inner {
padding: 24rpx;
}
.shop-card-top {
align-items: flex-end;
}
.shop-name {
flex: 1;
font-size: 34rpx;
font-weight: 600;
color: #1b2b4b;
letter-spacing: 0.5rpx;
}
.meta-row {
margin-top: 16rpx;
align-items: center;
gap: 16rpx;
}
.first-time {
flex-shrink: 0;
font-size: 22rpx;
color: #5b6b8a;
}
.progress-row {
flex: 1;
min-width: 180rpx;
}
.cover-wrap {
position: relative;
height: 220rpx;
}
.cover {
width: 100%;
height: 100%;
}
.cover-mask {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, rgba(0, 0, 0, 0.55) 100%);
}
.cover-content {
position: absolute;
left: 24rpx;
right: 24rpx;
bottom: 20rpx;
color: #ffffff;
}
.title {
font-size: 34rpx;
font-weight: 600;
letter-spacing: 0.5rpx;
}
.subText {
font-size: 22rpx;
opacity: 0.92;
}
.tag {
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 22rpx;
border: 1rpx solid rgba(255, 255, 255, 0.4);
background: rgba(255, 255, 255, 0.22);
box-sizing: border-box;
}
.body {
padding: 24rpx;
}
.progress-label {
font-size: 24rpx;
color: #5b6b8a;
margin-bottom: 12rpx;
}
.progress-bar {
position: relative;
height: 15rpx;
border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%);
overflow: hidden;
}
.progress {
height: 13rpx;
margin: 1rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
}
.progress-percent {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18rpx;
font-weight: 600;
color: rgba(27, 43, 75, 0.92);
line-height: 1;
pointer-events: none;
text-shadow: 0 0 6rpx rgba(255, 255, 255, 0.9);
}
.stats {
margin-top: 20rpx;
}
.stat {
width: 48%;
padding: 20rpx 22rpx 12rpx;
border-radius: 20rpx;
box-sizing: border-box;
background: #f7faff;
border: 1rpx solid #e6ecfb;
}
.stat-head {
gap: 12rpx;
}
.stat-title {
font-size: 22rpx;
color: #5b6b8a;
}
.stat-icon {
width: 28rpx;
height: 28rpx;
}
.stat-value {
font-size: 42rpx;
font-weight: 700;
color: #ff4d3f;
margin-top: 10rpx;
}
.stat-value.leaf {
color: #12b76a;
}
</style>