<template>
    <div>
        <div class="title">{{ $t('me.AddTheWhitelistOfNodeDividendAddresses') }}</div>
        <div class="input-box">
            <van-field v-model="message" :placeholder="$t('me.PleaseProvideTheCompleteAddressOfYourWallet')" />
        </div>
        <div class="admin-btn">
            <van-button class="add" @click="changeFun(1)">{{ $t('me.AddToTheWhitelist') }}</van-button>
            <van-button class="delete" color="#4765DD" @click="changeFun(2)">{{ $t('me.RemoveTheWhitelist') }}</van-button>
            <van-button class="add" @click="changeFun(3)">{{ $t('me.JoinTheAdministratorGroup') }}</van-button>
            <van-button class="delete" color="#4765DD" @click="changeFun(4)">{{ $t('me.RemoveAdministrator') }}</van-button>
        </div>
    </div>
</template>

<script setup>
import { whiteListAdd,whiteListRemove,managerAdd,managerRemove } from '@/api/path/jdfh.api'
import { showToast } from 'vant';
const message = ref('');
const changeFun = async (type) => {
    if (!message.value) {
        showToast($t('me.PleaseEnterTheAddress'));
	    return;
	}
    let res = ''
    if(type == 1){
        res = await whiteListAdd({address:message.value});
    }else if(type == 2){
        res = await whiteListRemove({address:message.value});
    }else if(type == 3){
        res = await managerAdd({address:message.value});
    }else{
        res = await managerRemove({address:message.value});
    }
    if(res.ret){
        showToast(res.data);
    }
    message.value = '';
}
</script>

<style lang="less" scoped>
.title{
    margin: 20px 0 16px;
    text-align: center;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    font-size: 15px;
    color: #000000;
}
.input-box{
    background: #F2F2F2;
    border-radius: 8px;
    border: 1px solid #D8D8D8;
    margin: 0 30px;
    height: 64px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    font-size: 15px;
    color: #8D8D8D;
    :deep(.van-cell){
        background: initial !important;
        height: 64px;
        box-sizing: border-box;
        line-height: 64px;
        padding: 0 16px !important;
    }
}
.admin-btn{
    margin: 32px 30px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    box-sizing: border-box;
    .add,.delete{
        width: calc(95% / 2);
        height: 32px;
        line-height: 32px;
        border-radius: 17px;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 15px;
        color: #FFFFFF;
        border: none !important;
    }
    .add{
        background: #869EFF;
    }
}
</style>