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(){
  22. /**
  23. * 获取本地存储中launchFlag的值
  24. * 若存在,说明不是首次启动,直接进入首页;
  25. * 若不存在,说明是首次启动,进入引导页;
  26. */
  27. try {
  28. // 获取本地存储中launchFlag标识
  29. const value = uni.getStorageSync('launchFlag');
  30. if (value) {
  31. uni.setStorage({
  32. key: 'launchFlag',
  33. data: true,
  34. });
  35. // launchFlag=true直接跳转到首页
  36. uni.switchTab({
  37. url: '/pages/sale/information'
  38. });
  39. } else {
  40. // launchFlag!=true显示引导页
  41. this.guidePages = true
  42. }
  43. } catch(e) {
  44. // error
  45. uni.setStorage({
  46. key: 'launchFlag',
  47. data: true,
  48. success: function () {
  49. console.log('error时存储launchFlag');
  50. }
  51. });
  52. this.guidePages = true
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style>
  59. page,.main{
  60. width: 100%;
  61. height: 100%;
  62. }
  63. </style>