main.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Vue from 'vue';
  2. import App from './App';
  3. Vue.config.productionTip = false;
  4. App.mpType = 'app';
  5. // 接口封装
  6. import request from '@/https/http.js'
  7. Vue.prototype.$http = request;
  8. // 请求地址
  9. import { baseUrl } from '@/https/url.js'
  10. Vue.prototype.$httpUrl = baseUrl; //请求地址上传图片路径
  11. //校验手机格式
  12. function checkMobile(mobile) {
  13. return RegExp(/^1[34578]\d{9}$/).test(mobile);
  14. }
  15. // 校验身份证
  16. var id=/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}([0-9]|x|X)$/;
  17. function cardtest (idCard){
  18. return id.test(idCard)
  19. };
  20. Vue.prototype.$checkMobile = checkMobile;
  21. Vue.prototype.$checkId = cardtest;
  22. import tabBar from "@/components/tabBar.vue"
  23. Vue.component('tabBar', tabBar)
  24. // 引入全局uView
  25. import uView from 'uview-ui';
  26. Vue.use(uView);
  27. Vue.mixin({
  28. onLoad(option) {
  29. this.initLogin()
  30. },
  31. methods: {
  32. initLogin(){
  33. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  34. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  35. console.log(curRoute)
  36. if(!uni.getStorageSync('token')){
  37. if(!(curRoute == 'pages/login/login' || curRoute == 'pages/login/agreement' || curRoute == 'pages/login/forget' || curRoute == 'pages/login/perfect' || curRoute == 'pages/login/change-gongsi')){
  38. uni.reLaunch({
  39. url: '/pages/login/login'
  40. });
  41. }
  42. }
  43. },
  44. }
  45. })
  46. const app = new Vue({
  47. ...App
  48. });
  49. app.$mount();