<template>
	<view style="display: flex;flex-direction: column;">
		<!-- 禁用弹窗 -->
			 <restrictedTip ref="restrictedTip"/>
		<!-- #ifdef APP -->
		<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()" style="top: 10rpx;"></text>
		<!-- #endif -->
		
		<view>
			<menu-list v-if="menuList != 'undefined '" :menuList="minorMenuLists"></menu-list>
		</view>
		<view class="footer">
			<view class="foter-btn">
				<button class="btn" @click="outLing()">退出登录</button>
			</view>
			
		</view>
	</view>

</template>

<script>
	import  MenuList from "@/components/menuList/menuList.vue"
	import {companyInfo} from "@/environments/environment";
	import dataHandling from "@/util/dataHandling";
	import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
	import api from "@/api/api";
	import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
	export default {
		components:{ MenuList,restrictedTip, },
		data() {
			return {
				menuList:null,
				minorMenuLists: [{
						title: '账号绑定设置',
						icon: 'shareEcode',
						link: '/pages/personalCenter/system/accontsetting',
						isOpen: true,
						isShow: true,
						isTips: false,
					},
					{
						title: '清除缓存',
						icon: 'card',
						link: '',
						isOpen: true,
						isShow: true,
						isTips: true,
					},
					// {
					// 	title: '关于'+companyInfo.appName+'APP',
					// 	icon: 'myCertify',
					// 	link: '/pages/personalCenter/accountoperation/aboutcffp',
					// 	isOpen: true,
					// 	isShow: true,
					// 	isTips: false,
					// },
				]
			}
		},
		onShow() {
			if(uni.getStorageSync('loginType')=='codelogin'){
							this.queryInfo()
						}
			// #ifdef H5
			initJssdkShare(() => {
			  setWechatShare();
			}, window.location.href);
			// #endif
			// #ifdef APP
			this.minorMenuLists.push({
						title: '关于'+companyInfo.appName+'APP',
						icon: 'myCertify',
						link: '/pages/personalCenter/accountoperation/aboutcffp',
						isOpen: true,
						isShow: true,
						isTips: false,
					},)
			// #endif
		},
		destroyed() {
			uni.hideToast();
		},
		methods:{
			queryInfo() {
							api.queryInfo({userId:uni.getStorageSync('cffp_userId')}).then(res=>{
								// 保存用户得个人信息
								if (res['success']) {
									delete res.data.commonResult
									
									const cffp_userInfo = {
										...res.data
									}
									// 账号禁用用户
									if(res.data.userIsActive&&res.data.userIsActive==2){
										this.$refs.restrictedTip.open()
										uni.setStorageSync('userIsActive',String(res.data.userIsActive))
										return
									}
									if(res.data.userIsActive&&res.data.userIsActive!=2){
										this.$refs.restrictedTip.close()
										uni.removeStorageSync('userIsActive')
									}
									
									uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo));
									uni.setStorageSync('user_mobile', res.data.mobile)
									
								}
								
							})
						},
			goBack(){
				uni.switchTab({
					url: '/pages/personalCenter/personalCenter'
				});
			},
			outLing(){
				uni.showModal({
					title: '退出登录',
					content: '确定要退出登录吗?',
					showCancel: true,
					success: function(res) {
						if (res.confirm) {
								dataHandling.pocessTracking(
								  '退出登录',
								  `用户退出系统`,
								  '点击',
								  2,
								  '设置',
								  'pages/personalCenter/system/settings'
								)
								try {
									if(uni.getStorageSync('savedShareImage')){
										uni.removeStorageSync('savedShareImage')
									}
									uni.setStorageSync('loginType','visitor');
								} catch (e) {
									console.log(e)
								    // error
								}
								console.log('退出登录');
								uni.clearStorageSync();
								uni.redirectTo({
									url:'/myPackageA/login/login'
								})
								
							uni.showToast({
								title: '操作成功',
								icon: 'none'
							});
						} else {
							console.log('已取消')
						}
					}
				});
			},
		},
		
	}
</script>

<style scoped>
	.footer{
		width: 100vw;
		position: fixed;
		bottom: 40rpx;
	}
	.foter-btn{
		padding: 0 20rpx;
	}
	.btn{
		background:  #20269B;
		border-radius: 40rpx;
		font-size: 28rpx;
	}
</style>
