fix: 修复返回功能非退出页面的问题,修复首页未获取token的问题
feat: 新增并引入获取BD和agency列表的接口,
This commit is contained in:
parent
028ba67659
commit
2aee9c9e97
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user