index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. this.tabIndex = this.tabID;
  46. if (index == 1 && !this.loadOn.resource) {
  47. this.loadOn.resource = true;
  48. }
  49. if (index == 2 && !this.loadOn.sell) {
  50. this.loadOn.sell = true;
  51. }
  52. if (index == 3 && !this.loadOn.news) {
  53. this.loadOn.news = true;
  54. }
  55. if (index == 4 && !this.loadOn.my) {
  56. this.loadOn.my = true;
  57. }
  58. this.tabID = index;
  59. //设置颜色
  60. if (index == 0) {
  61. _tool.setBarColor(false);
  62. }
  63. if (index == 1 || index == 2 || index == 3) {
  64. _tool.setBarColor(true);
  65. }
  66. if (index == 4) {
  67. _tool.setBarColor(false);
  68. }
  69. uni.pageScrollTo({
  70. scrollTop: 0,
  71. duration: 0
  72. });
  73. },
  74. sellCloseTap() {
  75. this.tabTap(this.tabIndex);
  76. },
  77. },
  78. onPageScroll(e) {
  79. this.scrollY = e.scrollTop;
  80. //console.log(e.scrollTop);
  81. },
  82. onReachBottom(e) {
  83. let timestamp = new Date().getTime();
  84. this.scrollBottom = timestamp;
  85. },
  86. }
  87. </script>
  88. <style lang="scss">
  89. //APP端引用。玄学问题,在这里引入css文件后,APP端才生效,在app.vue里引入无效。原因未知...
  90. //可自行测试在APP上是否有效,如果有效,可删除下面的引入代码。
  91. /* #ifdef APP-PLUS */
  92. @import "../../static/colorui/main.css";
  93. @import "../../static/colorui/icon.css";
  94. @import "../../static/zaiui/style/app.scss";
  95. /* #endif */
  96. </style>