index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="index">
  3. <index-my />
  4. <index-data />
  5. <index-index />
  6. <index-commu />
  7. <index-tabbar />
  8. </view>
  9. </template>
  10. <script>
  11. import indexMy from '../../components/index/index-my.vue'
  12. import indexData from '../../components/index/index-data.vue'
  13. import indexCommu from '../../components/index/index-commu.vue'
  14. import indexIndex from '../../components/index/index-index.vue'
  15. import indexTabbar from '../../components/index/index-tabbar.vue'
  16. export default {
  17. components: {
  18. indexMy,
  19. indexData,
  20. indexIndex,
  21. indexCommu,
  22. indexTabbar
  23. },
  24. computed: {
  25. activeIndex() {
  26. return this.$store.state.app.index_tabbar_index
  27. }
  28. },
  29. watch: { // 监听首页 tabbar 变化,适时开启下拉刷新
  30. activeIndex: {
  31. handler(val) {
  32. if (val === 0) {
  33. this.setPullDown()
  34. } else {
  35. uni.stopPullDownRefresh()
  36. this.offPullDown()
  37. }
  38. },
  39. immediate: true
  40. }
  41. },
  42. methods: {
  43. setPullDown() {
  44. getCurrentPages()[getCurrentPages().length - 1].$getAppWebview().setStyle({
  45. "pullToRefresh": {
  46. support: true,
  47. offset: "23%",
  48. style: "circle",
  49. color: "#F76454"
  50. }
  51. })
  52. },
  53. offPullDown() {
  54. getCurrentPages()[getCurrentPages().length - 1].$getAppWebview().setStyle({ pullToRefresh: { support: false } })
  55. }
  56. },
  57. onPullDownRefresh() {
  58. uni.$emit('INDEXPULLDOWNREFRESH' + this.activeIndex)
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .index {
  64. height: 100%;
  65. }
  66. </style>