当前位置: 首页 > news >正文

横店建设网站南通做公司网站

横店建设网站,南通做公司网站,网上商城购物系统,兰州网络推广制度思路&#xff1a;使用两个scroll-view&#xff0c;tabbar分类导航使用scrollleft移动&#xff0c;内容联动使用页面滚动onPageScroll监听滚动高度 效果图 <template><view class"content" ><view :class"[isSticky ? tab-sticky: ]">…

思路:使用两个scroll-view,tabbar分类导航使用scrollleft移动,内容联动使用页面滚动onPageScroll监听滚动高度

效果图
效果图

<template><view class="content" ><view :class="[isSticky ? 'tab-sticky': '']"><view class="base-combox" ><uni-icons type="location-filled" color="#85D8CE" size="25" /><text class="tag-text">{{base[0].name}}</text></view><view class="u-tab" :class="[!isSticky ? 'tab-sticky': '']"><scroll-view scroll-x="true" scroll-with-animation="true" class="u-tab-view menu-scroll-view" :scroll-left="scrollLeft"><view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[isActive == index ? 'u-tab-item-active' : '']"@tap.stop="swichMenu(index)"><view class="u-line-1">{{item.name}}</view></view></scroll-view></view></view><scroll-view :scroll-top="scrollTop" scroll-y scroll-with-animation class="right-box" @scroll="upScroll"><view class="page-view"><view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index"><view class="item-title"><text>{{item.name}}</text></view><view class="item-container"><view class="thumb-box" v-for="(item1, index1) in item.children" :key="index1" @tap="goList(item1)"><image v-if="item1.icon != ''" class="item-menu-image" :src="item1.icon" mode=""></image><view v-else class="item-menu-image row-c" style="background-color: #F4F6F8;"><text style="font-size: 20rpx;color: #d0d0d0;">加载失败</text></view><view class="item-menu-name">{{item1.name}}</view></view></view></view></view></scroll-view></view>
</template><script>export default {components: {},data() {return {moduleData: [],base:[{name:"请选择地点",id:'0'}],showType:'horizontally', //vertically,horizontallymenuIcon:'../../static/list_h.png',//../../static/list_v.pngtabbar: [],isActive : 0,scrollLeft: 0, // 横向滚动条位置scrollTop: 0,baseComboxH: 0,   // 地址区的高度tabbarScrollW: 0, // 导航区宽度tabbarScrollH: 0, // 导航区高度isSticky: true, // 是否吸顶timer: null // 定时器}},onLoad(option) {this.tabbar = [{id:1,name:"菜单一",children:[{id:11,name:"子菜单一"},{id:12,name:"子菜单二"}]},{id:2,name:"菜单二",children:[{id:11,name:"子菜单一子菜单一子菜单一子菜单一",icon:"/static/bq2.png"},{id:12,name:"子菜单二"},{id:13,name:"子菜单三"},{id:14,name:"子菜单四"},{id:15,name:"子菜单五"},{id:16,name:"子菜单六"}]},{id:3,name:"菜单三",children:[{id:21,name:"子菜单一"},{id:22,name:"子菜单二"}]},{id:3,name:"菜单四",children:[{id:31,name:"子菜单一"},{id:32,name:"子菜单二"}]},{id:5,name:"菜单五",children:[{id:41,name:"子菜单一"},{id:42,name:"子菜单二"}]},{id:6,name:"菜单六",children:[{id:51,name:"子菜单一"},{id:52,name:"子菜单二"}]}]},onReady() {},mounted(){this.getScrollW();},onPageScroll(e){//console.log(e,e.scrollTop)if(this.timer){clearTimeout(this.timer)}this.timer = setTimeout(() => { // 节流this.timer = null;// scrollHeight为右边菜单垂直中点位置// let scrollHeight = e.detail.scrollTop + this.menuHeight / 2;// scrollHeight为右边菜单头部位置let scrollHeight = e.scrollTop + this.tabbarScrollH + this.baseComboxH + 26;let len = this.tabbar.lengthfor (let i = 0; i < len-1; i++) {let height1 = this.tabbar[i].top;let height2 = this.tabbar[i + 1].top;// console.log(height2,scrollHeight,height1)if (scrollHeight >= height1 && scrollHeight < height2) {this.tabbarStatus(i);return ;}}if(scrollHeight >= this.tabbar[len-1].top){this.tabbarStatus(len-1);return ;}}, 10)},methods: {goList(value) {var item = {title:value.title,labelName:value.labelName}uni.navigateTo({url:value.url+'?item='+encodeURIComponent(JSON.stringify(item))})},/*** 点击上方的tab切换* @index 传入的 ID*/async swichMenu(index) {if (index == this.isActive ) return;//this.scrollLeft = 0;this.$nextTick(function(){//for (let i = 0; i < index - 1; i++) {//this.scrollLeft += this.tabbar[i].width//};// this.isActive = index;// // 效果三(当前点击子元素居中展示)  不受子元素宽度影响// this.scrollLeft = this.tabbar[index].left - this.tabbarScrollW / 2 + this.tabbar[index].width / 2;this.tabbarStatus(index);//this.scrollTop = this.tabbar[index].topuni.pageScrollTo({duration:200, // 毫秒scrollTop: (this.tabbar[index].top - this.tabbarScrollH - this.baseComboxH - 18) // 位置});// console.log(this.scrollLeft,this.scrollTop)})},// 获取标题区域宽度,和每个子元素节点的宽度以及元素距离左边栏的距离getScrollW() {const query = uni.createSelectorQuery().in(this);query.select('.u-tab-view').boundingClientRect(data => {// 拿到 scroll-view 组件宽度高度this.tabbarScrollW = data.widththis.tabbarScrollH = data.height}).exec();query.select('.base-combox').boundingClientRect(data => {// 拿到 base-combox 高度this.baseComboxH = data.height}).exec();query.selectAll('.u-tab-item').boundingClientRect(data => {let dataLen = data.length;for (let i = 0; i < dataLen; i++) {//  scroll-view 子元素组件距离左边栏的距离this.tabbar[i].left = data[i].left;//  scroll-view 子元素组件宽度this.tabbar[i].width = data[i].width}}).exec();query.selectAll('.class-item').boundingClientRect(data => {let dataLen = data.length;for (let i = 0; i < dataLen; i++) {//  scroll-view 子元素组件距离上边栏的距离this.tabbar[i].top = data[i].top;}}).exec()},upScroll(e){if(e.detail.scrollTop>50){this.isSticky = true}else{this.isSticky = false}console.log(e.detail.scrollTop)},/*** 设置上方菜单的滚动状态* @index 传入的 ID*/async tabbarStatus(index) {this.isActive = index;// 效果三(当前点击子元素居中展示)  不受子元素宽度影响this.scrollLeft = this.tabbar[index].left - this.tabbarScrollW / 2 + this.tabbar[index].width / 2;}}}
</script><style scoped>page{background-color: #fafafa !important;display: block;/* overflow: hidden; */}.content {min-height: 100vh;display: flex;flex-direction: column;}.base-combox{align-items: center;justify-content: center;height: 50rpx;}.u-tab-item-active {position: relative;color: #000;font-size: 16px;font-weight: 600;}.u-tab-item-active::after {content: ''; // 必须display: block;width: 30px;height: 4px;background-color: #000;margin: 0 auto;border-radius: 10px;}.u-tab{border-bottom: 1rpx solid #f2f2f2;background-color: #ffffff;z-index: 99;width: 100%;align-items: center;height: 100rpx;margin-top: 10px;}.u-tab-view{box-sizing: border-box;padding-left: 30rpx;padding-right: 30rpx;width: 100%;white-space: nowrap;}.u-tab-item{display: inline-block;box-sizing: border-box;line-height: 60rpx;margin-right: 35rpx;font-size: 16px;padding-top: 10px;},.u-line-1{padding-bottom: 7px;}/* 隐藏scroll-view滚动条 *//deep/::-webkit-scrollbar{display: none;}uni-scroll-view .uni-scroll-view::-webkit-scrollbar {display: none}.right-box{/* height: 100vh; */}.page-view {padding: 16rpx;flex-direction: column;}.class-item {display: block;margin-bottom: 30rpx;background-color: #fff;padding: 16rpx;border-radius: 8rpx;}.class-item:last-child {min-height: calc(100vh - 102rpx - 50rpx - 20rpx - 88rpx - 32rpx - 64rpx );}.item-title {font-size: 26rpx;color: $u-main-color; font-weight: bold;}.item-menu-name {margin-top: 8rpx;font-weight: normal;font-size: 24rpx;color: $u-main-color;}.item-container {display: flex;flex-wrap: wrap;}.thumb-box {width: 25%;display: flex;align-items: center;justify-content: center;flex-direction: column;margin-top: 20rpx;}.item-menu-image {width: 60rpx;height: 60rpx;}.tab-sticky{display: flex;flex-direction: column;position: -webkit-sticky;position: sticky;top: var(--window-top);z-index: 99;background-color: #fff;}</style>
http://www.yayakq.cn/news/351408/

相关文章:

  • 网站信息系统建设手机百度云转换wordpress
  • 赣州建网站减肥单页网站
  • 做dnf辅助网站免费观看短视频的软件
  • 怎么做网站链接广告内部网站建设合同
  • 在线网站做气泡图seo下载站
  • 设计公司网站公司详情哈尔滨网站开发公司电话
  • 杭州建设网站制作扬中网站
  • 义乌外贸公司网站wordpress 修改路径
  • 桂林网站建设设计企业宣传制作app哪个好
  • 做生存曲线的网站网站访问量怎么增加
  • 局域网网站建设工具网页制作的公司找时代创信
  • 做网站怎么添加关键词进销存管理软件哪个好
  • 网站描本链接怎么做响应式网站 html
  • 英文网站建设服务合同如何做网站预览
  • 域名购买哪个网站好门户网站开发jz190
  • 什么是网站和网页海外运营工作内容
  • 六安市网站制作公司分类信息网站平台有哪些
  • 企业建设银行网站登录不了wordpress菜单教程
  • 简易网站制作软件做vi的网站
  • 十堰哪里有做网站的沈阳做网站推广的公司
  • 做网站必要性外国大气网站设计
  • 网站建设哪家专业百度推广怎么找客户
  • dedecms一键更新网站内在空间官网
  • 泊头网站建设公司手机版的网站用什么开发
  • 嘉兴网站关键字优化专业旅游网站建设
  • 国内网站建设排名阿里企业邮箱手机登录
  • 博湖网站建设台州企业网站搭建电话
  • 农村建设设计网站首页做p2p网站的公司
  • wordpress插件+手机版给甜品网站做seo
  • discuz 门户网站模板网络营销第2版课后答案