quanwei
2025-10-28 36cacbaf78e510713002fcd5e3d61cece2e01421
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<template>
    <view class="branch-container" :data-theme='theme()' :class="theme() || ''">
        <view class="top-box">
            <view class="index-search-box index-search-box_re d-b-c" id="searchBox">
                <view class="index-search index-search_re t-c flex-1">
                    <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="top-add d-s-c" @click="gotoPage('pages/branch/admin/branch/add')">
                    <text class="iconfont icon-ziyuan2 f24 mr10"></text>
                    <text class="f24">添加</text>
                </view>
            </view>
        </view>
        <!--内容-->
        <view class="branch-box" v-if="!loading">
            <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50" @scrolltolower="scrolltolowerFunc">
                <view :class="topRefresh ? 'top-refresh open' : 'top-refresh'">
                    <view class="circle" v-for="(circle, n) in 3" :key="n"></view>
                </view>
                <view class="list-box p-0-20">
                    <view class="item bg-white radius24 mt20" v-for="(item,index) in listData" :key="index">
                        <view class="item-info-box">
                            <view class="item-info ww100">
                                <view class="d-b-c">
                                    <view class="gray3 f30 fb text-ellipsis-2">{{item.name}}</view>
                                    <view class="gray6">ID:{{item.branch_id}}</view>
                                </view>
                                <view class="gray6 f26 pt20">所在区域:{{item.region.province}}{{item.region.city}}{{item.region.region}}</view>
                                <view class="gray6 f26 pt20">联系人:{{item.link_name}}</view>
                            </view>
                        </view>
                        <view class="item-operation d-e-c pt30">
                            <!-- <view class="item-btn" @click="onQRCode(item.branch_id)">二维码</view> -->
                            <view class="item-btn" @click="callPhone(item.link_phone)">打电话</view>
                            <view class="item-btn" @click="onEdit(item.branch_id)">编辑</view>
                            <view class="item-btn" @click="onDelete(item.branch_id)">删除</view>
                        </view>
                    </view>
                </view>
                <!--列表-->
                <!-- 没有记录 -->
                <view class="none-data-box" v-if="listData.length==0 && !loading">
                    <image :src="remoteImg('no_thing')" mode="widthFix"></image>
                    <text>暂无数据</text>
                </view>
                <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
            </scroll-view>
        </view>
        <!--二维码-->
        <Popup :show="isCodeImg" type="middle" @hidePopup="hideCodePopupFunc">
            <view class="ww100 p20 box-s-b">
                <image class="ww100" :src="codeImg" mode="widthFix"></image>
            </view>
            <view class="ww100">
                <button class="btn-red mt20" type="default" @click="saveCodeImg">保存图片</button>
            </view>
        </Popup>
    </view>
</template>
 
