// models/Http.js
import axios from 'axios'
axios.defaults.baseURL = 'http://192.168.4.93:7001'
axios.defaults.withCredentials = true;
class Http{
static request({url,method='get',data={},params}){
return axios({
url,
method,
data,
params
})
}
}
export default Http
// models/GoodsHttp.js
import Http from './Http'
class GoodsHttp extends Http{
static getPagination({offset=0,limit=8}){
this.request({
url:'/api/goods',
params:{
offset,
limit
}
})
}
// 获取价格区间0-100
static getPriceRange({min,max}){
this.request({
url:'/api/goods',
params:{
min,
max
}
})
}
// 价格升降序
static getSortPrice(price){
this.request({
url:'/api/sort',
params:{
price
}
})
}
}
export default GoodsHttp