App.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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) {
  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. if (cacheManager.get('auth')) {
  63. if (cacheManager.get('auth').type === 2) {
  64. uni.reLaunch({
  65. url: `/pages/admin/ShouYe/shouye`,
  66. success() {
  67. }
  68. })
  69. } else {
  70. uni.reLaunch({
  71. url: `/pages/client/ShouYe/shouye`,
  72. success() {
  73. }
  74. })
  75. }
  76. }
  77. // #endif
  78. },
  79. onHide: function() {
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. /* 公共样式 */
  85. @import '/common/styles/index.scss';
  86. // 西文、雅黑、黑体、宋体
  87. body,
  88. html,
  89. #app {
  90. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  91. margin: 0;
  92. padding: 0;
  93. box-sizing: border-box;
  94. }
  95. </style>