main.js 3.5 KB

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