<template>
    <div class="account_frontPage">
		<a-tabs class="account_frontPage_body" v-model:activeKey="activeKey" @change="changeTabs">
			<a-tab-pane v-for="item in frontPageList" :key="item.key">
				<myInformation v-if="item.key == 'myInformation'" :ref="item.key"></myInformation>
				<bind v-if="item.key == 'bind'" :ref="item.key"></bind>
				<cancelRenewal v-if="item.key == 'cancelRenewal'" :ref="item.key"></cancelRenewal>
				<template #tab>
					<a-badge :count="0" >
						<span>{{item.title}}</span>
					</a-badge>
				</template>
			</a-tab-pane>
		</a-tabs>
    </div>
</template>
<script lang="ts">
import { defineComponent,computed,ref,reactive,nextTick,toRefs,createVNode, onMounted} from 'vue'
import { Https } from "@/tool/https";
import { useRouter,useRoute } from 'vue-router'
import { Modal,message } from 'ant-design-vue';
import { useStore } from "vuex";
import { setCookie, getCookie, WriteCookie } from "@/tool/cookie";
import myInformation from '@/component/Account/frontPage/mylnformation.vue';
import bind from '@/component/Account/frontPage/bindPage.vue';
import cancelRenewal from '@/component/Account/frontPage/cancelRenewal.vue';
import { useI18n } from 'vue-i18n'
export default defineComponent({
    components:{
		myInformation,
		bind,
		cancelRenewal,
    },
    setup() {
		const {t} = useI18n()
		const router = useRouter()
        const store = useStore();
		let accountfrontPage = reactive({
			frontPageList:[
				{
					title:t('account.myInfor'),
					key:'myInformation',
				},{
					title:t('account.bindWeChat'),
					key:'bind',
				},{
					title:t('account.cancel'),
					key:'cancelRenewal',
				}
				
			],
			activeKey: '',
		})
		let domRefs:any = reactive({
			myInformation:ref(null),
			bind:ref(null),
			cancelRenewal:ref(null),
		})
		let changeTabs = (key:any)=>{
			console.log(key);
			
			// if(accountfrontPage.activeKey == 'service')return
		}
		let setReadStatus = (value:any)=>{
			return new Promise((resolve,reject)=>{
				if(value.isRead == 1)return reject('')
				let data = {
					type:accountfrontPage.activeKey,
					notificationIdList:value.id
				}
				Https.axiosPost(Https.httpUrls.setReadStatus,'',{params:data}).then((rv)=>{
					if(rv){
						resolve(rv)
						// store.commit('setfrontPageSystem',rv)
					}
				}).catch((err)=>{
					reject(err)
				})
			})
			
		}
		let setAllfrontPage = ()=>{
			return new Promise((resolve,reject)=>{
				let data = {
					type:accountfrontPage.activeKey
				}
				Https.axiosPost(Https.httpUrls.oneClickRead,'',{params:data}).then((rv)=>{
					resolve(rv)
				}).catch((err)=>{
					reject(err
					)
				})
			})
		}
		let getHistory = (data:any)=>{
			return new Promise((resolve,reject)=>{
				data.type = accountfrontPage.activeKey
				let url = Https.httpUrls.getHistoryNotification
				// if(data.type == 'follow'){
				// 	url = Https.httpUrls.porfolioGetFollowerList
				// }
				Https.axiosPost(url,data).then((rv)=>{
					if(rv){
						// domRefs[data.type][0].setfrontPageList(rv,data)
						resolve(rv)
					}
				}).catch((err)=>{
					reject(err)
				})
			})
		}
		onMounted(()=>{
			let key = accountfrontPage.frontPageList[0].key
			accountfrontPage.activeKey = key
		})
        return{
           ...toRefs(accountfrontPage),
           ...toRefs(domRefs),
		   setReadStatus,
		   changeTabs,
		   setAllfrontPage,
		   getHistory,
        }
    },
    data(){
        return{
            
        }
    },
})
</script>
<style lang="less" scoped>
.account_frontPage{
	width: 100%;
	.account_frontPage_body{
		padding-bottom: 3rem;
		:deep(.ant-badge){
			font-size: var(--aida-fsize2);
		}
		:deep(.ant-tabs-tabpane){
			padding: 0 5rem;
		}
		:deep(.ant-tabs-nav){
			padding: 0rem 5rem;
			&::before{
			    display: none;
			}
			.ant-tabs-nav-wrap{
				.ant-tabs-tab-btn{
					font-size: 2.4rem;
				}
				.ant-tabs-tab-active{
					.ant-tabs-tab-btn{
						font-weight: 900;
					}
				}
			}
			.ant-tabs-ink-bar{
				background: #000;
			}
		}
		
	}
}
</style>

