main.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import Vue from 'vue';
  2. import App from './App';
  3. import uView from 'uview-ui';
  4. import store from '@/store';
  5. import cache from '@/mixin/cache';
  6. import empty from '@/components/empty';
  7. import tabbar from '@/components/tabbar';
  8. import { router, RouterMount } from '@/router'; //路径换成自己的
  9. import '@/static/iconfont/iconfont.css'; // iconfont的引入
  10. App.mpType = 'app';
  11. Vue.use(router);
  12. Vue.use(uView);
  13. Vue.mixin(cache);
  14. Vue.component('empty', empty);
  15. Vue.component('tabbar', tabbar);
  16. Vue.config.productionTip = false;
  17. App.mpType = 'app';
  18. function isPromise(obj) {
  19. return (
  20. !!obj &&
  21. (typeof obj === 'object' || typeof obj === 'function') &&
  22. typeof obj.then === 'function'
  23. );
  24. }
  25. uni.addInterceptor({
  26. returnValue(res) {
  27. if (!isPromise(res)) {
  28. return res;
  29. }
  30. return new Promise((resolve, reject) => {
  31. res.then(res => {
  32. if (res[0]) {
  33. reject(res[0]);
  34. } else {
  35. resolve(res[1]);
  36. }
  37. });
  38. });
  39. },
  40. });
  41. const app = new Vue({
  42. store,
  43. ...App,
  44. });
  45. // #ifdef H5
  46. RouterMount(app, router, '#app');
  47. // #endif
  48. app.$mount();