<template>
	<view class="container">
		<view class="robot">
			<image src="../../static/home/robot.png" mode="aspectFit"></image>
		</view>
		<view class="titleText">SmartAssistant</view>
		<view class="selectContent">
			<view class="select_box" v-for="(item, index) in dataList" :key="index" @click="clickToItem(item, index)">
				{{ item }}
			</view>
		</view>
		<view class="userInfo">
			<view class="user_regist" @click="clickToRegist">注册</view>
			<view class="user_login" @click="clickToLogin">登录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: ['首页', 'AI聊天', 'AI画图'],
				currenIndex: this.selectedIndex
			}
		},
		props: {
			selectedIndex: {
				type: Number,
				default: 0
			}
		},
		mounted() {
			this.$emit('clickToIndex', this.currenIndex)
		},
		methods:{
			clickToItem(item, index) {
				if(this.currenIndex === index) {
					return
				}
				this.currenIndex = index
				this.$emit('clickToIndex', index)
			},
			clickToRegist() {
				
			},
			clickToLogin() {
				
			}
		}
		
	}
</script>

<style lang="scss">
	.container{
		position: fixed;
		width: 100%;
		height: 60px;
		top: 0%;
		left: 0;
		background: linear-gradient(to right, #303373, #C9A391);
		display: flex;
		box-sizing: border-box;
		align-items: center;
		.robot{
			flex-shrink: 0;
			width: 48px;
			height: 48px;
			margin-left: 15px;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.titleText{
			display: flex;
			margin-left: 10px;
			// height: 100%;
			font-size: 30px;
			font-weight: 500;
			color: #ffffff;
		}
		.selectContent{
			display: flex;
			flex-direction: row;
			height: 100%;
			align-items: center;
			
			.select_box{
				display: flex;
				margin-left: 40px;
				color: #ffffff;
			}
		}
		
		.userInfo{
			position: absolute;
			display: flex;
			box-sizing: border-box;
			height: 100%;
			top: 0px;
			right: 10px;
			align-items: center;
			.user_regist{
				display: flex;
				width: 65px;
				height: 28px;
				border-radius: 28px;
				color: #878787;
				background-color: #ffffff;
				justify-content: center;
				align-items: center;
			}
			.user_login{
				display: flex;
				width: 65px;
				height: 28px;
				border-radius: 28px;
				color: #ffffff;
				background-color: #4C9CF1;
				justify-content: center;
				align-items: center;
				margin-left: 10px;
			}
		}
	}
</style>