<template>
	<view>
		<view class="box" @click="editImg()">
			<image class="left" :src="value" mode="aspectFill"></image>
			<view class="right">
				<text>{{label}}</text>
				<image src="@/static/img/toRight.png" mode=""></image>
			</view>
		</view>
		<uni-popup ref="popup" type="bottom">
			111
		</uni-popup>
	</view>
</template>

<script>
	import { upLoadingFileOss } from "@/common/js/upLoadingFile";
	
	export default {
		props:{
			label: {
			  type: String,
			  default: '标题'
			},
			value:{
				type: String,
				default: ''
			},
		},
		data(){
			return{
				
			}
		},
		methods:{
			showsdasa(){
				let isH5=false
				// #ifdef H5
				isH5=true
				// #endif
				if(isH5){
					this.editImg(1)
				}else{
					this.$refs.popup.open('top')
				}
			},
			editImg(type){
				uni.chooseImage({
					count: 1,
					sizeType: ["compressed", "camera"],
					sourceType: [type===1?"album":"camera"],
					success:(res)=>{
						if (res.errMsg == "chooseImage:ok"){
							tools.showLoading()
							this.upLoadOss(res.tempFiles[0].path)
						}else{
							// tools.error('头像选择失败')
						}
					}
				})
			},
			
			upLoadOss(path){
				 upLoadingFileOss(path).then((res)=>{
					 if(res.code===1){
						 
					 }else{
						 
					 }
				 }).catch(()=>{
					 tools.hideLoading()
				 })
				
				
			},
		},
	}
</script>

<style scoped lang="scss">
	.box{
		width: 100%;
		height: 152rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		image{
			width: 96rpx;
			height: 96rpx;
			border-radius: 50%;
		}
		.left{
			font-size: 32rpx;
		}
		.right{
			display: flex;
			align-items: center;
			text{
				font-size: 32rpx;
				color: #333;
			}
			image{
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>