liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<template>
    <view :class="[Visible ? 'usable-popup supplier_open' : 'usable-popup supplier_close', theme() || '']" :data-theme='theme()'>
        <view class="popup-bg" @click="closePopup(null)"></view>
        <view class="main pt30" v-on:click.stop>
            <view class="popup-search d-s-c pb30 pr border-b-e">
                <view class="search-box d-s-c">
                    <text class="icon iconfont icon-sousuo"></text>
                    <input type="text" v-model="keyword" class="flex-1 ml10 f26 gray3" value="" placeholder-class="f26 gray9"
                     placeholder="请输入企业名称关键词进行搜索" confirm-type="search" @confirm="searchFunc()" />
                </view>
                <view class="iconfont icon-guanbi" @click="closePopup(null)"></view>
            </view>
            <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" :show-scrollbar="false" lower-threshold="50" @scrolltolower="scrolltolowerFunc">
                <view class="supplier-box">
                    <view class="supplier-item d-b-c" v-for="(item, index) in listData" :key="index">
                        <view class="title f28">{{item.name}}</view>
                        <view class="select-box" @click="chooseSupplier(item)">
                            <i class="iconfont icon-xuanze theme-price" v-if="select_supplier['shop_supplier_id'] == item.shop_supplier_id"></i>
                            <view class="round" v-else></view>
                        </view>
                    </view>
                </view>
                
                <!-- 没有记录 -->
                <view class="none-data-box" v-if="listData.length==0">
                    <image :src="remoteImg('no_thing')" mode="widthFix"></image>
                    <text>暂无数据</text>
                </view>
                <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
            </scroll-view>
            <view class="footer-btn bg-white p-0-30 pt20 pb20">
                <button type="default" @click="onSubmit" class="btn-submit theme-btn">确定</button>
            </view>
        </view>
    </view>
</template>
 
<script>
    import uniLoadMore from '@/components/uni-load-more.vue';
    export default {
        components: {
            uniLoadMore,
        },
        data() {
            return {
                /*手机高度*/
                phoneHeight: 0,
                /*可滚动视图区域高度*/
                scrollviewHigh: 0,
                /*是否可见*/
                Visible: false,
                listData: [],
                /*最后一页码数*/
                last_page: 0,
                /*当前页面*/
                page: 1,
                /*每页条数*/
                list_rows: 10,
                /*有没有更多*/
                no_more: false,
                /*是否正在加载*/
                loading: true,
                select_supplier: {},
                keyword: '', // 搜索关键词
            };
        },
        props: ['isOpenSupplier', 'activity_id'],
        computed: {
            /*加载中状态*/
            loadingType() {
                if (this.loading) {
                    return 1;
                } else {
                    if (this.listData.length != 0 && this.no_more) {
                        return 2;
                    } else {
                        return 0;
                    }
                }
            }
        },
        onLoad() {},
        mounted() {
            this.init();
        },
        watch: {
            isOpenSupplier: function(n, o) {
                if (n != o) {
                    this.Visible = n;
                }
            }
        },
        created() {
            this.getData();
        },
        methods: {
            /*初始化*/
            init() {
                let self = this;
                uni.getSystemInfo({
                    success(res) {
                        self.phoneHeight = res.windowHeight;
                        self.scrollviewHigh = self.phoneHeight * 0.7
                    }
                });
            },
            
            /*初始化列表数据*/
            initData() {
                this.page = 1;
                this.last_page = 0;
                this.listData = [];
            },
            
            /*获取数据*/
            getData() {
                let self = this;
                self.loading = true;
                self._get(
                    'branch.admin.supplier/lists', {
                        keyword: self.keyword,
                        page: self.page,
                        list_rows: self.list_rows,
                    },
                    function(res) {
                        self.loading = false;
                        self.listData = self.listData.concat(res.data.list.data);
                        self.last_page = res.data.list.last_page;
                        if (res.data.list.last_page <= 1) {
                            self.no_more = true;
                        } else {
                            self.no_more = false;
                        }
                    }
                );
            },
            
            searchFunc() {
                this.listData = [];
                this.page = 1;
                /*获取列表*/
                this.getData();
            },
            
            chooseSupplier(item) {
                this.select_supplier = {
                    name: item.name,
                    shop_supplier_id: item.shop_supplier_id
                };
            },
            
            onSubmit() {
                this.closePopup(this.select_supplier);
            },
                        
            /*可滚动视图区域到底触发*/
            scrolltolowerFunc() {
                let self = this;
                if (self.no_more) {
                    return;
                }
                self.page++;
                if (self.page <= self.last_page) {
                    self.getData();
                } else {
                    self.no_more = true;
                }
            },
                        
            /*关闭弹窗*/
            closePopup(e) {
                this.$emit('close', e);
            }
        }
    };
</script>
 
<style lang="scss" scoped>
    .usable-popup .popup-bg {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 110;
    }
 
    .usable-popup .main {
        position: fixed;
        width: 100%;
        bottom: 0;
        min-height: 200rpx;
        background-color: #ffffff;
        transform: translate3d(0, 1380rpx, 0);
        transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
        bottom: env(safe-area-inset-bottom);
        z-index: 110;
        border-radius: 30rpx 30rpx 0 0;
    }
 
    .usable-popup.supplier_open .main {
        transform: translate3d(0, 0, 0);
    }
 
    .usable-popup.supplier_close .popup-bg {
        display: none;
    }
    
    // .footer-btn .btn-submit {
    //     height: 88rpx;
    //     line-height: 88rpx;
    //     font-size: 30rpx;
    //     border: 1rpx solid #ff5704;
    //     border-radius: 88rpx;
    // }
    
    .supplier-box {
        padding: 20rpx;
        .supplier-item {
            padding: 15rpx 0;
            font-size: 28rpx;
            height: 38rpx;
            .select-box {
                .iconfont {
                    font-size: 42rpx;
                }
                .round {
                    width: 30rpx;
                    height: 30rpx;
                    border: 4rpx solid #999999;
                    border-radius: 30rpx;
                }
            }
        }
    }
    
    .popup-search {
        .search-box {
            background: #f5f5f5;
            padding: 10rpx 20rpx;
            width: 500rpx;
            border-radius: 60rpx;
        }
        
        .icon-guanbi {
            position: absolute;
            right: 30rpx;
            top: 15rpx;
            color: #666666;
        }
    }
    
</style>