card滑动效果

news/2025/10/14 11:34:17/文章来源:https://www.cnblogs.com/yjd-05/p/19140309

 

image

image

 

<template><view class="member-benefits"><!-- 卡片滑动容器 --><view class="card-slider" :style="{background: currentSliderGradient,transition: 'background 0.5s ease'  // 渐变背景平滑过渡}"><view class="title">表头</view><view class="slider-track" :style="{ transform: `translateX(-${currentIndex * (110 - overlapPercent)}%)` }"@touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd"@touchcancel="handleTouchEnd"><view v-for="(level, index) in levels" :key="level.level" class="benefit-card" :class="{'active-card': index === currentIndex,'prev-card': index === currentIndex - 1,'next-card': index === currentIndex + 1}" :style="{ background: currentCardSliderGradient }"><view class="slider-stau">{{ level.status }}</view><view class="slider-con"><view><h2 class="benefit-title" :style="{ color: currentLevelData.testCol }">{{ level.level }}</h2><p class="benefit-desc1" :style="{ color: currentLevelData.testCol }">匹配 <text :style="{ color: currentLevelData.pricColor }">{{ level.matchTime }}</text>服务期 <text :style="{ color: currentLevelData.pricColor }">{{ level.cycle }}</text></p></view><image class="slider-con_img" src="https://qiniu.5ug.top/alabo/dev_uploads/lan/logo.png" /></view><p class="benefit-desc" :style="{ color: currentLevelData.testCol }">权益 <text :style="{ color: currentLevelData.pricColor }">{{ level.price }}</text>券 <text :style="{ color: currentLevelData.pricColor }">{{ level.ticket }}</text></p></view></view><!-- 提示语 --><view class="tips" v-if="currentLevelData.tips1" :style="{ background: currentLevelData.tipsBg }"><view class="tips-con"><view class="tips-tips1">{{ currentLevelData.tips1 }}</view><view>{{ currentLevelData.tips2 }}<text style="color:#fdca5c">{{ currentLevelData.profit }}</text></view></view><image class="tips-img" src="https://qiniu.5ug.top/alabo/dev_uploads/lan/logo.png" /></view></view><view class="upgrade-con"><view class="upgrade-tips"> 轮播文字 </view><view class="upgrade-section"><h3 class="upgrade-title">title</h3><ul class="upgrade-tasks"><!-- <li v-for="(task, index) in currentLevelData.upgrade.tasks" :key="index" class="upgrade-tasks_li"> --><li v-for="(task, index) in tasks" :key="index" class="upgrade-tasks_li"><view class="upgrade-tasks_li_t"><img :src="task.icon" alt="任务图标" class="upgrade-tasks_li_ticon" /><span>{{ task.text }}</span></view><view v-for="(dItem, dIndex) in task.device" :key="dIndex" class="upgrade-device"><text class="upgrade-device_dian">・</text>text1{{ dItem.v1 }}text2{{ dItem.examine }},text3{{ dItem.discount }}</view></li></ul></view></view><view v-if="currentLevelData.button" class="upgrade-button">¥ price{{ currentLevelData.button.price1 }}元+券{{ currentLevelData.button.price2 }}元 {{currentLevelData.button.text}}</view></view>
</template><script>
export default {data() {return {currentIndex: 0, // 当前卡片索引startX: 0, // 触摸起始X坐标moveX: 0, // 触摸移动X坐标isDragging: false, // 是否正在拖动overlapPercent: 20, // 卡片重叠百分比(控制前后卡片显示范围)levels: [{level: "title1",cardSliderGradient: 'linear-gradient(to right, #f5fcfc, #d2e0e7, #d5e6ec, #a3bac6)',sliderGradient: "linear-gradient(to bottom, #7d979e 0%, #446f7d 100%)",status: '未达成',matchTime: '1-7天',cycle: '5天', price: '1000元',ticket: '100元',pricColor: '#446f7d',testCol: "#88939b",button: { price1: 1000, price2: 100, text: "直接开通" },},{level: "title2",cardSliderGradient: 'linear-gradient(to right, #fffbf1, #fbdcb0, #fae9d1, #fab35d)',sliderGradient: "linear-gradient(to bottom, #ca834a 0%, #8e5324 100%)",status: '未达成',matchTime: '1-7天',cycle: '6天',price: '3000元', ticket: '100元',pricColor: '#8e5324',testCol: "#b78d64",button: { price1: 3000, price2: 100, text: "直接开通" },},],tasks: [{icon: "https://qiniu.5ug.top/alabo/dev_uploads/lan/logo.png",text: "title5",device: [{ v1: '《等级1》', examine: '8个任务', discount: '70折' },{ v1: '《等级2》', examine: '6个任务', discount: '78折' },]},{icon: "https://qiniu.5ug.top/alabo/dev_uploads/lan/logo.png",text: "title6",device: [{ v1: '《任务1》', examine: '三个四星', discount: '90折' },{ v1: '《任务2》', examine: '三个三星', discount: '92折' },]},],};},computed: {currentSliderGradient() {return this.levels[this.currentIndex].sliderGradient || "linear-gradient(135deg, #ee631c 0%, #f89e53 100%)";},currentCardSliderGradient() {return this.levels[this.currentIndex].cardSliderGradient || "";},currentLevelData() {return this.levels[this.currentIndex] || {};}},methods: {handleTouchStart(e) {this.isDragging = true;this.startX = e.touches[0].clientX;},handleTouchMove(e) {if (!this.isDragging) return;this.moveX = e.touches[0].clientX;},handleTouchEnd() {if (!this.isDragging) return;const diffX = this.moveX - this.startX;const threshold = 50; // 滑动触发阈值const cardWidthRatio = 100 - this.overlapPercent + 10;if (diffX > threshold && this.currentIndex > 0) {this.currentIndex--;} else if (diffX < -threshold && this.currentIndex < this.levels.length - 1) {this.currentIndex++;}this.isDragging = false;this.startX = 0;this.moveX = 0;},},
};
</script><style scoped>
@import './two.scss';
</style>

  

.title {position: absolute;top: 25rpx;left: 42%;color: #fff;font-size: 32rpx;
}.member-benefits {font-family: "Microsoft Yahei", sans-serif;max-width: 600px;
}/* 滑动容器核心样式 */
.card-slider {position: relative;overflow: hidden;padding: 250rpx 20rpx 40rpx 20rpx;
}.slider-track {display: flex;/* 核心动画:位置变化时平滑过渡 */transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);will-change: transform;/* 告诉浏览器提前优化渲染 */
}/* 卡片基础样式 */
.benefit-card {flex-shrink: 0;width: 90%;margin: 0 1%;border-radius: 18px;/* padding: 20px; */box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);/* 所有属性变化均有动画 */will-change: transform, opacity, box-shadow;
}/* 当前激活卡片样式(放大+增强阴影) */
.benefit-card.active-card {transform: scale(1);opacity: 1;box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);z-index: 3;/* 层级最高,覆盖前后卡片 */
}/* 前一张卡片样式(缩小+半透明) */
.benefit-card.prev-card {transform: scale(0.9) translateX(-5%);/* 缩小并向右偏移 *//* opacity: 0.7; */z-index: 2;
}/* 后一张卡片样式(缩小+半透明) */
.benefit-card.next-card {transform: scale(0.9) translateX(-5%);/* 缩小并向左偏移 *//* opacity: 0.7; */z-index: 2;
}/* 非相邻卡片样式(进一步缩小+降低透明度) */
.benefit-card:not(.active-card):not(.prev-card):not(.next-card) {transform: scale(0.8);opacity: 0.5;z-index: 1;
}/* 卡片内部元素样式 */
.benefit-badge {width: 70px;height: 70px;margin-bottom: 12px;transition: transform 0.3s ease;
}.active-card .benefit-badge {transform: scale(1.1);/* 当前卡片徽章轻微放大 */
}.benefit-title {font-size: 22px;margin-bottom: 10px;font-weight: 600;
}.slider-stau {display: inline;color: #fff;padding: 8rpx 18rpx;font-size: 20rpx;background-color: #b8c3c2;border-radius: 18rpx 0 20rpx 0;
}.slider-con {display: flex;padding: 30rpx;
}.benefit-desc1 {font-size: 15px;color: #555;margin-bottom: 6px;
}.benefit-desc {font-size: 15px;color: #555;margin-bottom: 6px;padding: 0 30rpx 20rpx 30rpx;
}.slider-con_img {width: 200rpx;height: 120rpx;margin: auto;
}/* 其他区域样式保持不变 */
.tips {padding: 8px;border-radius: 4px;margin-top: 12px;color: #fffafd;display: flex;justify-content: space-between;align-items: center;font-size: 30rpx;
}.tips-con {display: flex;flex-direction: column;
}.tips-tips1 {font-size: 20rpx;margin-bottom: 15rpx;
}.tips-img {width: 40px;height: 24px;
}.upgrade-con {background-color: #f8f8f8;border-radius: 30rpx 30rpx 0 0;margin-top: -20rpx;padding-top: 30rpx;position: relative;
}.upgrade-tips {background-color: #f9e8df;color: #f56f29;padding: 8px;margin: 0 20rpx;border-radius: 4px;margin-bottom: 16px;
}.upgrade-section {max-height: 46vh;overflow: scroll;background-color: #fff;border-radius: 8px;padding: 32rpx 32rpx 0 32rpx;margin: 0 20rpx;/* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}.upgrade-title {font-size: 16px;margin-bottom: 8px;width: 260rpx;
}.upgrade-tasks {list-style: none;padding: 0;
}.upgrade-tasks_li {margin-bottom: 15px;
}.upgrade-tasks_li_t {display: flex;align-items: center;
}.upgrade-tasks_li_ticon {width: 40px;height: 24px;margin-right: 8px;
}.upgrade-device {margin-left: 70rpx;display: flex;/* align-items: center */color: #a6a6aa;font-size: 25rpx;
}.upgrade-device_dian {font-size: 40rpx;
}.upgrade-button {width: 83%;margin: 20rpx auto 0 auto;background-color: #722ed1;color: #fff;padding: 10px;border-radius: 4px;text-align: center;cursor: pointer;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/936726.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2025年成都一对一培训机构优选榜:成都一对一辅导/补习/培训/补习班/辅导机构推荐,成都美博教育脱颖而出

在当今快速发展的时代,人们对自我提升的渴望愈发强烈,教育培训市场也因此迎来了蓬勃发展的黄金时期。无论是想要提升职业技能以适应职场竞争,还是追求个人兴趣爱好的培养,又或是为了满足知识更新的需求,越来越多的…

打印机共享修复,打印机无法共享,打印机修复工具下载及安装教程

软件介绍 下面推荐多款打印机共享修复工具,其实基本都能修复打印机问题,个别软件就是指定修复。能够自动诊断并修复多种常见问题,如无法安装打印机、无法连接到打印机、打印后台处理程序服务遇到问题等。只需下载并…

web中静态资源加载失败的降级处理

在Web应用中,静态资源加载失败的降级处理可通过以下方案实现:备用资源:提供备用的静态资源,当主资源加载失败时,加载备用资源。 默认样式:为关键元素提供默认样式,确保即使某些CSS文件加载失败,页面仍能基本显…

2025年保温隔热挤塑泡沫板推荐哪个厂家好?xps挤塑板/石墨聚苯板公司推荐

做建筑保温工程的朋友,肯定都遇过这种糟心事儿:有的保温隔热挤塑泡沫板厂家,要么供货拖拖拉拉,工地等着材料进场却迟迟不到;要么板子质量参差不齐,有的密度不够一压就碎,有的导热系数不达标影响保温效果;更有甚…

实用指南:消息队列 MQ

实用指南:消息队列 MQpre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", &quo…

2025 年最新推荐高性价比实木家具厂家排行榜:涵盖实木床餐边柜/餐桌斗柜/书柜/梳妆台/床头柜/餐椅沙发/休闲椅优质厂家精选

当前实木家具市场繁杂,消费者挑选时常常陷入困境。众多品牌质量参差不齐,贴皮冒充纯实木、环保认证掺假等问题频发,价格跨度大且专业辨别难度高,让消费者难以找到高性价比产品。为解决这些难题,帮助消费者在选购实…

多智能体微服务实战(3/4):Aspire 打造本地 K8s 开发环境

开发6个微服务需要6个终端窗口?.NET Aspire让你一行命令启动所有服务!本文实战演示Aspire的核心价值:自动服务发现、统一配置管理、可视化Dashboard、分布式追踪。从本地开发到生产部署(Azure Container Apps),彻…

2025 年液位计厂家最新推荐排行榜:投入式 / 磁致伸缩 / 防爆 / 防水 / 浮球液位计优质企业全面解析

在工业生产、水利工程、石油化工等众多领域,液位计是保障生产安全、提升运营效率的核心设备,其性能优劣直接影响企业生产流程的稳定性与资源利用的合理性。当前液位计市场品牌繁杂,既有技术成熟的老牌企业,也有新兴…

智表 ZCELL 公式引擎,帮你解锁自定义函数与跨表计算的强大能力

智表ZCELL创新性地解决了数据处理中的两大痛点:自定义函数和跨表计算。其公式引擎支持用户根据业务需求编写专属函数,通过简单代码即可实现复杂计算逻辑,同时采用类似Excel的跨表引用语法,轻松实现多表数据联动计算…

2025 年水下打捞公司服务推荐榜:水下打捞手机/水下打捞黄金/水下打捞戒指/水下打捞沉船/水下打捞转头,聚焦专业与高效,助力解决各类水下应急需求

随着水上交通、水利工程及民用水下作业需求的不断增加,水下打捞服务已从传统工程领域逐步延伸至民用应急场景,涵盖沉船处置、设备打捞及个人贵重物品(如手机、黄金、戒指等)找回等多个方向,2025 年市场规模预计持…

SAP 中物料视图必填字段(用下程序定期校验)

最近在作一个定时任务,每天扫描物料主数据的质量,保证所有必填字段要录下正确; 活到老,学到老。

一文读懂Optimism,Arbitrum,ZK Rollups 共识算法

Optimism (OP) 共识算法详细解析 Optimism 作为 Ethereum Layer 2 (L2) 乐观rollup解决方案,其共识算法主要依赖于乐观执行模型:交易在 L2 上假设有效执行,并批量提交到 Ethereum Layer 1 (L1) 以继承其安全性。核心…

【光照】UnityURP渲染中的HDR

《Unity URP中的HDR渲染技术解析》摘要:本文深入探讨Unity通用渲染管线(URP)中HDR渲染的核心原理与实现。HDR通过浮点纹理存储光照信息,解决了传统LDR渲染范围有限的缺陷,能更真实地表现亮度对比(100,000:1)。文章详…

在jupyter notebook中使用自己创建的conda虚拟环境的Python内核

前情提要: 安装完Anaconda后,已经自带了jupyter notebook,随后我们创造自己的虚拟环境X(conda默认是base环境),但目前在jupyter notebook中无法选择虚拟环境X中的内核。我们需要把我们的虚拟环境加入到Jupyter中…

Flutter顶部状态栏显示,安全区设置等,防止各种异性屏挡住应用操作栏

经过测试,用下方文章的第4中方法可以实现 原文地址:Flutter 状态栏完美攻略,不要找了,都在这里了 - 简书本篇文章的前提是使用Scaffold和AppBar组件。 1. 沉浸式状态栏Scaffold(extendBodyBehindAppBar: true,appBar…

实用指南:JavaWeb-Ajax、监听器、过滤器及对应案例和jstl补充

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

LGP11189 [KDOI R10] 水杯降温 学习笔记

LGP11189 [KDOI R10] 水杯降温 学习笔记 \(\texttt{Luogu Link}\) 前言 不拖啦。 题意简述 有一棵 \(n\) 个结点的树,以 \(1\) 为根。每个结点 \(u\) 有权值(水杯),初始为 \(a_u\)。 你有两种操作,可进行任意次:…

electron+vue——区分窗口普通关闭和强制退出 - 前端

preload.js:import { contextBridge, ipcRenderer } from "electron";contextBridge.exposeInMainWorld("desktopHandler", {onWindowClose: (callback) => ipcRenderer.on("window-clos…

notepad++中使用正则表达式过滤数据

示例: 姓名: 王五邮箱: wangwu@example.com姓名: 张三电话: 138-1234-5678姓名: 李四电话: 13987654321电话: 13987654123姓名: 王五邮箱: wangwu@example.com过滤包含姓名下面是电话的段落: ^姓名:((?!^姓名).)*?…

从孔子到马斯克:理解原理与问对问题的智慧史

懂原理的人,能看清方向;会提问的人,能突破迷雾。一、从“知其理”开始:理解让人清晰 我们做事时,常会感到困惑:为什么别人总能更快找到关键点、制定计划,而自己容易陷入混乱? 其实,差别往往不在“努力程度”,…