App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. import {useIsCanBack} from "@/store/isCanBack.js"
  11. export default {
  12. // creat by wgy 0619 生命周期 钩子
  13. onLaunch: function() {
  14. // #ifdef APP-PLUS
  15. if (cacheManager.get('auth')) {
  16. uni.reLaunch({
  17. url: `/pages/study/index`,
  18. success() {
  19. plus.navigator.closeSplashscreen();
  20. }
  21. })
  22. }else if(cacheManager.get('wxLogin') &&!(cacheManager.get('wxLogin').bind)){
  23. console.log('微信登录且未绑定')
  24. // 微信登录且未绑定
  25. } else {
  26. cacheManager.clearAll()
  27. uni.reLaunch({
  28. url: '/pages/login/index' ,
  29. success() {
  30. plus.navigator.closeSplashscreen();
  31. }
  32. });
  33. }
  34. // #endif
  35. },
  36. onShow: function() {
  37. // #ifdef APP-PLUS
  38. // if (cacheManager.get('auth')) {
  39. // uni.reLaunch({
  40. // url: `/pages/study/index`
  41. // })
  42. // }else if(!(cacheManager.get('wxLogin').bind)){
  43. // console.log('asdfadsfadsfasd')
  44. // // 微信登录且未绑定
  45. // } else {
  46. // cacheManager.clearAll()
  47. // uni.redirectTo({
  48. // url: '/pages/login/index'
  49. // });
  50. // }
  51. if (cacheManager.get('auth')) {
  52. uni.reLaunch({
  53. url: `/pages/study/index`,
  54. success() {
  55. plus.navigator.closeSplashscreen();
  56. }
  57. })
  58. }else if(cacheManager.get('wxLogin') &&!(cacheManager.get('wxLogin').bind)){
  59. console.log('微信登录且未绑定')
  60. // 微信登录且未绑定
  61. } else {
  62. cacheManager.clearAll()
  63. uni.reLaunch({
  64. url: '/pages/login/index' ,
  65. success() {
  66. plus.navigator.closeSplashscreen();
  67. }
  68. });
  69. }
  70. const webview = plus.webview.currentWebview();
  71. plus.key.addEventListener('backbutton', () => {
  72. const store = useIsCanBack();
  73. if (!store.isCanBack) {
  74. event.preventDefault();
  75. return false
  76. } else {
  77. return true
  78. }
  79. });
  80. // #endif
  81. },
  82. onHide: function() {
  83. // // console.log('App Hide')
  84. // // #ifdef APP-PLUS
  85. // if (cacheManager.get('auth')) {
  86. // uni.reLaunch({
  87. // url: `/pages/study/index`
  88. // })
  89. // }else if(!(cacheManager.get('wxLogin').bind)){
  90. // console.log('asdfadsfadsfasd')
  91. // // 微信登录且未绑定
  92. // } else {
  93. // cacheManager.clearAll()
  94. // uni.redirectTo({
  95. // url: '/pages/login/index'
  96. // });
  97. // }
  98. // // #endif
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. /* 公共样式 */
  104. @import '/common/styles/index.scss';
  105. // 西文、雅黑、黑体、宋体
  106. body,
  107. html,
  108. #app {
  109. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  110. margin: 0;
  111. padding: 0;
  112. box-sizing: border-box;
  113. }
  114. </style>