123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- "use strict";
- function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }
- var imgUrl = 'https://cmcoa.oss-cn-shanghai.aliyuncs.com/';
- var apiUrl = 'http://api.inet.cmcinc.cn/';
- // let apiUrl = 'http://118.24.176.28:8766/'
- // let imgUrl = 'http://cdn.info666.com/'
- var service = axios.create({
- baseURL: apiUrl,
- timeout: 90000
- }); // let resLoading = {}
- service.interceptors.request.use(function (config) {
- // resLoading = app.$loading({
- // lock: true,
- // text: 'Loading',
- // spinner: 'el-icon-loading',
- // background: 'rgba(255, 255, 255, 0.7)'
- // })
- var data = {
- 'from': 0,
- 'page': 1,
- 'rows': 10,
- 'userId': Cookies.get('userId'),
- 'sidx': '',
- 'sord': '',
- 'token': '',
- 'reqdata': {}
- };
- _instanceof(config.data, FormData) || (config.data = Object.assign(data, config.data)); //判断是否上传文件
- // config.headers['Authorization'] = cookiesDeploy.getToken()
- return config;
- }, function (error) {
- Promise.reject(error);
- });
- service.interceptors.response.use(function (res) {
- console.log(res);
- return new Promise(function (resolve, reject) {
- if (res.data.state === 206) {
- // resLoading.close()
- alert(206);
- reject(res.data.msg);
- } else if (res.status === 200) {
- // resLoading.close()
- if (res.data.state !== 100) {
- reject(res.data.msg);
- } else {
- resolve(res.data);
- }
- } else {
- // if (res.status > 100 && res.status < 200) {
- // if (whiteList.indexOf(process.env.NODE_ENV) !== -1) {
- // // let url = `http://monitor.info666.com/monitor/alert?projectAbbr=batterycloud-test&errorMsg=接口:${api}(${res.statusText})&logPath=前端开发环境(${process.env.NODE_ENV})`
- // // axios.get(url)
- // }
- // }
- // resLoading.close()
- reject(res); // }
- }
- });
- }, function (error) {
- console.log(error); // loading.close()
- // Message({
- // message: '请求异常' + error,
- // type: 'error',
- // duration: 5 * 1000
- // })
- // resLoading.close()
- // vant.Toast({
- // message: error
- // })
- // console.log(error);
- });
|