main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import Vue from 'vue';
  2. import App from './App';
  3. import cuCustom from '@/public/colorui/components/cu-custom.vue'
  4. Vue.component('cu-custom', cuCustom)
  5. /* 自定义图片和文件上传组件 */
  6. import FileUpload from '@/components/file-upload/index.vue'
  7. Vue.component('file-upload', FileUpload)
  8. /* 自定义Tabbar组件 */
  9. import customTabbar from '@/components/custom-tabbar/index.vue'
  10. Vue.component('custom-tabbar', customTabbar)
  11. /* 自定义头部背景块组件 */
  12. import customTopHeader from '@/components/custom-top-header/index.vue'
  13. Vue.component('custom-top-header', customTopHeader)
  14. import aloneAuthUser from '@/components/alone-auth-user/index.vue'
  15. Vue.component('alone-auth-user', aloneAuthUser)
  16. import aloneAuthPone from '@/components/alone-auth-phone/index.vue'
  17. Vue.component('alone-auth-phone', aloneAuthPone)
  18. //引入uView框架
  19. // import './public/uview-ui/index.js';
  20. //引入config文件
  21. import config from '@/config/env';
  22. Vue.prototype.$config = config
  23. //引入API请求
  24. import api from '@/utils/api.js';
  25. Vue.prototype.$api = api
  26. //引入Utils类库
  27. import util from '@/utils/util.js';
  28. Vue.prototype.$util = util
  29. //时间日期js处理库
  30. import moment from '@/public/moment/moment.js'
  31. Vue.prototype.$moment = moment
  32. //JS Linq插件
  33. // import Enumerable from './public/linq-js/linq-js.min.js'
  34. // Enumerable.config.as = 'em';
  35. //引入自定义字典扩展
  36. import '@/public/dict-extend/index.js';
  37. //自定义Log打印插件
  38. import '@/utils/debugger.js';
  39. //移动端调试插件
  40. // import VConsole from 'vconsole';
  41. // 或者使用配置参数来初始化,详情见文档
  42. // const vConsole = new VConsole({ theme: 'dark' });
  43. // #ifdef H5
  44. // 路由API: http://hhyang.cn/src/router/start/quickstart.html
  45. import Router, {RouterMount} from 'uni-simple-router';
  46. Vue.use(Router)
  47. //初始化
  48. const router = new Router({
  49. encodeURI: false, //不编码传输
  50. routes: ROUTES //路由表
  51. });
  52. //
  53. router.afterEach((to, from) => {// 页面跳转后做的处理操作
  54. if (history) {
  55. let query = to.query
  56. delete query.detail
  57. //H5会自动给每个跳转url自动加上tenant_id、app_id,以便链接的复制
  58. if (!query.tenant_id) {
  59. query.tenant_id = App.globalData.tenantId
  60. }
  61. if (!query.app_id) {
  62. query.app_id = App.globalData.appId
  63. }
  64. if (!query.component_appid) {
  65. query.component_appid = App.globalData.componentAppId
  66. }
  67. // 记录进入app时的url
  68. if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') {
  69. window.entryUrl = location.href.split('#')[0]
  70. }
  71. var ary = [];
  72. for (var p in query) {
  73. if (query.hasOwnProperty(p) && query[p]) {
  74. ary.push(encodeURIComponent(p) + '=' + encodeURIComponent(query[p]));
  75. }
  76. }
  77. if (ary.length > 0) {
  78. let url = "?" + ary.join('&');
  79. // history.replaceState(null, null, url);//替换页面显示url
  80. setTimeout(() => {
  81. history.replaceState(history.state, null, url); // uni-simple-router 组件中应该做了什么处理操作,这里延迟替换路由页面
  82. }, 100);
  83. }
  84. }
  85. })
  86. import 'utils/ican-H5Api';// 对齐H5的部分API,保持API通用跨平台;文档:https://ext.dcloud.net.cn/plugin?id=415
  87. // #endif
  88. Vue.config.productionTip = false;
  89. App.mpType = 'app';
  90. const app = new Vue({
  91. ...App
  92. });
  93. //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
  94. // #ifdef H5
  95. RouterMount(app, '#app');
  96. // #endif
  97. // #ifndef H5
  98. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  99. // #endif