quanyawei
2024-07-04 1e71dd86f6d0c4fc7e5143600d4bc4b50992a2a7
pages/index/index.vue
New file
@@ -0,0 +1,89 @@
<template>
   <view class="newIndex">
      <uni-nav-bar backgroundColor='#000' color='#fff' statusBar :border='false' fixed :title="title" />
      <u-loading-page :loading="loading"></u-loading-page>
      <agencyPage v-if="isShow" ref="agencyPage"></agencyPage>
      <myInfor v-if="!isShow"></myInfor>
      <tabBar v-if="showTabBar" @handleChangeTabe='handleChangeTabe' :currIndex='currIndex'></tabBar>
   </view>
</template>
<script>
   import agencyPage from '@/pages/actionChange/agencyPage/index.vue'
   import myInfor from '@/pages/actionChange/myInfor/index.vue'
   import tabBar from '@/pages/actionChange/components/commonUserTabBar.vue'
   export default {
      data() {
         return {
            isShow: true,
            loading: true,
            showTabBar: true,
            token: '',
            currIndex: '0',
            title: '首页'
         }
      },
      components: {
         agencyPage,
         myInfor,
         tabBar
      },
      async onLoad() {
         await this.$onLaunched
         this.getData()
      },
      onReady() {},
      onShow() {
         this.currIndex = '0'
         this.showTabBar = true
      },
      onReachBottom() {
         //这里是判断是否需要继续掉接口
         this.$refs.agencyPage.onBottom()
      },
      mounted() {
         //等待登录成功
         this.token = uni.getStorageSync('tonken')
         console.log('已经进了index页面了', this.token)
         this.loading = false
         uni.$on('currIndex', data => {
            console.log('currIndexOn', data)
            this.currIndex = data.data.index
            this.showTabBar = data.data.showTabBar
            this.$refs.agencyPage.setData()
         })
         this.share.title = this.title
      },
      methods: {
         getData() {
            console.log('获取数据')
            this.$refs.agencyPage.setData()
         },
         handleChangeTabe(index) {
            if (index === 2) {
               this.isShow = false
               this.title = '我的'
               this.share.title = this.title
            }
            if (index === 0) {
               this.isShow = true
               this.title = '首页'
               this.share.title = this.title
               this.$nextTick(() => {
                  this.getData()
               })
            }
            if (index === 1) {
               uni.navigateTo({
                  url: '/pages/actionChange/newPage/index'
               })
               this.showTabBar = false
            }
         }
      }
   }
</script>
<style>
   .newIndex {
      width: calc(100vw);
   }
</style>