绿满眶商城微信小程序-uniapp
zxl
3 天以前 a8e2f971ecaa34570f679ec6f33c9a48cf109f82
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<template>
    <view class="container">
        <view class="header">
            <text class="title">客户列表</text>
        </view>
        <!-- 搜索框 -->
        <view class="search-box">
            <u-search v-model="query.username" placeholder="搜索客户" :showAction="false" @change="searchMember"></u-search>
        </view>
 
        <!-- 内容区域 -->
        <scroll-view scroll-y class="member-list" @scrolltolower="loadMore" :lower-threshold="100">
            <view>
                <view class="member-item" v-for="(member, index) in memberList" :key="member.id"
                    v-if="memberList.length > 0">
 
                    <view class="member-info">
                        <text class="mobile">{{ member.mobile }}</text>
                        <text class="region">{{ member.region }}</text>
                    </view>
                    <!-- 操作按钮区域 -->
                    <view class="action-buttons">
                        <u-button type="primary" size="mini" @click.stop="navigateToDetail(member.id)"
                            class="edit-btn">修改</u-button>
                        <u-button type="error" size="mini" @click.stop="joinBlack(member.id)"
                            class="delete-btn"></u-button>
                    </view>
 
                </view>
            </view>
 
            <!-- 改进的加载更多提示 -->
            <view>
                <u-loadmore class="load-more" v-if="memberList.length > 0"
                    :status="loading ? 'loading' : noMore ? 'nomore' : 'loadmore'" :load-text="{
                        loadmore: '上拉加载更多',
                        loading: '正在加载',
                        nomore: '没有更多了'
                      }" />
            </view>
            <view style="height:150rpx">
 
            </view>
        </scroll-view>
 
 
 
    </view>
</template>
 
<script>
    import {
        getPage,
    } from "@/api/customerManager.js"
    import '@/components/uview-components/uview-ui';
    export default {
        data() {
            return {
                loading: false,
                noMore: false,
 
                query: {
                    username: '',
                    pageNumber: 1,
                    pageSize: 15,
                },
                memberList: [],
                total:0,
            }
        },
        onLoad(){
            this.getPage()
        },
        methods: {
            // 搜索用户
            searchMember() {
                this.query.pageNumber = 1
                this.noMore = false
                this.clerkList = []
                this.getPage()
            },
            joinBlack(memberId){
                
            },
            async getPage(){
                uni.showLoading({
                    title: '加载中'
                });
                getPage(this.query).then(res =>{
                    uni.hideLoading();
                    if (res.statusCode === 200) {
                        const newData = res.data.data;
                        // 更新总数据量
                        this.total = res.data.total || 0;
                        // 追加或替换数据
                        this.memberList = this.query.pageNumber === 1 ?
                            newData :
                            [...this.memberList, ...newData];
                            
                        // 判断是否还有更多数据
                        this.noMore = newData.length < this.query.pageSize ||
                            this.memberList.length >= this.total;
                        
                    }
                })
            },
            // 加载更多
            loadMore() {
                if (!this.noMore) {
                    this.query.pageNumber++
                    this.getPage()
                }
            },
 
        }
    }
</script>
 
<style lang="scss" scoped>
    .action-buttons {
      display: flex;
      margin-left: 20rpx;
    }
    .container {
        padding: 20rpx;
        height: 100vh;
        display: flex;
        flex-direction: column;
        background-color: #f5f5f5;
    }
 
    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20rpx 0;
        margin-bottom: 20rpx;
 
        .title {
            font-size: 36rpx;
            font-weight: bold;
            color: #333;
        }
 
 
    }
 
    .search-box {
        margin-bottom: 20rpx;
    }
 
    .member-list {
        flex: 1;
        overflow: hidden;
    }
 
    .member-item {
        display: flex;
        align-items: center;
        padding: 20rpx;
        margin-bottom: 20rpx;
        background-color: #fff;
        border-radius: 12rpx;
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
 
        .avatar {
            width: 80rpx;
            height: 80rpx;
            border-radius: 50%;
            margin-right: 20rpx;
        }
 
        .member-info {
            flex: 1;
            display: flex;
            flex-direction: column;
 
            .mobile {
                font-size: 32rpx;
                color: #333;
                margin-bottom: 8rpx;
            }
 
            .region {
                font-size: 24rpx;
                color: #999;
            }
        }
    }
 
    .load-more {
        padding: 20rpx 0;
        text-align: center;
        color: #999;
        font-size: 26rpx;
        background-color: #f7f8fa;
    }
</style>