移动系统liao
2025-02-17 557c2711a3e103ebc3d0492344eca9730d5e92b2
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="万能表单" 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>
        <block v-if="list.length > 0">
            <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="goDetail(item.id)">
                    <view class="coreshop-flex coreshop-flex-nowrap">
                        <u--image width="25px" height="25px" :src="item.image" mode="aspectFill" :showLoading="true"></u--image>
                        <view class="u-line-2 coreshop-padding-left-5 coreshop-font-14">{{item.name}}</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>
        </block>
        <!-- 无数据时默认显示 -->
        <view class="coreshop-emptybox" v-else>
            <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/data.png'" icon-size="150" text="暂无数据" mode="list"></u-empty>
        </view>
        <!-- 登录提示 -->
        <coreshop-login-modal></coreshop-login-modal>
    </view>
</template>
 
<script>
 
    export default {
 
        data() {
            return {
                page: 1,
                limit: 10,
                list: [],
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
            };
        },
        onLoad(options) {
            this.getFormList();
        },
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.getFormList();
            }
        },
        methods: {
            getFormList() {
                let data = {
                    page: this.page,
                    limit: this.limit,
                };
                this.status = 'loading';
                this.$u.api.getFormList(data).then(res => {
                    if (res.status) {
                        if (res.data.length > 0) {
                            const _list = res.data;
 
                            for (var i = 0; i < _list.length; i++) {
                                if (_list[i].images) {
                                    _list[i].image = _list[i].images.split(',')[0];
                                }
                            }
 
 
                            this.list = [...this.list, ..._list];
                            if (res.data.count > this.list.length) {
                                this.status = 'loadmore';
                                this.page++;
                            } else {
                                // 数据已加载完毕
                                this.status = 'nomore';
                            }
                        } else {
                            // 数据已加载完毕
                            this.status = 'nomore';
                        }
 
                    } else {
                        // 接口请求出错了
                        this.$u.toast(res.msg);
                    }
                });
            },
            goDetail(id) {
                this.$u.route('/pages/form/details/details', { id: id });
            }
        }
    };
</script>
 
<style lang="scss" scoped>
</style>