App.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. if (cacheManager.get('auth')) {
  14. uni.reLaunch({
  15. url: `/pages/study/index`,
  16. success() {
  17. plus.navigator.closeSplashscreen();
  18. }
  19. })
  20. }else if(cacheManager.get('wxLogin') &&!(cacheManager.get('wxLogin').bind)){
  21. console.log('微信登录且未绑定')
  22. // 微信登录且未绑定
  23. } else {
  24. cacheManager.clearAll()
  25. uni.reLaunch({
  26. url: '/pages/login/index' ,
  27. success() {
  28. plus.navigator.closeSplashscreen();
  29. }
  30. });
  31. }
  32. },
  33. onShow: function() {
  34. // #ifdef APP-PLUS
  35. // if (cacheManager.get('auth')) {
  36. // uni.reLaunch({
  37. // url: `/pages/study/index`
  38. // })
  39. // }else if(!(cacheManager.get('wxLogin').bind)){
  40. // console.log('asdfadsfadsfasd')
  41. // // 微信登录且未绑定
  42. // } else {
  43. // cacheManager.clearAll()
  44. // uni.redirectTo({
  45. // url: '/pages/login/index'
  46. // });
  47. // }
  48. const webview = plus.webview.currentWebview();
  49. plus.key.addEventListener('backbutton', () => {
  50. event.preventDefault();
  51. return false
  52. });
  53. // #endif
  54. },
  55. onHide: function() {
  56. // // console.log('App Hide')
  57. // // #ifdef APP-PLUS
  58. // if (cacheManager.get('auth')) {
  59. // uni.reLaunch({
  60. // url: `/pages/study/index`
  61. // })
  62. // }else if(!(cacheManager.get('wxLogin').bind)){
  63. // console.log('asdfadsfadsfasd')
  64. // // 微信登录且未绑定
  65. // } else {
  66. // cacheManager.clearAll()
  67. // uni.redirectTo({
  68. // url: '/pages/login/index'
  69. // });
  70. // }
  71. // // #endif
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. /* 公共样式 */
  77. @import '/common/styles/index.scss';
  78. // 西文、雅黑、黑体、宋体
  79. body,html,#app {
  80. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  81. margin: 0;
  82. padding: 0;
  83. box-sizing: border-box;
  84. }
  85. </style>