<template>
	<view class="content">
		<button @click="$refs.configPopup.open()">{{ locale.agreement }}</button>
		<button @click="$refs.changeLanguage.open()">切换语言</button>
		<button @click="$utils.navigateTo('/map/map')">地图</button>
		<button @click="uploadImage">图片上传</button>
		
		<text>{{ image }}</text>
		
		<uv-upload
		:fileList="fileList" 
		:maxCount="5" 
		multiple 
		width="150rpx" 
		height="150rpx"
		@delete="deleteImage"
		@afterRead="afterRead"
		:previewFullImage="true"></uv-upload>
		
		<changeLanguage ref="changeLanguage"/>
		
		<configPopup
		keyValue="asd"
		ref="configPopup"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				image : '',
				fileList: [],
			}
		},
		computed : {
			locale(){
				return this.$t('pages.index.index')
			}
		},
		methods: {
			//上传图片
			uploadImage(){
				let self = this
				this.$Oss.ossUploadImage({
					success(url){
						self.image = url
					}
				})
			},
			deleteImage(e){
				this.fileList.splice(e.index, 1)
			},
			afterRead(e){
				let self = this
				e.file.forEach(file => {
					self.$Oss.ossUpload(file.url).then(url => {
						self.fileList.push({
							url
						})
					})
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content{
		padding: 20px;
		button{
			margin-bottom: 10rpx;
		}
	}
</style>
