index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view>
  3. <!--首页-->
  4. <home :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==0?true:false" v-if="loadOn.home"/>
  5. <!--资源-->
  6. <resource :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==1?true:false" v-if="loadOn.resource"/>
  7. <!--卖二手-->
  8. <!-- <sell :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==2?true:false" v-if="loadOn.sell" @closeTap="sellCloseTap"/> -->
  9. <!--消息-->
  10. <!-- <news :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==3?true:false" v-if="loadOn.news"/> -->
  11. <!--我的-->
  12. <my :scrollY="scrollY" :scrollBottom="scrollBottom" :show="tabID==4?true:false" v-if="loadOn.my"/>
  13. <!--底部导航-->
  14. <footer-tabbar :tabID='tabID' :msgDot='true' @tabTap='tabTap'/>
  15. </view>
  16. </template>
  17. <script>
  18. //加载组件
  19. import home from '@/components/zaiui-common/view/home';
  20. import find from '@/components/zaiui-common/view/find';
  21. import sell from '@/components/zaiui-common/view/sell';
  22. import news from '@/components/zaiui-common/view/news';
  23. import resource from '@/components/zaiui-common/view/resource';
  24. import my from '@/components/zaiui-common/view/my';
  25. //固定组件
  26. import footerTabbar from '@/components/zaiui-common/footer/footer-tabbar';
  27. //工具函数
  28. import _tool from '@/static/zaiui/util/tools.js';
  29. export default {
  30. components: {
  31. home, find, sell, resource, news, my, footerTabbar,
  32. },
  33. data() {
  34. return {
  35. loadOn: {home: true, find: false, resource: false, sell: false, news: false, my: false }, scrollY: 0, scrollBottom: 0, tabID: 0, tabIndex: 0,
  36. }
  37. },
  38. onLoad() {
  39. },
  40. onReady() {
  41. _tool.setBarColor(true);
  42. },
  43. methods: {
  44. tabTap(index) {
  45. Object.keys(this.loadOn).forEach(key => {
  46. this.loadOn[key] = false;
  47. })
  48. this.tabIndex = this.tabID;
  49. if (index == 0 && !this.loadOn.home) {
  50. this.loadOn.home = true;
  51. }
  52. if (index == 1 && !this.loadOn.resource) {
  53. this.loadOn.resource = true;
  54. }
  55. if (index == 2 && !this.loadOn.sell) {
  56. this.loadOn.sell = true;
  57. }
  58. if (index == 3 && !this.loadOn.news) {
  59. this.loadOn.news = true;
  60. }
  61. if (index == 4 && !this.loadOn.my) {
  62. this.loadOn.my = true;
  63. }
  64. this.tabID = index;
  65. //设置颜色
  66. if (index == 0) {
  67. _tool.setBarColor(false);
  68. }
  69. if (index == 1 || index == 2 || index == 3) {
  70. _tool.setBarColor(true);
  71. }
  72. if (index == 4) {
  73. _tool.setBarColor(false);
  74. }
  75. console.log(this.tabID, this.loadOn)
  76. uni.pageScrollTo({
  77. scrollTop: 0,
  78. duration: 0
  79. });
  80. },
  81. sellCloseTap() {
  82. this.tabTap(this.tabIndex);
  83. },
  84. },
  85. onPageScroll(e) {
  86. this.scrollY = e.scrollTop;
  87. //console.log(e.scrollTop);
  88. },
  89. onReachBottom(e) {
  90. let timestamp = new Date().getTime();
  91. this.scrollBottom = timestamp;
  92. },
  93. }
  94. </script>
  95. <style lang="scss">
  96. //APP端引用。玄学问题,在这里引入css文件后,APP端才生效,在app.vue里引入无效。原因未知...
  97. //可自行测试在APP上是否有效,如果有效,可删除下面的引入代码。
  98. /* #ifdef APP-PLUS */
  99. @import "../../static/colorui/main.css";
  100. @import "../../static/colorui/icon.css";
  101. @import "../../static/zaiui/style/app.scss";
  102. /* #endif */
  103. </style>