App.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script>
  2. import {
  3. onBackPress
  4. } from "@dcloudio/uni-app"
  5. import cacheManager from "@/utils/cacheManager.js";
  6. import {useIsCanBack} from "@/store/isCanBack.js";
  7. export default {
  8. // creat by wgy 0619 生命周期 钩子
  9. onLaunch: function() {
  10. // #ifdef APP-PLUS
  11. if (cacheManager.get('auth')) {
  12. uni.reLaunch({
  13. url: `/pages/Login/index`,
  14. success() {
  15. plus.navigator.closeSplashscreen();
  16. }
  17. })
  18. } else {
  19. cacheManager.clearAll()
  20. uni.reLaunch({
  21. url: '/pages/Login/index' ,
  22. success() {
  23. plus.navigator.closeSplashscreen();
  24. }
  25. });
  26. }
  27. // #endif
  28. },
  29. onShow: function() {
  30. // #ifdef APP-PLUS
  31. const webview = plus.webview.currentWebview();
  32. plus.key.addEventListener('backbutton', () => {
  33. const store = useIsCanBack();
  34. if (!store.isCanBack) {
  35. event.preventDefault();
  36. return false
  37. } else {
  38. return true
  39. }
  40. });
  41. // #endif
  42. },
  43. onHide: function() {
  44. }
  45. }
  46. </script>
  47. <style lang="scss">
  48. /* 公共样式 */
  49. @import '/common/styles/index.scss';
  50. // 西文、雅黑、黑体、宋体
  51. body,html,#app {
  52. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  53. margin: 0;
  54. padding: 0;
  55. box-sizing: border-box;
  56. }
  57. </style>