<template>
	<view>
		
		<view class="profile_item profile_item1">
			<text>Photo</text>
			<view class="profile_item_right">
				<image src="../../static/img/logo.png" mode="" class="head_img" v-show="!user_info.isLogin"></image>
				<image :src="user_info.user_head?user_info.user_head:user_info.headicons[5]" mode="" class="head_img" v-if="user_info.isLogin"></image>
				<image src="../../static/img/right1.png" alt="" class="right_img"></image>
			</view>
		</view>
		<view class="profile_item " @click="$refs.inputDialog.open()">
			<text>Name</text>
			<view class="profile_item_right">
				<text>{{user_info.nickname}}</text>
				<image src="../../static/img/right1.png" alt="" class="right_img"></image>
			</view>
		</view>
		<view class="profile_item ">
			<text>Email</text>
			<view class="profile_item_right">
				<image src="../../static/img/gantan.png" alt="" class="right_img1" v-if="user_info.is_validated==0"></image>
				<text>{{user_info.is_validated==0?'unverified':user_info.email}}</text>
				<image src="../../static/img/right1.png" alt="" class="right_img"></image>
			</view>
		</view>
		<navigator :url="'/pages/login/verifyEmail?type=0&email='+user_info.email" >
			<view class="profile_item ">
				<text>Change Password</text>
				<view class="profile_item_right">
					<image src="../../static/img/right1.png" alt="" class="right_img"></image>
				</view>
			</view>
		</navigator>
		<view class="profile_item ">
			<text>Ship to</text>
			<view class="profile_item_right">
				<text>United States</text>
				<image src="../../static/img/right1.png" alt="" class="right_img"></image>
			</view>
		</view>
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose"  mode="input" title="输入内容"  
				placeholder="请输入姓名" @confirm="dialogInputConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import {defaultRequest2} from '../../api/index.js'
	export default {
		data() {
			return {
				user_info:{
					isLogin:false,
				},
				query:{
					_action:'updateinfo',
					nickname:''
				}
			}
		},
		methods:{
			getUserInfo(){
				let data={_action:'getinfo'}
				defaultRequest2(data).then(res=>{
					console.info(res)
					if(res.error==0){
						res.data.isLogin=true
						this.user_info=res.data
						uni.setStorageSync('user_info',this.user_info)
					}else{
						this.user_info=uni.getStorageSync('user_info')
					}
				})
			},
			dialogInputConfirm(val){
				this.query.nickname=val
				defaultRequest2(this.query).then(res=>{
					console.info(res)
					if(res.error==0){
						uni.showToast({
							title:'修改成功',
							icon:'none'
						})
						this.getUserInfo()
					}
				})
			}
		},
		onLoad() {
			this.user_info=uni.getStorageSync('user_info')
			this.getUserInfo()
		}
	}
</script>

<style>
	page{
		border-top: 13.33rpx #F7F7F7 solid;
		padding-left: 26.67rpx;
	}
	
</style>
<style lang="scss" scoped>
	
	.profile_item{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 24rpx;
		font-weight: bold;
		padding: 40rpx 0;
		padding-right: 33.33rpx;
		border-bottom: 1.33rpx #ECECEC solid;
		box-sizing: border-box;
		
		.profile_item_right{
			display: flex;
			align-items: center;
			.head_img{
				width: 112rpx;
				height: 112rpx;
				border-radius: 50%;
			}
			.right_img{
				width: 18.67rpx;
				height: 18.67rpx;
				margin-left: 20rpx;
			}
			.right_img1{
				width: 25.33rpx;
				height: 25.33rpx;
				margin-right: 9.33rpx;
			}
		}
		
	}
	.profile_item1{
		padding: 17.33rpx 0;
		padding-right: 33.33rpx;
	}
</style>