<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text" style="height: 100vh;">
		<view class="relative" :style="{height: `calc(${statusBar}px + 55px)`}">
			<view class="width-100b fixed1" :style="{height: `calc(${statusBar}px + 55px)`}">
				<view class="width-100b flex align-center"
					:style="{paddingTop: statusBar + 'px', height: `calc(${statusBar}px + 55px)`}">
					<i @tap="router.goBack()" class="cuIcon-back font-30" style="position: absolute;left: 30rpx;" ></i>
					<view class="height-80 flex align-center justify-end absolute" style="right: 30rpx; min-width: 240rpx;">
						<view @tap="router.push('/pages/lang/lang')" class="lang-btn">
							<image class="lang-icon" src="/static/earth-icon.png" mode="aspectFit"></image>
							<text class="lang-text">{{i18n.lang && i18n.lang.title ? i18n.lang.title : 'Lang'}}</text>
						</view>
						<!-- 主题切换按钮已移除 -->
				</view>
				</view>
			</view>
		</view>
		<view class="height-250 padding-w-45 flex align-center justify-between">
			<view v-if="userinfo.is_angel" @click="wacth(userinfo.avatar)"
				class="width-150 height-150 relative margin-r-20 flex align-center justify-center">
				<image class="width-110 height-110 radiu-50b" :src="userinfo.avatar" mode=""></image>
				<image class="width-150 height-150 absolute" style="top: 0;left: 0;"
					src="../../static/imgs/my/headimg@2x.png" mode=""></image>
			</view>
			<image v-else @click="wacth(userinfo.avatar)" class="width-120 height-120 margin-r-37 radiu-10"
				:src="userinfo.avatar" mode=""></image>

			<view @click="router.push('/pages/my/person/index')" class="flex-1 flex align-center">
				<view class="flex-1 height-100 flex direction-column align-start justify-between">
					<text
						class="width-400 font-38 bold-font hidden-nowrap-ellipsis-1">{{userinfo.nickname}}</text>
					<view class="flex align-center">
						<view class="levelBox">{{userinfo.level}}</view>
						<view class="gradeBox">{{userinfo.grade}}</view>
					</view>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
		</view>

		<view class="">
			<view @click="router.push('/pages/my/address/index')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/tibidizhi@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.address.title}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
		</view>
		<view class="">
			<view @click="router.push('/pages/my/safety/index')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/anquan.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.safety.title}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
			<view @click="router.push('/pages/my/safety/real')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/shenfen@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.safety.shiming}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
		</view>
		<view class="">
			<!-- <view @click="router.push('/pages/my/butiranKadar/butiranKadar')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/feilv@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.newWord.mytitle4}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view> -->
			<view @click="router.push('/pages/my/aboutUs/rate_overview')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/huilv@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.newWord.mytitle5}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
			<!-- <view @click="router.push('/pages/my/aboutUs/API')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/API@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.newWord.mytitle6}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view> -->
			<!-- <view @click="tos(i18n.newWord.no)" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/shouquan@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.newWord.mytitle7}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view> -->
		</view>
		<view class="">
			<view @click="router.push('/pages/my/help/index')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/bangzhu@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.bangzhu.title}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
			<view @click="router.push('/pages/my/share/index')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/haoyou@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.share.title}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
			<!-- <view @click="router.push('/pages/my/aboutUs/join_community')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/shequn@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.newWord.mytitle10}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view> -->
			<view @click="router.push('/pages/my/aboutUs/index')" class="listBox">
				<view class="flex align-center">
					<image class="width-42 height-42 margin-r-32" src="/static/imgs/my/women@2x.png" mode="">
					</image>
					<text class="font-32 medium-font">{{i18n.mine.about.title}}</text>
				</view>
				<i class="cuIcon-right font-30"></i>
			</view>
		</view>

		<view class="width-600 padding-b-40" style="margin: 10% auto;">
			<button @click="logout" class="cu-btn loginBtn">{{i18n.mine.signout}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBar: uni.getSystemInfoSync().statusBarHeight,
				userinfo: {},
				themeChange: true,
				theme:'',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			}
		},
		onLoad() {
			this.theme = this.$store.state.lightTheme
			this.themeChange = true
		},
		onShow() {
			const lang = uni.getStorageSync('Language')
			if (lang) {
				this.$i18n.locale = lang
			}
			this.getInfo()
		},
		methods: {
			getInfo() {
				this.post('/my/get_userinfo').then((res) => {
					console.log('用户信息', res)
					if (res.code == 1) {
						this.userinfo = res.data
					}
				})
			},
			wacth(url) {
				uni.previewImage({
					urls: [url]
				})
			},
			logout() {
				var that = this
				uni.showModal({
					title: this.i18n.mine.tishi,
					content: this.i18n.mine.content,
					cancelText: this.i18n.mine.cancelText,
					confirmText: this.i18n.mine.confirmText,
					success(res) {
						if (res.confirm) {
							uni.showLoading()
							that.post('/user/logout').then((res) => {
								uni.hideLoading()
								if (res.code == 1) {
									uni.removeStorageSync('token');
									uni.removeStorageSync('user_id');
									uni.removeStorageSync('userinfo');
									that.tos(res.msg)
									setTimeout(() => {
										uni.reLaunch({
											url: '/pages/login/index'
										})
									}, 500)
								}
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.fixed1 {
		position: fixed;
		top: 0;
		z-index: 990;
	}

	.listBox {
		width: 750rpx;
		height: 96rpx;
		padding: 0 46rpx;
		// background: #FFFFFF;
		border-top: 1rpx solid rgba(220, 220, 220, 0.1);
		// border-bottom: 1rpx solid rgba(220, 220, 220, 0.1);
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.lang-btn {
		display: flex;
		align-items: center;
		font-size: 26rpx;
		padding: 8rpx 14rpx;
		border-radius: 8rpx;
		border: 1rpx solid rgba(220, 220, 220, 0.4);
		background: rgba(255, 255, 255, 0.08);
		max-width: 260rpx;
	}

	.lang-icon {
		width: 28rpx;
		height: 28rpx;
		margin-right: 8rpx;
	}

	.lang-text {
		font-size: 26rpx;
		line-height: 1;
		max-width: 200rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.loginBtn {
		width: 600rpx;
		height: 96rpx;
		background: #F00 !important;
		border-radius: 12rpx;
		color: #FFF;
		font-size: 32rpx;
	}

	.levelBox {
		height: 40rpx;
		line-height: 40rpx;
		margin-right: 20rpx;
		background-color: #E5F9F2;
		padding: 0 14rpx;
		font-size: 20rpx;
		color: #333;
		border-radius: 10rpx;
		font-family: "Bold" !important;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.gradeBox {
		height: 40rpx;
		line-height: 40rpx;
		margin-right: 20rpx;
		background-color: #FFEBEB;
		padding: 0 14rpx;
		font-size: 20rpx;
		color: #333;
		border-radius: 10rpx;
		font-family: "Bold" !important;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}
</style>
