1. // models/Http.js
    2. import axios from 'axios'
    3. axios.defaults.baseURL = 'http://192.168.4.93:7001'
    4. axios.defaults.withCredentials = true;
    5. class Http{
    6. static request({url,method='get',data={},params}){
    7. return axios({
    8. url,
    9. method,
    10. data,
    11. params
    12. })
    13. }
    14. }
    15. 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