移动系统liao
2024-05-09 5d6cb15ac86d9174393cb9d1538d69b567e2c26c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar :title="typeName" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
 
        <view class="coreshop-bg-white coreshop-margin-10">
            <view class="coreshop-flex coreshop-solid-bottom coreshop-justify-between coreshop-flex-nowrap coreshop-padding-top-10 coreshop-padding-bottom-10 coreshop-padding-left-10 coreshop-padding-right-10" v-for="item in list" :key="item.id" @click="goArticleDetail(item.id)">
                <view class="coreshop-flex coreshop-flex-nowrap">
                    <u--image width="25px" height="25px" :src="item.coverImage" mode="aspectFill" :showLoading="true"></u--image>
                    <view class="u-line-2 coreshop-padding-left-5 coreshop-font-14">{{item.title}}</view>
                </view>
                <view class="coreshop-text-gray coreshop-text-right coreshop-justify-end">
                    <u-icon name="arrow-right-double"></u-icon>
                </view>
            </view>
        </view>
        <view>
            <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="0" margin-bottom="20" class="coreshop-padding-top-10" />
        </view>
        <!-- 登录提示 -->
        <coreshop-login-modal></coreshop-login-modal>
    </view>
</template>
 
<script>
    
    export default {
        
        data() {
            return {
                id: 0, // 文章分类id
                page: 1,
                limit: 10,
                list: [],
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
                articleType: [],
                typeName: '',
            };
        },
        onLoad(options) {
            if (options.id) {
                this.id = Number(options.id);
                this.articleList();
            }
        },
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.articleList();
            }
        },
        methods: {
            articleList() {
                let data = {
                    page: this.page,
                    limit: this.limit,
                    id: this.id
                };
                this.status = 'loading';
                this.$u.api.articleList(data).then(res => {
                    if (res.status) {
                        this.articleType = res.data.articleType;
                        for (var i = 0; i < this.articleType.length; i++) {
                            if (this.id === this.articleType[i].id) {
                                this.typeName = this.articleType[i].name;
                            }
                        }
 
                        const _list = res.data.list;
                        this.list = [...this.list, ..._list];
                        if (res.data.count > this.list.length) {
                            this.status = 'loadmore';
                            this.page++;
                        } else {
                            // 数据已加载完毕
                            this.status = 'nomore';
                        }
                    } else {
                        // 接口请求出错了
                        this.$u.toast(res.msg);
                    }
                });
            },
            change(item) {
                this.id = item.id;
                this.list = [];
                this.page = 1;
                this.limit = 10;
                this.loadStatus = 'more';
                this.articleList();
            }
        }
    };
</script>
 
<style lang="scss" scoped>
</style>