enter.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. mounted() {
  24. let systemInfo = uni.getSystemInfoSync()
  25. this.subviewTop = 60
  26. this.subviewHeight = systemInfo.windowHeight
  27. this.onNotification()
  28. },
  29. onUnload() {
  30. this.offNotification()
  31. },
  32. methods: {
  33. onNotification() {
  34. let self = this
  35. uni.$on(config.notification.switch_page_index, function(index) {
  36. // console.log('notification_index', index)
  37. if(self.nav_current_index == index) {
  38. return
  39. }
  40. self.nav_current_index = index
  41. })
  42. },
  43. offNotification() {
  44. uni.$off(config.notification.switch_page_index)
  45. },
  46. homeNavigatorClick(index) {
  47. if(index == config.page_index.ai_chat ||
  48. index == config.page_index.ai_draw) {
  49. if(this.tools.is_login_gotoLogin(index) == false) {
  50. return
  51. }
  52. }
  53. this.nav_current_index = index
  54. this.tools.current_navigator_page_index = index
  55. }
  56. },
  57. components: {
  58. enterNavigator,
  59. home,
  60. AIChat,
  61. AIDraw
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .container{
  67. background-color: #2A2832;
  68. }
  69. </style>