main.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // #ifndef VUE3
  2. import Vue from 'vue'
  3. import App from './App'
  4. //导入网络请求包
  5. import {$http} from '@escook/request-miniprogram'
  6. //5.导入store的自定义模块
  7. import store from '@/information/store.js'
  8. //导入uView组件库
  9. import uView from '@/uni_modules/uview-ui'
  10. //配置公共方法
  11. import RepeatClick from './utils/RepeatClick.js'
  12. Vue.prototype.$noMultipleClicks = RepeatClick.noMultipleClicks;
  13. //挂载到uni.$http上方便调用
  14. uni.$http = $http
  15. //请求根路径
  16. // $http.baseUrl = 'https://www.uinav.com'
  17. //挂载请求拦截器
  18. $http.beforeRequest = function(options) {
  19. uni.showLoading({
  20. title: '数据加载中...'
  21. })
  22. //挂载请求头
  23. //判断当前请求的是否为有权限的接口
  24. // if(options.url.indexOf('/pages/login/login') !== -1){
  25. //为header中添加必要信息(权限字段)
  26. // options.header = {
  27. // }
  28. //}
  29. }
  30. //挂载响应拦截器
  31. $http.afterRequest = function() {
  32. uni.hideLoading()
  33. }
  34. //封装的展示消息提示方法
  35. uni.$showMsg = function(title = '请求失败', duration = 1500){
  36. uni.showToast({
  37. title,
  38. duration,
  39. icon: 'none'
  40. })
  41. }
  42. Vue.config.productionTip = false
  43. App.mpType = 'app'
  44. //app实例对象
  45. const app = new Vue({
  46. ...App,
  47. //6.挂载到app实例对象里
  48. store
  49. })
  50. app.$mount()
  51. // #endif
  52. // #ifdef VUE3
  53. import { createSSRApp } from 'vue'
  54. import App from './App.vue'
  55. export function createApp() {
  56. const app = createSSRApp(App)
  57. return {
  58. app
  59. }
  60. }
  61. // #endif