main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import Vue from 'vue'
  2. import App from './App'
  3. import { config } from './config/config'
  4. import store from './store'
  5. import Request from '@/js_sdk/luch-request/luch-request/index.js';
  6. const http = new Request();
  7. import './utils/filter'
  8. Vue.config.productionTip = false
  9. //栏目标题设置
  10. const setNavbarTitle = (title,defaultTitle) => {
  11. uni.setNavigationBarTitle({
  12. title:title || defaultTitle
  13. })
  14. }
  15. //封装全局登录检查函数:backpage为登录后返回的页面;backtype为打开页面的类型[1 : redirectTo 2 : switchTab]
  16. //3种页面跳转方式:NavigationTo(直接打开新页面),RedirectTo(覆盖原页面后打开新页面),SwitchTo(切换顶部导航的方式来切换页面)
  17. Vue.prototype.checkLogin = function(backpage, backtype){
  18. var TOKEN = uni.getStorageSync('token');//本地持久化存储
  19. if(TOKEN == ''){
  20. uni.redirectTo({url:'/page/login/login?backpage='+backpage+'&backtype='+backtype});
  21. return false;
  22. }
  23. return [TOKEN];//已经登录返回数组TOKEN等用户信息
  24. }
  25. Vue.prototype.$api = {http,setNavbarTitle}
  26. Vue.prototype.$store = store
  27. Vue.prototype.config = config
  28. App.mpType = 'app'
  29. const app = new Vue({
  30. ...App
  31. })
  32. app.$mount()