<template>
	<view>
		<!-- 禁用弹窗 -->
			 <restrictedTip ref="restrictedTip"/>
		<view class="personalInfo">
			<view class="ulBox">
				<view v-for="item in menuList.filter(v=>v.isShow)" :key="item.title" @click="goDetail(item)"
					class="liBox">
					<view class="infoBox">
						<!-- <image :src="'/static/moduleIcon/'+item.icon+'.png'" alt="" srcset="" mode="widthFix"></image> -->
						<text>{{item.title}}</text>
					</view>
					<view class="iconBox">
						<text v-if="item.contentType">{{item.contentType}}</text>
						<i v-else class="iconfont icon-youjiantou"></i>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
	import api from "@/api/api";
	import restrictedTip from '@/components/commonPopup/restrictedTip.vue';
	export default {
		components:{
						restrictedTip,
					},
		props: {
			menuList: {
				type: Array
			}
		},
		data() {
			return {}
		},
		onShow() {
			if(uni.getStorageSync('loginType')=='codelogin'){
							this.queryInfo()
						}
			// #ifdef H5
						initJssdkShare(() => {
						  setWechatShare();
						}, window.location.href);
						// #endif
		},
		mounted() {
			console.log(this.minorMenuLists, 7412)
		},
		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)
									
								}
								
							})
						},
			goDetail(item) {
				if (item.isShow == true && item.isOpen == true) {
						if (item.isTips == true) {
							uni.showModal({
								title: item.title,
								content: '确定要进行' + item.title + '操作吗?',
								showCancel: true,
								success: function(res) {
									if (res.confirm) {
										uni.showToast({
											title: '操作成功',
											icon: 'none'
										});
									} else {
										console.log('已取消')
									}
								}
							});
						} else if (item.link != null) {
							uni.navigateTo({
								url: item.link
							});
						}else {
							console.log('错误抛出')
						}
				} else {
					common.errorDialog(2, '该模块正在开发中，敬请期待！', '提示');
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.personalInfo {
		background: #fff;
		width: 95%;
		margin: 6rpx auto 0;

		.ulBox {
			padding: 0 30rpx;

			.liBox {
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #E6E6E6;
				height: 92rpx;

				.infoBox {
					display: flex;
					align-items: center;

					image {
						width: 52rpx !important;
						height: 52rpx;
					}
				}

				&:last-child {
					border: none;
				}
			}
		}
	}
</style>
