<template>
	<view class="mine-page">
		<!-- 头部 -->
		<headContent borderBottom>
			<template #left>
				<reverse-back />
			</template>
			<template #content>
				<view class="haed-title">
					个人中心
				</view>
			</template>
			<template #right>
				<page-style />
			</template>
		</headContent>

		<!-- 个人信息 -->
		<view class="mine-info" v-if="showMuen">
			<view class="mine-account">{{ userInfo.account }}</view>
			<!-- <view class="mine-account">{{ $showAccount(userInfo.account_number) }}</view> -->
			<view class="mine-UID">UID: {{ userInfo.id }}<text v-show="userInfo.id" class="mine-copy iconfont"
					@click.stop="setCopy(userInfo.id)">&#xe65f;</text>
			</view>
		</view>
		<!-- 个人信息 -->
		<view class="mine-info" v-else @click.stop="goLogin()">
			<view class="mine-account">点击登录/注册</view>
			<view class="mine-UID">Hi, 欢迎来到BiKing</view>
		</view>

		<gap />
		<!-- 个人信息 -->
		<view class="mine-muen">
			<view v-show="showMuen" class="mine-muen-item" @click.stop="openSafetySet()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xec4d;</text>
					<!-- 
					<text class="muen-icon iconfont">&#xe616;</text> -->
					<text class="muen-text">安全设置</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
					<!-- <image class="muen-more-icon" src="../../static/logo.png" mode="aspectFit" /> -->
				</view>
			</view>
			<view v-show="showMuen" class="mine-muen-item" @click.stop="goIdentification()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe616;</text>
					<text class="muen-text">身份验证</text>
				</view>
				<view class="muen-more">
					<text class="muen-more-text">{{ userInfo.is_realname == 1 ? '去认证' : '' }}</text>
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view v-show="showMuen" class="mine-muen-item" @click.stop="getAddress()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe688;</text>
					<text class="muen-text">提现地址</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view v-show="showMuen" class="mine-muen-item">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe784;</text>
					<text class="muen-text">我的红包</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view v-show="showMuen" class="mine-muen-item" @click.stop="openActivityCenter()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe614;</text>
					<text class="muen-text">活动中心</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view class="mine-muen-item" @click.stop="openShare()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe615;</text>
					<text class="muen-text">邀请链接</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view v-show="showMuen" class="mine-muen-item">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe6e3;</text>
					<text class="muen-text">合约战绩</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
		</view>

		<gap />
		<view class="mine-muen">
			<view class="mine-muen-item" @click.stop="openSetting()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe616;</text>
					<text class="muen-text">系统设置</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
		</view>
		<gap />
		<view class="mine-muen">
			<view class="mine-muen-item">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe823;</text>
					<text class="muen-text">检查更新</text>
				</view>
				<view class="muen-more">
					<text class="muen-more-text">当前版本 V2.4.6 62</text>
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
		</view>
		<gap />
		<view class="mine-muen">
			<view class="mine-muen-item" @click.stop="getService()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe621;</text>
					<text class="muen-text">在线客服</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view class="mine-muen-item" @click.stop="getAboutUs()">
				<view class="muen-content">
					<text class="muen-icon iconfont">&#xe609;</text>
					<text class="muen-text">关于我们</text>
				</view>
				<view class="muen-more">
					<text class="more-icon iconfont">&#xe8b5;</text>
				</view>
			</view>
			<view class="mine-btn" @click.stop="retreatFromLogin" v-show="showMuen">
				安全退出
			</view>
		</view>


		<!-- 邀请 -->
		<sharePage ref="sharePageRef" :tabBar="false" />

		<!-- 确认退出 -->
		<confirm-popup ref="confirmPopup" @confirm="confirmOut" content="确认退出此账号"/>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import reverseBack from "@/components/headModules/reverse-back.vue"
	import pageStyle from "@/components/headModules/style.vue"
	import {
		Way_getUserInfo
	} from "@/utils/common-request.js"
	import {
		refreshAccount
	} from "@/utils/common.js"

	export default {
		components: {
			pageStyle,
			reverseBack
		},
		data() {
			return {
				showMuen: false,
				userInfo: {}
			};
		},
		onShow() {

		},
		computed: {
			...mapGetters([
				'token'
			]),
		},
		watch: {
			token: {
				handler(newToken) {
					this.showMuen = newToken ? true : false
					if (newToken) {
						this.getUserInfo()
					}
				},
				immediate: true
			}
		},
		methods: {
			// 获取用户信息
			getUserInfo() {
				Way_getUserInfo().then(res => {
					this.userInfo = res
				}).catch(err => {
					this.userInfo = {}
				})
			},
			// 去登陆
			goLogin() {
				uni.navigateTo({
					url: '/pages/login/index'
				});
			},
			// 打开邀请
			openShare() {
				this.$nextTick(() => {
					this.$refs.sharePageRef.openShare()
				})
			},
			// 系统设置
			openSetting() {
				uni.navigateTo({
					url: '/pages/content/setting'
				})
			},
			// 安全设置
			openSafetySet() {
				uni.navigateTo({
					url: '/pages/content/safety-set'
				})
			},
			// 在线客服
			getService() {
				uni.navigateTo({
					// url: '/pages/content/customer-service'
					url: this.$path.service
				})
			},
			// 关于我们
			getAboutUs() {
				// this.getSinglePage(1)
				uni.navigateTo({
					url:'/pages/content/About-Us'
				})
			},
			// 安全退出
			retreatFromLogin() {
				this.$nextTick(() => {
					this.$refs.confirmPopup.open()
				});
			},
			// 确认 安全退出 
			confirmOut() {
				refreshAccount()
			},
			// 获取地址列表
			getAddress() {
				uni.navigateTo({
					url: '/pages/content/address'
				})
			},
			openActivityCenter() {
				// this.getSinglePage(2)
				
				uni.navigateTo({
					url: '/pages/content/activity-center'
				})
			},

			getSinglePage(id) {

				uni.navigateTo({
					url: `/pages/content/h5-list?id=${id}`
				})
			},
			setCopy(val) {
				uni.setClipboardData({
					data: val,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						})
					}
				});
			},
			// 去认证
			goIdentification(){
				uni.navigateTo({
					url:'/pages/content/identification/index'
				})
				
				// , {
				// 	"path": "pages/content/identification/index",
				// 	"style": {
				// 		"navigationBarTitleText": "身份验证",
				// 		"enablePullDownRefresh": false
				// 	}
				
				// }, {
				// 	"path": "pages/content/identification/select-type",
				// 	"style": {
				// 		"navigationBarTitleText": "选择验证类型",
				// 		"enablePullDownRefresh": false
				// 	}
				
				// }
				
				
				
				
			}



		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.mine-info {
		width: 100%;
		min-height: 140rpx;
		background-color: $modules-box-bg;
		padding: 23rpx $pages-padding 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.mine-account {
			font-size: 34rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			color: #1a1a1a;
		}

		.mine-UID {
			margin-top: 13rpx;
			font-size: 22rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			color: #808080;
			display: flex;
			align-items: center;

			.copy-UID {
				width: 22rpx;
				height: 26rpx;
				margin-left: 12rpx;
			}

			.mine-copy {
				margin-left: 10rpx;
				font-size: 30rpx;
			}
		}
	}

	// <view class="mine-muen">
	// 	<view class="muen-content">
	// 		<image class="muen-icon" src="../../static/logo.png" mode="aspectFit" /> <text class="muen-text">安全设置</text>
	// 	</view>
	// 	<image class="muen-moey" src="../../static/logo.png" mode="aspectFit" />
	// </view>
	.mine-muen-item {
		width: 100%;
		height: 94rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: $modules-box-bg;
		padding: 0 $pages-padding;
		border-bottom: 1rpx solid #f2f2f2;

		&:last-child {
			border-bottom: none;
		}

		.muen-content {
			display: flex;
			align-items: center;

			.muen-icon {
				width: 50rpx;
				// height: 28rpx;
				font-size: 32rpx;
			}

			.muen-text {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-Regular;
				font-weight: 400;
				color: #1a1a1a;
				line-height: 40rpx;
			}
		}

		.muen-more {
			flex-shrink: 0;
			display: flex;
			align-items: center;

			.muen-more-text {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-Regular;
				font-weight: 400;
				color: #0abd76;
				padding-right: 8rpx;
			}

			.more-icon {

				font-size: 30rpx;
				color: #939292;
				transform: rotate(-180deg);
			}
		}
	}

	.mine-btn {
		width: 690rpx;
		height: 90rpx;
		margin: 80rpx auto;
		background: #05c175;
		border-radius: 8rpx;


		font-size: 30rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #ffffff;
		line-height: 90rpx;
		letter-spacing: 0.64rpx;
	}
</style>