App.vue 1.2 KB

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