h5 移动端左右联动分类页面

33 篇文章 1 订阅
9 篇文章 2 订阅

查看演示

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.min.css"/>
		<title>侧边选项卡-左右联动</title>
		<style>
			.content-left-scroll{width: 120px; height: -webkit-calc(100vh - 50px); height: calc(100vh - 50px); background: #F4F4F4; overflow: hidden; overflow-y: scroll; display: inline-block; position: absolute; top: 50px; left: 0;}
			.content-left-warp{width: 100%; height: auto;} 
			.content-left-scroll li{width: 100%; height: 55px; line-height: 55px; text-align: center; font-size: 15px; color: #333;}
			.content-left-scroll li.active{width: 121px; color: var(--aui-color); background: #FFF; position: relative; z-index: 2;}
			.content-left-scroll li.active:before{content: ''; width: 2px; height: 55px; background: var(--aui-bg); border-radius: 3px; position: absolute; top: 0; left: 0;}
			.content-right-scroll{width: -webkit-calc(100vw - 120px); width: calc(100vw - 120px); height: -webkit-calc(100vh - 50px); height: calc(100vh - 50px); background: #FFF; overflow: hidden; overflow-y: scroll; position: absolute; top: 50px; left: 120px;}
			.content-right-warp{width: 100%; height: auto; padding: 15px 10px; box-sizing: border-box; font-size: 0;}
			.content-right-scroll .banner{width: 100%; margin-bottom: 10px;}
			.content-right-scroll .banner img{width: 100%;}
			.content-right-scroll li{width: 33.33%; margin-bottom: 10px; padding: 0 0px; box-sizing: border-box; text-align: center; display: inline-block; vertical-align: top;}
			.content-right-scroll li img{width: 40px; margin-bottom: 5px;}
			.content-right-scroll li p{width: 100%; line-height: 20px; font-size: 12px; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
		</style>
	</head>
	<body>		
	    <div class="container" id="app">
			<header class="aui-header">
				<a class="aui-header-left" onclick="aui.closeWin()"><i class="iconfont iconreturn"></i></a>
				<div class="aui-header-title">侧边选项卡-左右联动</div>
			</header>
	    	<div class="aui-content" v-cloak  >				
				<div class="content-left-scroll col-after">
					<div class="content-left-warp">
						<ul>
							<li class="row-after" v-for="(item, index) in items.leftData" :class="{'active' : currentLeftIndex==index}" :index="index" @click.stop="chooseLeftLi($event)">{{item.name}}</li>
						</ul>
					</div>
				</div>
				<div class="content-right-scroll">
					<div class="content-right-warp">
						<ul v-for="(item, index) in items.rightData">
							<div class="banner"><img src="../../img/image/banner.png" alt=""></div>
							<li v-for="list in item">
								<div class="img"><img :src="list.img" alt=""></div>
								<p class="name">{{list.name}}</p>
							</li>
						</ul>
					</div>
				</div>
	    	</div>			
	    </div>
		<script type="text/javascript" charset="utf-8" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	    <script type="text/javascript" src="../../lib/vue.min.js"></script>
	    <script type="text/javascript" src="../../lib/jquery/jquery-2.1.3.min.js"></script>
	    <script type="text/javascript" src="../../js/aui.min.js"></script>
	   	<script type="text/javascript">
	   		window.onload = function(){				
	   			apiready();
	   		}
	   		apiready = function() {
	   			var vm = new Vue({
	   				el: "#app",
	   				data: {							   											
						currentLeftIndex: 0,
						items: {
							leftData: [],
							rightData: []
						},
	   				},
	   				created: function(){
	   					var _this = this;
						
	   				},
	   				mounted: function() {
	   					var _this = this;	
						_this.getData();
						_this.scrollRight();
	   	            },
	   	            updated: function () {
	   	                var _this = this;
	   	                _this.$nextTick(function () {
	   		
	   	                })
	   	            },
	   	            methods: {
						getData(){
							var _this = this;
							for(var i = 0; i < 10; i++){
								_this.items.leftData.push({
									name: '一级菜单'+(i+1), 
									id: i,
								});
								var arr = [];
								for(var j = 0; j < 15; j++){
									arr.push({
										name: '二级菜单'+(i+1)+'-'+(j+1), id: i, 
										img: 'http://pic2.sc.chinaz.com/files/pic/pic9/201910/bpic14122.jpg',
									});
								}
								_this.items.rightData.push(arr);
							}
						},
						//左侧选择
						chooseLeftLi(e){
							var _this = this,
								el = e.currentTarget,								
								index = Number($(el).attr("index"));
							_this.currentLeftIndex = index;
							$(".content-left-scroll").animate({
								scrollTop: e.currentTarget.offsetTop - ($(window).height() - $(el).height() - 54) / 2
							},200);
							$(".content-right-scroll").animate({
								scrollTop: document.querySelector(".content-right-warp ul:nth-child("+ (index + 1) +")").offsetTop - 10
							},0);									
						},	
						scrollRight(){
							var _this = this;
							$(".content-right-scroll").on("touchmove touchend", function(){
								var self = this;
								for(var i = 0; i < $(".content-right-warp ul").length; i++){
									!(function(index){
										if(index > 0){
											var T = $(self).scrollTop();
											var RT = document.querySelector(".content-right-warp ul:nth-child("+ (index) +")").offsetTop;
											var RT_PRE = document.querySelector(".content-right-warp ul:nth-child("+ (index + 1) +")").offsetTop;
											var LT = document.querySelector(".content-left-scroll li:nth-child("+ (index) +")").offsetTop;
											var LH = document.querySelector(".content-left-scroll li:nth-child("+ (index) +")").offsetHeight;
											if(T >= RT){
												_this.currentLeftIndex = index - 1;
												$(".content-left-scroll").animate({
													scrollTop: LT - ($(window).height() - LH - 54) / 2
												},0);
												if(T >= RT_PRE){
													_this.currentLeftIndex = index;
												}
											}
										}
									})(i);									
								}
							});
						},
	   	            }
	   			});
	   		}
	   	</script>
	</body>
</html>

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
h5移动端datepicker是一种用于移动设备上选择日期的工具。它可以方便用户在移动设备上进行日期选择,以便进行各种操作,如预约、计划安排等。 h5移动端datepicker有以下几个特点: 1. 用户友好:h5移动端datepicker具有简洁明了的界面设计,使用户可以轻松地选择日期。它通常会提供一个日历视图,让用户通过滚动、点击或手势操作来选择日期。 2. 自定义功能:h5移动端datepicker还提供了一些自定义功能,使用户可以根据自己的需要进行设置。例如,用户可以选择日期的格式、语言、主题等,以满足自己的个性化需求。 3. 兼容性强:h5移动端datepicker通常能够适配各种移动设备的屏幕大小和操作方式。它可以在不同的移动浏览器、操作系统和设备上正常工作,保证用户在各种移动设备上都能够顺利使用。 4. 轻量级:h5移动端datepicker通常是基于h5技术实现的,它的代码量相对较小,加载速度快,不会消耗过多的设备资源。这样可以保证在移动设备上运行顺畅,并且不会对设备的性能产生太大影响。 总之,h5移动端datepicker是一种方便实用的工具,可以帮助用户在移动设备上快速选择日期。它具有用户友好、自定义功能、兼容性强和轻量级等特点,能够在各种移动设备上流畅运行。无论是进行预约、计划安排还是其他使用场景,h5移动端datepicker都能够帮助用户轻松地选择日期。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风如白话

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值