<template> <view class="content"> <view class="top"> <!-- 搜索框 --> <view class="Search-box"> <view class="Search-box-size"> <image class="box-img" src="../../static/images/img01.png"></image> <input type="text" class="box-word" placeholder="请输入关键字" v-model="keyword" /> </view> <view class="Search-box-sort" @click="messagesearch">搜索</view> </view> </view> <scroll-view scroll-y="true" :style="{'height': height}" class="good-content"> <view class="list-box" v-for="(item,index) in science" :key='index' @click="Jump(item.id)"> <view class="box-left"> <image :src="(item.image.indexOf('http') != -1 )? item.image: ($store.state.baseURL + item.image)" mode="" class="left-img"></image> </view> <view class="box-right"> <view class="right-top word1_ellipsis"> {{item.title}} </view> <view class="right-center"> {{item.synopsis}} </view> <view class="right-foot"> <!-- 已阅读人数:{{item.visit || 0}} --> </view> </view> </view> <uni-load-more :status="loadingType"></uni-load-more> </scroll-view> </view> </template> <script> import { getArticList } from '@/api/index.js'; export default { data() { return { loadingType: 'more', keyword: '', science: [], page: 1, limit: 10, height: '', } }, onLoad() { this.loadData(); }, onReady(res) { var obj = this; uni.getSystemInfo({ success: resu => { const query = uni.createSelectorQuery(); query.select('.good-content').boundingClientRect(); query.exec(function(res) { obj.height = resu.windowHeight - res[0].top + 'px'; }); }, fail: res => {} }); }, onReachBottom() { this.loadData() }, filters: { time(val) { let arr = val.split(' ') return arr[0] } }, methods: { messagesearch() { let keyword = this.keyword; console.log(keyword); let arrlist = []; for (let i = 0; i < this.science.length; i++) { if (this.science[i].title.indexOf(keyword) != -1) { arrlist.push(this.science[i]); } } this.science = arrlist; if (keyword == '') { this.loadData(); } }, loadData() { let obj = this; if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') { return } obj.loadingType = 'loading' getArticList({ ifyid: 1 }).then(({ data }) => { obj.science = obj.science.concat(data.list); obj.page++ if (obj.limit == data.list) { obj.loadingType = 'more' } else { obj.loadingType = 'noMore' } }); }, Jump(id) { uni.navigateTo({ url: "/pages/applic/info?id=" + id }) }, } } </script> <style lang="scss"> //搜索框 .Search-box { padding-left: 20rpx; padding-right: 20rpx; height: 100rpx; background: #ffffff; display: flex; justify-content: space-between; align-items: center; .Search-box-sort { font-size: 30rpx; font-weight: 500; color: rgba(102, 102, 102, 1); .sort-text { width: 57rpx; height: 29rpx; font-size: 30rpx; font-weight: 500; color: rgba(51, 51, 51, 1); line-height: 58rpx; margin-right: 19rpx; } .sort-img { width: 21rpx; height: 11rpx; margin-bottom: 4rpx; } } .Search-box-size { width: 630rpx; height: 65rpx; border-radius: 32rpx; background-color: #f1f1f1; padding-left: 36rpx; display: flex; align-items: center; .box-img { height: 32rpx; width: 32rpx; margin-right: 16rpx; } .box-word { width: 100%; font-size: 22rpx; font-weight: 500; color: rgba(205, 203, 203, 1); line-height: 55rpx; } } } .content { line-height: 1; .list-box { width: 725rpx; height: 200rpx; margin: 0 auto 20rpx; background: #FFFFFF; box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06); border-radius: 7rpx; padding: 0 20rpx; display: flex; align-items: center; .box-left { width: 230rpx; height: 145rpx; margin-right: 20rpx; .left-img { width: 230rpx; height: 145rpx; } } .box-right { width: 430rpx; height: 145rpx; position: relative; .right-top { font-size: 25rpx; font-weight: bold; color: #333333; margin-bottom: 24rpx; } .right-center { width: 362rpx; // height: 53rpx; font-size: 21rpx; font-weight: bold; color: #999999; line-height: 33rpx; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; //在第几行显示... -webkit-box-orient: vertical; } .right-foot { font-size: 21rpx; font-weight: bold; color: #999999; line-height: 31rpx; text-align: right; // margin-top: 13rpx; position: absolute; right: 0; bottom: 0; } } } } .good-content { padding-top: 20rpx; } </style>