enter.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="container">
  3. <enterNavigator :selectedIndex="nav_current_index" @clickToIndex='homeNavigatorClick'/>
  4. <home :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.home" />
  5. <AIChat :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.ai_chat" />
  6. <AIDraw :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.ai_draw" />
  7. </view>
  8. </template>
  9. <script>
  10. import enterNavigator from '../../pages/enter/enter-navigator.vue'
  11. import home from '../../pages/home/home.vue'
  12. import AIChat from '../../pages/AI_chat/AI_chat.vue'
  13. import AIDraw from '../../pages/AI-draw/AI-draw.vue'
  14. import config from '../../utils/config.js'
  15. export default {
  16. data() {
  17. return {
  18. nav_current_index: 0, // 当前导航索引
  19. subviewTop: 0,
  20. subviewHeight: 0,
  21. }
  22. },
  23. methods: {
  24. homeNavigatorClick(index) {
  25. if(index == config.page_index.ai_chat ||
  26. index == config.page_index.ai_draw) {
  27. if(this.tools.is_login_gotoLogin() == false) {
  28. return
  29. }
  30. }
  31. this.nav_current_index = index
  32. }
  33. },
  34. mounted() {
  35. let systemInfo = uni.getSystemInfoSync()
  36. this.subviewTop = 60
  37. this.subviewHeight = systemInfo.screenHeight - this.subviewTop
  38. let self = this
  39. uni.$on(config.notification.switch_page_index, function(index) {
  40. self.nav_current_index = index
  41. })
  42. },
  43. onUnload() {
  44. uni.$off(config.notification.switch_page_index)
  45. },
  46. components: {
  47. enterNavigator,
  48. home,
  49. AIChat,
  50. AIDraw
  51. }
  52. }
  53. </script>
  54. <style lang="scss">
  55. .container{
  56. }
  57. </style>