App.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. const webview = plus.webview.currentWebview();
  52. plus.key.addEventListener('backbutton', () => {
  53. const store = useIsCanBack();
  54. if (!store.isCanBack) {
  55. event.preventDefault();
  56. return false
  57. } else {
  58. return true
  59. }
  60. });
  61. // #endif
  62. },
  63. onHide: function() {
  64. // // console.log('App Hide')
  65. // // #ifdef APP-PLUS
  66. // if (cacheManager.get('auth')) {
  67. // uni.reLaunch({
  68. // url: `/pages/study/index`
  69. // })
  70. // }else if(!(cacheManager.get('wxLogin').bind)){
  71. // console.log('asdfadsfadsfasd')
  72. // // 微信登录且未绑定
  73. // } else {
  74. // cacheManager.clearAll()
  75. // uni.redirectTo({
  76. // url: '/pages/login/index'
  77. // });
  78. // }
  79. // // #endif
  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>