首页标签特效
This commit is contained in:
parent
87c6fe7112
commit
9d9aa3d006
1
components.d.ts
vendored
1
components.d.ts
vendored
|
|
@ -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']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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中获取,则整合它们的数据
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user