单军华
2018-03-28 f99cf1d5cc50407394501853be06cb39f38a092c
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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
//
//  UserSignPage.m
//  istanbul
//
//  Created by WindShan on 2017/6/13.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "UserSignPage.h"
#import "GloriaLabel.h"
#import "MyAnimatedAnnotationView.h"
#import "BaseNaviController.h"
#import "HotelSelPage.h"
#import "NetworkSingleton.h"
#import "SignInfo.h"
 
@interface UserSignPage ()<BMKMapViewDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
{
 
    
    CLLocationDegrees locateLatitude;
    CLLocationDegrees locateLongitude;
    
    BMKPointAnnotation* pointAnnotation;
    BMKPointAnnotation* animatedAnnotation;
    NSString * currentAdress;
    NSString * currentzhengmingName;
    NSString * currentzhengmingTel;
    
    UITextField * zhengmingNameTF;
    UITextField * zhengmingTelTF;
    GloriaLabel* addressLabel;
    
    GloriaLabel* signInTime;
    GloriaLabel* signOutTime;
    GloriaLabel* signInDistrib;
    GloriaLabel* signOutDistrib;
    
    UIButton * sign_in_btn;
    UIButton * sign_out_btn;
    
}
 
@property (nonatomic, strong) UITableView                   * tableView;
@end
 
