App.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <script>
  2. import {
  3. onBackPress
  4. } from "@dcloudio/uni-app"
  5. import cacheManager from "@/utils/cacheManager.js";
  6. import {
  7. useIsCanBack
  8. } from "@/store/isCanBack.js";
  9. export default {
  10. // creat by wgy 0619 生命周期 钩子
  11. onLaunch: function() {
  12. // #ifdef APP-PLUS
  13. if (cacheManager.get('auth')) {
  14. uni.reLaunch({
  15. url: `/pages/admin/ShouYe/shouye`,
  16. success() {
  17. plus.navigator.closeSplashscreen();
  18. }
  19. })
  20. } else {
  21. cacheManager.clearAll()
  22. uni.reLaunch({
  23. url: '/pages/Login/index',
  24. success() {
  25. plus.navigator.closeSplashscreen();
  26. }
  27. });
  28. }
  29. // #endif
  30. // #ifdef H5
  31. if (cacheManager.get('auth')) {
  32. if (cacheManager.get('auth').type == 2 || cacheManager.get('auth').type == 5) {
  33. uni.reLaunch({
  34. url: `/pages/admin/ShouYe/shouye`,
  35. success() {
  36. }
  37. })
  38. }
  39. /* H5修改每次访问到登录页面的bug
  40. else {
  41. uni.reLaunch({
  42. url: `/pages/client/ShouYe/shouye`,
  43. success() {
  44. }
  45. })
  46. }*/
  47. }
  48. // #endif
  49. },
  50. onShow: function() {
  51. // #ifdef APP-PLUS
  52. const webview = plus.webview.currentWebview();
  53. plus.key.addEventListener('backbutton', () => {
  54. const store = useIsCanBack();
  55. if (!store.isCanBack) {
  56. event.preventDefault();
  57. return false
  58. } else {
  59. return true
  60. }
  61. });
  62. // #endif
  63. // // #ifdef H5
  64. // alert(cacheManager.get('auth'))
  65. // alert(123123123)
  66. // if (cacheManager.get('auth')) {
  67. // if (cacheManager.get('auth').type === 2 || cacheManager.get('auth').type == 5) {
  68. // uni.reLaunch({
  69. // url: `/pages/admin/ShouYe/shouye`,
  70. // success() {
  71. // }
  72. // })
  73. // } else {
  74. // uni.reLaunch({
  75. // url: `/pages/client/ShouYe/shouye`,
  76. // success() {
  77. // }
  78. // })
  79. // }
  80. // }
  81. // // #endif
  82. },
  83. onHide: function() {
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. /* 公共样式 */
  89. @import '/common/styles/index.scss';
  90. // 西文、雅黑、黑体、宋体
  91. body,
  92. html,
  93. #app {
  94. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  95. margin: 0;
  96. padding: 0;
  97. box-sizing: border-box;
  98. }
  99. </style>