王飞
2025-01-23 99365608dec6eade7d645a91fb0f2205a332d1f1
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
var req_url = getApp().globalData.base_url;
const app = getApp()
Page({
    data: {
        buttonColor: 0,
        //   list: [],   //会员列表
        total: 0,    //分页总数
        page: 1,    //分页记录数
        pagesize: 10,   //分页大小
        isLoading: false,
        onRefresh: true,
        value: '',
        info1:'',
        info: '',
        count: '',
        showEmpty: true,
        zyp: [
        ],
    },
 
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function (options) {
        this.getList();
    },
    onShow() {
        this.setData({
            showEmpty: true,
            zyp: [
            ],
        })
        this.getList();
    },
    /**
   * 请求后台获取数据
   */
    getList: function () {
        wx.showLoading({
            title: '加载中',//加载转圈显示
        });
        var that = this;
        var onRefresh = that.data.onRefresh;//false为重新刷新数据,true为分页累加数据
        //请求后台数据
        wx.request({
            url: req_url + "/findtHandel",
            data: {
                phone:wx.getStorageSync('phone'),
                ishandle: that.data.buttonColor,
                username: wx.getStorageSync('username'),
                'page': that.data.page,
                'limit': that.data.pagesize,
            },
            method: 'get',
            success: function (res) {
                console.log(res);
                var datas = res.data.data;
                if (res.statusCode != 200) {
                    wx.showToast({
                        title: '获取数据失败',
                        icon: 'none',
                        duration: 2000
                    });
                } else {
                    var zypd = []
                    if (datas != null && datas.length > 0) {
                        console.log(onRefresh);
                        if (!onRefresh) {//false为重新刷新数据,true为分页累加数据
                            // var zypd = []
                            datas.forEach(function (item, index) {
                                var json = {}
                                json.type = item.zyptype ,
                                json.phone = item.phone,
                                    json.name = item.handelname,
                                    json.number = item.zypcode,
                                    json.time = item.applicationtime,
                                    json.handle = item.ishandle,
                                    json.local = item.local,
                                    json.bumen = item.bumen,
                                    json.opinion = item.opinion,
                                    json.safetymeasure = item.safetymeasure,
                                    json.issafetymeasure = item.issafetymeasure,
                                    
                                    zypd.push(json)
                            });
                            if (that.data.buttonColor == 0) {
                                that.setData({
                                    // onRefresh: true, 
                                    showEmpty: false,
                                    count: res.data.data.length,
                                    info: res.data.data.length,
                                    zyp: that.data.zyp.concat(zypd),
                                    page: that.data.page + 1
                                })
                            } else {
                                that.setData({
                                    // onRefresh: true, 
                                    showEmpty: false,
                                    info: res.data.data.length,
                                    count: res.data.data.length,
                                    zyp: that.data.zyp.concat(zypd),
                                    page: that.data.page + 1
                                })
                            }
                        } else {
 
                            datas.forEach(function (item, index) {
                                var json = {}
                                json.type = item.zyptype ,
                                json.phone = item.phone,
                                    json.name = item.handelname,
                                    json.number = item.zypcode,
                                    json.time = item.applicationtime,
                                    json.handle = item.ishandle,
                                    json.local = item.local,
                                    json.bumen = item.bumen,
                                    json.opinion = item.opinion,
                                    json.safetymeasure = item.safetymeasure,
                                    json.issafetymeasure = item.issafetymeasure,
                                    zypd.push(json)
                            });
                            if (that.data.buttonColor == 0) {
                                that.setData({
                                    showEmpty: false,
                                    count: res.data.data.length,
                                    info: res.data.data.length,
                                    zyp: zypd, //重新覆盖list,
                                    page: that.data.page + 1
                                })
                            } else {
                                that.setData({
                                    showEmpty: false,
                                    info: res.data.data.length,
                                    count: res.data.data.length,
                                    zyp: zypd, //重新覆盖list,
                                    page: that.data.page + 1
                                })
                            }
 
                        }
 
                    } else {
                        wx.showToast({
                            title: '没有更多数据了',
                            icon: 'none'
                        })
 
                        if (res.data.data.length == 0) {
 
                            that.setData({
                                showEmpty: true,
                                info:undefined,
                                // showEmpty:false,
                                zyp: zypd, //重新覆盖list,
                                isloading: true
                            })
                        }
                        that.setData({
 
                            isloading: true
                        })
 
                    }
                }
            },
            complete: function (res) {
                wx.hideLoading();
            },
            fail: function (res) {
            }
        })
    },
    bindDownLoad: function () {
        wx.showLoading({
            title: '加载中',//加载转圈显示
        });
        setTimeout(() => {
 
            this.setData({
                buttonColor: 0,
                page: 1,
                pagesize: 10,
                onRefresh: true, //重新加载数据
                isLoading: false
            })
 
            this.getList();
            wx.showNavigationBarLoading()
            wx.hideNavigationBarLoading()
        }, 1000)
    },
    onScrollToLower: function () {
        // console.log(11111111111);
        // console.log(this.data.count);
        // if (this.data.count > 10) {
        //     wx.showLoading({
        //         title: '加载中',//加载转圈显示
        //     });
        //     var that = this;
        //     that.setData({
        //         onRefresh: false //累加数据
        //     });
        //     this.getList();
        // }
    },
    daishen: function () {
        this.setData({
            page: 1,
            buttonColor: 0,
            onRefresh: true //重新加载数据
        })
        this.getList();
    },
    yishen: function () {
        this.setData({
            page: 1,
            buttonColor: 1,
            onRefresh: true //重新加载数据
        })
        this.getList();
    },
    bindViewTap: function (e) {
        // json.issafetymeasure = item.issafetymeasure,
        console.log(this.data.zyp);
        console.log(this.data.zyp[e.currentTarget.dataset.index].issafetymeasure);
        if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="动火作业") {
            console.log(111111);
            wx.navigateTo({
                url: '../fireSafetymeasure/fireSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else  if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="受限空间") {
            wx.navigateTo({
                url: '../SpanceSafetymeasure/SpanceSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="高处安全") {
            wx.navigateTo({
                url: '../AltitudeSafetymeasure/AltitudeSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="吊装安全") {
            wx.navigateTo({
                url: '../LiftingSafetymeasure/LiftingSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="临时用电安全") {
            wx.navigateTo({
                url: '../ElectricitySafetymeasure/ElectricitySafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="动土安全") {
            wx.navigateTo({
                url: '../GroundSafetymeasure/GroundSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="断路安全作业") {
            wx.navigateTo({
                url: '../CircuitSafetymeasure/CircuitSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else if (this.data.zyp[e.currentTarget.dataset.index].issafetymeasure=="盲板抽堵安全") {
            wx.navigateTo({
                url: '../BilndSafetymeasure/BilndSafetymeasure?safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure+'&zypcode=' +  this.data.zyp[e.currentTarget.dataset.index].number+'&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen+'&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion
            })
        }else{
            console.log(e);
            console.log(this.data.zyp[e.currentTarget.dataset.index].opinion);
            wx.navigateTo({
                url: '../handle/handle?zypcode=' + this.data.zyp[e.currentTarget.dataset.index].number + '&zyptepe=' + this.data.zyp[e.currentTarget.dataset.index].type + '&bumen=' + this.data.zyp[e.currentTarget.dataset.index].bumen + '&opinion=' + this.data.zyp[e.currentTarget.dataset.index].opinion+ '&safetymeasure=' + this.data.zyp[e.currentTarget.dataset.index].safetymeasure
            })
        }
      
    },
    onClick() {
        var that = this;
        if (that.data.value === '') {
            that.setData({
                total: 0,    //分页总数
                page: 1,    //分页记录数
                pagesize: 10,
                onRefresh: true
            })
            this.getList()
        } else {
            var onRefresh = that.data.onRefresh;//false为重新刷新数据,true为分页累加数据
 
            wx.request({
                url: req_url + "/findHandelSearch",
                data: {
                    phone:wx.getStorageSync('phone'),
                    ishandle: that.data.buttonColor,
                    username: wx.getStorageSync('username'),
                    code: that.data.value,
                    'page': 1,
                    'limit': that.data.pagesize,
                },
                verify: false,
                loading: true,
                title: '请稍后...',
                success: (res) => {
 
                    var datas = res.data;
                    if (res.statusCode != 200) {
                        wx.showToast({
                            title: '搜索失败',
                            icon: 'none',
                            duration: 2000
                        });
                    } else {
                        var zypd = []
                        if (datas != null && datas.length > 0) {
                            if (!onRefresh) {//false为重新刷新数据,true为分页累加数据
                                datas.forEach(function (item, index) {
                                    var json = {}
                                    json.type = item.zyptype,
 
                                    json.phone = item.phone,
                                        json.name = item.handelname,
                                        json.number = item.zypcode,
                                        json.time = item.applicationtime,
                                        json.handle = item.ishandle,
                                        json.local = item.local,
                                        json.safetymeasure = item.safetymeasure,
                                        json.issafetymeasure = item.issafetymeasure,
                                        zypd.push(json)
                                });
                                if (that.data.buttonColor == 0) {
                                    that.setData({
                                        showEmpty: false,
                                        count: res.data.data.length,
                                        info: res.data.data.length,
                                        zyp: that.data.zyp.concat(zypd),
                                        page: that.data.page + 1
                                    })
                                } else {
                                    that.setData({
                                        showEmpty: false,
                                        info: res.data.data.length,
                                        count: res.data.data.length,
                                        // zyp: zypd,
                                        zyp: that.data.zyp.concat(zypd),
                                        page: that.data.page + 1
                                    })
                                }
                            } else {
                                datas.forEach(function (item, index) {
                                    var json = {}
                                    json.type = item.zyptype,
                                    json.phone = item.phone,
                                        json.name = item.handelname,
                                        json.number = item.zypcode,
                                        json.time = item.applicationtime,
                                        json.handle = item.ishandle,
                                        json.local = item.local,
                                        json.safetymeasure = item.safetymeasure,
                                        json.issafetymeasure = item.issafetymeasure,
                                        zypd.push(json)
                                });
 
                                if (that.data.buttonColor == 0) {
                                    that.setData({
                                        showEmpty: false,
                                        count: res.data.data.length,
                                        info: res.data.data.length,
                                        zyp: zypd, //重新覆盖list,
                                        page: that.data.page + 1
                                    })
                                } else {
                                    that.setData({
                                        showEmpty: false,
                                        info: res.data.data.length,
                                        count: res.data.data.length,
                                        zyp: zypd, //重新覆盖list,
                                        page: that.data.page + 1
                                    })
                                }
                            }
                        } else {
                            wx.showToast({
                                title: '没有更多数据了',
                                icon: 'none'
                            })
                            if (res.data.data.length == 0) {
                                that.setData({
                                    showEmpty: true,
                                    zyp: zypd, //重新覆盖list,
                                    isloading: true
                                })
                            }
                            that.setData({
                                isloading: true
                            })
                        }
                    }
                }
            })
        }
    },
    onChange(e) {
        this.setData({
            value: e.detail,
        });
    },
    itemPdfOn(e) {
        console.log(e);
        wx.showLoading({
            title: '加载中',
        })
        wx.redirectTo({
            url: `/pages/details/details?num=` + e.currentTarget.dataset.num + `&type=` + e.currentTarget.dataset.type + `&local=` + e.currentTarget.dataset.local + `&phone=` + e.currentTarget.dataset.phone+ `&name=` + e.currentTarget.dataset.name
        })
        // if (e.currentTarget.dataset.type == "受限空间作业") {
        //     wx.redirectTo({
        //         url: `/pages/Zypspace/Zypspace?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle + `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "动火作业") {
        //     wx.redirectTo({
        //         url: `/pages/Zypfire/Zypfire?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "吊装安全作业") {
        //     wx.redirectTo({
        //         url: `/pages/Zyplifting/Zyplifting?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "动土安全作业") {
        //     wx.redirectTo({
        //         url: `/pages/ZypGround/ZypGround?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "高处安全作业") {
        //     wx.redirectTo({
        //         url: `/pages/ZypAltitude/ZypAltitude?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "断路安全作业") {
        //     wx.redirectTo({
        //         url: `/pages/ZypCircuit/ZypCircuit?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "临时用电作业") {
        //     wx.redirectTo({
        //         url: `/pages/ZypElectricity/ZypElectricity?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // } else if (e.currentTarget.dataset.type == "盲板抽堵作业") {
        //     wx.redirectTo({
        //         url: `/pages/ZypBlind/ZypBlind?num=` + e.currentTarget.dataset.num + `&handle=` + e.currentTarget.dataset.handle+ `&bumen=` + e.currentTarget.dataset.bumen
        //     })
        // }
 
 
 
    },
    onSearch() {
        var that = this;
        if (that.data.value === '') {
            that.setData({
                total: 0,    //分页总数
                page: 1,    //分页记录数
                pagesize: 10,
                onRefresh: true
            })
            this.getList()
        } else {
            var onRefresh = that.data.onRefresh;//false为重新刷新数据,true为分页累加数据
 
            wx.request({
                url: req_url + "/findHandelSearch",
                data: {
                    phone:wx.getStorageSync('phone'),
                    ishandle: that.data.buttonColor,
                    username: wx.getStorageSync('username'),
                    code: that.data.value,
                    'page': 1,
                    'limit': that.data.pagesize,
                },
                verify: false,
                loading: true,
                title: '请稍后...',
                success: (res) => {
 
                    var datas = res.data;
                    if (res.statusCode != 200) {
                        wx.showToast({
                            title: '搜索失败',
                            icon: 'none',
                            duration: 2000
                        });
                    } else {
                        var zypd = []
                        if (datas != null && datas.length > 0) {
                            if (!onRefresh) {//false为重新刷新数据,true为分页累加数据
                                datas.forEach(function (item, index) {
                                    var json = {}
                                    json.type = item.zyptype ,
                                    json.phone = item.phone,
                                        json.name = item.handelname,
                                        json.number = item.zypcode,
                                        json.time = item.applicationtime,
                                        json.handle = item.ishandle,
                                        json.safetymeasure = item.safetymeasure,
                                        json.issafetymeasure = item.issafetymeasure,
                                        json.local = item.local,
                                        zypd.push(json)
                                });
                                if (that.data.buttonColor == 0) {
                                    that.setData({
                                        showEmpty: false,
                                        count: res.data.data.length,
                                        info: res.data.data.length,
                                        zyp: that.data.zyp.concat(zypd),
                                        page: that.data.page + 1
                                    })
                                } else {
                                    that.setData({
                                        showEmpty: false,
                                        info: res.data.data.length,
                                        count: res.data.data.length,
                                        // zyp: zypd,
                                        zyp: that.data.zyp.concat(zypd),
                                        page: that.data.page + 1
                                    })
                                }
                            } else {
                                datas.forEach(function (item, index) {
                                    var json = {}
                                    json.type = item.zyptype,
                                    json.phone = item.phone,
                                        json.name = item.handelname,
                                        json.number = item.zypcode,
                                        json.time = item.applicationtime,
                                        json.handle = item.ishandle,
                                        json.safetymeasure = item.safetymeasure,
                                        json.issafetymeasure = item.issafetymeasure,
                                        json.local = item.local,
                                        zypd.push(json)
                                });
 
                                if (that.data.buttonColor == 0) {
                                    that.setData({
                                        showEmpty: false,
                                        count: res.data.data.length,
                                        info: res.data.data.length,
                                        zyp: zypd, //重新覆盖list,
                                        page: that.data.page + 1
                                    })
                                } else {
                                    that.setData({
                                        showEmpty: false,
                                        info: res.data.data.length,
                                        count: res.data.data.length,
                                        zyp: zypd, //重新覆盖list,
                                        page: that.data.page + 1
                                    })
                                }
                            }
                        } else {
                            wx.showToast({
                                title: '没有更多数据了',
                                icon: 'none'
                            })
                            if (res.data.data.length == 0) {
                                that.setData({
                                    showEmpty: true,
                                    zyp: zypd, //重新覆盖list,
                                    isloading: true
                                })
                            }
                            that.setData({
                                isloading: true
                            })
                        }
                    }
                }
            })
        }
    },
    methods: {
 
    },
})