main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import Vue from 'vue'
  2. import App from './App'
  3. // vuex
  4. import store from './store'
  5. // 引入全局uView
  6. import uView from '@/uni_modules/uview-ui'
  7. import baseApi from '@/util/base.js'
  8. import request from '@/util/request.js'
  9. import utils from '@/util/util.js'
  10. import webim from 'webim.js';
  11. import helper from '@/common/helper.js'
  12. import dw from '@/util/dw.js'
  13. Vue.prototype.$dw = dw
  14. // import axios from 'axios'
  15. // import TabbarView from "./common/TabBarView.js";
  16. // Vue.prototype.$tabbarView = new TabbarView();
  17. Vue.prototype.$api = baseApi
  18. Vue.prototype.$request = request
  19. Vue.prototype.$utils = utils
  20. Vue.prototype.$helper = helper
  21. Vue.prototype.$socket = webim;
  22. Vue.prototype.$store = store
  23. // Vue.prototype.$axios = axios
  24. // import axios from 'axios'
  25. // // 解决uniapp 适配axios请求,避免报adapter is not a function错误
  26. // axios.defaults.adapter = config => {
  27. // console.log(config)
  28. // return new Promise((resolve, reject) => {
  29. // let settle = require('axios/lib/core/settle');
  30. // let buildURL = require('axios/lib/helpers/buildURL');
  31. // uni.request({
  32. // method: config.method.toUpperCase(),
  33. // url: config.baseURL + buildURL(config.url, config.params, config.paramsSerializer),
  34. // header: config.headers,
  35. // data: config.data,
  36. // dataType: config.dataType,
  37. // responseType: config.responseType,
  38. // sslVerify: config.sslVerify,
  39. // complete: function complete(response) {
  40. // // console.log("执行完成:", response)
  41. // response = {
  42. // data: response.data,
  43. // status: response.statusCode,
  44. // errMsg: response.errMsg,
  45. // header: response.header,
  46. // config: config
  47. // };
  48. // settle(resolve, reject, response);
  49. // }
  50. // })
  51. // })
  52. // }
  53. Vue.config.productionTip = false
  54. App.mpType = 'app'
  55. Vue.use(uView)
  56. const logout = () => {
  57. uni.removeStorage({
  58. key: 'userInfo'
  59. })
  60. }
  61. Vue.prototype.$api = {
  62. logout,
  63. };
  64. // #ifdef MP
  65. // 引入uView对小程序分享的mixin封装
  66. const mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js')
  67. Vue.mixin(mpShare)
  68. // #endif
  69. const app = new Vue({
  70. store,
  71. ...App
  72. })
  73. // // 引入请求封装
  74. // require('./util/request/index')(app)
  75. app.$mount()
  76. // #ifdef APP-PLUS
  77. let main = plus.android.runtimeMainActivity();
  78. plus.runtime.quit = function() {
  79. main.moveTaskToBack(false);
  80. };
  81. plus.nativeUI.toast = (function(str) {
  82. if (str == '再按一次退出应用') {
  83. main.moveTaskToBack(false);
  84. return false;
  85. }
  86. });
  87. // #endif