enter.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="container">
  3. <enterNavigator :selectedIndex="nav_current_index" @clickToIndex='homeNavigatorClick'/>
  4. <home :viewTop="subviewTop" :viewHeight="subviewHeight" v-show="nav_current_index == config.page_index.home" />
  5. <AIChat :viewTop="subviewTop" :viewHeight="subviewHeight" v-show="nav_current_index == config.page_index.ai_chat" />
  6. <AIDraw :viewTop="subviewTop" :viewHeight="subviewHeight" v-show="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. this.tools.current_navigator_page_index = index
  33. }
  34. },
  35. mounted() {
  36. let systemInfo = uni.getSystemInfoSync()
  37. this.subviewTop = 60
  38. this.subviewHeight = systemInfo.screenHeight - this.subviewTop
  39. let self = this
  40. uni.$on(config.notification.switch_page_index, function(index) {
  41. if(self.nav_current_index == index) {
  42. return
  43. }
  44. self.nav_current_index = index
  45. })
  46. },
  47. onUnload() {
  48. uni.$off(config.notification.switch_page_index)
  49. },
  50. components: {
  51. enterNavigator,
  52. home,
  53. AIChat,
  54. AIDraw
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. .container{
  60. background-color: #ffffff;
  61. }
  62. </style>