fix: 修复返回功能非退出页面的问题,修复首页未获取token的问题

feat: 新增并引入获取BD和agency列表的接口,
This commit is contained in:
hzj 2025-09-09 10:36:35 +08:00
parent 028ba67659
commit 2aee9c9e97
2 changed files with 134 additions and 49 deletions

View File

@ -1,12 +1,12 @@
import { get, post } from "../utils/http.js";
import { get, post } from '../utils/http.js';
export const searchUser = async (userId) => {
try {
const response = await get(`/user/user-profile/search?account=${userId}`);
return response;
} catch (error) {
console.error("Failed to fetch search user:", error);
console.error("error:" + error.response.errorMsg);
console.error('Failed to fetch search user:', error);
console.error('error:' + error.response.errorMsg);
throw error;
}
};
@ -19,8 +19,32 @@ export const searchPayRechargeUser = async (params) => {
);
return response;
} catch (error) {
console.error("Failed to fetch search pay recharge user:", error);
console.error("error:" + error.response.errorMsg);
console.error('Failed to fetch search pay recharge user:', error);
console.error('error:' + error.response.errorMsg);
throw error;
}
};
// 获取BD列表
export const getBDList = async (userId) => {
try {
const response = await get(`/team/bd/page?sysOrigin=LIKEI&userId=${userId}`);
return response;
} catch (error) {
console.error('Failed to fetch get BD list:', error);
console.error('error:' + error.response.errorMsg);
throw error;
}
};
// 获取金币代理列表
export const getAgencyList = async (data) => {
try {
const response = await post(`/wallet/freight-gold/client/pageFreight`, data);
return response;
} catch (error) {
console.error('Failed to fetch get agency list:', error);
console.error('error:' + error.response.errorMsg);
throw error;
}
};

View File

@ -1,6 +1,6 @@
<template>
<div class="fullPage">
<MobileHeader title="Admin Center">
<MobileHeader title="Admin Center" :isHomePage="true">
<template v-slot:extraFunction>
<div style="color: rgba(187, 146, 255, 1) !important; font-weight: 600" @click="send">
Send
@ -88,6 +88,8 @@
</div>
</transition>
</div>
<!-- 触发加载功能 -->
<div ref="loadmore" v-if="showLoading"></div>
</div>
<!-- agency列表 -->
@ -158,24 +160,26 @@
</template>
<script setup>
import MobileHeader from "../components/MobileHeader.vue";
import { onMounted, ref, computed } from "vue";
import { getAdminCenterList, giveProps } from "@/api/itemDistribution";
import { searchUser } from "@/api/userInfo";
import { showError, showWarning, showInfo, showSuccess } from "@/utils/toast.js";
import { useRouter } from "vue-router";
import { usePageInitializationWithConfig } from "@/utils/pageConfig.js";
import MobileHeader from '../components/MobileHeader.vue';
import { onMounted, ref, computed, watch } from 'vue';
import { getAdminCenterList, giveProps } from '@/api/itemDistribution';
import { getBDList, getAgencyList } from '@/api/userInfo';
import { showError, showWarning, showInfo, showSuccess } from '@/utils/toast.js';
import { useRouter } from 'vue-router';
import { usePageInitializationWithConfig } from '@/utils/pageConfig.js';
import { getUserId } from '@/utils/userStore.js';
import { useDebounce, useThrottle } from '@/utils/useDebounce';
const router = useRouter();
const tabList = ref([
{
id: 1,
name: "BD",
name: 'BD',
},
{
id: 2,
name: "Recharge Agency",
name: 'Recharge Agency',
},
]);
@ -185,7 +189,7 @@ const tabItems = ref([]); // 存储标签DOM引用
//
const setActiveTab = (index) => {
if (activeIndex.value != index) {
console.log("切换标签");
console.log('切换标签');
activeIndex.value = index;
selectedBDIndex.value = -1;
selectedAgencyIndex.value = -1;
@ -194,17 +198,17 @@ const setActiveTab = (index) => {
// 线
const underlineStyle = computed(() => {
console.log("计算属性");
console.log('计算属性');
if (tabItems.value.length === 0) return {}; //
const activeTab = tabItems.value[activeIndex.value];
console.log("选中元素的左边距", activeTab.offsetLeft);
console.log('选中元素的左边距', activeTab.offsetLeft);
return {
position: "absolute",
position: 'absolute',
left: `${activeTab.offsetLeft + activeTab.offsetWidth / 2 - 15 / 2}px`,
bottom: "0",
transition: "left 0.3s ease", //
bottom: '0',
transition: 'left 0.3s ease', //
};
});
@ -219,52 +223,109 @@ const showAgencyInfo = (index) => {
}; //agency
const send = async () => {
router.push({ path: "/item-distribution" });
router.push({ path: '/item-distribution' });
};
const BDList = ref([
{
name: "BD1",
id: "123",
host: "111",
agency: "222",
},
{
name: "BD2",
id: "456",
host: "333",
agency: "444",
},
]); // BD
// const BDList = ref([]) // BD
const BDList = ref(
Array.from(
{ length: 20 },
(item) =>
(item = {
name: 'BD2',
id: '456',
host: '333',
agency: '444',
})
)
); // BD
const agencyList = ref([
{
name: "agency1",
id: "666",
thisMonth: "112",
lastMonth: "223",
name: 'agency1',
id: '666',
thisMonth: '112',
lastMonth: '223',
},
{
name: "agency2",
id: "777",
thisMonth: "334",
lastMonth: "445",
name: 'agency2',
id: '777',
thisMonth: '334',
lastMonth: '445',
},
]); //
const rechargeDetail = ref({
total: "123456",
lastMonth: "12345",
total: '123456',
lastMonth: '12345',
}); //
//
usePageInitializationWithConfig("ADMIN_CENTER");
usePageInitializationWithConfig('ADMIN_CENTER');
onMounted(() => {
console.log("onMounted");
const totalAgencyCurrent = ref(2); //
const agencyCurrent = ref(1); //
const showLoading = ref(true);
onMounted(async () => {
if (tabItems.value.length > 0) {
underlineStyle.value; //
}
const userId = getUserId();
const resBDList = await getBDList(userId);
console.log('resBDList:', resBDList);
getAgencise();
//
if (loadmore.value) {
observer.observe(loadmore.value);
}
});
//
const getAgencise = async () => {
let agencyData = {
pageQuery: {
cursor: agencyCurrent.value,
limit: 20,
searchCount: true,
},
sysOrigin: 'LIKEI',
close: false,
};
const resagencyList = await getAgencyList(agencyData);
console.log('resagencyList:', resagencyList);
if (resagencyList.status && resagencyList.body) {
totalAgencyCurrent.value = resagencyList.body.total;
agencyCurrent.value = resagencyList.body.current;
if (resagencyList.body.total <= resagencyList.body.current * resagencyList.body.size) {
// showLoading.value = false
}
}
};
// div
const loadmore = ref(null);
const test = () => {
console.log('加载数据1');
};
const debouceGetBDList = useThrottle(test, 1000);
// IntersectionObserver
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0) {
debouceGetBDList();
//
if (totalAgencyCurrent.value > agencyCurrent.value) {
// console.log('')
}
}
});
});
</script>