一般在utils文件夹下api.js文件里面写接口,接口环境判断
var href = window.location.href //两者都可以拿到当前运行URL链接
// var host = window.location.host
let _ipcc_cst;
const _sysServer = (/(creditcard.ecitic.com)/i.test(location.origin))?'https://creditcard.ecitic.com':'https://e.test.bank.ecitic.com';
if (href.indexOf('citiccard') != -1) {
// 生产环境
} else if (href.indexOf('uat') != -1) {
// UAT
} else if (href.indexOf('sit') != -1 || href.indexOf('test') != -1) {
// 测试环境
} else {
// localhost
_ipcc_cst = 'https://28.105.147.55:8080/ipss-cst-service'
}
const Api = {
VIDEO: _ipcc_cst + '/queue/count-number', // 查询排队位数
};
export default Api
然后在utils文件夹下common.js下引入:
import Api from './api'
import Http from './http'
const common = {
install (Vue) {
this.$spi = Api
this.$http = new Http(this)
}
}
最后在main.js引入common挂载到vue
import C from 'uutils/common'
Vue.use(C)