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) => { export const searchUser = async (userId) => {
try { try {
const response = await get(`/user/user-profile/search?account=${userId}`); const response = await get(`/user/user-profile/search?account=${userId}`);
return response; return response;
} catch (error) { } catch (error) {
console.error("Failed to fetch search user:", error); console.error('Failed to fetch search user:', error);
console.error("error:" + error.response.errorMsg); console.error('error:' + error.response.errorMsg);
throw error; throw error;
} }
}; };
@ -19,8 +19,32 @@ export const searchPayRechargeUser = async (params) => {
); );
return response; return response;
} catch (error) { } catch (error) {
console.error("Failed to fetch search pay recharge user:", error); console.error('Failed to fetch search pay recharge user:', error);
console.error("error:" + error.response.errorMsg); 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; throw error;
} }
}; };

View File

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