enter.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.screenHeight - this.subviewTop
  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. if(self.nav_current_index == index) {
  37. return
  38. }
  39. self.nav_current_index = index
  40. })
  41. uni.$on(config.notification.login_success_goback_after_gotoAI, function() {
  42. if(self.nav_current_index == config.page_index.ai_chat) {
  43. return
  44. }
  45. self.nav_current_index = config.page_index.ai_chat
  46. })
  47. },
  48. offNotification() {
  49. uni.$off(config.notification.switch_page_index)
  50. uni.$off(config.notification.login_success_goback_after_gotoAI)
  51. },
  52. homeNavigatorClick(index) {
  53. if(index == config.page_index.ai_chat ||
  54. index == config.page_index.ai_draw) {
  55. if(this.tools.is_login_gotoLogin() == false) {
  56. return
  57. }
  58. }
  59. this.nav_current_index = index
  60. this.tools.current_navigator_page_index = index
  61. }
  62. },
  63. components: {
  64. enterNavigator,
  65. home,
  66. AIChat,
  67. AIDraw
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .container{
  73. background-color: #2A2832;
  74. }
  75. </style>