recommend.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <view
  5. class="recommend"
  6. @click="transformation(index)"
  7. v-for="(item, index) in top"
  8. :key="item.id"
  9. :class="{ recommendtwo: recommendindex == index }"
  10. >
  11. {{ item.name }}
  12. </view>
  13. </view>
  14. <!-- <view class="capacity" :is="currentView"></view> -->
  15. <recommendTop v-if="recommendindex == 0" ref="recommend"></recommendTop>
  16. <merchantTop v-if="recommendindex == 1" @bottomList="getbottomlist" ref="merchant"></merchantTop>
  17. </view>
  18. </template>
  19. <script>
  20. import recommendTop from "./recommend-top/top.vue";
  21. import merchantTop from "./merchant-top/top.vue";
  22. export default {
  23. components: {
  24. recommendTop,
  25. merchantTop,
  26. },
  27. data() {
  28. return {
  29. recommendindex: 0,
  30. top: [
  31. {
  32. id: 1,
  33. name: "推荐",
  34. },
  35. {
  36. id: 2,
  37. name: "商学院",
  38. },
  39. ],
  40. bottomList: []
  41. };
  42. },
  43. // onShow() {
  44. // if(this.recommendindex==1){
  45. // this.$refs.merchant.getMsg()
  46. // }
  47. // },
  48. //上拉加载
  49. onReachBottom() {
  50. if (this.recommendindex == 0) {
  51. this.$refs.recommend.loaderMore();
  52. } else if (this.recommendindex == 1) {
  53. this.$refs.merchant.loaderMore();
  54. }
  55. },
  56. //下拉刷新
  57. onPullDownRefresh() {
  58. this.isload();
  59. uni.stopPullDownRefresh();
  60. },
  61. onReady(){
  62. this.isload();
  63. },
  64. methods: {
  65. getbottomlist(e){
  66. this.bottomList = e
  67. },
  68. transformation(index) {
  69. console.log(index, 'index')
  70. this.recommendindex = index;
  71. },
  72. isload() {
  73. if (this.recommendindex == 0) {
  74. this.$refs.recommend.isload();
  75. } else {
  76. this.$refs.merchant.isload();
  77. }
  78. },
  79. },
  80. };
  81. </script>
  82. <style>
  83. page{
  84. background-color: #F5F5F5;
  85. }
  86. </style>
  87. <style lang="scss" scoped>
  88. .container {
  89. .top {
  90. overflow: hidden;
  91. padding-top: 30rpx;
  92. line-height: 120rpx;
  93. z-index: 1;
  94. width: 100%;
  95. height: 120rpx;
  96. position: fixed;
  97. background-color: #0B844A;
  98. display: flex;
  99. justify-content: center;
  100. align-items: center;
  101. color: rgba(255, 255, 255, 1);
  102. .recommend {
  103. font-size: 36rpx;
  104. font-weight: 500;
  105. box-sizing: border-box;
  106. margin: 0 52rpx;
  107. height: 120rpx;
  108. }
  109. .recommendtwo {
  110. border-bottom: 4rpx #ffffff solid;
  111. border-radius: 2rpx;
  112. }
  113. }
  114. }
  115. .recommend {
  116. overflow: hidden;
  117. }
  118. </style>