App.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. // 有auth
  20. if (cacheManager.get('auth')) {
  21. banbenImpinfo({}).then(res => {
  22. if (res.code == 0) {
  23. //学过
  24. if (res.data.typeId != 0) {
  25. uni.reLaunch({
  26. url: `/pages/chanpinneirong/index?banbenId=${res.data.banbenId}&danyuanId=${res.data.danyuanId}&typeId=${res.data.typeId}`,
  27. success() {
  28. plus.navigator.closeSplashscreen();
  29. }
  30. })
  31. } else {
  32. // 没学过
  33. uni.reLaunch({
  34. url: `/pages/chanpinXuanze/index`,
  35. success() {
  36. plus.navigator.closeSplashscreen();
  37. }
  38. })
  39. }
  40. }
  41. }).catch(() => {
  42. toast("App.vue,banbenImpinfo接口错误")
  43. cacheManager.clearAll()
  44. return false
  45. })
  46. } else {
  47. cacheManager.clearAll()
  48. uni.reLaunch({
  49. url: '/pages/login/index',
  50. success() {
  51. plus.navigator.closeSplashscreen();
  52. }
  53. });
  54. }
  55. // #ifdef APP-PLUS
  56. // #endif
  57. },
  58. onShow: function() {
  59. // #ifdef APP-PLUS
  60. const webview = plus.webview.currentWebview();
  61. plus.key.addEventListener('backbutton', () => {
  62. const store = useIsCanBack();
  63. if (!store.isCanBack) {
  64. event.preventDefault();
  65. return false
  66. } else {
  67. return true
  68. }
  69. });
  70. // #endif
  71. },
  72. onHide: function() {
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. /* 公共样式 */
  78. @import '/common/styles/index.scss';
  79. // 西文、雅黑、黑体、宋体
  80. body,
  81. html,
  82. #app {
  83. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  84. margin: 0;
  85. padding: 0;
  86. box-sizing: border-box;
  87. }
  88. </style>