<template>

	<RefreshView ref="mescrollRef" :pageBg="EDEDED" :hasBack="true" text="个人信息" :useDownScroll="false" :useUpScroll="false" >
		<view @click="uploadHeadImage()" class="menu-item">
			<text class="text">头像</text>
			<image :src="page.headImage" style="width: 70rpx;height: 70rpx;margin-right: 10rpx;"></image>
			<image class = "more" src="../../static/img/public/more.png" ></image>
		</view>
		<view class="line-thin"></view>
		<view @click="toModiNickName()" class="menu-item">
			<text class="text">昵称</text>
			<text class="explain">{{page.userNickName}}</text>
			<image class = "more" src="../../static/img/public/more.png" ></image>
		</view>
		<view class="line-thin"></view>
		<view @click="toRealInfo()" class="menu-item">
			<text class="text">实名信息</text>
			<text class="explain">{{page.realAttestationExplain}}</text>
			<image class = "more" src="../../static/img/public/more.png" ></image>
		</view>
	</RefreshView>

</template>

<script>
	export default {
		data() {
			return {
				page: {
					sysUserInfoSid:"",
					headImage: "http://www.ourpyw.com/upload//touxiang/default_tx.jpg",
					userNickName: "",
					loginName: "",
					realAttestationExplain:""
				},
				parameter:{
					sysUserSid:"",
				}

			}
		},
		onLoad(options){
			this.parameter.sysUserSid = options.sysUserSid
			// this.parameter.sysUserInfoSid = options.sysUserInfoSid
		},
		onShow() {
			console.log("初始化")
			let _this = this
			_this.HTTP({
				url: 'aos/v1/aosUser/getPersonalInfoBySysUserSid/' + _this.parameter.sysUserSid,
				method: 'GET',
				paramsType: "FORM",
				loading: true
			}).then((res) => {
				_this.page = res.data
				console.log('========================================================', _this.page)
			});
		},
		methods: {
			uploadHeadImage(){
				this.chooseUpload(1,"portal/file/upload","file")
					.then((res) => {
						console.log("url>>>>", res);
						let _this = this
						let url = res.urls[0].fullUrl
						console.log("头像地址", url);
						_this.HTTP({
							url: 'aos/v1/aosUser/modifyHeadImage',
							method: 'PUT',
							paramsType: "FORM",
							data: {
								sysUserInfoSid: _this.page.sysUserInfoSid,
								headImageUrl: url,
							},
							loading: true
						}).then((res) => {
							_this.page.headImage =url
						});
					})
				return;
			},	
			toModiNickName(){
				let _this = this
				if (getApp().globalData.isLogin ) {
						uni.navigateTo({
							url: 'ModiNickName?userNickName=' + _this.page.userNickName + "&sysUserInfoSid=" + _this.page.sysUserInfoSid 
						})
					}
			},
			toRealInfo(){
				let _this = this
				if (getApp().globalData.isLogin ) {
					uni.navigateTo({
						url: '../me/RealInfo?sysUserSid=' + _this.parameter.sysUserSid
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	@import url("../../static/master.css");
</style>
