main.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import Vue from 'vue'
  2. import App from './App'
  3. import uView from "uview-ui";
  4. Vue.use(uView);
  5. // ColorUI的 导航栏
  6. import cuCustom from './colorui/components/cu-custom.vue'
  7. Vue.component('cu-custom',cuCustom)
  8. import comSelectPicture from './components/comSelectPicture/comSelectPicture.vue'
  9. Vue.component('com-select-picture',comSelectPicture)
  10. // 此处为演示vuex使用,非uView的功能部分
  11. import store from '@/store';
  12. // 引入uView提供的对vuex的简写法文件
  13. let vuexStore = require('@/store/$u.mixin.js');
  14. Vue.mixin(vuexStore);
  15. App.mpType = 'app'
  16. // 全局过滤器 -- 金额保留两位
  17. Vue.filter('moneyFilter', function (value) {
  18. if (!value || isNaN(value)) return 0.0
  19. return new Number(value).toFixed(1)
  20. })
  21. const app = new Vue({
  22. ...App
  23. })
  24. const msg = (title, duration=1500, mask=false, icon='none')=>{
  25. //统一提示方便全局修改
  26. if(Boolean(title) === false){
  27. return;
  28. }
  29. uni.showToast({
  30. title,
  31. duration,
  32. mask,
  33. icon
  34. });
  35. }
  36. const json = type=>{
  37. //模拟异步请求数据
  38. return new Promise(resolve=>{
  39. setTimeout(()=>{
  40. resolve(Json[type]);
  41. }, 500)
  42. })
  43. }
  44. const prePage = ()=>{
  45. let pages = getCurrentPages();
  46. let prePage = pages[pages.length - 2];
  47. // #ifdef H5
  48. return prePage;
  49. // #endif
  50. return prePage.$vm;
  51. }
  52. Vue.prototype.$fire = new Vue();
  53. Vue.prototype.$store = store;
  54. Vue.prototype.$api = {msg, json, prePage};
  55. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  56. import httpInterceptor from '@/common/http.interceptor.js'
  57. Vue.use(httpInterceptor, app)
  58. // http接口API集中管理引入部分
  59. import httpApi from '@/api/http.api.js'
  60. Vue.use(httpApi, app)
  61. import common from '@/common/common.js'
  62. Vue.prototype.$formatPhone = common.formatPhone;
  63. Vue.prototype.$formatName = common.formatName;
  64. Vue.prototype.$videoList = common.videoList;
  65. app.$mount()