list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="warpbox">
  3. <!-- 搜索 -->
  4. <view class="searbox">
  5. <view class="censear">
  6. <image src="/static/img/search.png" class="searimg" ></image>
  7. <input type="text" placeholder="请输入关键词搜索" :focus="focus" v-model="name" @input="queryData" class="lself" placeholder-style="color:#999;font-size:24rpx;">
  8. </view>
  9. </view>
  10. <view class="topChose">
  11. <picker @change="changeParent" :value="parentIndex" :range="parentList" :range-key="'name'">
  12. <view class="left">
  13. <view>{{parentList[parentIndex] && parentList[parentIndex].name}}</view>
  14. <image src="/static/img/xia.png" class="xiaimg" ></image>
  15. </view>
  16. </picker>
  17. <picker @change="changeType" :value="typeIndex" :range="typeList" :range-key="'name'">
  18. <view class="left">
  19. <view>{{typeList[typeIndex] && typeList[typeIndex].name}}</view>
  20. <image src="/static/img/xia.png" class="xiaimg" ></image>
  21. </view>
  22. </picker>
  23. </view>
  24. <view class="artic_warp">
  25. <view class="artic_item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
  26. <view class="artic_top">
  27. <view class="artic_name">{{item.title}}</view>
  28. <view class="artic_info">
  29. <image :src="item.img" class="artic_img" ></image>
  30. <view class="artic_con">{{item.desc}}</view>
  31. </view>
  32. </view>
  33. <view class="artic_bot">
  34. <view class="bot_left">
  35. <view class="bot_time">{{item.createtime}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="noData" v-if="list.length == 0">暂无更多</view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import { netArticleList,netKnowledgeList } from '@/api/api.js'
  45. export default{
  46. data() {
  47. return{
  48. type_id:'',
  49. pid:'',
  50. pname:'',
  51. name:'',
  52. list:[],
  53. page:1,
  54. totalPage:1,
  55. focus:false,
  56. name:'',
  57. showSelectL:false,//显示筛选选项
  58. showSelectR:false,
  59. parentList:[],
  60. parentIndex:0,
  61. parentid:'',
  62. typeList:[],
  63. typeIndex:0,
  64. }
  65. },
  66. onLoad(options) {
  67. },
  68. onShow() {
  69. this.getParentList()
  70. },
  71. onReachBottom() {
  72. if(this.page >= this.totalPage){
  73. return
  74. }
  75. this.page ++
  76. this.getList()
  77. },
  78. methods:{
  79. //搜索
  80. queryData(e) {
  81. this.list = []
  82. this.getList()
  83. },
  84. init() {
  85. this.page = 1
  86. this.list = []
  87. this.getList()
  88. },
  89. getList() {
  90. let params = {
  91. page:this.page,
  92. type_ids: this.typeList[this.typeIndex] ? this.typeList[this.typeIndex].id : '',
  93. name:this.name
  94. }
  95. netArticleList(params).then(res=>{
  96. this.list = this.list.concat(res.data.data)
  97. this.totalPage = res.data.last_page
  98. })
  99. },
  100. getParentList() {
  101. netKnowledgeList({pid:this.pid}).then(res=>{
  102. this.parentList = res.data
  103. this.getChild()
  104. })
  105. },
  106. getChild() {
  107. if(this.parentList[this.parentIndex]){
  108. netKnowledgeList({pid:this.parentList[this.parentIndex].id}).then(res=>{
  109. this.typeList = res.data
  110. this.init()
  111. })
  112. }
  113. },
  114. changeParent(e){
  115. this.parentIndex = e.detail.value
  116. this.getChild()
  117. },
  118. changeType(e) {
  119. this.typeIndex = e.detail.value
  120. this.init()
  121. },
  122. toDetail(item) {
  123. uni.navigateTo({
  124. url:'/pages/knowledge_base/detail?id='+item.id+'&tid='+this.type_id+'&pid='+this.pid
  125. })
  126. },
  127. handleClickLeft(){
  128. this.showSelectR = false
  129. this.showSelectL = true
  130. },
  131. handleClickRight(){
  132. this.showSelectL = false
  133. this.showSelectR = true
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .topChose{
  140. display: flex;
  141. justify-content: space-around;
  142. align-items: center;
  143. height: 100rpx;
  144. .left{
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. .xiaimg{
  149. width:26rpx;
  150. height:16rpx;
  151. margin-left:10rpx;
  152. }
  153. view{
  154. font-size: 26rpx;
  155. color: #333333;
  156. }
  157. }
  158. }
  159. .searbox{
  160. padding:10rpx 0 20rpx 0;
  161. display: flex;
  162. justify-content: center;
  163. align-items: center;
  164. .censear{
  165. display: flex;
  166. justify-content: flex-start;
  167. align-items: center;
  168. padding:0 24rpx;
  169. border-radius: 34rpx;
  170. background:#FFFFFF;
  171. border:1rpx solid #7FC2FF;
  172. width:487rpx;
  173. height:60rpx;
  174. .searimg{
  175. width:35rpx;
  176. height:35rpx;
  177. margin-right: 15rpx;
  178. }
  179. .lself{
  180. font-size:24rpx;
  181. }
  182. }
  183. }
  184. .artic_title{
  185. width:690rpx;
  186. background:#fff;
  187. border-radius: 10rpx;
  188. margin:24rpx auto;
  189. box-shadow: 1rpx 1rpx 8rpx 2rpx rgba(0,0,0,0.1);
  190. font-size:34rpx;
  191. color:#0287FF;
  192. text-align: center;
  193. line-height: 70rpx;
  194. }
  195. .artic_warp{
  196. .artic_item{
  197. width:690rpx;
  198. margin:0 auto 24rpx;
  199. box-shadow: 1rpx 1rpx 8rpx 2rpx rgba(0,0,0,0.1);
  200. padding:24rpx 30rpx;
  201. border-radius: 20rpx;
  202. .artic_top{
  203. display: flex;
  204. flex-direction: column;
  205. justify-content: center;
  206. align-items: flex-start;
  207. .artic_img{
  208. width:140rpx;
  209. height:140rpx;
  210. border-radius: 10rpx;
  211. margin-right:30rpx;
  212. flex-shrink: 0;
  213. }
  214. .artic_name{
  215. width:390rpx;
  216. font-size:28rpx;
  217. color:#666;
  218. margin-bottom:24rpx;
  219. overflow: hidden;
  220. text-overflow:ellipsis;
  221. white-space: nowrap;
  222. }
  223. .artic_info{
  224. display: flex;
  225. flex-wrap: nowrap;
  226. .artic_con{
  227. font-size:26rpx;
  228. height:100rpx;
  229. color:#999;
  230. line-height: 34rpx;
  231. display: -webkit-box;
  232. -webkit-box-orient: vertical;
  233. -webkit-line-clamp: 3;
  234. overflow: hidden;
  235. }
  236. }
  237. }
  238. .artic_bot{
  239. display: flex;
  240. justify-content: space-between;
  241. align-items: center;
  242. margin-top:30rpx;
  243. .bot_left{
  244. display: flex;
  245. justify-content: flex-start;
  246. align-items: center;
  247. .headerimg{
  248. width:50rpx;
  249. height:50rpx;
  250. border-radius: 50%;
  251. }
  252. .bot_name{
  253. font-size:26rpx;
  254. color:#999999;
  255. margin:0 30rpx;
  256. }
  257. .bot_time{
  258. font-size:26rpx;
  259. color:#999999;
  260. }
  261. }
  262. .bot_right{
  263. display: flex;
  264. justify-content: flex-end;
  265. align-items: center;
  266. .bot_right_box{
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. font-size:26rpx;
  271. color:#999999;
  272. margin-right:24rpx;
  273. .openimg{
  274. width:30rpx;
  275. height:30rpx;
  276. margin-right:10rpx;
  277. }
  278. .commimg{
  279. width:25rpx;
  280. height:25rpx;
  281. margin-right:10rpx;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .icon_creat {
  289. position: fixed;
  290. z-index: 1;
  291. bottom: 130rpx;
  292. right: 100rpx;
  293. image {
  294. width: 80rpx;
  295. height: 80rpx;
  296. border-radius: 50%;
  297. }
  298. }
  299. </style>