App.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. uni.reLaunch({
  33. url: `/pages/admin/ShouYe/shouye`,
  34. success() {
  35. }
  36. })
  37. } else {
  38. cacheManager.clearAll()
  39. uni.reLaunch({
  40. url: '/pages/Login/index',
  41. success() {
  42. }
  43. });
  44. }
  45. // #endif
  46. },
  47. onShow: function() {
  48. // #ifdef APP-PLUS
  49. const webview = plus.webview.currentWebview();
  50. plus.key.addEventListener('backbutton', () => {
  51. const store = useIsCanBack();
  52. if (!store.isCanBack) {
  53. event.preventDefault();
  54. return false
  55. } else {
  56. return true
  57. }
  58. });
  59. // #endif
  60. // #ifdef H5
  61. if (cacheManager.get('auth')) {
  62. uni.reLaunch({
  63. url: `/pages/admin/ShouYe/shouye`,
  64. success() {
  65. }
  66. })
  67. } else {
  68. cacheManager.clearAll()
  69. uni.reLaunch({
  70. url: '/pages/Login/index',
  71. success() {
  72. }
  73. });
  74. }
  75. // #endif
  76. },
  77. onHide: function() {
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. /* 公共样式 */
  83. @import '/common/styles/index.scss';
  84. // 西文、雅黑、黑体、宋体
  85. body,
  86. html,
  87. #app {
  88. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  89. margin: 0;
  90. padding: 0;
  91. box-sizing: border-box;
  92. }
  93. </style>