tj
2 天以前 93775e1f3d79a1e11b839abbf24201dafcd9e646
app/src/main/java/com/example/firstapp/ui/home/HomeFragment.kt
@@ -302,8 +302,8 @@
            // 其他标签点击事件需要检查会员状态
            val memberOnlyTabs = mapOf(
                tabIncome to { homeViewModel.loadIncomeData() },
                tabFlight to { homeViewModel.loadFlightData() },
                tabTrain to { homeViewModel.loadTrainData() }
//                tabFlight to { homeViewModel.loadFlightData() },
//                tabTrain to { homeViewModel.loadTrainData() }
            )
            memberOnlyTabs.forEach { (tab, loadAction) ->
@@ -312,8 +312,8 @@
                        hideAllRecyclers()
                        when (tab) {
                            tabIncome -> incomeRecycler.visibility = View.VISIBLE
                            tabFlight -> flightRecycler.visibility = View.VISIBLE
                            tabTrain -> trainRecycler.visibility = View.VISIBLE
//                            tabFlight -> flightRecycler.visibility = View.VISIBLE
//                            tabTrain -> trainRecycler.visibility = View.VISIBLE
                        }
                        updateTabStyles(tab)
                        loadAction()
@@ -367,7 +367,8 @@
    private fun updateTabStyles(selectedTab: UnderlineTextView) {
        binding.apply {
            val tabs = listOf(tabExpress, tabFinance, tabIncome, tabFlight, tabTrain)
//            val tabs = listOf(tabExpress, tabFinance, tabIncome, tabFlight, tabTrain)
            val tabs = listOf(tabExpress, tabFinance, tabIncome)
            tabs.forEach { tab ->
                // 设置文字颜色为黑色或灰色
                tab.setTextColor(ContextCompat.getColor(requireContext(),
@@ -416,8 +417,8 @@
                tabExpress.visibility = View.GONE
                tabFinance.visibility = View.GONE
                tabIncome.visibility = View.GONE
                tabFlight.visibility = View.GONE
                tabTrain.visibility = View.GONE
//                tabFlight.visibility = View.GONE
//                tabTrain.visibility = View.GONE
                // 获取用户信息判断是否是会员
                val savedPhone = PreferencesManager.getPhone()
@@ -451,14 +452,14 @@
                                        tabIncome.visibility = if (category.isEnabled) View.VISIBLE else View.GONE
                                        if (categories.indexOf(category) == 0 && category.isEnabled) tabIncome.performClick()
                                    }
                                    "航班" -> {
                                        tabFlight.visibility = if (category.isEnabled) View.VISIBLE else View.GONE
                                        if (categories.indexOf(category) == 0 && category.isEnabled) tabFlight.performClick()
                                    }
                                    "火车票" -> {
                                        tabTrain.visibility = if (category.isEnabled) View.VISIBLE else View.GONE
                                        if (categories.indexOf(category) == 0 && category.isEnabled) tabTrain.performClick()
                                    }
//                                    "航班" -> {
//                                        tabFlight.visibility = if (category.isEnabled) View.VISIBLE else View.GONE
//                                        if (categories.indexOf(category) == 0 && category.isEnabled) tabFlight.performClick()
//                                    }
//                                    "火车票" -> {
//                                        tabTrain.visibility = if (category.isEnabled) View.VISIBLE else View.GONE
//                                        if (categories.indexOf(category) == 0 && category.isEnabled) tabTrain.performClick()
//                                    }
                                }
                            }
                        }
@@ -596,7 +597,37 @@
                    if (isMember) {
                        // 会员可以看到所有分类
                        adapter.setCategories(categories)
                        val serverCategories = RetrofitClient.apiService.getUserCategories(response.data?.id.toString())
                        if(serverCategories.size==2 && serverCategories[0].name=="快递"&&serverCategories[1].name=="还款"){
                            // 将 serverCategories 转换为可变列表
                            val mutableServerCategories = serverCategories.toMutableList()
                            // 添加多个新分类
                            mutableServerCategories.add(CategoryConfig(
                                id = 5,
                                name = "火车票",
                                order = 4,
                                isEnabled = false
                            ))
                            mutableServerCategories.add(CategoryConfig(
                                id = 4,
                                name = "航班",
                                order = 3,
                                isEnabled = false
                            ))
                            mutableServerCategories.add(CategoryConfig(
                                id = 3,
                                name = "收入",
                                order = 2,
                                isEnabled = false
                            ))
                            // 设置适配器的分类列表
                            adapter.setCategories(mutableServerCategories)
                        }else {
                            adapter.setCategories(serverCategories)
                        }
                    } else {
                        // 非会员只能看到快递和还款
                        val limitedCategories = categories.filter {