index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <page-meta>
  3. <navigation-bar :title="title" background-color="#FFFFFF" front-color="#000000" />
  4. </page-meta>
  5. <view v-if="!login">
  6. <login :login.sync='login' />
  7. </view>
  8. <view v-else>
  9. <swiper class="swiper-box" :current-item-id="active" @change='swiperChange' easing-function="easeInCubic">
  10. <swiper-item class="swiper-item" item-id='home'>
  11. <home v-if="activeObj.home" ref='home' />
  12. </swiper-item>
  13. <swiper-item class="swiper-item" item-id='cinema'>
  14. <cinema v-if="activeObj.cinema" ref='cinema' />
  15. </swiper-item>
  16. <swiper-item class="swiper-item" item-id='applist'>
  17. <applist v-if="activeObj.applist" ref='applist' />
  18. </swiper-item>
  19. <swiper-item class="swiper-item" item-id='user'>
  20. <user v-if="activeObj.user" ref='user' />
  21. </swiper-item>
  22. </swiper>
  23. <!-- <home v-if="activeObj.home" v-show="active=='home'" ref='home' />
  24. <cinema v-if="activeObj.cinema" v-show="active=='cinema'" ref='cinema'/>
  25. <applist v-if="activeObj.applist" v-show="active=='applist'" ref='applist' />
  26. <user v-if="activeObj.user" v-show="active=='user'" ref='user' /> -->
  27. <van-tabbar :active="active" @change="onChange" :placeholder='true' active-color="#E31818" inactive-color="#999999">
  28. <van-tabbar-item name='home' icon='wap-home'>
  29. <!-- <van-icon slot="icon" name="/static/imgs/fxh.png" /> -->
  30. <!-- <van-icon slot="icon-active" name="/static/imgs/fx.png" /> -->
  31. 首页
  32. </van-tabbar-item>
  33. <van-tabbar-item name='cinema' icon='video'>
  34. <!-- <van-icon slot="icon" name="/static/imgs/fxh.png" /> -->
  35. <!-- <van-icon slot="icon-active" name="/static/imgs/fx.png" /> -->
  36. 电影
  37. </van-tabbar-item>
  38. <van-tabbar-item name='applist' icon='search'>
  39. <!-- <van-icon slot="icon" name="/static/imgs/zth.png" /> -->
  40. <!-- <van-icon slot="icon-active" name="/static/imgs/zt.png" /> -->
  41. 发现
  42. </van-tabbar-item>
  43. <van-tabbar-item name='user' icon='manager'>
  44. <!-- <van-icon slot="icon" name="/static/imgs/wdh.png" /> -->
  45. <!-- <van-icon slot="icon-active" name="/static/imgs/wd.png" /> -->
  46. 我的
  47. </van-tabbar-item>
  48. </van-tabbar>
  49. </view>
  50. <van-toast id="van-toast" />
  51. </template>
  52. <script>
  53. import applist from './components/applist.vue'
  54. import find from './components/find/index.vue'
  55. import user from './components/user.vue'
  56. import topic from './components/topic/index.vue'
  57. import login from './components/login.vue'
  58. import home from './components/home.vue'
  59. import cinema from './components/cinema.vue'
  60. export default {
  61. components: {
  62. applist,
  63. find,
  64. user,
  65. topic,
  66. login,
  67. home,
  68. cinema
  69. },
  70. data() {
  71. return {
  72. login: false,
  73. active: 'home',
  74. activeObj: {},
  75. }
  76. },
  77. onLoad: function(option) {
  78. if (option.active) {
  79. this.active = option.active
  80. }
  81. this.activeObj[this.active] = true
  82. },
  83. onShareAppMessage: function() {},
  84. onReachBottom() {
  85. if (this.active == 'home') {
  86. this.$refs.home.onBottom()
  87. }
  88. if (this.active == 'applist') {
  89. this.$refs.applist.onBottom()
  90. }
  91. },
  92. computed: {
  93. title() {
  94. if (!this.login) return '登录'
  95. switch (this.active) {
  96. case 'home':
  97. return '首页';
  98. case 'cinema':
  99. return '电影';
  100. case 'applist':
  101. return '发现';
  102. case 'user':
  103. return '我的';
  104. }
  105. }
  106. },
  107. methods: {
  108. onChange(event) {
  109. // event.detail 的值为当前选中项的索引
  110. this.active = event.detail
  111. this.activeObj[this.active] = true
  112. // wx.startPullDownRefresh()
  113. // this.$nextTick(function() {
  114. // wx.stopPullDownRefresh()
  115. // })
  116. },
  117. swiperChange(event){
  118. this.active = event.detail.currentItemId
  119. this.activeObj[this.active] = true
  120. // wx.startPullDownRefresh()
  121. // this.$nextTick(function() {
  122. // wx.stopPullDownRefresh()
  123. // })
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. .swiper-box {
  130. height: calc(100vh - 100rpx - env(safe-area-inset-bottom));
  131. .swiper-item {
  132. // overflow: auto;
  133. }
  134. }
  135. </style>