<template>
	<view class="page">
		<navBar title="个人资料" :back="true" color="black" background="white" />

		<view class="content">
			<view class="item" style="border-radius: 0rpx 0rpx 0rpx 24rpx;;">
				<view class="line" @click="chooseAvatar">
					<view class="left">
						头像
					</view>
					<view class="right">
						<image :src="avatarUrl?avatarUrl:'/static/index/img1.png'" mode="" class="avatar"></image>
						<image src="/static/my/parr.png" mode="" class="arr"></image>
					</view>
				</view>
				<view class="line">
					<view class="left">
						昵称
					</view>
					<view class="right">
						<view class="">
							王花花
						</view>
						<image src="/static/my/bj.png" mode="" class=""
							style="width: 24rpx;height: 24rpx;margin-left: 8rpx;"></image>
					</view>
				</view>
				<view class="line">
					<view class="left">
						性别
					</view>
					<view class="right">
						<view class="" style="margin-right: 20rpx;">
							男
						</view>
						<image src="/static/my/parr.png" mode="" class="arr"></image>
					</view>
				</view>
			</view>




			<view class="item" style="">
				<view class="line">
					<view class="left">
						真实姓名
					</view>
					<view class="right">
						刘花花
					</view>
				</view>
				<view class="line">
					<view class="left">
						生日
					</view>
					<view class="right">
						1930-03-29
					</view>
				</view>
				<view class="line">
					<view class="left">
						手机号
					</view>
					<view class="right">
						18298037860
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uploadUrl from '@/common/config.js'
	export default {
		components: {

		},
		data() {
			return {
				avatarUrl: ''
			}
		},
		onLoad(options) {},
		methods: {
			chooseAvatar() {
				let _this = this
				uni.chooseImage({
					success(res) {
						console.log('res', res.tempFilePaths[0]);
						_this.upImg(res.tempFilePaths[0])
					}
				})
			},
			upImg(file) {
				console.log('upImg的file', file)
				let _this = this
				uni.uploadFile({
					url: uploadUrl.baseUrl, // 上传的 URL 地址
					filePath: file, // 要上传的图片本地路径
					name: 'file', // 上传图片时使用的字段名
					header: { // 自定义请求头
						'Content-Type': 'multipart/form-data'
					},
					formData: {
						'fileType': 'images',
						'dirName': 'cert',
						'tag': 'lamp'
					},
					success: function(uploadRes) {
						let result = JSON.parse(uploadRes.data)
						if (result.code == 0) {
							_this.avatarUrl = result.data.file
							console.log('上传后的头像url地址', result.data.file)
						}
					},
					fail: function(err) {
						console.log('upload failed:', err)
					}
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>