<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<navInfo :title="'个人中心'"></navInfo>	
		<view class="bgTopImg">
			<image slot="right"  :src="`${urls}/navBg@2x.png`" class="bgTopImg"></image>
		</view>
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex padding justify-between">
				<view class="flex align-center">
				</view>
				<view @click="handleToInfo" class="flex align-center">
				</view>
			</view>
		</view>
		<view class="content-section">
			<view class="mine-actions grid col-3 text-center">
				<view class="photo">
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						style="border: 3px solid #4CB2B6;width: 160rpx;height: 160rpx;">
				</view>
				<view v-if="name" @click="handleToInfo" class="user-info">
					<view class="u_title"> 昵称：{{ name }}
					</view>
					<view style="height: 2rpx;background-color: #E5E5E5;margin-top: 40rpx;width: 92%;margin-left:4%;">
					</view>
				</view>
				<u-cell-group :border="false" customStyle="margin-top:30rpx">
					<u-cell :border="false" :icon="bianjiziliao" title="编辑资料" isLink @click.native="handleToEditInfo">
					</u-cell>
					<u-cell :border="false" :icon="danweixinxi" @click.native="goUnit" isLink title="单位信息" v-if="!isStreet"></u-cell>
					<u-cell :border="false" :icon="jianchajilu" @click.native="auditRecord" isLink title="工作记录">
					</u-cell>
					<u-cell :border="false" :icon="jianchajilu" @click.native="goInstuct" isLink title="操作说明">
					</u-cell>
				</u-cell-group>
				<view v-if="name" class="user-info" style="padding-bottom: 40rpx;">
					<u-button @click="handleLogout" type="primary" shape="circle" size="default" color="#4CB2B6"
						text="退出登录">
					</u-button>
				</view>
        </view>
			</view>
		</view>
	</view>
</template>
<script>
	// #ifdef H5
	import navInfo from '@/pagesA/components/my-nav/nav'
	// #endif
	import storage from '@/utils/storage'
	import {
		getUserProfile
	} from "@/api/system/user"
	import config from '@/config'
	const baseUrlImg=config.baseUrlImg
	export default {
		components: {
			// #ifdef H5
			navInfo
			// #endif
		},
		data() {
			return {
				urls:baseUrlImg,
				jianchajilu:`${baseUrlImg}/jianchajilu.png`,
				bianjiziliao: `${baseUrlImg}/bianjiziliao.png`,
				danweixinxi:`${baseUrlImg}/danweixinxi.png`,
				name: this.$store.state.user.name,
				version: getApp().globalData.config.appInfo.version,
				isStreet:null
			}
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		onShow() {
			this.getUser()
				this.isStreet = uni.getStorageSync('getUserInfo_key').streetInfo; //登录用户的街道id
		},
		methods: {
			getUser() {
				getUserProfile().then(response => {
					// this.name= response.data
					this.name = response.data.username
				})
			},
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				uni.navigateTo({
					url: '/pages/mine/info/edit'
				})
			},
			goUnit() {
				uni.navigateTo({
					url: '/pagesA/fire/unit_info/index'
				})
			},
			auditRecord() {
				uni.navigateTo({
					url:`/pagesB/fire/check_record/index?my=onlymy`
				})
			},
			goInstuct(){
				uni.navigateTo({
					url:`/pages/mine/instruct/instruct`
				})
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/mine/setting/index')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {
						this.$tab.reLaunch('/pages/index')
						// this.$tab.reLaunch('/pages/work/index')
					})
				})
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/mine/help/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				this.$modal.showToast('微信搜索 naidaguo 后，添加好友后拉你进技术交流群')
			},
			handleBuilding() {
				this.$modal.showToast('模块建设中~')
			}
		}
	}
</script>
<style lang="scss" scoped>
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		width: 100%;
		height: 100%;

		.header-section {
			/*#ifdef H5*/
				padding: 15px 15px 100rpx 15px;
			/* #endif */
			/* #ifdef  MP-WEIXIN*/
			padding: 15px 15px 240rpx 15px;
			/* #endif */
			color: white;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}
		}

		.content-section {
			position: relative;
			top: -100rpx;

			.user-info {
				margin-top: 40px;
				width: 100%;

				.u_title {
					font-size: 18px;
					text-align: center;
					line-height: 40rpx;
				}
			}

			.mine-actions {
				margin: 60rpx 15px;
				padding: 20px 0px;
				border-radius: 30px;
				background-color: white;
				position: relative;
				text-align: center;
				box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63);

				.photo {
					position: absolute;
					left: 50%;
					top: -80rpx;
					transform: translate(-120rpx);
				}

				.action-item {
					.icon {
						font-size: 28px;
					}

					.text {
						display: block;
						font-size: 13px;
					}
				}
			}
		}
	}

	/deep/.u-cell__title {
		flex: none !important;
	}

	/deep/.u-cell__left-icon-wrap[data-v-913eaa32],
	.u-cell__left-icon-wrap.data-v-913eaa32 {
		margin-right: 14px;
	}

	/deep/.u-button[data-v-3bf2dba7],
	/deep/.u-button.data-v-3bf2dba7,/deep/.u-button {
		width: 48% !important;
	}
</style>
