index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class='productSort' :style="'height:'+winHeight+'px'">
  3. <view class="con-box" :style="viewColor">
  4. <view class='aside'>
  5. <scroll-view scroll-y="true" style="height: 100%; overflow: hidden;" scroll-with-animation='true'>
  6. <view v-for="(item,index) in productList" :key="item.category_id">
  7. <view class='item acea-row row-center-wrapper' :class='index==navActive?"on":""' v-show='item.children && item.children.length > 0'
  8. @click='tap(index,"b"+index)'><text class="item_text">{{item.cate_name}}</text>
  9. </view>
  10. </view>
  11. </scroll-view>
  12. </view>
  13. <view class='conter'>
  14. <scroll-view scroll-y="true">
  15. <view class='listw' v-for="(item,index) in childList" :key="item.topic_id">
  16. <view class='list'>
  17. <navigator hover-class='none' :url="'/pages/plantGrass/plant_search_list/index?id='+item.topic_id" class='item acea-row'>
  18. <view class='picture'>
  19. <image :src='item.pic'></image>
  20. </view>
  21. <view class='text'>
  22. <view class="name line1">{{item.topic_name}}</view>
  23. <view class="info">{{item.count_use || 0}}篇内容 </view>
  24. </view>
  25. </navigator>
  26. </view>
  27. </view>
  28. <view :style='"height:"+(height-300)+"rpx;"'></view>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. // +----------------------------------------------------------------------
  36. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  37. // +----------------------------------------------------------------------
  38. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  39. // +----------------------------------------------------------------------
  40. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  41. // +----------------------------------------------------------------------
  42. // | Author: CRMEB Team <admin@crmeb.com>
  43. // +----------------------------------------------------------------------
  44. let app = getApp();
  45. import { getTopicList } from '@/api/community.js';
  46. import { mapGetters } from "vuex";
  47. export default {
  48. computed: mapGetters(['viewColor']),
  49. data() {
  50. return {
  51. productList: [],
  52. navActive: 0,
  53. number: "",
  54. height: 0,
  55. winHeight: 0,
  56. childList: []
  57. }
  58. },
  59. watch:{
  60. },
  61. onLoad(options) {
  62. let that = this
  63. uni.getSystemInfo({
  64. success: function(res) {
  65. console.log(res,'res')
  66. that.winHeight = res.windowHeight
  67. },
  68. });
  69. },
  70. onShow() {
  71. if (!this.productList.length) {
  72. this.getAllCategory();
  73. }
  74. },
  75. onReady() {},
  76. methods: {
  77. tap: function(index, id) {
  78. this.navActive = index;
  79. this.childList = this.productList[index].children
  80. },
  81. getAllCategory: function() {
  82. let that = this;
  83. getTopicList().then(res => {
  84. that.productList = res.data;
  85. for(let i=0; i < that.productList.length; i++){
  86. if(that.productList[i].children && that.productList[i].children.length > 0){
  87. that.navActive = i;
  88. that.childList = that.productList[i].children;
  89. return
  90. }
  91. }
  92. })
  93. },
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. .productSort {
  99. display: flex;
  100. flex-direction: column;
  101. width: 100%;
  102. .con-box {
  103. flex: 1;
  104. display: flex;
  105. overflow: hidden;
  106. }
  107. }
  108. .productSort .aside {
  109. background-color: #f5f5f5;
  110. overflow-y: auto;
  111. overflow-x: hidden;
  112. width: 202rpx;
  113. height: 100%;
  114. overflow-y: scroll;
  115. }
  116. .productSort .aside .item {
  117. height: 100rpx;
  118. width: 100%;
  119. font-size: 28rpx;
  120. color: #666666;
  121. }
  122. .productSort .aside .item_text {
  123. padding-left: 20rpx;
  124. overflow: hidden;
  125. text-overflow: ellipsis;
  126. display: -webkit-box;
  127. -webkit-line-clamp: 2;
  128. -webkit-box-orient: vertical;
  129. }
  130. .productSort .aside .item.on {
  131. background-color: #ffffff;
  132. border-left: 4rpx solid var(--view-theme);
  133. width: 100%;
  134. text-align: center;
  135. color: var(--view-theme);
  136. font-weight: bold;
  137. }
  138. .productSort .conter {
  139. flex: 1;
  140. height: 100%;
  141. padding: 0 30rpx;
  142. background-color: #ffffff;
  143. overflow-y: scroll;
  144. }
  145. .productSort .conter .list {
  146. flex-wrap: wrap;
  147. }
  148. .productSort .conter .list .item {
  149. margin-top: 26rpx;
  150. margin-bottom: 40rpx;
  151. align-items: center;
  152. }
  153. .productSort .conter .list .item .picture {
  154. width: 110rpx;
  155. height: 110rpx;
  156. border-radius: 8rpx;
  157. }
  158. .productSort .conter .list .item .picture image {
  159. width: 100%;
  160. height: 100%;
  161. border-radius: 8rpx;
  162. }
  163. .productSort .conter .list .item .text{
  164. margin-left: 30rpx;
  165. }
  166. .productSort .conter .list .text .name {
  167. font-size: 28rpx;
  168. color: #282828;
  169. font-weight: bold;
  170. max-width: 300rpx;
  171. }
  172. .productSort .list .item .info {
  173. font-size: 24rpx;
  174. color: #999999;
  175. margin-top: 10rpx;
  176. }
  177. </style>