import { MessageBox } from 'element-ui';
|
|
const dev = process.env.NODE_ENV === "development";
|
import validate from './validate';
|
import chart from './chart';
|
|
let apiPrefix = window.location.protocol;
|
|
switch (process.env.NODE_ENV) {
|
case 'dev':
|
apiPrefix += "//test.huacheng.nhys.cdnhxx.com/";
|
|
break;
|
case 'production': // build
|
apiPrefix += "//117.172.73.53:8099/";
|
break;
|
default:
|
apiPrefix += "//test.huacheng.nhys.cdnhxx.com/";
|
}
|
|
console.log(apiPrefix);
|
|
demo.access('__API_HTTP__', apiPrefix + 'api/huacheng-communitybackstage/'); // 请求地址
|
demo.access('__API_UPLOAD__', apiPrefix + 'api/huacheng-communitybackstage/communitypartybuilding/uploadimage'); // 上传地址
|
demo.access('__API_HTTP_ZONGZHI__', 'http://117.172.73.171:9901/'); //综治网址
|
demo.access('__API_UPLOADFILE__', apiPrefix + '/api/huacheng-communitybackstage/convenient/upload/file'); // 上传地址
|
|
|
const api = {
|
http: demo.__API_HTTP__,
|
zzhttp: demo.__API_HTTP_ZONGZHI__,
|
upload: demo.__API_UPLOAD__,
|
files: demo.__API_UPLOADFILE__,
|
ip: 'https://restapi.amap.com/v3/ip',
|
map: 'https://restapi.amap.com/v3/geocode',
|
weather: 'https://restapi.amap.com/v3/weather/weatherInfo',
|
};
|
let login = {
|
show: false, account: '', password: ''
|
};
|
|
let title = '攀枝花社区管理平台';
|
|
const JCROLEID = "1674595011976527873"//基层查询的角色id
|
|
if (dev) {
|
api.http = '/www/';
|
api.upload = api.http + 'communitypartybuilding/uploadimage';
|
api.files = api.http + 'convenient/upload/file';
|
api.map = '/amap/';
|
login.show = true;
|
}
|
|
console.log(api);
|
|
|
// 历史记录
|
let historyPath = {
|
get () {
|
let o = demo.$cache.get('path');
|
try {
|
o = JSON.parse(o);
|
} catch (e) {
|
o = [];
|
console.log(e + '');
|
}
|
if (o.length > 20) {
|
o = o.splice(0, 20);
|
}
|
return o;
|
},
|
set (d) {
|
if (demo._is_obj(d).code === 6) {
|
let v = this.get();
|
v = v.filter(k => {
|
return +k.id !== +d.id;
|
});
|
d.timeout = Date.now();
|
v.unshift(d);
|
demo.$cache.edit('path', JSON.stringify(v));
|
}
|
},
|
clear () {
|
demo.$cache.edit('path', '[]');
|
return [];
|
}
|
};
|
|
function model (title, err, fn, code) {
|
MessageBox({
|
title: title,
|
message: err,
|
type: ['error', 'warning', 'success'][code] || 'info',
|
showCancelButton: true,
|
closeOnClickModal: false,
|
closeOnPressEscape: false,
|
callback: (e) => {
|
if (e === 'confirm') {
|
fn(1);
|
} else { fn(0); }
|
}
|
});
|
}
|
|
export default {
|
static: dev ? '/' : './',
|
api,
|
model: model,
|
version: '0.1',
|
history: historyPath,
|
validate,
|
login,
|
successCode: 200,
|
title,
|
debug: false,
|
mine: { key: '59bd0f70c4e3b074f0e215cfc1221c40' },
|
chart,
|
JCROLEID
|
};
|