12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <template>
- <view>
- <view class="search">
- <u-search placeholder="搜索资讯" v-model="param.title" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
- </view>
- <view class="list">
- <view class="news_item" v-for="(item, index) in list" :key="index" @click="detail(item)">
- <image src="../../static/tp.jpg" mode="aspectFill" class="img"></image>
- <view class="con">
- <view class="title ellip">{{ item.title }}</view>
- <view class="source omit">{{ item.source }}</view>
- <view class="releaseTime">{{ item.releaseTime }}</view>
- </view>
- </view>
- <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
- <u-empty v-if="!loadMore && list.length == 0"></u-empty>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- list: [],
- param: { pageNo: 1, pageSize: 10 },
- loadMore: true
- };
- },
- onLoad(e) {
- if (e.keyword) {
- this.param.title = e.keyword;
- this.refresh();
- } else {
- this.getData();
- }
- },
- methods: {
- getData() {
- this.http.request({
- url: '/level-one-server/app/TbPortNews/getPortNewsList',
- data: this.param,
- loading: 'false',
- success: res => {
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- }
- });
- },
- detail(item) {
- uni.navigateTo({ url: '/pages/news/detail?id=' + item.id });
- },
- //刷新数据
- refresh() {
- this.loadMore = true;
- this.param.pageNo = 1;
- this.list = [];
- this.getData();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.refresh();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- //上拉加载
- onReachBottom() {
- if (this.loadMore) {
- this.param.pageNo++;
- this.getData();
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: $pg;
- }
- .list {
- padding: 12px;
- }
- </style>
|