import { defineStore } from 'pinia'
import { bindApplyStore } from './bindApply'

export const useBadgeStore = defineStore('badge', () => {
  const { getApplyBindInfoList } = bindApplyStore()

  async function refreshBadge() {
    // 我的
    const mineIndex = 2
    const size = (await getApplyBindInfoList())?.length
    if (size) {
      uni.setTabBarBadge({
        index: mineIndex,
        text: `${size}`,
      })
    } else {
      uni.removeTabBarBadge({
        index: mineIndex,
      })
    }
  }

  return {
    refreshBadge,
  }
})
