main.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. var TOKENHEAD = uni.getStorageSync('tokenhead');
  20. var USERINFO = uni.getStorageSync('userInfo');
  21. if(TOKEN == '' || TOKENHEAD == '' || USERINFO == ''){
  22. uni.redirectTo({url:'/pages/login/login?backpage='+backpage+'&backtype='+backtype});
  23. return false;
  24. }
  25. return [TOKEN,TOKENHEAD,USERINFO];//已经登录返回数组TOKEN等用户信息
  26. }
  27. import $wxApi from "./wxapi.js";
  28. Vue.prototype.$wxApi = $wxApi;
  29. Vue.prototype.$api = {http,setNavbarTitle}
  30. Vue.prototype.$getimg = config.imgUrl
  31. Vue.prototype.$placeImg = config.placeImg
  32. Vue.prototype.$store = store
  33. Vue.prototype.config = config
  34. App.mpType = 'app'
  35. const app = new Vue({
  36. ...App
  37. })
  38. app.$mount()