main.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // uni.addInterceptor('navigateTo', {
  62. // // 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转
  63. // invoke(e) {
  64. // if (e.url === '/pages/login/index' ||e.url === '/pages/login/indexChoice') {
  65. // next()
  66. // }else{
  67. // var serverId = uni.getStorageSync('userInfo').serverId;
  68. // if (serverId == undefined || serverId == null || serverId == '') {
  69. // window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb8aac61262a027d6&redirect_uri=https://test-plateform.uxianxin.com/%23/pages/login/index&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
  70. // }
  71. // }
  72. // },
  73. // success(e) {
  74. // debugger
  75. // }
  76. // })
  77. app.$mount()