style: 风云榜样式调整

This commit is contained in:
2026-06-26 13:33:38 +08:00
parent 2b54995709
commit 655eceafbc
5 changed files with 190 additions and 227 deletions
+49 -4
View File
@@ -4,6 +4,10 @@
class="image m-r-16 shrink" class="image m-r-16 shrink"
:class="{ w_180: props.source === 3, h_180: props.source === 3 }" :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" /> <image :src="props.data.picUrl" mode="scaleToFill" />
</view> </view>
<view class="flex1 flex-column ju-between"> <view class="flex1 flex-column ju-between">
@@ -156,14 +160,13 @@
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup>
import { fen2yuan } from '@/sheep/hooks/useGoods'; import { fen2yuan } from '@/sheep/hooks/useGoods';
import { ref, onMounted, getCurrentInstance, defineProps, watch } from 'vue'; import { ref, getCurrentInstance, defineProps, watch, computed } from 'vue';
import { formatOrderStatus } from '@/sheep/hooks/useGoods'; import { formatOrderStatus } from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/ai/index'; import * as api from '@/sheep/api/ai/index';
import { makeViewBoxTransform } from 'zrender/lib/tool/parseSVG';
const { proxy } = getCurrentInstance() as any; const { proxy } = getCurrentInstance();
const props = defineProps({ const props = defineProps({
data: { data: {
@@ -182,6 +185,12 @@ import { makeViewBoxTransform } from 'zrender/lib/tool/parseSVG';
default: 'id', default: 'id',
}, },
}); });
const cornerText = computed(() => {
const raw = String(props?.data?.shoppingPlazaName || '').trim();
if (!raw) return '';
return raw;
});
let timeText = ref('结束'); let timeText = ref('结束');
let hour = ref(0); let hour = ref(0);
let minute = ref(0); let minute = ref(0);
@@ -328,6 +337,7 @@ import { makeViewBoxTransform } from 'zrender/lib/tool/parseSVG';
} }
.image { .image {
position: relative;
width: 248rpx; width: 248rpx;
height: 248rpx; height: 248rpx;
border-radius: 8rpx; border-radius: 8rpx;
@@ -339,6 +349,41 @@ import { makeViewBoxTransform } from 'zrender/lib/tool/parseSVG';
} }
} }
.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 { .stockText {
color: #000; color: #000;
} }
+43 -4
View File
@@ -6,7 +6,7 @@
:showLeftButton="false" :showLeftButton="false"
> >
<view class="ai-store-page h100 flex-column"> <view class="ai-store-page h100 flex-column">
<view class="top-area"> <view class="top-area" :class="{'top-area1': index === 1}">
<view class="tab-header"> <view class="tab-header">
<view <view
v-for="(tab, i) in nav" v-for="(tab, i) in nav"
@@ -182,6 +182,23 @@
const timeRound = ref([]); const timeRound = ref([]);
const selectedTimeId = ref(null); const selectedTimeId = ref(null);
const navName = ref(''); const navName = ref('');
const timeRoundNameMap = computed(() => {
const arr = Array.isArray(timeRound.value) ? timeRound.value : [];
const map = {};
arr.forEach((it) => {
const id = it?.id;
if (id === null || id === undefined) return;
map[String(id)] = String(it?.name || '').trim();
});
return map;
});
const attachShoppingPlazaName = (item) => {
const map = timeRoundNameMap.value;
const id = item?.shoppingPlazaId ?? item?.roundTimeId;
const name = id === null || id === undefined ? '' : map[String(id)] || '';
return { ...item, shoppingPlazaName: name };
};
function changeTimeRound(e) { function changeTimeRound(e) {
navName.value = e.name; navName.value = e.name;
@@ -340,7 +357,7 @@
pageNo: mescroll?.num || 1, pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10, pageSize: mescroll?.size || 10,
keyWord: searchText.value, keyWord: searchText.value,
timeId: selectedTimeId.value, // timeId: selectedTimeId.value,
...mescroll.params, ...mescroll.params,
}); });
} }
@@ -381,7 +398,8 @@
}; };
}); });
} else { } else {
curPageData = res.data?.list || []; const raw = Array.isArray(res.data?.list) ? res.data.list : [];
curPageData = raw.map(attachShoppingPlazaName);
} }
if (mescroll?.num === 1) dataList.value = []; if (mescroll?.num === 1) dataList.value = [];
@@ -389,6 +407,22 @@
pageCommodity.value?.getState(true, curPageData.length); pageCommodity.value?.getState(true, curPageData.length);
}; };
watch(
timeRound,
() => {
if (index.value !== 0) return;
if (!Array.isArray(dataList.value) || !dataList.value.length) return;
const map = timeRoundNameMap.value;
dataList.value = dataList.value.map((it) => {
const id = it?.shoppingPlazaId ?? it?.roundTimeId;
const name = id === null || id === undefined ? '' : map[String(id)] || '';
if (name === it?.shoppingPlazaName) return it;
return { ...it, shoppingPlazaName: name };
});
},
{ deep: true },
);
const paymentRef = ref(null); const paymentRef = ref(null);
const addCar = (data) => { const addCar = (data) => {
paymentRef.value?.addCar(data); paymentRef.value?.addCar(data);
@@ -442,8 +476,13 @@
.top-area { .top-area {
padding: 0 24rpx 24rpx; padding: 0 24rpx 24rpx;
background: #2556ec; background: url('/static/ai_bg.png') no-repeat center top;
background-size: cover;
// border-radius: 0 0 30rpx 30rpx;
}
.top-area1{
border-radius: 0 0 30rpx 30rpx; border-radius: 0 0 30rpx 30rpx;
background: #2556ec;
} }
.tab-header { .tab-header {
@@ -1,59 +1,53 @@
<template> <template>
<view class="earnings-carousel" v-if="active"> <view class="earnings-carousel">
<view class="earnings-header"> <view class="earnings-header">
<view class="earnings-title"> <view class="earnings-title">
<view class="earnings-title__icon"> <view class="earnings-title__icon">
<uni-icons type="medal-filled" size="16" color="#ffffff" /> <image class="earnings-title__icon-img" src="/static/icon/medal.png" mode="aspectFit" />
</view> </view>
<view class="earnings-title__text">销量风云榜</view> <view class="earnings-title__text">销量风云榜</view>
</view> </view>
</view> </view>
<view class="earnings-pager" @touchstart="pause()" @touchend="resume()" @touchcancel="resume()"> <swiper
<view class="earnings-track" :style="trackStyle" @transitionend="onTrackTransitionEnd"> class="earnings-swiper"
:current="currentPageIndex"
:autoplay="autoplay"
:interval="interval"
:duration="duration"
:circular="swiperPages.length > 1"
:disable-touch="true"
:indicator-dots="false"
@change="onSwiperChange"
>
<swiper-item v-for="(page, pageIndex) in swiperPages" :key="pageIndex">
<view class="earnings-page"> <view class="earnings-page">
<view class="earnings-row"> <view class="earnings-row">
<view class="rank-card" v-for="(item, i) in currentItems" :key="item.orderItemId || `a-${i}`"> <view class="rank-card" v-for="(item, i) in page" :key="item.orderItemId || i">
<view class="rank-top"> <view class="rank-top">
<image class="rank-avatar" :src="getAvatar(item)" mode="aspectFill" /> <image class="rank-avatar" :src="getAvatar(item)" mode="aspectFill" />
</view> </view>
<view class="rank-name lineOne">{{ item.nickname || maskMobile(item.mobile) || '-' }}</view> <view class="rank-name lineOne">{{ item.nickname || maskMobile(item.mobile) || '-' }}</view>
<view class="rank-goods">
<image class="rank-goods__img" :src="getGoodsPic(item)" mode="aspectFill" />
<view class="rank-goods__mask">
<view class="rank-rate">{{ formatPercent(item.progress) }}</view> <view class="rank-rate">{{ formatPercent(item.progress) }}</view>
<view class="rank-progress"> <view class="rank-progress">
<view class="rank-progress__bar" :style="{ width: `${clampProgress(item.progress)}%` }" /> <view class="rank-progress__bar" :style="{ width: `${clampProgress(item.progress)}%` }" />
</view> </view>
<view class="rank-goods"> </view>
<image class="rank-goods__img" :src="getGoodsPic(item)" mode="aspectFill" />
</view> </view>
<view class="rank-goods__name lineOne">{{ item.spuName || '-' }}</view> <view class="rank-goods__name lineOne">{{ item.spuName || '-' }}</view>
</view> </view>
</view> </view>
</view> </view>
<view class="earnings-page"> </swiper-item>
<view class="earnings-row"> </swiper>
<view class="rank-card" v-for="(item, i) in nextItems" :key="item.orderItemId || `b-${i}`">
<view class="rank-top">
<image class="rank-avatar" :src="getAvatar(item)" mode="aspectFill" />
</view>
<view class="rank-name lineOne">{{ item.nickname || maskMobile(item.mobile) || '-' }}</view>
<view class="rank-rate">{{ formatPercent(item.progress) }}</view>
<view class="rank-progress">
<view class="rank-progress__bar" :style="{ width: `${clampProgress(item.progress)}%` }" />
</view>
<view class="rank-goods">
<image class="rank-goods__img" :src="getGoodsPic(item)" mode="aspectFill" />
</view>
<view class="rank-goods__name lineOne">{{ item.spuName || '-' }}</view>
</view>
</view>
</view>
</view>
</view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, onUnmounted, ref, watch } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { earningsPage } from '@/sheep/api/ai/index'; import { earningsPage } from '@/sheep/api/ai/index';
@@ -66,50 +60,40 @@
type: Number, type: Number,
default: 5, default: 5,
}, },
autoplay: {
type: Boolean,
default: true,
},
interval: { interval: {
type: Number, type: Number,
default: 0, default: 5000,
}, },
duration: { duration: {
type: Number, type: Number,
default: 6000, default: 450,
},
speed: {
type: Number,
default: 90,
},
maxItems: {
type: Number,
default: 25,
}, },
}); });
const currentPageNo = ref(1); const currentPageIndex = ref(0);
const total = ref(0); const total = ref(0);
const pagesMap = ref({}); const pagesMap = ref({});
const loadingMap = ref({}); const loadingMap = ref({});
const isPaused = ref(false);
const offsetPercent = ref(0);
const isTransitioning = ref(false);
const stopFlag = ref(false);
const displayCurrentNo = ref(1);
const displayNextNo = ref(1);
const frozenNextNo = ref(1);
let nextTimer = null;
const normalizeSize = (val, def) => { const normalizeSize = (val, def) => {
const n = Math.floor(Number(val)); const n = Math.floor(Number(val));
return Number.isFinite(n) && n > 0 ? n : def; return Number.isFinite(n) && n > 0 ? n : def;
}; };
const autoplay = computed(() => props.autoplay && swiperPages.value.length > 1);
const interval = computed(() => { const interval = computed(() => {
const n = Number(props.interval); const n = Number(props.interval);
return Number.isFinite(n) && n >= 0 ? n : 0; return Number.isFinite(n) && n > 0 ? n : 5000;
}); });
const duration = computed(() => { const duration = computed(() => {
const n = Number(props.duration); const n = Number(props.duration);
return Number.isFinite(n) && n > 0 ? n : 6000; return Number.isFinite(n) && n >= 0 ? n : 450;
}); });
const totalPages = computed(() => { const totalPages = computed(() => {
@@ -135,35 +119,27 @@
return [...arr, ...Array.from({ length: size - arr.length }, () => ({}))]; return [...arr, ...Array.from({ length: size - arr.length }, () => ({}))];
}; };
const isPageLoaded = (pageNo) => { const pages = computed(() => {
const no = normalizePageNo(pageNo); const arr = [];
return Array.isArray(pagesMap.value[String(no)]); const pageCount = totalPages.value || 1;
}; for (let i = 0; i < pageCount; i += 1) {
const key = String(i + 1);
const nextPageNo = computed(() => normalizePageNo(currentPageNo.value + 1)); arr.push(normalizePageList(pagesMap.value[key]));
}
const currentItems = computed(() => { return arr;
const key = String(displayCurrentNo.value);
return normalizePageList(pagesMap.value[key]);
}); });
const nextItems = computed(() => { const swiperPages = computed(() => {
const key = String(displayNextNo.value); if (!pages.value.length) return [];
return normalizePageList(pagesMap.value[key]); if (totalPages.value === 1) return [pages.value[0], pages.value[0]];
}); return pages.value;
const trackStyle = computed(() => {
const d = isTransitioning.value ? duration.value : 0;
return {
transform: `translate3d(${offsetPercent.value}%, 0, 0)`,
transitionProperty: 'transform',
transitionDuration: `${d}ms`,
transitionTimingFunction: 'linear',
};
}); });
const fetchPage = async (pageNo) => { const fetchPage = async (pageNo) => {
const res = await earningsPage({ pageNo, pageSize: normalizeSize(props.pageSize, 5) }).catch(() => ({ code: -1 })); const res = await earningsPage({
pageNo,
pageSize: normalizeSize(props.pageSize, 5),
}).catch(() => ({ code: -1 }));
if (res?.code !== 0) return; if (res?.code !== 0) return;
const data = res?.data || {}; const data = res?.data || {};
total.value = Number(data?.total) || 0; total.value = Number(data?.total) || 0;
@@ -171,10 +147,10 @@
pagesMap.value[String(pageNo)] = list; pagesMap.value[String(pageNo)] = list;
}; };
const ensurePageLoaded = (pageNo) => { const ensurePageLoaded = (pageNo, force = false) => {
const no = normalizePageNo(pageNo); const no = normalizePageNo(pageNo);
const key = String(no); const key = String(no);
if (pagesMap.value[key]) return Promise.resolve(); if (!force && pagesMap.value[key]) return Promise.resolve();
if (loadingMap.value[key]) return loadingMap.value[key]; if (loadingMap.value[key]) return loadingMap.value[key];
const p = fetchPage(no).finally(() => { const p = fetchPage(no).finally(() => {
loadingMap.value[key] = null; loadingMap.value[key] = null;
@@ -183,67 +159,15 @@
return p; return p;
}; };
const clearAllTimers = () => { const onSwiperChange = (e) => {
if (nextTimer) clearTimeout(nextTimer); const next = Number(e?.detail?.current);
nextTimer = null; if (!Number.isFinite(next)) return;
}; currentPageIndex.value = next;
const currentPageNo = totalPages.value > 1 ? next + 1 : 1;
const clearNextTimer = () => { ensurePageLoaded(currentPageNo, true);
if (nextTimer) clearTimeout(nextTimer); if (totalPages.value > 1) {
nextTimer = null; ensurePageLoaded(currentPageNo + 1);
};
const startTransition = () => {
if (!props.active || stopFlag.value || isPaused.value) return;
if (isTransitioning.value) return;
if ((totalPages.value || 1) <= 1) return;
ensurePageLoaded(nextPageNo.value);
ensurePageLoaded(nextPageNo.value + 1);
const candidateNext = isPageLoaded(nextPageNo.value) ? nextPageNo.value : displayCurrentNo.value;
frozenNextNo.value = candidateNext;
displayNextNo.value = candidateNext;
isTransitioning.value = true;
offsetPercent.value = -50;
};
const scheduleNext = () => {
clearNextTimer();
if (!props.active || stopFlag.value || isPaused.value || isTransitioning.value) return;
if ((totalPages.value || 1) <= 1) return;
nextTimer = setTimeout(() => {
startTransition();
}, interval.value);
};
const onTrackTransitionEnd = () => {
if (!isTransitioning.value) return;
isTransitioning.value = false;
const target = frozenNextNo.value || displayCurrentNo.value;
if (target !== displayCurrentNo.value) {
currentPageNo.value = target;
displayCurrentNo.value = target;
} }
displayNextNo.value = displayCurrentNo.value;
offsetPercent.value = 0;
setTimeout(() => {
if (!props.active || stopFlag.value) return;
const next = nextPageNo.value;
displayNextNo.value = isPageLoaded(next) ? next : displayCurrentNo.value;
ensurePageLoaded(next);
ensurePageLoaded(next + 1);
if (isPaused.value) return;
if (interval.value > 0) {
scheduleNext();
return;
}
startTransition();
}, 16);
clearNextTimer();
}; };
const clampProgress = (val) => { const clampProgress = (val) => {
@@ -273,30 +197,13 @@
return `${s.slice(0, 3)}****${s.slice(7)}`; return `${s.slice(0, 3)}****${s.slice(7)}`;
}; };
const reset = () => { const reset = async () => {
currentPageNo.value = 1; currentPageIndex.value = 0;
total.value = 0; total.value = 0;
pagesMap.value = {}; pagesMap.value = {};
loadingMap.value = {}; loadingMap.value = {};
isPaused.value = false; await ensurePageLoaded(1);
offsetPercent.value = 0; await ensurePageLoaded(2);
isTransitioning.value = false;
stopFlag.value = false;
displayCurrentNo.value = 1;
displayNextNo.value = 1;
frozenNextNo.value = 1;
clearAllTimers();
};
const pause = () => {
isPaused.value = true;
clearNextTimer();
};
const resume = () => {
if (!isPaused.value) return;
isPaused.value = false;
if (!isTransitioning.value) scheduleNext();
}; };
watch( watch(
@@ -304,62 +211,27 @@
(val) => { (val) => {
if (val) { if (val) {
reset(); reset();
ensurePageLoaded(1).finally(() => {
ensurePageLoaded(2);
ensurePageLoaded(3);
displayCurrentNo.value = 1;
displayNextNo.value = 1;
const next = nextPageNo.value;
displayNextNo.value = isPageLoaded(next) ? next : displayCurrentNo.value;
scheduleNext();
});
} else {
stopFlag.value = true;
clearAllTimers();
} }
}, },
{ immediate: true }, { immediate: true },
); );
watch( watch(
() => currentPageNo.value, () => props.pageSize,
() => { () => {
if (props.active) ensurePageLoaded(nextPageNo.value); if (props.active) reset();
}, },
); );
watch( onMounted(() => {
totalPages, if (props.active) reset();
(tp) => {
if (!props.active) return;
if ((tp || 1) <= 1) {
clearNextTimer();
return;
}
scheduleNext();
},
);
watch(
() => [props.pageSize, props.interval, props.duration],
() => {
if (!props.active) return;
offsetPercent.value = 0;
isTransitioning.value = false;
scheduleNext();
},
);
onUnmounted(() => {
stopFlag.value = true;
clearAllTimers();
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.earnings-carousel { .earnings-carousel {
margin-top: 18rpx; margin-top: 18rpx;
padding: 16rpx 12rpx 18rpx; padding: 16rpx 12rpx 0;
border-radius: 24rpx; border-radius: 24rpx;
background: linear-gradient(90deg, #4a7bff 0%, #9eb7ff 100%); background: linear-gradient(90deg, #4a7bff 0%, #9eb7ff 100%);
box-sizing: border-box; box-sizing: border-box;
@@ -368,7 +240,7 @@
.earnings-header { .earnings-header {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 6rpx 12rpx; padding: 0 6rpx 0;
} }
.earnings-title { .earnings-title {
@@ -387,29 +259,25 @@
justify-content: center; justify-content: center;
} }
.earnings-title__icon-img {
width: 28rpx;
height: 28rpx;
display: block;
}
.earnings-title__text { .earnings-title__text {
font-size: 32rpx; font-size: 32rpx;
font-weight: 900; font-weight: 900;
color: #1d4ed8; color: #1d4ed8;
} }
.earnings-pager { .earnings-swiper {
height: 310rpx; height: 280rpx;
overflow: hidden;
}
.earnings-track {
width: 200%;
height: 100%;
display: flex;
align-items: center;
will-change: transform;
transform: translate3d(0, 0, 0);
} }
.earnings-page { .earnings-page {
width: 50%; width: 100%;
height: 100%; height: 270rpx;
display: flex; display: flex;
align-items: center; align-items: center;
} }
@@ -455,29 +323,29 @@
} }
.rank-rate { .rank-rate {
margin-top: 8rpx;
font-size: 24rpx; font-size: 24rpx;
font-weight: 900; font-weight: 900;
color: #2556ec; color: #ffffff;
text-align: center; line-height: 1;
} }
.rank-progress { .rank-progress {
margin-top: 10rpx; margin-top: 8rpx;
height: 12rpx; height: 12rpx;
border-radius: 999rpx; border-radius: 999rpx;
background: rgba(37, 86, 236, 0.14); background: rgba(255, 255, 255, 0.5);
overflow: hidden; overflow: hidden;
} }
.rank-progress__bar { .rank-progress__bar {
height: 100%; height: 100%;
border-radius: 999rpx; border-radius: 999rpx;
background: linear-gradient(90deg, #2d8df8 0%, #3c5ff9 100%); background: linear-gradient(90deg, #ffb347 0%, #ff8a00 100%);
} }
.rank-goods { .rank-goods {
margin-top: 14rpx; margin-top: 14rpx;
position: relative;
border-radius: 14rpx; border-radius: 14rpx;
background: #f3f5f8; background: #f3f5f8;
overflow: hidden; overflow: hidden;
@@ -489,6 +357,17 @@
height: 100%; height: 100%;
} }
.rank-goods__mask {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 10rpx;
background: rgba(17, 24, 39, 0.32);
box-sizing: border-box;
}
.rank-goods__name { .rank-goods__name {
margin-top: 10rpx; margin-top: 10rpx;
font-size: 22rpx; font-size: 22rpx;
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B