网络请求

import axios from 'axios';

const baseURL = 'http://172.22.68.59/api/' //测试接口


export function httpCline(config) {
const install = axios.create({
baseURL,
timeOut: 5000
});
install.interceptors.request.use(config => {
if (JSON.parse(localStorage.getItem('citydata'))) {
JSON.parse(localStorage.getItem('citydata')).Token || '';
}
return config;
}, err => {
return err
});
install.interceptors.response.use(res => {
return res.data;
}, err => {
return err;
});
return install(config);
}


用法:
api.js
import {
httpCline
} from './request';


//获取北斗渔船信息
export function api_GetBeidouShipPath() {
return httpCline({
method: 'get',
url: apiurl_103 +'DataCenter/GetBeidouShipPath',
})
}


组件:
import { api_GetBeidouShipPath } from '../../../../network/api.js';
//渔船方法
async ClicFishingBoat(){
var that=this;
if(that.IsFishingBoat){
that.IsFishingBoat=false;
let res = await api_GetBeidouShipPath();
if(res.IsSuc) {
this.addPoints(res.Data);//根据坐标点批量打点
}

}else{
that.IsFishingBoat=true;
that.mymap.map.removeLayer(that.pointLayer);
}
},

 

posted @ 2022-09-28 10:19  小林222  阅读(22)  评论(0)    收藏  举报