123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import Vue from 'vue'
- import App from './App'
- import router from './router'
- import VueRouter from 'vue-router';
- import './public-path';
- import globalData from '@/components/common/globaldata/global.data';
- let instance = null
- import VueAMap from 'vue-amap'
- // import actions from './micro/actions.js'
- Vue.use(VueAMap);
- Vue.use(globalData);
- VueAMap.initAMapApiLoader({
- key: '0ef96708d5fb4a73de7e72be72cf7648',
- Plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.MarkerClusterer']
- });
- // import Echarts from 'echarts'
- var Echarts = require('echarts');
- Vue.prototype.dateFormatA = function (row, column) {
- let date = row[column.property];
- if (Vue.prototype.isEmptyObjVue(date)) {
- return '';
- }
- return moment(date).format('YYYY-MM-DD HH:mm');
- }
- Vue.prototype.$echarts = Echarts;
- import dataV from '@jiaminghi/data-view'
- Vue.use(dataV)
- // console.log(window.location);
- import util from './script/util'
- // let token=util.getUrlKey('token');
- // console.log(token);
- import Axios from 'axios';
- import ElementUI from 'element-ui';
- import moment from 'moment'
- import {
- Message
- } from 'element-ui';
- import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
- Vue.use(ElementUI, {
- size: 'small'
- });
- //列表斑马线显示
- ElementUI.Table.props.stripe = { type: Boolean, default: true }
- //判空
- Vue.prototype.isEmptyObjVue = function (obj) {
- if (obj == null || obj == undefined || ("" + obj) == "") {
- return true;
- }
- return false;
- };
- Vue.prototype.formateDay = function (date) {
- if (Vue.prototype.isEmptyObjVue(date)) {
- return '';
- }
- return moment(date).format('YYYY-MM-DD');
- }
- Vue.prototype.formateMonth = function (date) {
- if (Vue.prototype.isEmptyObjVue(date)) {
- return '';
- }
- return moment(date).format('YYYY-MM');
- }
- Vue.prototype.$axios = Axios;
- Vue.config.productionTip = false
- let apiUrl = process.env.baseUrl;
- // console.log(apiUrl);
- Axios.defaults.timeout = 300000; //设置请求时间
- Axios.defaults.baseURL = apiUrl;
- var loading;
- function startLoading() {
- loading = (new Vue()).$loading({
- lock: true,
- text: "拼命加载中...",
- background: "rgba(0,0,0,0.4)"
- });
- }
- function endLoading() {
- loading.close();
- }
- Vue.prototype.formatMinute = function (duration) {
- if (!duration) return "00小时00分00秒";
- let day = parseInt(duration / (60 * 60 * 24))
- let h = parseInt((duration % (60 * 60 * 24)) / (60 * 60))
- let m = parseInt((duration - h * 60 * 60 - day * (60 * 60 * 24)) / 60)
- let s = (duration % 60).toFixed(0);
- h = h.toString().length < 2 ? "0" + h.toString() : h.toString();
- m = m.toString().length < 2 ? "0" + m.toString() : m.toString();
- s = s.toString().length < 2 ? "0" + s.toString() : s.toString();
- return h + '小时' + m.toString() + '分' + s.toString() + '秒';
- }
- Axios.interceptors.request.use(
- config => {
- if (config.url.indexOf('/salesGmvAndBookcount') == -1 && config.url.indexOf('/bigScreen') == -1) {
- startLoading();
- }
- config.headers.token = window.localStorage.getItem('token');
- // config.headers.token = token;
- return config;
- },
- err => {
- Message.error('请求超时!');
- return Promise.reject(err);
- });
- //axios统一错误处理
- Axios.interceptors.response.use(data => {
- endLoading();
- // if (data.status && data.status == 200) {
- // }
- if (data.data.errno == 501) {
- Message.error({ message: '服务端错误: ' + data.data.errmsg });
- }
- if (data.data.errno == 502) {
- Message.error({ message: '服务端错误: ' + data.data.data + data.data.errmsg });
- }
- if (data.data.errno == 503) {
- Message.error({ message: '服务器异常,请联系相关人员!' })
- }
- if (data.data.errno == 400) {
- // Message.error({ message: '权限不够' });
- Message.error({ message: data.data.errmsg });
- }
- if (data.data.errno == 401) {
- Message.error({
- message: '身份过期,请重新登陆'
- });
- if (window.localStorage.getItem('token') == "") {
- Message.error({
- message: '身份过期,请重新登陆'
- });
- // router.push('/login');
- // window.localStorage.removeItem('token')
- }
- // router.push('/login');
- // window.localStorage.removeItem('token')
- }
- // return data;
- if (data.data.errno == 0) {
- return data
- } else if (data.data.errno == -1) {
- Message.error({
- message: data.data.data
- });
- return Promise.reject(data);
- } else {
- if (data.status == 200 && data.request.responseType == 'blob')
- return data;
- return Promise.reject(data);
- }
- }, err => {
- endLoading();
- (new Vue()).$message({
- showClose: true,
- message: '接口错误,请稍后重试',
- type: 'error'
- });
- return Promise.reject(err);
- })
- /* eslint-disable no-new */
- // new Vue({
- // el: '#app',
- // router,
- // components: { App },
- // template: '<App/>'
- // })
- let routers = null;
- function render(props = {}) {
-
- const { container } = props
- routers = new VueRouter({
- base: window.__POWERED_BY_QIANKUN__ ? '/report' : '/',
- mode: 'history',
- router,
- });
- instance = new Vue({
- router,
- data(){
- return {
- parentStore: props.parentStore,
- }
- },
- render: (h) => h(App),
- }).$mount(container ? container.querySelector("#sub-report") :'#sub-report');
- }
- // 独立运行时
- if (!window.__POWERED_BY_QIANKUN__) {
- render();
- }
- export async function bootstrap() {
- console.log('[vue] vue app bootstraped');
- }
- export async function mount(props) {
-
- render(props);
- }
- export async function unmount() {
- instance.$destroy();
- instance.$el.innerHTML = '';
- instance = null;
- }
- // onBeforeUnmount(() => {
- // state.microApp.unmount(); // state.microApp 为微应用实例
- // });
- ;
|