Administrator
2021-07-02 f516111a9ee42ad4cc11a8e2f85b8fb9986516ae
首页新闻数据整合
3 files modified
80 ■■■■ changed files
api/mock/home.js 4 ●●●● patch | view | raw | blame | history
pages/alarm_list/alarm_list.vue 1 ●●●● patch | view | raw | blame | history
pages/home/home.vue 75 ●●●● patch | view | raw | blame | history
api/mock/home.js
@@ -60,7 +60,7 @@
    })
}
// 获取顶部按钮数据
// 获取业务按钮数据
export function fakeNavButton() {
    return new Promise((resolute, reject) => {
        try {
@@ -103,7 +103,7 @@
    })
}
// 获取服务按钮数据
// 获取业务按钮数据
export function fakeServiceButton() {
    return new Promise((resolute, reject) => {
        try {
pages/alarm_list/alarm_list.vue
@@ -195,7 +195,6 @@
                            "content-type": "application/x-www-form-urlencoded"
                        },
                        success(res) {
                            console.log(res, 123);
                            if (res.data.code == 200) {
                                that.data = res.data.data.page;
                                that.totalNumber = res.data.data.number[0];
pages/home/home.vue
@@ -98,14 +98,15 @@
                    v-for="(item, index) in newsList" :key="index">
                    <view class="left">
                        <view class="info">
                            [中国空间站] 神舟十二号载人发射任务取得圆满成功
                            {{item.title}}
                        </view>
                        <view class="date">
                            <image src="/static/images/home/date.png" class="icon" mode=""></image>
                            2021.06.17
                            <!-- <image src="/static/images/home/date.png" class="icon" mode=""></image> -->
                            <view class="advisory-title-name">{{item.sourceName}}</view>
                            <view class="advisory-title-time">{{item.createTime}}</view>
                        </view>
                    </view>
                    <image src="/static/workbench/huojian.png" mode="" class="img"></image>
                    <image :src="item.url" mode="" class="img"></image>
                </navigator>
                <u-loadmore :status="status" />
            </view>
@@ -132,12 +133,13 @@
                positionArr: [],
                status: 'loadmore',
                list: 15,
                page: 0,
                page: 1,
                pagesize: 2,
                keyword: '',
                focus: false,
                bannerList: [],
                noticeList: [],
                newsList: [{}, {}],
                newsList: [],
                navButton: [],
                serviceButton: [],
                tabbar:this.$store.state.tabbar
@@ -166,8 +168,11 @@
            fakeServiceButton().then(data => {
                this.serviceButton = data;
            });
            //获取新闻信息
            this.getArtcilePageList();
        },
        onReachBottom() {
            // 后续将改为与后端联动
            if (this.page >= 3) return;
            this.status = 'loading';
@@ -176,7 +181,8 @@
                this.list += 10;
                if (this.page >= 3) this.status = 'nomore';
                else this.status = 'loading';
                this.newsList.push(...[{}, {}]);
                // this.newsList.push(...[{}, {}]);
                this.getArtcilePageList();
            }, 2000);
        },
        methods: {
@@ -202,6 +208,43 @@
                        url:url
                    })
                }
            },
            //获取资讯信息
            getArtcilePageList() {
                var that = this;
                uni.request({
                    url: this.$store.state.piAPI + '/article/article/page',
                    method: 'GET',
                    data: {
                        current: this.page,
                        size: this.pagesize
                    },
                    success: (res) => {
                        if (res.data.code == 200) {
                            if (res.data.data.records) {
                                //如果总数小于pageSize,不做其他操作
                                if (res.data.data.total < this.pagesize) {
                                    that.newsList = res.data.data.records;
                                } else {
                                    if (res.data.data.records.length < this.pagesize) {
                                        //如果数量小于分页数量,则为最后一页
                                        this.status = 'nomore'
                                    } else {
                                        //如果数量小于分页数量,则为最后一页
                                        this.status = 'loading';
                                    }
                                    res.data.data.records.forEach(item =>{
                                        that.newsList.push(item);
                                    })
                                }
                            } else {
                                // this.isLoadMore=true;
                                // this.loadStatus='nomore';
                            }
                            uni.stopPullDownRefresh();
                        }
                    }
                });
            }
        }
    };
@@ -466,9 +509,10 @@
                        font-size: 28rpx;
                        font-family: PingFang SC;
                        font-weight: 500;
                        font-weight: 550;
                        color: #585b61;
                        line-height: 36rpx;
                        letter-spacing: 1px;
                    }
                    .date {
@@ -485,13 +529,24 @@
                        font-family: PingFang SC;
                        font-weight: 500;
                        color: #a6abb5;
                        .advisory-title-name{
                            font-size: 0.7rem;
                            letter-spacing: 1px;
                        }
                        .advisory-title-time{
                            margin-left: 0.8rem;
                            font-size: 0.7rem;
                        }
                    }
                }
                .img {
                    flex-shrink: 0;
                    width: 252rpx;
                    height: 160rpx;
                    width: 232rpx;
                    height: 140rpx;
                    border-radius: 20rpx;
                    background-color: #82848a;
                }