@implementation UserSignPage
 
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}
 
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSInteger textLength = 0;
    
    if ([string isEqualToString:@""]) {
        textLength = textField.text.length-1;
    }
    else
    {
        textLength = textField.text.length+1;
    }
    
    BOOL flag = NO;
    if( textField == zhengmingTelTF )
    {
        // 检测手机号是否合法
        if( textLength == 11 && [StringUtil isMobile:[zhengmingTelTF.text stringByAppendingString:string]] == NO)
        {
            [Global alertMessage:@"手机号码不合法,请重新输入!"];
        }
        
        // 大于11位数不让输入
        if( textLength > 11 )
            return NO;
    }
    
    flag = YES;
    if (flag)
    {
        //        [loginBtn setBackgroundColor:BLUECOLOR];
        //        loginBtn.userInteractionEnabled = YES;
    }
    else
    {
        //        loginBtn.backgroundColor = [UIColor lightGrayColor];
        //        loginBtn.userInteractionEnabled = NO;
    }
    
    return flag;
}
 
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if ([textField isFirstResponder]) {
        [textField resignFirstResponder];
    }
    return YES;
}
 
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self textFieldShouldReturn:zhengmingNameTF];
    [self textFieldShouldReturn:zhengmingTelTF];
}
 
 
- (UITableView *)tableView
{
    if (!_tableView)
    {
        _tableView = [[UITableView alloc] init];
        
        
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.backgroundColor = [UIColor clearColor];
        //_tableView.userInteractionEnabled = NO;
        
        [self.view addSubview:_tableView];
        
        [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsMake(0 , 0, 0, 0));
        }];
        
        _tableView.tableFooterView = [UIView new];
    }
    return _tableView;
}
#pragma mark - UITableViewDelegate&UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
 
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
//    return 0;
//}
//
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
 
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
 
 
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if( indexPath.row < 4)
        return 35;
    else
        return 200;
}
 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSString * identifier = @"signCell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (nil == cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        
    }
    
    //cell.delegate = self;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.userInteractionEnabled = YES;
    CGFloat xxx;
    switch (indexPath.row) {
        case 0:
        {
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
            cell.image = [UIImage imageNamed:@"icon_green_call"];
            cell.text  = _curHotel_Id != nil?_curHotel_Id.name:@"选择酒店";
            cell.textColor = kUIColorFromRGB(0x00b744);
            xxx = cell.imageView.frame.origin.x;
        }
            break;
        case 1:
        {
            cell.image = [UIImage imageNamed:@"sign_address_tag"];
            //cell.text  = currentAdress;
            if(addressLabel==nil)
            {
               addressLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(38+10, 0, SCREEN_WIDTH-cell.textLabel.frame.origin.x, 40)];
                addressLabel.font = FONT14;
                addressLabel.textAlignment = NSTextAlignmentLeft;
                addressLabel.userInteractionEnabled = NO;
                addressLabel.textColor = kUIColorFromRGB(0x00b744);
                [cell.contentView addSubview:addressLabel];
            }
            
            addressLabel.text = currentAdress;
        }
            break;
        case 2:
        {
            cell.image = [UIImage imageNamed:@"sign_prove_tag"];
            if(zhengmingNameTF==nil)
            {
                zhengmingNameTF = [[UITextField alloc] initWithFrame:CGRectMake(38, 0, SCREEN_WIDTH-cell.textLabel.frame.origin.x, 40)];
                zhengmingNameTF.font = [UIFont fontWithName:@"Arial" size:16];
                zhengmingNameTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入证明人"attributes:@{ NSForegroundColorAttributeName:kUIColorFromRGB(0x6e6e6e)}];
                zhengmingNameTF.delegate = self;
                [zhengmingNameTF setValue:kUIColorFromRGB(0x00b744) forKeyPath:@"_placeholderLabel.textColor"];
                //userPhoneTextField.layer.borderColor = [RgbColor(213, 213, 213) CGColor];
                zhengmingNameTF.textColor = kUIColorFromRGB(0x00b744);
                //zhengmingNameTF.keyboardType = UIKeyboardTypeNumberPad;
                zhengmingNameTF.textAlignment = NSTextAlignmentLeft;
                zhengmingNameTF.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                // 设置一个空白blankView,15.0就是这块View的宽度width,也是光标的位置,根据你自己的需要设定大小
                UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(zhengmingNameTF.frame.origin.x,zhengmingNameTF.frame.origin.y,10.0, zhengmingNameTF.frame.size.height)];
                zhengmingNameTF.leftView = blankView;
                zhengmingNameTF.leftViewMode =UITextFieldViewModeAlways;
                zhengmingNameTF.userInteractionEnabled = YES;
                //zhengmingNameTF.returnKeyType = UIReturnKeyDone;//改变为完成键
                [cell.contentView addSubview:zhengmingNameTF];
            }
 
            if(![currentzhengmingName isEqualToString:@""])
            {
                zhengmingNameTF.text = currentzhengmingName;
            }
        }
            break;
        case 3:
        {
            cell.image = [UIImage imageNamed:@"icon_green_call"];
            if(zhengmingTelTF==nil)
            {
                zhengmingTelTF = [[UITextField alloc] initWithFrame:CGRectMake(38, 0, SCREEN_WIDTH-cell.textLabel.frame.origin.x, 40)];
                zhengmingTelTF.font = [UIFont fontWithName:@"Arial" size:16];
                zhengmingTelTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入证明人手机号"attributes:@{ NSForegroundColorAttributeName:kUIColorFromRGB(0x6e6e6e)}];
                zhengmingTelTF.delegate = self;
                [zhengmingTelTF setValue:kUIColorFromRGB(0x00b744) forKeyPath:@"_placeholderLabel.textColor"];
                //zhengmingTelTF.layer.borderColor = [RgbColor(213, 213, 213) CGColor];
                zhengmingTelTF.textColor = kUIColorFromRGB(0x00b744);
                zhengmingTelTF.keyboardType = UIKeyboardTypeNumberPad;
                zhengmingTelTF.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                // 设置一个空白blankView,15.0就是这块View的宽度width,也是光标的位置,根据你自己的需要设定大小
                UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(zhengmingTelTF.frame.origin.x,zhengmingTelTF.frame.origin.y,10.0, zhengmingTelTF.frame.size.height)];
                zhengmingTelTF.leftView = blankView;
                zhengmingTelTF.leftViewMode =UITextFieldViewModeAlways;
                zhengmingTelTF.textAlignment = NSTextAlignmentLeft;
                //zhengmingTelTF.returnKeyType = UIReturnKeyDone;//改变为完成键
                [cell.contentView addSubview:zhengmingTelTF];
            }
            
            if(![currentzhengmingTel isEqualToString:@""])
            {
                zhengmingTelTF.text = currentzhengmingTel;
            }
        }
            break;
        default:
            break;
    }
 
    cell.backgroundColor = [UIColor clearColor];
    cell.alpha = 0.5;
    if( indexPath.row != 4)
    {
        UIView * _pline = [[UIView alloc] initWithFrame:CGRectMake(0, 35, SCREEN_WIDTH, 1)];
        _pline.backgroundColor = [UIColor grayColor];
        [cell.contentView addSubview:_pline];
    }
    
    return cell;
}
 
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    [self.view endEditing:YES];
    
    if(indexPath.row == 0)
    {
        // 跳转选择酒店
        HotelSelPage* page = [[HotelSelPage alloc] initIsFirstPage:NO];
        
        page.bSelRoom = 0;
        // 跳转界面
        BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:page];
        [self presentViewController:baseNav animated:YES completion:nil];
        
    }
}
 
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [_mapView viewWillAppear];
    _mapView.delegate = self;
    _locService.delegate = self;
    _geocodesearch.delegate = self;
    
    if(_curHotel_Id != nil)
    {
        [self getusersign];
    }
}
 
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewDidDisappear:YES];
    
    [_mapView viewWillDisappear];
    _mapView.delegate = nil; // 不用时,置nil
    _locService.delegate = nil;
    _geocodesearch.delegate = nil;
}
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"签到打卡";
    [self setNavigationLeft:@"返回" sel:@selector(backAction)];
    [self setNavigationRight:@"刷新" sel:@selector(startLocation)];
    
    //适配ios7
    if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0))
    {
        self.navigationController.navigationBar.translucent = NO;
    }
    
    
    [self initMap];
    [self startLocation];
    currentzhengmingName = @"";
    currentAdress = @"";
    currentzhengmingTel = @"";
    self.tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 140);
    
    CGFloat _bottomBkH = 230;
    CGFloat _offW = 0;
     CGFloat _offH = 0;
    if(IsiPhone4 || IsiPhone5)
    {
        _bottomBkH = 200;
        _offW = 20;
        _offH = 15;
    }
    
    UIImageView * _bottomBk = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-_bottomBkH, SCREEN_WIDTH, _bottomBkH)];
    _bottomBk.image = [UIImage imageNamed:@"sign_user_btn_bk"];
    _bottomBk.userInteractionEnabled = YES;
    [self.view addSubview:_bottomBk];
    
    // 签到
    UIImageView * sign_daka_bk1 = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH/2-140+_offW)/2, (_bottomBkH-120)/3, 140-_offW, 120)];
    sign_daka_bk1.image = [UIImage imageNamed:@"sign_daka_bk"];
    sign_daka_bk1.userInteractionEnabled = YES;
    [_bottomBk addSubview:sign_daka_bk1];
    
    UIImageView * sign_no_in_bk = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH/2-140+_offW)/2, -20, 94-_offW, 94-_offW)];
    sign_no_in_bk.image = [UIImage imageNamed:@"sign_no_in_bk"];
    [sign_daka_bk1 addSubview:sign_no_in_bk];
    
    signInTime = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 40-_offH, 94-_offW, 40)];
    signInTime.font = [UIFont boldSystemFontOfSize:14];
    signInTime.textAlignment = NSTextAlignmentCenter;
    signInTime.textColor = [UIColor whiteColor];
    signInTime.text = @"08:30";
    [sign_no_in_bk addSubview:signInTime];
    
    signInDistrib = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 60-_offH, 140-_offW, 40)];
    signInDistrib.font = FONT14;
    signInDistrib.textAlignment = NSTextAlignmentCenter;
    signInDistrib.textColor = kUIColorFromRGB(0x6e6e6e);
    signInDistrib.text = @"首次签到";
    [sign_daka_bk1 addSubview:signInDistrib];
    
    sign_in_btn = [UIButton buttonWithType:UIButtonTypeCustom];
    sign_in_btn.frame = CGRectMake((140-100-_offW)/2, 90-_offH, 100, 21);
    [sign_in_btn setBackgroundImage:[UIImage imageNamed:@"sign_no_btn_bk" ] forState:UIControlStateNormal];
    [sign_in_btn setTitle:@"点击此处打卡" forState:UIControlStateNormal];
    sign_in_btn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    [sign_in_btn setTitleColor:kUIColorFromRGB(0x00b744) forState:UIControlStateNormal];
    [sign_in_btn addTarget:self action:@selector(usersign_in_action) forControlEvents:UIControlEventTouchUpInside];
    [sign_daka_bk1 addSubview:sign_in_btn];
    
    // 签离
    UIImageView * sign_daka_bk2 = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2+(SCREEN_WIDTH/2-140+_offW)/2, (_bottomBkH-120)/3, 140-_offW, 120)];
    sign_daka_bk2.image = [UIImage imageNamed:@"sign_daka_bk"];
    sign_daka_bk2.userInteractionEnabled = YES;
    [_bottomBk addSubview:sign_daka_bk2];
    
    UIImageView * sign_out_bk = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH/2-140+_offW)/2, -20, 94-_offW, 94-_offW)];
    sign_out_bk.image = [UIImage imageNamed:@"sign_out_bk"];
    
    [sign_daka_bk2 addSubview:sign_out_bk];
    
    signOutTime = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 40-_offH, 94-_offW, 40)];
    signOutTime.font = [UIFont boldSystemFontOfSize:14];
    signOutTime.textAlignment = NSTextAlignmentCenter;
    signOutTime.textColor = [UIColor whiteColor];
    signOutTime.text = @"17:30";
    [sign_out_bk addSubview:signOutTime];
    
    signOutDistrib = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 60-_offH, 140-_offW, 40)];
    signOutDistrib.font = FONT14;
    signOutDistrib.textAlignment = NSTextAlignmentCenter;
    signOutDistrib.textColor = kUIColorFromRGB(0x6e6e6e);
    signOutDistrib.text = @"已签退";
    [sign_daka_bk2 addSubview:signOutDistrib];
    
    sign_out_btn = [UIButton buttonWithType:UIButtonTypeCustom];
    sign_out_btn.frame = CGRectMake((140-100-_offW)/2, 90-_offH, 100, 21);
    [sign_out_btn setBackgroundImage:[UIImage imageNamed:@"sign_in_btn_bk" ] forState:UIControlStateNormal];
    [sign_out_btn setTitle:@"已签退" forState:UIControlStateNormal];
    sign_out_btn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    [sign_out_btn setTitleColor:kUIColorFromRGB(0xff8b00) forState:UIControlStateNormal];
    [sign_out_btn addTarget:self action:@selector(usersign_out_action) forControlEvents:UIControlEventTouchUpInside];
    [sign_daka_bk2 addSubview:sign_out_btn];
    
    signInDistrib.text = @"首次签到";
    [sign_in_btn setTitle:@"点击此处打卡" forState:UIControlStateNormal];
    signOutDistrib.text = @"离开签退";
    [sign_out_btn setTitle:@"点击此处签退" forState:UIControlStateNormal];
    
}
 
