uni-app 之来回滑动切换tab

<template>
	<view>
		<view class="end-title">
			<view @tap="tabtap(0)" :class="{btna:tabIndex == 0}">检查记录</view>
			<view @tap="tabtap(1)" :class="{btna:tabIndex == 1}">相关附件</view>
			<view @tap="tabtap(2)" :class="{btna:tabIndex == 2}">结论</view>
		</view>
		<view class="uni-tab-bar">
			<swiper class="swiper-box"  :style="{height:swiperheight+'px'}" :current="tabIndex" @change="tabChange">
				<swiper-item v-for="(items,index) in tabBars" :key="index">
					<scroll-view scroll-y class="list">
						<template v-if="index==0">
							<record :item="detailData" :hiddens='hiddens'></record>
						</template>
						<template v-else-if="index==1">
							<annex :item="detailData" :hiddens='hiddens'></annex>
						</template>
						<template v-else>
							<result :item="detailData" :hiddens='hiddens' :fileUrl='fileUrl'></result>
						</template>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	import record from "../../components/detail/record.vue";
	import swiperTab from "../../components/index/swiper-tab.vue";
	import annex from "../../components/detail/annex.vue";
	import result from "../../components/detail/result.vue";
	export default {
		components: {
			record,
			annex,
			result,
			swiperTab

		},
		data() {
			return {
				btnnum: 0,
				detailData: {},
				hiddens: null,
				swiperheight: 500,
				tabIndex: 0,
				tabBars: [{
					name: '检查记录'
				}, {
					name: '相关附件'
				}, {
					name: '结论'
				}],
				fileUrl:''
			}
		},
		onLoad(e) {
			this.hiddens = e.a
			this.tabtap(e.a)
			this.detailData = JSON.parse(e.detailData)
			if(this.detailData.fileUrl){
			this.fileUrl = this.detailData.fileUrl
			}
			uni.getSystemInfo({
				success: (res) => {
					this.swiperheight= res.windowHeight - uni.upx2px(100)
				}
			});
		},
		
		methods: {
			tabtap(index) {
				this.tabIndex = index;
			},
			// 滑动事件
			tabChange(e) {
				this.tabIndex = e.detail.current;
			}


		},
	}
</script>

<style>
	/* 将三个内容view的display设置为none(隐藏) */
	.end-title {
		display: flex;
		height: 90upx;
		align-items: center;
		font-size: 34upx;
		background: #FFFFFF;

	}

	.end-title view {
		flex-grow: 1;
		text-align: center;
		padding: 10upx 0;
		
		/* margin-bottom: 10upx; */
	}

	.end-cont {
		display: none;
	}

	.btna {
		color: #FFFFFF;
		background: #00A0FF;
		line-height: 70upx;
	}

	.dis {
		display: block;
	}

	.uni-swiper-tab {
		border-bottom: 1upx solid #EEEEEE;
		background-color: #FFFFFF;
		display: flex;
		height: 90upx;
		align-content: space-between;
	}

	.swiper-tab-list {
		color: #969696;
		font-weight: bold;
		font-size: 34upx;
		text-align: center;
	}

	.uni-tab-bar .active {
		color: #343434;
	}

	.active .swiper-tab-line {
		border-bottom: 6upx solid #FEDE33;
		/* width: 70upx; */
		margin: auto;
		border-top: 6upx solid #FEDE33;
		border-radius: 20upx;
	}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

jiojio冲冲冲

能帮助你是我最大的动力

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

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

打赏作者

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

抵扣说明:

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

余额充值