| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 | <template>    <div class="tab-bar-wrappeer">        <template            v-for="(item, index) in tabbarData"            :key="index">            <div class="tab-item"                  v-if="item.path != '/NFT' || item.path == '/NFT' && showNFTTab"                 @click="tabbarHandler(item, index)">                    <red-dot class="red-dots"                        v-if="unReadCountTask > 0 && item.path == '/message' && currentTab.path != '/message'"                        ></red-dot>                    <img                        :src="                            index == currentTab.index                                ? item.iconActive                                : item.iconInActive                        "                    />                    <div                        class="text"                        :class="{ 'active-tab': index == currentTab.index }"                    >                        {{ item.name }}                    </div>            </div>        </template>    </div></template><script setup>import { ref, onMounted, defineProps, defineEmits, nextTick, watch } from "vue";import redDot from "@/view/components/red-dot.vue";import router from "@/router/popup.js";import { setBadgeInfo, hideBadge } from "@/logic/background/twitter";import { nftListMine } from "@/http/nft.js";import { getAllMessageInfo } from "@/http/messageApi"const props = defineProps({    userInfo: {        type: Object,        default: () => {            return {                accessToken: undefined,            };        }    },});watch(    () => props.userInfo,    (newVal) => {        getNFTListMine();    },    {        deep: true    });let currentTab = ref({    index: 0,    path: '/'});let unReadCountTask = ref(0);let showNFTTab = ref(true);let tabbarData = ref([    {        name: "Wallet",        path: "/",        iconActive: require("@/assets/svg/icon-tab-wallet-active.svg"),        iconInActive: require("@/assets/svg/icon-tab-wallet.svg"),    },    {        name: "NFTs",        path: "/NFT",        iconActive: require("@/assets/svg/icon-tab-NFT-active.svg"),        iconInActive: require("@/assets/svg/icon-tab-NFT.svg"),    },    {        name: "Message",        path: "/message",        iconActive: require("@/assets/svg/icon-tab-message-active.svg"),        iconInActive: require("@/assets/svg/icon-tab-message.svg"),    },    {        name: "More",        path: "/more",        iconActive: require("@/assets/svg/icon-tab-more-active.svg"),        iconInActive: require("@/assets/svg/icon-tab-more.svg"),    },]);let NFTReqParams = {    params: {        pageNum: 1,        pageSize: 20,    },};const emits = defineEmits(["tabbarClick"]);const tabbarHandler = (params, index) => {    setMessageCount();    currentTab.value.index = index;    currentTab.value.path = params.path;    router.push(params.path);    emits("tabbarClick", params);};const setActiveTab = () => {    nextTick(() => {        let path = router.currentRoute.value.path;        let list = tabbarData.value;        for (let i = 0; i < list.length; i++) {            if (path == list[i].path) {                currentTab.value.index = i;                currentTab.value.path = path;                break;            }        }    })};const getNFTListMine = () => {    console.log(props.userInfo.accessToken)    if(!props.userInfo.accessToken) return;    nftListMine({        params: NFTReqParams.params,    }).then((res) => {        if (res.data && res.data.length) {            showNFTTab.value = true;        } else {            showNFTTab.value = false;        }    });};const setMessageCount = () => {    if(!props.userInfo.accessToken) return;    getAllMessageInfo({params: {    }}).then(res => {        if(res.code == 0) {            let {unReadCountTotal = 0, unReadCountWalletDetail = 0, unReadCountTaskLuckdrop = 0} = res.data;            unReadCountTask.value = unReadCountTaskLuckdrop;            if(unReadCountTotal > 0) {                let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal+'';                setBadgeInfo({data: {text}});            } else {                hideBadge();            }        }    });}onMounted(() => {    setActiveTab();    setMessageCount();});</script><style scoped lang="scss">.tab-bar-wrappeer {    background: #ffffff;    box-shadow: inset 0px 1px 0px #ececec;    width: 100%;    height: 70px;    display: flex;    align-items: center;    justify-content: center;    position: absolute;    z-index: 1000;    bottom: 0px;    cursor: pointer;        .tab-item {            flex: 1;            text-align: center;            position: relative;            .text {                font-weight: 500;                font-size: 12px;                color: #c0c0c0;            }            .active-tab {                color: #1d9bf0 !important;            }            .red-dots {                position: absolute;                right: 32%;                top: 0px;            }        }    }</style>
 |