index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="warpbox">
  3. <view class="know_warp">
  4. <view class="know_left">
  5. <scroll-view scroll-y class="leftscroll">
  6. <view class="listwarp">
  7. <view class="list_item" :class="parentid == item.id ? 'list_item_active' : ''" v-for="(item,index) in parentList" :key="index" @click="changeParent(item)">{{item.name}}</view>
  8. </view>
  9. </scroll-view>
  10. </view>
  11. <view class="know_right">
  12. <view class="right_title">类目分类</view>
  13. <scroll-view scroll-y class="rightscroll">
  14. <view class="tabwarp">
  15. <view class="tab_item" :class="typeIndex == index ? 'tab_item_active' : ''" v-for="(item,index) in typeList" :key="index" @click="changeType(index)">{{item.name}}</view>
  16. <van-empty v-if="typeList.length == 0" description="暂无更多"></van-empty>
  17. </view>
  18. </scroll-view>
  19. <view class="right_btn" @click="sureList">确认</view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import { netKnowledgeList } from '@/api/api.js'
  26. export default{
  27. data() {
  28. return{
  29. pid:0,
  30. parentList:[],
  31. parentid:'',
  32. parentname:'',
  33. typeList:[],
  34. typeIndex:0
  35. }
  36. },
  37. onLoad() {
  38. this.getList()
  39. },
  40. methods:{
  41. getList() {
  42. netKnowledgeList({pid:this.pid}).then(res=>{
  43. this.parentList = res.data
  44. this.parentid = res.data[0].id
  45. this.parentname = res.data[0].name
  46. this.getChild()
  47. })
  48. },
  49. changeParent(item) {
  50. this.parentid = item.id
  51. this.parentname = item.name
  52. this.typeIndex = null
  53. this.getChild()
  54. },
  55. getChild() {
  56. netKnowledgeList({pid:this.parentid}).then(res=>{
  57. this.typeList = res.data
  58. })
  59. },
  60. changeType(index) {
  61. this.typeIndex = index
  62. },
  63. sureList() {
  64. if(!this.typeList[this.typeIndex]){
  65. uni.showToast({
  66. title:'请选择类目分类',
  67. icon:'none'
  68. })
  69. return
  70. }
  71. let id = this.typeList[this.typeIndex].id
  72. let pname = this.parentname
  73. let name = this.typeList[this.typeIndex].name
  74. uni.navigateTo({
  75. url:'/pages/knowledge_base/list?id='+id+'&pname='+pname+'&name='+name
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .know_warp{
  83. width:750rpx;
  84. height:100vh;
  85. display: flex;
  86. justify-content: space-between;
  87. align-items: center;
  88. .know_left{
  89. width:250rpx;
  90. height:100vh;
  91. .leftscroll{
  92. width:100%;
  93. height:100%;
  94. background:#f5f5f5;
  95. .listwarp{
  96. .list_item{
  97. font-size:32rpx;
  98. color:#999999;
  99. padding:30rpx 40rpx;
  100. background:#f5f5f5;
  101. border-bottom:1rpx solid rgba(153, 153, 153, 0.5);
  102. border-right:1rpx solid rgba(153, 153, 153, 0.5);
  103. }
  104. .list_item_active{
  105. background:#fff;
  106. color:#0287FF;
  107. border-right:0;
  108. position: relative;
  109. &::before{
  110. width:20rpx;
  111. height:100%;
  112. content:'';
  113. position: absolute;
  114. left:0;
  115. top:0;
  116. background:#0287FF;
  117. }
  118. }
  119. }
  120. }
  121. }
  122. .know_right{
  123. width:500rpx;
  124. height:100%;
  125. .right_title{
  126. font-size:30rpx;
  127. color:#666666;
  128. text-align: center;
  129. padding:30rpx 0;
  130. }
  131. .right_btn{
  132. width:415rpx;
  133. height:88rpx;
  134. border-radius: 10rpx;
  135. background:#0287FF;
  136. font-size:32rpx;
  137. color:#fff;
  138. text-align: center;
  139. line-height: 88rpx;
  140. margin:0 auto;
  141. }
  142. .rightscroll{
  143. width:100%;
  144. height:calc(100vh - 230rpx);
  145. .tabwarp{
  146. display: flex;
  147. justify-content: flex-start;
  148. align-items: center;
  149. flex-wrap: wrap;
  150. .tab_item{
  151. font-size:30rpx;
  152. padding:10rpx 34rpx;
  153. border-radius: 10rpx;
  154. border:1rpx solid #0287FF;
  155. color:#0287FF;
  156. margin-right:15rpx;
  157. margin-left:15rpx;
  158. margin-bottom:24rpx;
  159. flex-shrink: 0;
  160. }
  161. .tab_item_active{
  162. background:#0287FF;
  163. color:#fff;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </style>