App.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. banbenImpinfo({}).then(res => {
  23. if (res.code == 0) {
  24. //学过
  25. if (res.data.typeId != 0) {
  26. uni.reLaunch({
  27. url: `/pages/chanpinneirong/index?banbenId=${res.data.banbenId}&danyuanId=${res.data.danyuanId}&typeId=${res.data.typeId}`,
  28. success() {
  29. plus.navigator.closeSplashscreen();
  30. }
  31. })
  32. } else {
  33. // 没学过
  34. uni.reLaunch({
  35. url: `/pages/chanpinXuanze/index`,
  36. success() {
  37. plus.navigator.closeSplashscreen();
  38. }
  39. })
  40. }
  41. }
  42. }).catch(() => {
  43. toast("App.vue,banbenImpinfo接口错误")
  44. cacheManager.clearAll()
  45. return false
  46. })
  47. } else {
  48. cacheManager.clearAll()
  49. uni.reLaunch({
  50. url: '/pages/login/index',
  51. success() {
  52. plus.navigator.closeSplashscreen();
  53. }
  54. });
  55. }
  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>