main.js 2.03 KB
import Vue from 'vue';
import App from './App';
import '@/config/umtrack.js';
import cache from '@/utils/cache';
import { formatImagePath } from '@/utils/imagePath';

Vue.config.productionTip = false;
Vue.prototype.formatImagePath = formatImagePath;

import uView from '@/uni_modules/uview-ui';
Vue.use(uView);

let colorPrimary = '#1E7B6B';

uni.$u.setConfig({
  config: {
    color: {
      'u-primary': colorPrimary,
    },
  },
	props: {
    line: {
      color: 'rgba(151, 151, 151, 0.2)'
    },
    swiper: {
      bgColor: 'inherit'
    },
		tabs: {
      lineColor: colorPrimary,
		},
    steps: {
      activeColor: colorPrimary,
    },
    radio: {
      activeColor: colorPrimary,
    },
    checkbox: {
      activeColor: colorPrimary,
    },
    picker: {
      confirmColor: colorPrimary,
    },
    switch: {
      activeColor: colorPrimary,
    },
    input: {
      fontSize: 'inherit'
    },
    text: {
      size: 'inherit',
      color: 'inherit'
    },
    icon: {
      color: 'inherit'
    },
	}
});

// 混入与组件List相关的页面生命周期
Vue.mixin({
  onPullDownRefresh() {
    if (this.mpType === 'page' && this.$refs.list) this.$refs.list.pullDownRefresh();
  },
  onReachBottom() {
    if (this.mpType === 'page' && this.$refs.list) this.$refs.list.reachBottom();
  },
  methods: {
    onSearch(config) {
      if (this.mpType === 'page' && this.$refs.list) this.$refs.list.search(config);
    },
  }
});

// 页面内获取当前页面参数
Object.defineProperty(Vue.prototype, '$params', {
  get: function get() {
    const routes = getCurrentPages();
    return routes[routes.length - 1].options;
  },
});

import store from './store'

Vue.config.productionTip = false;
Vue.prototype.$store = store;
Vue.prototype.$cache = cache;
App.mpType = 'app';

const app = new Vue({
  store,
  ...App
});

require('@/utils/uniapp.js')(uni);
// 引入请求封装,将app参数传递到配置中
require('@/config/request.js')(app);
// http接口API抽离,免于写url或者一些固定的参数
require('@/common/api.js')(app);

app.$mount();