张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
    <view class="steam_monitor">
        <scroll-view
            scroll-y="true"
            class="steam_index_scroll"
            :scroll-top="scrollTop" 
            refresher-enabled="true" 
            refresher-background="#EAEAEA"
            :refresher-triggered="triggered" 
            @refresherpulling="refresherrefresh"
            @scrolltolower="scrolltoLower">
            <view class="steam_mains">
                <view class="steam_card_index" v-for="(item,index) in steamMonitorList" :key="index">
                    <view class="steam_card_header">{{index+1}}号</view>
                    <view class="steam_card_main">
                        <view class="steam_card_text">温度:</view>
                        <view class="steam_card_datas">{{item.temperature}}℃</view>
                    </view>
                    <view class="steam_card_main" style="top:65px">
                        <view class="steam_card_text">湿度:</view>
                        <view class="steam_card_datas">{{item.humidity===null?0:item.humidity}}%</view>
                    </view>
                </view>
            </view>
            <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
        </scroll-view>
    </view>
</template>
 
<script>
    import { throttle } from '../../plugins/public.js';
    export default{
        data(){
            return{
                pageNum: 1,
                pageSize: 1000000000,
                loadPage: 0,
                steamMonitorList:[],//蒸养监控
                scrollTop: 0,
                triggered: true,
                status: 'loading',
                loadText: {
                    loading: '努力加载中',
                    nomore: '没有更多数据了'
                },
            }
        },
        mounted(){
            this.searchSteamList()
        },
        methods:{
            //查询蒸养监控列表
            searchSteamList(){
                this.triggeredBear = true;
                this.steamMonitorList = [];
                let params = {
                    pageNum: this.pageNum,
                    pageSize:this.pageSize,
                }
                this.$api.reboSystem.searchSteamLists(params).then(res=>{
                    if(res.statusMsg === 'ok'){
                        this.steamMonitorList = res.data.list
                        this.loadPage = res.data.pages;
                        this.triggeredBear = false;
                        this.status = 'nomore';
                    }else{
                        uni.$u.toast(res.statusMsg);
                    }
                }).catch((err) => {
                    uni.$u.toast('请检查网络服务或联系管理员!')
                })
            },
            //自定义下拉刷新
            refresherrefresh: throttle(function() {
                this.status = 'loading';
                this.pageNum = 1;
                this.searchSteamList();
                uni.$u.toast('刷新成功');
            }, 500),
            //触底刷新
            scrolltoLower: throttle(function() {
                this.status = 'loading';
                if(this.pageNum >= this.loadPage) {
                    setTimeout(() => {
                        this.status = 'nomore'
                        uni.$u.toast('没有更多数据了');
                    },1000)
                    return
                } else {
                    this.pageNum+=1
                    let params = {
                        pageNum: this.pageNum,
                        pageSize:this.pageSize,
                    }
                    this.$api.reboSystem.searchSteamLists(params).then(res=>{
                        if(res.statusMsg === 'ok'){
                            this.steamMonitorList.push(...res.data.list)
                            this.loadPage = res.data.pages;
                            this.triggered = false;
                            this.status = 'nomore';
                        }else{
                            uni.$u.toast(res.statusMsg);
                        }
                    }).catch((err) => {
                        uni.$u.toast('请检查网络服务或联系管理员!')
                    })
                }
            }, 1500),
        }
    }
</script>
 
<style lang="scss" scoped>
    .steam_monitor{
        height: 100vh;
        padding: 10px 15px;
        background-color: #fff;
        
        .steam_index_scroll{
            height: 90%;
            
            .steam_mains{
                display:flex;
                flex-wrap: wrap;
                justify-content: space-between;
                &::after{
                    content: "";
                    width: calc(100%/3.5);
                }
                .steam_card_index{
                    width: 100px;
                    height: 100px;
                    margin: 8px 4px;
                    background-color: rgba(25, 119, 255, .12);
                    border-radius: 3px;
                    position: relative;
                    
                    .steam_card_header{
                        display: flex;
                        justify-content: center;
                        line-height: 23px;
                        background-color: rgba(25, 119, 255, .72);
                        height: 25px;
                        margin: 0 12px;
                        clip-path: polygon(0 0, 100% 0, 93% 100%, 7% 100%);
                        position: absolute;
                        left: 0;
                        right: 0;
                        color: rgba(255, 255, 255, 1);
                        font-size: 17px;
                        font-weight: 500;
                    }
                    .steam_card_main{
                        position: absolute;
                        top: 40px;
                        left: 0;
                        right: 0;
                        display:flex;
                        justify-content: center;
                        .steam_card_text{
                            color: rgba(51, 51, 51, 1);
                            font-size: 15px;
                            font-weight:500;
                        }
                        .steam_card_datas{
                            color: rgba(25, 119, 255, 1);
                            font-size: 15px;
                            font-weight: 500;
                            
                        }
                    }
                }
            }
        }
    }
</style>