<template>
	<cwg-page-wrapper :isHeaderFixed="true">
		<view class="page">
			<cwg-header :title="t('pages.mine.index')">
				<div class="language-switch" @click="router.push('/pages/mine/cog')">
					<cwg-icon color="#000" icon="cog-outline" />
				</div>
			</cwg-header>
			<view class="user-card">
				<view class="avatar"></view>
				<view class="user-info">
					<view class="phone">{{ userInfo?.email }}</view>
				</view>
			</view>
			<view class="group">
				<view class="group-item" @click="openProfile()">
					<cwg-icon color="#000" icon="shield-lock-open-outline" />
					<text class="item-text">{{ t("language.i3") }}</text>
					<text class="item-text version" v-if="!isPersonalInfoCompleted">{{ t("language.i0") }}</text>
					<text class="item-text version" v-if="isPersonalInfoCompleted">{{ t("State.ToCertified") }}</text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/apply-record/list')">
					<cwg-icon color="#000" icon="kksq" />
					<text class="item-text">{{ t("card.tab15") }}</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/wallet/balance')">
					<cwg-icon color="#000" icon="qbye" />
					<text class="item-text">{{ t("card.tab17") }}</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/wallet/vaultody-list')">
					<cwg-icon color="#000" icon="qbye" />
					<text class="item-text">钱包充值记录</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/wallet/withdraw-list')">
					<cwg-icon color="#000" icon="qbye" />
					<text class="item-text">钱包提现记录</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/mine/help')">
					<cwg-icon color="#000" icon="cjwt" />
					<text class="item-text">{{ t('pages.mine.help') }}</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
				<view class="group-item" @click="router.push('/pages/mine/cog')">
					<cwg-icon color="#000" icon="sz" />
					<text class="item-text">{{ t('pages.mine.cog') }}</text>
					<text class="version item-text"></text>
					<cwg-icon color="#000" icon="chevron-right" />
				</view>
			</view>
		</view>
	</cwg-page-wrapper>

</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import { useI18n } from "vue-i18n";
import useRouter from "@/hooks/useRouter";
import useUserStore from "@/stores/use-user-store";
const { t } = useI18n();
const userStore = useUserStore();
const router = useRouter();
const userInfo = computed(() => userStore.userInfo);
// 判断是否已完成个人信息认证
const isPersonalInfoCompleted = computed(() => {
	if (userInfo?.approveStatus == 2) {
		return true;
	} else {
		return false;
	}
});

function openProfile() {
	if (!isPersonalInfoCompleted.value) {
		router.push('/pages/mine/info');
	} else {
		router.push('/pages/mine/improve');
	}
}
</script>

<style scoped lang="scss">
@import "@/uni.scss";

:deep(.u-modal__content) {
	padding: px2rpx(24) px2rpx(40);

	.p1 {
		color: #363130;
		font-family: "League Spartan";
		font-size: px2rpx(17);
		font-style: normal;
		font-weight: 400;
		line-height: normal;
		margin-bottom: px2rpx(32);
	}

	.modal-class {
		width: px2rpx(300);

	}

	.title {
		color: #1a1a1a;
		text-align: center;
		font-family: Roboto;
		font-size: px2rpx(22);
		font-style: normal;
		font-weight: 600;
		line-height: px2rpx(22);
	}

	.no-button {
		width: 100%;
		margin: px2rpx(12) 0;

		.u-button {
			background-color: #ffbdc8 !important;
		}
	}

	.ok-button {
		margin: px2rpx(4) 0;
		/* background-color: #EA002A; */
	}
}

.user-card {
	width: 100%;
	display: inline-flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: px2rpx(24);
	padding-bottom: px2rpx(48);

	.avatar {
		width: px2rpx(64);
		height: px2rpx(64);
		border-radius: 50%;
		background: #d8d8d8 url("/static/images/avatars.png") center/cover no-repeat;
		border: 4rpx solid #fff;
	}

	.phone {
		color: #1a1a1a;
		font-family: Roboto;
		font-size: px2rpx(22);
		font-style: normal;
		font-weight: 600;
		line-height: px2rpx(4);
	}
}

.user-info .group {
	background: var(--action-bg);
	border-radius: px2rpx(16);
	margin-top: px2rpx(24);
	overflow: hidden;
}

.group-item {
	display: flex;
	align-items: center;
	padding: px2rpx(16) 0;
	color: #000;
	font-size: px2rpx(16);
	/* border-bottom: 2rpx solid var(--action-bg); */
	position: relative;
}

.group-item:last-child {
	border-bottom: none;
}

svg {
	width: px2rpx(24);
	height: px2rpx(24);
	color: #000;
	font-size: px2rpx(24);
}

.group-item .version {
	margin-left: auto;
	color: #000;
	font-size: px2rpx(16);
}

.item-text {
	margin-left: px2rpx(12);
}

.code-dialog {
	display: flex;
	justify-content: center;
	gap: px2rpx(12);
	padding: px2rpx(16);

	:deep(.u-popup__content) {
		width: 90% !important;
	}

	:deep(.u-modal) {
		width: 100% !important;
	}
}
</style>