// 获取签到信息
-(void)getusersign
{
    //params.put("userID", MainApp.userId);
    //params.put("hotelID", hotelid);
    NSString *path = [[NSString alloc] initWithFormat:GET_SIGN_INFO];
    
    NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
    
    [param setObject:[UserDefault stringForKey:@"user_id"] forKey:@"userID"];
    [param setObject:_curHotel_Id._id forKey:@"hotelID"];
    
    MPWeakSelf(self);
    [NetworkSingleton networkingPostMethod:param urlName:path success:^(id responseBody)
     {
         MPStrongSelf(self);
         BaseResModel * resModel = [Global toBaseModel:responseBody];
         
         if(resModel.code == 0)
         {
             //发送成功提示
             if(![Global isEmptyObject:resModel.content])
             {
                 NSMutableArray *modelTempArray = [SignInfo mj_objectArrayWithKeyValuesArray:resModel.content];
                 
                 BASE_INFO_FUN(resModel.content);
                 
                 if(modelTempArray.count > 0)
                 {
                     for( int i = 0; i < modelTempArray.count; i++ )
                     {
                         SignInfo * model = [modelTempArray objectAtIndex:i];
                         if(model.type == 1)
                         {
                             [sign_in_btn setTitle:@"已签到" forState:UIControlStateNormal];
                         }
                         else if(model.type == 2)
                         {
                             [sign_out_btn setTitle:@"已签退" forState:UIControlStateNormal];
                         }
                     }
                 }
                 else
                 {
                     signInDistrib.text = @"首次签到";
                     [sign_in_btn setTitle:@"点击此处签到" forState:UIControlStateNormal];
                     signOutDistrib.text = @"离开签退";
                     [sign_out_btn setTitle:@"点击此处签退" forState:UIControlStateNormal];
                 }
                 
                 [self.tableView reloadData];
                 
                 //[_modelArray addObjectsFromArray:modelTempArray];
                 //hotelSelModel = [AdModel mj_objectWithKeyValues:resModel.content];
                 
             }
             else
             {
                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }
         }
         else
         {
             [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
         }
     }
                                  failure:^(NSString *error)
     {
         
         [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self];
     }];
 
}
 
-(void)usersign_in_action
{
    if(currentAdress == nil)
    {
        [Global alertMessageEx:@"定位失败,请刷新您的位置信息!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(zhengmingNameTF.text.length == 0)
    {
        [Global alertMessageEx:@"请填写证明人名字!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(zhengmingTelTF.text.length == 0)
    {
        [Global alertMessageEx:@"请填写证明人电话!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(_curHotel_Id == nil)
    {
        [Global alertMessageEx:@"请选择酒店!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else
    {
        NSString *path = [[NSString alloc] initWithFormat:SIGN_IN];
        NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
        
        [param setObject:[UserDefault stringForKey:@"user_id"] forKey:@"userID"];
        [param setObject:currentAdress forKey:@"address"];
        //lat 37.785834,long -122.406417 %.8f
        [param setObject:[NSString stringWithFormat:@"%.8f",locateLatitude] forKey:@"lat"];
        [param setObject:[NSString stringWithFormat:@"%.8f",locateLongitude] forKey:@"lng"];
        [param setObject:zhengmingNameTF.text forKey:@"cert_name"];
        [param setObject:zhengmingTelTF.text forKey:@"cert_tel"];
        [param setObject:_curHotel_Id._id forKey:@"hotelID"];
        
        MPWeakSelf(self);
        [NetworkSingleton networkingPostMethod:param urlName:path success:^(id responseBody)
         {
             MPStrongSelf(self);
             BaseResModel * resModel = [Global toBaseModel:responseBody];
             
             if(resModel.code == 0)
             {
                 //发送成功提示
                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }
             else
             {
                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }
         }
                                       failure:^(NSString *error)
         {
             
             [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self];
         }];
    }
 
}
 
-(void)usersign_out_action
{
    if(currentAdress == nil)
    {
        [Global alertMessageEx:@"定位失败,请刷新您的位置信息!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(zhengmingNameTF.text.length == 0)
    {
        [Global alertMessageEx:@"请填写证明人名字!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(zhengmingTelTF.text.length == 0)
    {
        [Global alertMessageEx:@"请填写证明人电话!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else if(_curHotel_Id == nil)
    {
        [Global alertMessageEx:@"请选择酒店!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else
    {
        NSString *path = [[NSString alloc] initWithFormat:SIGN_OUT];
        
        NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
        
        [param setObject:[UserDefault stringForKey:@"user_id"] forKey:@"userID"];
        [param setObject:currentAdress forKey:@"address"];
        //lat 37.785834,long -122.406417 %.8f
        [param setObject:[NSString stringWithFormat:@"%.8f",locateLatitude] forKey:@"lat"];
        [param setObject:[NSString stringWithFormat:@"%.8f",locateLongitude] forKey:@"lng"];
        [param setObject:zhengmingNameTF.text forKey:@"cert_name"];
        [param setObject:zhengmingTelTF.text forKey:@"cert_tel"];
        [param setObject:_curHotel_Id._id forKey:@"hotelID"];
        
        MPWeakSelf(self);
        [NetworkSingleton networkingPostMethod:param urlName:path success:^(id responseBody)
         {
             MPStrongSelf(self);
             BaseResModel * resModel = [Global toBaseModel:responseBody];
             
             if(resModel.code == 0)
             {
                 //发送成功提示
                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }
             else
             {
                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }
         }
                                       failure:^(NSString *error)
         {
             
             [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self];
         }];
    }
}
 
-(void) initMap
{
    //初始化地图
    _mapView = [[BMKMapView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    _mapView.showsUserLocation = YES;//显示定位图层
    _mapView.showMapScaleBar=YES;
    _mapView.zoomLevel=18.0;
    _mapView.mapType = BMKMapTypeStandard;
    [self.view addSubview:_mapView];
    
    //    BMKLocationViewDisplayParam *param = [[BMKLocationViewDisplayParam alloc] init];
    //    param.accuracyCircleStrokeColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.5];
    //    param.accuracyCircleFillColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.3];
    //    param.isAccuracyCircleShow =true;//精度圈是否显示
    //    [_mapView updateLocationViewWithParam:param];
    
    _locService = [[BMKLocationService alloc]init];
    _locService.desiredAccuracy = kCLLocationAccuracyBest;
    
    _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
    _locService.delegate = self;
    
    NSLog(@"进入普通定位态");
    [_locService startUserLocationService];
    _mapView.showsUserLocation = NO;//先关闭显示的定位图层
    _mapView.userTrackingMode = BMKUserTrackingModeFollow;//设置定位的状态
    _mapView.showsUserLocation = YES;//显示定位图层
    
    _geocodesearch = [[BMKGeoCodeSearch alloc] init];
    
    _geocodesearch.delegate = self;
}
 
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
-(void)backAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
 
-(void)startLocation
{
    currentzhengmingTel = zhengmingTelTF.text;
    currentzhengmingName = zhengmingNameTF.text;
    
    [_locService startUserLocationService];
    
    _mapView.showsUserLocation = NO;
    _mapView.userTrackingMode = BMKUserTrackingModeFollow;
    _mapView.showsUserLocation = YES;
    
    
}
 
 
//停止定位
-(void)stopLocation
{
    [_locService stopUserLocationService];
    _mapView.showsUserLocation =  YES;//显示定位图层
}
 
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
    
    NSLog(@"address:%@----%@",result.addressDetail,result.address);
    
    currentAdress = result.address;
    
    [self.tableView reloadData];
    
    [self stopLocation];
    //[locateAddressLabel setText:[NSString stringWithFormat:@"地址:%@",result.address]];
    
    //addressDetail:     层次化地址信息
    
    //address:    地址名称
    
    //businessCircle:  商圈名称
    
    // location:  地址坐标
    
    //  poiList:   地址周边POI信息,成员类型为BMKPoiInfo
    
}
 
#pragma mark - Navigation
 
/**
 *在地图View将要启动定位时,会调用此函数
 *@param mapView 地图View
 */
- (void)willStartLocatingUser
{
    NSLog(@"start locate");
}
 
 
/**
 *用户方向更新后,会调用此函数
 *@param userLocation 新的用户位置
 */
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
//{
//    [_mapView updateLocationData:userLocation];
//    NSLog(@"heading is %@",userLocation.heading);
    
    
//    locateLatitude = userLocation.location.coordinate.latitude;
//    locateLongitude = userLocation.location.coordinate.longitude;
    
    //[latitudeLabel setText:[NSString stringWithFormat:@"经度:%lf",userLocation.location.coordinate.longitude]];
    //[longitudeLabel setText:[NSString stringWithFormat:@"纬度:%lf",userLocation.location.coordinate.latitude]];
    
    //[_mapView updateLocationData:userLocation];
    
    //_mapView.centerCoordinate = userLocation.location.coordinate; //更新当前位置到地图中间
    
    //地理反编码
    
    //BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
    
    // reverseGeocodeSearchOption.reverseGeoPoint = userLocation.location.coordinate;
    
    // BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
    
    //if(flag)
    //{
    
    //     NSLog(@"反geo检索发送成功");
    
    //[_locService stopUserLocationService];
    
    // }
    // else
    //{
    
    //     NSLog(@"反geo检索发送失败");
    // }
//}
 
/**
 *在地图View停止定位后,会调用此函数
 *@param mapView 地图View
 */
- (void)didStopLocatingUser
{
    NSLog(@"stop locate");
}
 
/**
 *定位失败后,会调用此函数
 *@param mapView 地图View
 *@param error 错误号,参考CLError.h中定义的错误号
 */
- (void)didFailToLocateUserWithError:(NSError *)error
{
    NSLog(@"location error");
}
 
/**
 *用户位置更新后,会调用此函数
 *@param userLocation 新的用户位置
 */
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
    NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
    
   // latitude = userLocation.location.coordinate.latitude;
   // longitude = userLocation.location.coordinate.longitude;
    
    locateLatitude = userLocation.location.coordinate.latitude;
    locateLongitude = userLocation.location.coordinate.longitude;
    
    [_mapView updateLocationData:userLocation];
    
    _mapView.centerCoordinate = userLocation.location.coordinate; //更新当前位置到地图中间
    
    //地理反编码
    
    BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
    
    reverseGeocodeSearchOption.reverseGeoPoint = userLocation.location.coordinate;
    
    BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
    
    if(flag)
    {
        
        NSLog(@"反geo检索发送成功");
        
        //[latitudeLabel setText:[NSString stringWithFormat:@"经度:%lf",longitude]];
       // [longitudeLabel setText:[NSString stringWithFormat:@"纬度:%lf",latitude]];
        
        [_mapView removeAnnotations:_mapView.annotations];
        //[self addPointAnnotation];
        
        //[_locService stopUserLocationService];
        
    }
    else
    {
        
        NSLog(@"反geo检索发送失败");
        
    }
    
}
 
#pragma mark 底图手势操作
/**
 *点中底图标注后会回调此接口
 *@param mapview 地图View
 *@param mapPoi 标注点信息
 */
- (void)mapView:(BMKMapView *)mapView onClickedMapPoi:(BMKMapPoi*)mapPoi
{
    NSLog(@"onClickedMapPoi-%@",mapPoi.text);
    NSString* showmeg = [NSString stringWithFormat:@"您点击了底图标注:%@,\r\n当前经度:%f,当前纬度:%f,\r\nZoomLevel=%d;RotateAngle=%d;OverlookAngle=%d", mapPoi.text,mapPoi.pt.longitude,mapPoi.pt.latitude, (int)_mapView.zoomLevel,_mapView.rotation,_mapView.overlooking];
    
    //latitude = mapPoi.pt.latitude;
    //longitude = mapPoi.pt.longitude;
    
    
    _mapView.centerCoordinate = mapPoi.pt; //更新当前位置到地图中间
    //地理反编码
    BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
    reverseGeocodeSearchOption.reverseGeoPoint = mapPoi.pt;
    BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
    
    if(flag)
    {
        
        NSLog(@"反geo检索发送成功");
        
        //[latitudeLabel setText:[NSString stringWithFormat:@"经度:%lf",longitude]];
        //[longitudeLabel setText:[NSString stringWithFormat:@"纬度:%lf",latitude]];
        
        [_mapView removeOverlays:_mapView.overlays];
        [_mapView removeAnnotations:_mapView.annotations];
        //[self addPointAnnotation];
        
        //[_locService stopUserLocationService];
        
    }
    else
    {
        NSLog(@"反geo检索发送失败");
        
    }
    
    NSLog(showmeg);
}
/**
 *点中底图空白处会回调此接口
 *@param mapview 地图View
 *@param coordinate 空白处坐标点的经纬度
 */
- (void)mapView:(BMKMapView *)mapView onClickedMapBlank:(CLLocationCoordinate2D)coordinate
{
    NSLog(@"onClickedMapBlank-latitude==%f,longitude==%f",coordinate.latitude,coordinate.longitude);
    NSString* showmeg = [NSString stringWithFormat:@"您点击了地图空白处(blank click).\r\n当前经度:%f,当前纬度:%f,\r\nZoomLevel=%d;RotateAngle=%d;OverlookAngle=%d", coordinate.longitude,coordinate.latitude,
                         (int)_mapView.zoomLevel,_mapView.rotation,_mapView.overlooking];
    
    //latitude = coordinate.latitude;
    //longitude = coordinate.longitude;
    
    _mapView.centerCoordinate = coordinate; //更新当前位置到地图中间
    //地理反编码
    BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
    reverseGeocodeSearchOption.reverseGeoPoint = coordinate;
    BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
    
    if(flag)
    {
        
        NSLog(@"反geo检索发送成功");
        
        //[latitudeLabel setText:[NSString stringWithFormat:@"经度:%lf",longitude]];
        //[longitudeLabel setText:[NSString stringWithFormat:@"纬度:%lf",latitude]];
        
        [_mapView removeAnnotations:_mapView.annotations];
        //[self addPointAnnotation];
        
        //[_locService stopUserLocationService];
        
    }
    else
    {
        NSLog(@"反geo检索发送失败");
        
    }
    
    NSLog(showmeg);
}
 
/**
 *双击地图时会回调此接口
 *@param mapview 地图View
 *@param coordinate 返回双击处坐标点的经纬度
 */
- (void)mapview:(BMKMapView *)mapView onDoubleClick:(CLLocationCoordinate2D)coordinate
{
    NSLog(@"onDoubleClick-latitude==%f,longitude==%f",coordinate.latitude,coordinate.longitude);
    NSString* showmeg = [NSString stringWithFormat:@"您双击了地图(double click).\r\n当前经度:%f,当前纬度:%f,\r\nZoomLevel=%d;RotateAngle=%d;OverlookAngle=%d", coordinate.longitude,coordinate.latitude,
                         (int)_mapView.zoomLevel,_mapView.rotation,_mapView.overlooking];
    
    
    //    latitude = coordinate.latitude;
    //    longitude = coordinate.longitude;
    //
    //    [_mapView removeOverlays:_mapView.overlays];
    //    [_mapView removeAnnotations:_mapView.annotations];
    //    [self addPointAnnotation];
    //    [self addAnimatedAnnotation];
    NSLog(showmeg);
}
 
/**
 *长按地图时会回调此接口
 *@param mapview 地图View
 *@param coordinate 返回长按事件坐标点的经纬度
 */
- (void)mapview:(BMKMapView *)mapView onLongClick:(CLLocationCoordinate2D)coordinate
{
    NSLog(@"onLongClick-latitude==%f,longitude==%f",coordinate.latitude,coordinate.longitude);
    NSString* showmeg = [NSString stringWithFormat:@"您长按了地图(long pressed).\r\n当前经度:%f,当前纬度:%f,\r\nZoomLevel=%d;RotateAngle=%d;OverlookAngle=%d", coordinate.longitude,coordinate.latitude,
                         (int)_mapView.zoomLevel,_mapView.rotation,_mapView.overlooking];
    
    //    latitude = coordinate.latitude;
    //    longitude = coordinate.longitude;
    //    [_mapView removeOverlays:_mapView.overlays];
    //    [_mapView removeAnnotations:_mapView.annotations];
    //    [self addPointAnnotation];
    //    [self addAnimatedAnnotation];
    NSLog(showmeg);
    
}
- (void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    NSString* showmeg = [NSString stringWithFormat:@"地图区域发生了变化(x=%d,y=%d,\r\nwidth=%d,height=%d).\r\nZoomLevel=%d;RotateAngle=%d;OverlookAngle=%d",(int)_mapView.visibleMapRect.origin.x,(int)_mapView.visibleMapRect.origin.y,(int)_mapView.visibleMapRect.size.width,(int)_mapView.visibleMapRect.size.height,(int)_mapView.zoomLevel,_mapView.rotation,_mapView.overlooking];
    
    //    latitude = coordinate.latitude;
    //    longitude = coordinate.longitude;
    
    
    NSLog(showmeg);
    
}
 
 
#pragma mark implement BMKMapViewDelegate
 
// 根据anntation生成对应的View
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation
{
    //普通annotation
    if ( annotation == pointAnnotation)
    {
        NSString *AnnotationViewID = @"renameMark";
        BMKPinAnnotationView *annotationView = (BMKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
        if (annotationView == nil)
        {
            annotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID];
            // 设置颜色
            annotationView.pinColor = BMKPinAnnotationColorPurple;
            // 从天上掉下效果
            annotationView.animatesDrop = NO;
            // 设置可拖拽
            annotationView.draggable = YES;
            
            annotationView.image = [UIImage imageNamed:@"addressAnnota"];
        }
        return annotationView;
    }
    
    //动画annotation
    NSString *AnnotationViewID = @"AnimatedAnnotation";
    MyAnimatedAnnotationView *annotationView = nil;
    
    if (annotationView == nil)
    {
        annotationView = [[MyAnimatedAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID];
    }
    
    NSMutableArray *images = [NSMutableArray array];
    
    for (int i = 1; i < 4; i++)
    {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"poi_%d.png", i]];
        [images addObject:image];
    }
    
    annotationView.annotationImages = images;
    return annotationView;
    
}
 
// 当点击annotation view弹出的泡泡时,调用此接口
- (void)mapView:(BMKMapView *)mapView annotationViewForBubble:(BMKAnnotationView *)view;
{
    CLLocationCoordinate2D coordinate;
    coordinate.latitude = locateLatitude;
    coordinate.longitude = locateLongitude;
    
    _mapView.centerCoordinate = coordinate; //更新当前位置到地图中间
    //地理反编码
    BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
    reverseGeocodeSearchOption.reverseGeoPoint = coordinate;
    BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
    
    if(flag)
    {
        
        NSLog(@"反geo检索发送成功");
        
        //[latitudeLabel setText:[NSString stringWithFormat:@"经度:%lf",locateLongitude]];
       // [longitudeLabel setText:[NSString stringWithFormat:@"纬度:%lf",locateLatitude]];
        
        [_mapView removeAnnotations:_mapView.annotations];
        //[self addPointAnnotation];
        
        //[_locService stopUserLocationService];
        
    }
    else
    {
        NSLog(@"反geo检索发送失败");
        
    }
    
    NSLog(@"paopaoclick");
}
 
- (void)dealloc
{
    if (_mapView) {
        _mapView = nil;
    }
}
 
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
@end