首页标签特效

This commit is contained in:
zpc 2025-07-25 03:11:54 +08:00
parent 87c6fe7112
commit 9d9aa3d006
5 changed files with 23 additions and 22 deletions

1
components.d.ts vendored
View File

@ -17,7 +17,6 @@ declare module 'vue' {
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']
Search: typeof import('./components/guyu/home/search.vue')['default'] Search: typeof import('./components/guyu/home/search.vue')['default']
SlideLabel: typeof import('./components/guyu/page/slide-label.vue')['default'] SlideLabel: typeof import('./components/guyu/page/slide-label.vue')['default']
SlideLable: typeof import('./components/guyu/page/slide-lable.vue')['default']
Swiper: typeof import('./components/guyu/home/swiper.vue')['default'] Swiper: typeof import('./components/guyu/home/swiper.vue')['default']
Tabs: typeof import('./components/guyu/home/tabs.vue')['default'] Tabs: typeof import('./components/guyu/home/tabs.vue')['default']
} }

View File

@ -2,10 +2,9 @@
<view class="tabs-container"> <view class="tabs-container">
<view class="tabs-wrapper"> <view class="tabs-wrapper">
<template v-for="(item, index) in slideLableList" :key="index"> <template v-for="(item, index) in slideLableList" :key="index">
<view class="tab-item-wrapper" :style="{ width: item.width }"> <view class="tab-item-wrapper" @click="clickTab(index)"
<SlideLabel ref="slideLabels" :style="{ width: item.width }">
style="width: 100%;height:40rpx;border-radius: 50rpx;border: 1rpx solid #9A8F79;" <SlideLabel ref="slideLabels" :defaultColor="item.active ? '#F5D677' : '#fff'">
:defaultColor="item.active ? '#F5D677' : '#fff'" @click="clickTab(index)">
<text class="tab-text myZt-500w">{{ item.name }}</text> <text class="tab-text myZt-500w">{{ item.name }}</text>
</SlideLabel> </SlideLabel>
</view> </view>

View File

@ -2,13 +2,13 @@
<view class="slide-label" :style="containerStyle"> <view class="slide-label" :style="containerStyle">
<!-- 默认颜色背景 --> <!-- 默认颜色背景 -->
<view class="color-bg default-color" :style="{ background: defaultColor }"></view> <view class="color-bg default-color" :style="{ background: defaultColor }"></view>
<!-- 右侧覆盖颜色 --> <!-- 右侧覆盖颜色 -->
<view class="color-bg right-cover" :style="rightCoverStyle" v-if="showRightCover"></view> <view class="color-bg right-cover" :style="rightCoverStyle" v-if="showRightCover"></view>
<!-- 左侧覆盖颜色 --> <!-- 左侧覆盖颜色 -->
<view class="color-bg left-cover" :style="leftCoverStyle" v-if="showLeftCover"></view> <view class="color-bg left-cover" :style="leftCoverStyle" v-if="showLeftCover"></view>
<!-- 内容层 --> <!-- 内容层 -->
<view class="content-layer"> <view class="content-layer">
<slot>{{ content }}</slot> <slot>{{ content }}</slot>
@ -34,12 +34,12 @@ const props = defineProps({
// //
height: { height: {
type: [Number, String], type: [Number, String],
default: '80rpx' default: '45rpx'
}, },
// //
borderRadius: { borderRadius: {
type: [Number, String], type: [Number, String],
default: '8rpx' default: '25rpx'
}, },
// //
textColor: { textColor: {
@ -96,19 +96,19 @@ const leftCoverStyle = computed(() => {
function coverFromRight(color, percent = 0) { function coverFromRight(color, percent = 0) {
// //
const safePercent = Math.max(0, Math.min(100, percent)); const safePercent = Math.max(0, Math.min(100, percent));
// //
rightCoverColor.value = color; rightCoverColor.value = color;
rightCoverPercent.value = safePercent; rightCoverPercent.value = safePercent;
// //
showRightCover.value = safePercent > 0; showRightCover.value = safePercent > 0;
// 0 // 0
if (safePercent === 0) { if (safePercent === 0) {
showRightCover.value = false; showRightCover.value = false;
} }
// //
emit('coverChange', { emit('coverChange', {
direction: 'right', direction: 'right',
@ -125,19 +125,19 @@ function coverFromRight(color, percent = 0) {
function coverFromLeft(color, percent = 0) { function coverFromLeft(color, percent = 0) {
// //
const safePercent = Math.max(0, Math.min(100, percent)); const safePercent = Math.max(0, Math.min(100, percent));
// //
leftCoverColor.value = color; leftCoverColor.value = color;
leftCoverPercent.value = safePercent; leftCoverPercent.value = safePercent;
// //
showLeftCover.value = safePercent > 0; showLeftCover.value = safePercent > 0;
// 0 // 0
if (safePercent === 0) { if (safePercent === 0) {
showLeftCover.value = false; showLeftCover.value = false;
} }
// //
emit('coverChange', { emit('coverChange', {
direction: 'left', direction: 'left',
@ -169,6 +169,7 @@ defineExpose({
position: relative; position: relative;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
border: 1rpx solid #9A8F79;
} }
.color-bg { .color-bg {

View File

@ -19,7 +19,7 @@
</view> </view>
<swiper class="swiper" :style="[{ height: swiperHeight + 'px' }]" :current="current" <swiper class="swiper" :style="[{ height: swiperHeight + 'px' }]" :current="current"
@transition="swiperTransition" @animationfinish="swiperAnimationfinish"> @transition="swiperTransition" @animationfinish="swiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in tabList" :key="index"> <swiper-item class="swiper-item" v-for="(item, index) in homeData?.categories" :key="index">
<guyu-home-goods-list ref="swiperList" :tabIndex="index" :currentIndex="current" <guyu-home-goods-list ref="swiperList" :tabIndex="index" :currentIndex="current"
@heightChanged="heightChanged"> @heightChanged="heightChanged">
</guyu-home-goods-list> </guyu-home-goods-list>

View File

@ -140,9 +140,11 @@ function getSystemInfoSync(useCache = false) {
const infoTypes = ['DeviceInfo', 'AppBaseInfo', 'WindowInfo']; const infoTypes = ['DeviceInfo', 'AppBaseInfo', 'WindowInfo'];
const { deviceInfo, appBaseInfo, windowInfo } = infoTypes.reduce((acc, key) => { const { deviceInfo, appBaseInfo, windowInfo } = infoTypes.reduce((acc, key) => {
const method = `get${key}`; const method = `get${key}`;
if (uni[method] && uni.canIUse(method)) { try{
acc[key.charAt(0).toLowerCase() + key.slice(1)] = uni[method](); if (uni[method] && uni.canIUse(method)) {
} acc[key.charAt(0).toLowerCase() + key.slice(1)] = uni[method]();
}
}catch{}
return acc; return acc;
}, {}); }, {});
// 如果deviceInfo、appBaseInfo和windowInfo都可以从各自专属的api中获取则整合它们的数据 // 如果deviceInfo、appBaseInfo和windowInfo都可以从各自专属的api中获取则整合它们的数据