<template>
  <view>
	 <tui-navigation-bar :isOpacity="false" @init="initNavigation" @change="opacityChange" :scrollTop="scrollTop" backgroundColor="#fff" color="#333">
	 	<view class="tab-box">
			<view class="avatar-box" @click="changeClerk">
				<u-avatar size="44" :src="clerk.avatar"></u-avatar>
				<view class="icon">
					<u-icon name="qiehuan1" size="20" color="#fff" custom-prefix="iconfont"></u-icon>
				</view>
			</view>
	 		<view class="zhong">
	 			<view class="tab-box">
	 				<view class="title-label" @click="tabsChange" :data-i="i" v-for="(item,i) in tabList" :key="i">
	 					<text
	 						:style="{fontWeight:current==i?'bold':'',fontSize:current==i?'36rpx':'28rpx'}">
	 						{{item.name}}
	 					</text>
	 				</view> 
	 			</view>
	 		</view>
	 	</view>
	 </tui-navigation-bar>

  </view>
</template>

<script>
	import tuiNavigationBar from "@/components/thorui/tui-navigation-bar/tui-navigation-bar.vue";
	import sheep from '@/sheep';
	export default {
		components: {
			tuiNavigationBar,
		},
		props: {
			title: {
				type: String,
				default: '',
			},
		},
		data() {
			return {
				top: 0, //标题图标距离顶部距离
				opacity: 1,
				height: 0,
				scrollTop: 0.5,
				
				tabList: [
					{
						name: '达人',
						value: '0',
					},
					{
						name: '最新',
						value: '2',
					},
					{
						name: '推荐',
						value: '1',
					},
				],
				current: 1, 
			}
		},
		computed: {
			clerk: {
			    get() {
			      return sheep.$store('sys').currentClerk;
			    },
			},
		},
		methods: {
			initNavigation(e) {
				this.height = e.height;
				this.opacity = e.opacity;
				this.top = e.top;
				this.$emit('initNav', e);
			},
			opacityChange(e) {
				this.opacity = e.opacity;
			},
			tabsChange(e) {
				this.current = e.currentTarget.dataset.i; 
				this.$emit('tabsChange', this.tabList[this.current].value);
			},
			changeClerk() {
				this.$emit('changeClerk');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zhong {
		//width: 230rpx;
	}
	
	.tab-box {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.avatar-box {
		display: flex;
		align-items: center;
		position: absolute;
		left: 40rpx;
		
		.icon {
			position: absolute;
			right: 0;
			bottom: 0;
		}
	}
	
	.tab-box .title-label {
		height: 44px;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
		//font-size: 34rpx;
	}
	
	.tab-box .title-label text {
		transition: all 0.3s;
	}
	

</style>