index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="main">
  3. <code-elf-guide v-if="guidePages"></code-elf-guide>
  4. </view>
  5. </template>
  6. <script>
  7. import codeElfGuide from '@/components/code-elf-guide/code-elf-guide.vue'
  8. export default {
  9. components: {
  10. codeElfGuide
  11. },
  12. data() {
  13. return {
  14. guidePages:true
  15. }
  16. },
  17. onLoad(){
  18. this.loadExecution()
  19. },
  20. methods: {
  21. loadExecution: function(){
  22. /**
  23. * 获取本地存储中launchFlag的值
  24. * 若存在,说明不是首次启动,直接进入首页;
  25. * 若不存在,说明是首次启动,进入引导页;
  26. */
  27. try {
  28. // 获取本地存储中launchFlag标识
  29. const value = uni.getStorageSync('launchFlag');
  30. if (value) {
  31. // launchFlag=true直接跳转到首页
  32. uni.switchTab({
  33. url: '/pages/tabBar/component/component'
  34. });
  35. } else {
  36. // launchFlag!=true显示引导页
  37. this.guidePages = true
  38. }
  39. } catch(e) {
  40. // error
  41. uni.setStorage({
  42. key: 'launchFlag',
  43. data: true,
  44. success: function () {
  45. console.log('error时存储launchFlag');
  46. }
  47. });
  48. this.guidePages = true
  49. }
  50. return;
  51. uni.switchTab({
  52. url: '/pages/tabBar/component/component'
  53. });
  54. }
  55. }
  56. }
  57. </script>
  58. <style>
  59. page,.main{
  60. width: 100%;
  61. height: 100%;
  62. }
  63. </style>