<template>
	<view class="content">
		<nav-bar></nav-bar>
		<view class="main">
			{{ $t('common.close') }}
		</view>
		<van-button type="primary" @click="selectLanguage('zh-cn')">中文</van-button>
		<van-button type="warning" @click="selectLanguage('en-us')">英文</van-button>
		<van-tabbar :active="active" @change="onChange" :placeholder="true" active-color="#3856ff" inactive-color="#666666">
			<van-tabbar-item v-for="(item, index) in list" :name="item.name" :key="index" :icon="item.icon">
				{{ item.text }}
			</van-tabbar-item>
		</van-tabbar>
	</view>
</template>

<script>
	import { setLocale } from '../../locales/i18n'
import {
		login
	} from '@/api/user'
	import NavBar from '@/components/layout/nav-bar.vue'

	export default {
		components: {
			NavBar
		},
		data() {
			return {
				active: 'home',
				title: 'Hello',
				list: [{
						name: 'home',
						icon: 'home-o',
						text: '首页',
						url: '/pages/index'
					}, {
						name: 'search',
						icon: 'search',
						text: '示例2',
						url: '/pages/signup/signup'
					},
					{
						name: 'friends',
						icon: 'friends-o',
						text: '示例3',
						url: '/pages/test'
					},
					{
						name: 'setting',
						icon: 'setting-o',
						text: '示例3',
						url: '/pages/test'
					}
				]
			}
		},
		created() {
			const apiUrl = process.env.BASE_API
			console.log('当前环境的API URL: ', apiUrl)
			console.log(uni.getLocale())
		},
		methods: {
			onChange(e) {
				this.active = e.detail
			},
			selectLanguage(language) {
				setLocale(language)
			}
		}
	}
</script>

<style lang="scss">
</style>