mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 03:46:45 +08:00
fix bug 用户中心接口调整
This commit is contained in:
@@ -79,68 +79,68 @@ export function useBoeApiPage(_url, params = {}, config = {
|
||||
};
|
||||
}
|
||||
|
||||
export function useBoeApi(_url, params = {}, config = {
|
||||
init: true,
|
||||
result: res => res.result,
|
||||
}) {
|
||||
// export function useBoeApi(_url, params = {}, config = {
|
||||
// init: true,
|
||||
// result: res => res.result,
|
||||
// }) {
|
||||
//
|
||||
// const state = reactive({
|
||||
// data: [],
|
||||
// loading: false,
|
||||
// });
|
||||
// watch(() => params, () => {
|
||||
// fetch();
|
||||
// });
|
||||
//
|
||||
// function fetch() {
|
||||
// state.loading = true;
|
||||
// return boeRequest(_url, params).then(r => {
|
||||
// state.data = config.result(r);
|
||||
// state.loading = false;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// config.init && fetch();
|
||||
// return {
|
||||
// ...toRefs(state),
|
||||
// fetch,
|
||||
// };
|
||||
// }
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
loading: false,
|
||||
});
|
||||
watch(() => params, () => {
|
||||
fetch();
|
||||
});
|
||||
|
||||
function fetch() {
|
||||
state.loading = true;
|
||||
return boeRequest(_url, params).then(r => {
|
||||
state.data = config.result(r);
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
config.init && fetch();
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
};
|
||||
}
|
||||
|
||||
export function useBoeUserListPage(_url, params = {}, init = true) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
loading: false,
|
||||
total: 0,
|
||||
totalPage: 0,
|
||||
page: 1,
|
||||
...params
|
||||
});
|
||||
|
||||
watch(() => params.keyword, throttle(fetch, 600));
|
||||
watch(() => params.page, fetch);
|
||||
|
||||
function fetch() {
|
||||
state.loading = true;
|
||||
if (!params.keyword) {
|
||||
state.loading = false;
|
||||
return;
|
||||
}
|
||||
return boeRequest(_url, params).then(r => {
|
||||
state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList];
|
||||
state.totalPage = r.result.totalPage;
|
||||
state.total = r.result.totalElement;
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
init && fetch();
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
};
|
||||
}
|
||||
// export function useBoeUserListPage(_url, params = {}, init = true) {
|
||||
//
|
||||
// const state = reactive({
|
||||
// data: [],
|
||||
// loading: false,
|
||||
// total: 0,
|
||||
// totalPage: 0,
|
||||
// page: 1,
|
||||
// ...params
|
||||
// });
|
||||
//
|
||||
// watch(() => params.keyword, throttle(fetch, 600));
|
||||
// watch(() => params.page, fetch);
|
||||
//
|
||||
// function fetch() {
|
||||
// state.loading = true;
|
||||
// if (!params.keyword) {
|
||||
// state.loading = false;
|
||||
// return;
|
||||
// }
|
||||
// return boeRequest(_url, params).then(r => {
|
||||
// state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList];
|
||||
// state.totalPage = r.result.totalPage;
|
||||
// state.total = r.result.totalElement;
|
||||
// state.loading = false;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// init && fetch();
|
||||
// return {
|
||||
// ...toRefs(state),
|
||||
// fetch,
|
||||
// };
|
||||
// }
|
||||
export function useNewRowsPageNoInit(_url, params) {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
@@ -318,7 +318,32 @@ export function useRequest(_url, params, init = true) {
|
||||
fetchData,
|
||||
};
|
||||
}
|
||||
export function useArrayRequest(_url, params, init = true) {
|
||||
|
||||
const data = ref([]);
|
||||
const loading = ref(false);
|
||||
|
||||
if (isRef(params)) {
|
||||
watch(params.value, () => {
|
||||
fetchData();
|
||||
});
|
||||
}
|
||||
|
||||
function fetchData() {
|
||||
loading.value = true;
|
||||
request(_url, unref(params)).then(r => {
|
||||
data.value = r.data;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
init && fetchData();
|
||||
return {
|
||||
data,
|
||||
loading,
|
||||
fetchData,
|
||||
};
|
||||
}
|
||||
export async function boeRequest(_url, params = {}) {
|
||||
const s = _url.split(" ");
|
||||
let url = s[0];
|
||||
|
||||
Reference in New Issue
Block a user