<script>
    import Popup from '@/components/uni-popup.vue';
    import uniLoadMore from '@/components/uni-load-more.vue';
    export default {
        components: {
            Popup,
            uniLoadMore
        },
        data() {
            return {
                /*手机高度*/
                phoneHeight: 0,
                /*可滚动视图区域高度*/
                scrollviewHigh: 0,
                /*商品列表*/
                listData: [],
                /*最后一页码数*/
                last_page: 0,
                /*当前页面*/
                page: 1,
                /*每页条数*/
                list_rows: 10,
                /*有没有更多*/
                no_more: false,
                /*是否正在加载*/
                loading: true,
                /*顶部刷新*/
                topRefresh: false,
                keyword: '', // 搜索关键词
                /*是否显示二维码*/
                isCodeImg: false,
                codeImg: '',
            };
        },
        computed: {
            /*加载中状态*/
            loadingType() {
                if (this.loading) {
                    return 1;
                } else {
                    if (this.listData.length != 0 && this.no_more) {
                        return 2;
                    } else {
                        return 0;
                    }
                }
            }
        },
        onLoad(e) {},
        onShow() {
            /*获取列表*/
            this.getlist();
        },
        mounted() {
            this.init();
 
        },
        onReachBottom() {},
        methods: {
            searchFunc() {
                this.listData = [];
                this.page = 1;
                /*获取列表*/
                this.getlist();
            },
            /*初始化*/
            init() {
                let _this = this;
                uni.getSystemInfo({
                    success(res) {
                        _this.phoneHeight = res.windowHeight;
                        // 计算组件的高度
                        let view = uni.createSelectorQuery().select('.top-box');
                        view.boundingClientRect(data => {
                            let h = _this.phoneHeight - data.height;
                            _this.scrollviewHigh = h;
                        }).exec();
                    }
                });
            },
 
            /*获取活动列表*/
            getlist() {
                let self = this;
                uni.showLoading({
                    title: '加载中'
                });
                let params = {
                    keyword: self.keyword,
                    list_rows: self.list_rows,
                    page: self.page
                };
                self.loading = true;
                self._get(
                    'branch.admin.branch/index', params, function(res) {
                        self.listData = 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;
                        }
                        uni.hideLoading();
                        self.loading = false;
                    }
                );
            },
            
            onEdit(e) {
                this.gotoPage('pages/branch/admin/branch/edit?branch_id=' + e);
            },
            
            /*还原初始化*/
            restoreData() {
                this.listData = [];
                this.keyword = '';
            },
            
            callPhone(phone){
                uni.makePhoneCall({
                    phoneNumber: phone + ''
                });
            },
            
            /*可滚动视图区域到底触发*/
            scrolltolowerFunc() {
                let self = this;
                if (self.no_more) {
                    return;
                }
                self.page++;
                if (self.page <= self.last_page) {
                    self.getlist();
                } else {
                    self.no_more = true;
                }
            },
            
            /*删除分会*/
            onDelete(e) {
                let self = this;
                wx.showModal({
                    title: "提示",
                    content: "您确定要删除此分会吗?",
                    success: function(o) {
                        o.confirm && self._get('branch.admin.branch/delete', {
                            branch_id: e
                        }, function(result) {
                            if (result.code == 1) {
                                uni.showToast({
                                    title: '删除成功',
                                    duration: 2000
                                });
                                self.getlist();
                            }
            
                        });
                    }
                });
            
            },
            
            /*二维码*/
            onQRCode(e) {
                let self = this;
                uni.showLoading({
                    title: '加载中'
                });
                let branch_id = e;
                let source = self.getPlatform();
                self._get(
                    'branch.admin.branch/qrcode', {
                        branch_id: branch_id,
                        source: source
                    },
                    function(res) {
                        uni.hideLoading();
                        self.isCodeImg = true;
                        self.codeImg = res.data.qrcode;
                    }
                );
            },
            
            /*关闭二维码*/
            hideCodePopupFunc() {
                this.isCodeImg = false;
            },
            
            //保存二维码
            saveCodeImg() {
                let self = this;
                uni.showLoading({
                    title: '加载中'
                });
                // 下载海报图片
                uni.downloadFile({
                    url: self.codeImg,
                    success(res) {
                        uni.hideLoading();
                        // 图片保存到本地
                        uni.saveImageToPhotosAlbum({
                            filePath: res.tempFilePath,
                            success(data) {
                                uni.showToast({
                                    title: '保存成功',
                                    icon: 'success',
                                    duration: 2000
                                });
                                // 关闭核销码窗口
                                self.isCodeImg = false;
                            },
                            fail(err) {
                                if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
                                    uni.showToast({
                                        title: '请允许访问相册后重试',
                                        icon: 'none',
                                        duration: 1000
                                    });
                                    setTimeout(() => {
                                        uni.openSetting();
                                    }, 1000);
                                }
                            },
                            complete(res) {
                                console.log('complete');
                            }
                        });
                    }
                });
            },
 
        }
    };
</script>
 
<style lang="scss" scoped>
    page {
        background: #f5f5f5;
    }
    .top-box {
        .inner-tab {
            position: relative;
            height: 70rpx;
            display: flex;
            justify-content: space-around;
            align-items: center;
            background: #ffffff;
            z-index: 9;
            .item {
                flex: 1;
                height: 100%;
                line-height: 70rpx;
                position: relative;
                color: #999;
                font-size: 28rpx;
                &.active {
                    color: #333333;
                    font-weight: bold;
                    &::after {
                        content: '';
                        width: 72rpx;
                        height: 4rpx;
                        background: #EE1414;
                        border-radius: 2rpx;
                        position: absolute;
                        bottom: 14rpx;
                        left: 0;
                        right: 0;
                        margin: auto;
                    }
                }
                .box {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    flex-direction: row;
                }
            }
        }
        .top-add {
            @include background_color('background_color');
            height: 60rpx;
            border-radius: 80rpx;
            color: #ffffff;
            padding: 0 20rpx;
            margin-left: 30rpx;
            
            .iconfont {
                color: #ffffff;
            }
        }
    }
    .branch-box {
        
        .list-box {
            
            .item{
                padding: 20rpx;
                
                .item-info-box {
                    display: flex;
                    
                    image {
                        width: 230rpx;
                        height: 120rpx;
                        border-radius: 12rpx;
                        background-color: rgba(0, 0, 0, 0.1);
                    }
                    
                    .item-info {
                        
                    }
                }
                
                .item-operation {
                    
                    .item-btn {
                        font-size: 24rpx;
                        color: #333333;
                        border: 1rpx solid #cccccc;
                        border-radius: 60rpx;
                        padding: 14rpx 20rpx;
                        margin-left: 12rpx;
                    }
                }
            }
        }
    }
    
 
    
</style>