App.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script>
  2. import {
  3. onBackPress
  4. } from "@dcloudio/uni-app"
  5. import {
  6. toast,
  7. getUserIdentity
  8. } from "@/utils/common";
  9. import {
  10. banbenImpinfo
  11. } from "@/api/login.js"
  12. import cacheManager from "@/utils/cacheManager.js";
  13. import {
  14. useIsCanBack
  15. } from "@/store/isCanBack.js"
  16. export default {
  17. // creat by wgy 0619 生命周期 钩子
  18. onLaunch: function() {
  19. // #ifdef APP-PLUS
  20. // 有auth
  21. if (cacheManager.get('auth')) {
  22. // 有内容缓存 跳到学习页面
  23. if (cacheManager.get('contentInfo')) {
  24. uni.switchTab({
  25. url: `/pages/chanpinneirong/index`,
  26. success() {
  27. plus.navigator.closeSplashscreen();
  28. }
  29. })
  30. } else {
  31. //没有内容缓存 请求接口
  32. uni.switchTab({
  33. url: `/pages/chanpinXuanze/index`,
  34. success() {
  35. plus.navigator.closeSplashscreen();
  36. }
  37. })
  38. }
  39. } else {
  40. cacheManager.clearAll()
  41. uni.reLaunch({
  42. url: '/pages/login/index',
  43. success() {
  44. plus.navigator.closeSplashscreen();
  45. }
  46. });
  47. }
  48. // #endif
  49. },
  50. onShow: function() {
  51. // #ifdef APP-PLUS
  52. const webview = plus.webview.currentWebview();
  53. plus.key.addEventListener('backbutton', () => {
  54. const store = useIsCanBack();
  55. if (!store.isCanBack) {
  56. event.preventDefault();
  57. return false
  58. } else {
  59. return true
  60. }
  61. });
  62. // #endif
  63. },
  64. onHide: function() {
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. /* 公共样式 */
  70. @import '/common/styles/index.scss';
  71. // 小米字体、思源黑体、苹果平方、数字字体、通用无衬线字体
  72. body,
  73. html,
  74. #app {
  75. font-family: "MiSans", "PingFang SC", sans-serif;
  76. margin: 0;
  77. padding: 0;
  78. box-sizing: border-box;
  79. }
  80. </style>