<template>
	<view class="system_content column-justify-sb center">
		<view :style="{marginTop:`${$tools.topHeight()}px`}">
			<view class="column justify-center avatar r-100">
				<view class="avatar r-100" style="background-color: rgba(0, 0, 0, 0.1);"></view>
				<view class="row-c avatar_name m-l20">
					<image class="wh-100 r-circle" v-if="!memberData.head_img"
						src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-avatar.png"
						mode="aspectFill"></image>
					<image class="wh-100 r-circle" v-else :src="memberData.head_img" mode="aspectFill"></image>
					<view class="column m-l20 flex">
						<view class="size-30 text-color-333 ellipsis" style="width: 160rpx;">
							{{ memberData.name ? memberData.name : memberData.nickname }}
						</view>
						<view class="size-26 text-color-666 ellipsis" style="width: 160rpx;">
							{{memberData.position_name?memberData.position_name:'无'}}
						</view>
					</view>
				</view>
			</view>
			<view class="system_item">
				<view class="row-c p-tb25" v-for="(item,index) in systemList" :key="index" @click="onGoSetting(item)">
					<image class="m-r20" :src="item.icon" mode=""></image>
					<text class="size-28 text-color-333">{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="system-button m-b50">
			<view class="system-quit">
			</view>
			<view class="system-button button-text size-28 button-color sys-weight-600" @click="exitAccount">
				退出登录
			</view>
		</view>
	</view>
</template>

<script>
	import {
		logout
	} from "@/api/user";

	export default {
		props: {
			memberData: {
				default: {
					position_name: "",
					head_img: "",
					id: 5,
					name: "",
					nickname: "",
					phone: "",
				}
			}
		},
		data() {
			return {
				topNavHeight: null,
				systemList: [{
						icon: "https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-info.png",
						name: '个人信息',
						id: 1
					}, {
						icon: "https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-lock.png",
						name: '修改密码',
						id: 2
					}, {
						icon: "https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-phone.png",
						name: '修改手机号',
						id: 3
					}, {
						icon: "https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-phone.png",
						name: '邀请二维码',
						id: 4
					},
					{
						icon: "/static/img/index/to_excel.png",
						name: '转换工具',
						id: 5
					},
				]
			}
		},
		created() {
			this.topNavHeight = getApp().globalData.topNavHeight
		},
		mounted() {},
		methods: {
			moveHandle() {
				return false
			},
			exitAccount() {
				uni.showModal({
					title: '提示',
					content: '是否退出当前账户？',
					success: (res) => {
						if (res.confirm) {
							logout()
							uni.clearStorageSync()
							uni.reLaunch({
								url: `/pages/login/index`
							})
						}
					}
				});
			},
			onGoSetting(item) {
				if (item.id === 1) {
					return uni.navigateTo({
						url: `/page_subpack/personal_details/personal_details`
					})
				} else if (item.id === 4) {
					// uni.navigateTo({
					// 	url: `/page_subpack/system_setting/system_setting?id=${item.id}&title=${item.name}`
					// })
				} else if (item.id === 5) {
					uni.navigateTo({
						url: `/page_subpack/transition/to_excel`
					})
				} else {
					uni.navigateTo({
						url: `/page_subpack/system_setting/system_setting?id=${item.id}&title=${item.name}`
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.system_content {
		width: 375rpx;
		height: 100vh;
		background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/popup_bg.png");
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.avatar {
		width: 315rpx;
		height: 140rpx;
	}

	.avatar_name {
		position: absolute;
	}

	.system_item {
		width: 315rpx;
		margin-top: 50rpx;

		image {
			width: 30rpx;
			height: 32rpx;
		}
	}

	.system-button {
		width: 335rpx;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		position: relative;
	}

	.system-quit {
		width: 335rpx;
		height: 90rpx;
		line-height: 90rpx;
		background: #3ABF7D;
		opacity: 0.3;
		border-radius: 30rpx;

		.quit-active {
			opacity: 1;
		}
	}

	.button-text {
		position: absolute;
		top: 0;
	}
</style>