This commit is contained in:
yuping
2022-12-13 18:27:38 +08:00
parent c75d463c40
commit 6ce31f7ba7

View File

@@ -2,6 +2,7 @@ import router from "@/router";
import {reactive, ref, toRefs, watch} from "vue"; import {reactive, ref, toRefs, watch} from "vue";
import axios from 'axios'; import axios from 'axios';
import {getCookie} from "@/api/utils"; import {getCookie} from "@/api/utils";
import {BASE} from "@/api/api";
export function usePage(_url, param) { export function usePage(_url, param) {
@@ -22,7 +23,7 @@ export function usePage(_url, param) {
function fetchData() { function fetchData() {
state.loading = true state.loading = true
request(_url, state.params).then(r => { request(_url, state.params).then(r => {
state.params.pageNo === 1 ? (state.data = (r.data.records||r.data.rows)) : (state.data = [...state.data, ...(r.data.records||r.data.rows)]) state.params.pageNo === 1 ? (state.data = (r.data.records || r.data.rows)) : (state.data = [...state.data, ...(r.data.records || r.data.rows)])
state.size = r.data.size state.size = r.data.size
state.total = r.data.total state.total = r.data.total
state.current = r.data.current state.current = r.data.current
@@ -82,7 +83,7 @@ export async function request(_url, params) {
} }
const body = method !== 'get' ? params || {} : {} const body = method !== 'get' ? params || {} : {}
return axios({ return axios({
url, url: BASE + url,
method, method,
headers: { headers: {
'X-Token': localStorage.getItem('token'), 'X-Token': localStorage.getItem('token'),