App.vue 2.1 KB

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