zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
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
//
//  PBAddPanoramaViewController.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2022/10/19.
//  Copyright © 2022 ProBIM. All rights reserved.
//
 
#import "PBAddPanoramaViewController.h"
#import "PBProjectModel.h"
#import "PBViewPointScrollView.h"
#import "PBChooseType.h"
#import "PBPanoramaModel.h"
#import "PBViewPointModel.h"
#import "PBModelsModel.h"
#import "HJCycleView.h"
 
static NSString *const ImageCellID = @"ImageCellID";
@interface PBAddPanoramaViewController ()<UITextFieldDelegate, LFImagePickerControllerDelegate>
@property (nonatomic, strong) PBChooseType *chooseTypeView;
@property (nonatomic, strong) NSDictionary *tagDict;
@property (nonatomic, weak) UIButton *tagBtn;
@property (nonatomic, strong) NSData *imageDate;
@property (nonatomic, copy) NSString *imageExtension;
@property (nonatomic, weak) UIImageView *panoramaImageV;
@property (nonatomic, weak) PBViewPointScrollView *vpScrollView;
@property (nonatomic, weak)UITextField *nameTF;
@property (nonatomic, weak)UITextField *panoramaNameTF;
@property (nonatomic, assign) BOOL isAddsubset;
@property (nonatomic, weak) HJCycleView *cycleview;
@end
 
@implementation PBAddPanoramaViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    [self setupUI];
    if (self.isAddsubset) {
        [self loadImage];
    }
}
- (void)setupNav {
    self.view.backgroundColor = [UIColor z_colorWithR:247 G:247 B:247];
    self.title = @"添加全景图";
    PBBackNavItem *backNav = [PBBackNavItem backNacItem];
    backNav.title = @" ";
    [backNav addTarget:self action:@selector(backItemAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithCustomView:backNav];
    self.navigationItem.leftBarButtonItem = backNavItem;
    UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction)];
    self.navigationItem.rightBarButtonItem = saveItem;
}
- (void)loadImage {
    [YJProgressHUD showProgress:@"正在加载辅助图片..." inView:self.view];
    NSString *labelId = @"";
    if (self.isAddsubset) {
        labelId = self.panoramaModel.LabelId;
    } else {
        labelId = [self.tagDict valueForKey:@"LabelId"];
    }
    [[PBNetworkTools sharedTools] GetLabelFileWithOrganizeId:self.projectModel.organizeid andLabelId:labelId AndCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showFailed:@"加载辅助图片失败" inview:self.view];
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
            [YJProgressHUD hide];
            NSMutableArray *imageM = [[NSMutableArray alloc] init];
            for (NSDictionary *obj in networkModel.Data) {
                NSString *url = [NSString stringWithFormat:@"%@/%@", PanoramaUrl, [obj valueForKey:@"FilePath"]];
                [imageM addObject:url];
            }
            self.cycleview.data = imageM.copy;
        }else {
            [YJProgressHUD showFailed:networkModel.Msg inview:self.view];
        }
    }];
}
- (void)saveAction {
    if (self.imageDate == nil) {
        [YJProgressHUD showMessage:@"请选择全景图" inView:self.view];
        return;
    }
    [YJProgressHUD showProgress:@"正在保存..." inView:self.view];
    PBViewPointModel *vpModel = self.vpScrollView.vpData;
    NSString *vpStr = nil;
    if (vpModel.Override) {
        NSDictionary *dict = [NSString convertTodictionaryOrArr:vpModel.Override];
        NSString *pos = [dict valueForKey:@"cameraPosition"];
        NSString *target = [dict valueForKey:@"controlPostion"];
        NSString *focalOffset = [dict valueForKey:@"focalOffset"];
        NSDictionary *vpDict = @{
                                @"pos" : pos,
                                @"target" : target,
                                @"focalOffset" : focalOffset
                                };
        
        vpStr = [NSString convertToJson:vpDict];
    }
    
    PBModelsModel *model = self.vpScrollView.modelData;
 
    NSString *targetPatchGuid =  nil;
    NSString *name = @"";
    NSString *labelId = @"";
    if(self.isAddsubset) {
        targetPatchGuid = self.panoramaModel.PbGuid;
    }else {
        name = self.nameTF.text;
        labelId = [self.tagDict valueForKey:@"LabelId"];
        if (name == nil || [name isEqualToString:@""]) {
           [YJProgressHUD showMessage:@"请输入全景图集名称" inView:self.view];
           return;
        }
        if (labelId == nil) {
            labelId = @"";
        }
    }
    NSString *panoramaName = [NSString stringWithFormat:@"%@.%@", self.panoramaNameTF.text, self.imageExtension];
    if (panoramaName == nil || [panoramaName isEqualToString:@""]) {
        [YJProgressHUD showMessage:@"请输入图片名称" inView:self.view];
        return;
    }
    [[PBNetworkTools sharedTools] UploadPanoramaImagesWithFile:self.imageDate andfileName:panoramaName andTargetPatchGuid:targetPatchGuid andOrganizeId:self.projectModel.organizeid andPbname:name andLabelId:labelId andModelId:model.ID andViewId:vpStr andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showFailed:@"保存失败" inview:self.view];
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1){
            [YJProgressHUD hide];
            if (self.SaveSuccessBlock) {
                self.SaveSuccessBlock();
            }
            [self.navigationController popViewControllerAnimated:YES];
        }else {
            [YJProgressHUD showFailed:networkModel.Msg inview:self.view];
        }
    }];
 
}
- (void)backItemAction {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)setupUI {
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:scrollView];
    scrollView.contentSize = CGSizeMake(self.view.width, 1200);
    scrollView.backgroundColor = PBColor(248, 248, 248);
    NSInteger width = self.view.width - 20;
    
    UIView *topView = [[UIView alloc] init];
    topView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(scrollView).offset(10);
        make.height.equalTo(@436);
        make.width.equalTo(@(width));
    }];
    [topView circleViewWithRadius:6];
    
    UIImageView *iconImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_panorama"]];
    [topView addSubview:iconImagV];
    [iconImagV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView).offset(13);
        make.left.equalTo(topView).offset(10);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    UILabel *addTitleL = [UILabel z_labelWithText:@"添加全景图" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
    [topView addSubview:addTitleL];
    [addTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView).offset(10);
        make.left.equalTo(iconImagV.mas_right).offset(10);
        make.height.equalTo(@21);
    }];
    UIView *bgV = [[UIView alloc] init];
    bgV.layer.cornerRadius = 6;
    bgV.layer.borderWidth = 1;
    bgV.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
    [topView addSubview:bgV];
    [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImagV.mas_bottom).offset(13);
        make.left.equalTo(iconImagV);
        make.right.equalTo(topView).offset(-10);
        make.height.equalTo(@40);
    }];
    UILabel *nameL = [UILabel z_labelWithText:@"图集名称" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
    [bgV addSubview:nameL];
    [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgV).offset(10);
        make.top.equalTo(bgV).offset(11);
        make.height.equalTo(@19);
    }];
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
    [bgV addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgV).offset(10);
        make.bottom.equalTo(bgV).offset(-10);
        make.width.equalTo(@1);
        make.left.equalTo(bgV).offset(72);
    }];
    UITextField *nameTF = [[UITextField alloc] init];
    nameTF.placeholder = @"请输入全景图集名称";
    nameTF.textAlignment= NSTextAlignmentLeft;
    nameTF.textColor = TitleColor;
    nameTF.font = [UIFont fontWithName:Coarse size:13.0];
    nameTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    nameTF.delegate = self;
    [bgV addSubview:nameTF];
    [nameTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(bgV);
        make.right.equalTo(bgV).offset(-12);
        make.left.equalTo(line).offset(10);
    }];
    
    
    UIView *bg1V = [[UIView alloc] init];
    bg1V.layer.cornerRadius = 6;
    bg1V.layer.borderWidth = 1;
    bg1V.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
    [topView addSubview:bg1V];
    [bg1V mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgV.mas_bottom).offset(10);
        make.left.equalTo(iconImagV);
        make.right.equalTo(topView).offset(-10);
        make.height.equalTo(@40);
    }];
    UILabel *tagL = [UILabel z_labelWithText:@"标签" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
    [bg1V addSubview:tagL];
    [tagL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bg1V).offset(10);
        make.top.equalTo(bg1V).offset(11);
        make.height.equalTo(@19);
    }];
    UIView *line1 = [[UIView alloc] init];
    line1.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
    [bg1V addSubview:line1];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bg1V).offset(10);
        make.bottom.equalTo(bg1V).offset(-10);
        make.width.equalTo(@1);
        make.left.equalTo(bg1V).offset(72);
    }];
    
    
    UIButton *tagBtn = [UIButton z_textButton:@"请选择标签" fontSize:13 normalColor:[UIColor z_colorWithR:102 G:102 B:102]];
    [tagBtn addTarget:self action:@selector(chooseTag) forControlEvents:UIControlEventTouchUpInside];
    tagBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [bg1V addSubview:tagBtn];
    [tagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(bg1V);
        make.right.equalTo(bg1V).offset(-12);
        make.left.equalTo(line1).offset(10);
    }];
    
    UIView *addImageView = [[UIView alloc] init];
    [topView addSubview:addImageView];
    [addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bg1V.mas_bottom).offset(10);
        make.left.right.equalTo(bgV);
        make.height.equalTo(@235);
    }];
    
    UIImageView *addImagebg = [[UIImageView alloc] init];
    addImagebg.image = [UIImage imageNamed:@"add_panorama_bg"];
    [addImageView addSubview:addImagebg];
    [addImagebg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(addImageView);
    }];
    
    UIView *btnView = [[UIView alloc] init];
    [addImageView addSubview:btnView];
    [btnView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(addImageView);
        make.size.mas_equalTo(CGSizeMake(105, 20));
    }];
    UIButton *addImage = [UIButton z_bgImageButton:[UIImage imageNamed:@"panorama_add"]];
    [addImage addTarget:self action:@selector(addImageAction) forControlEvents:UIControlEventTouchUpInside];
    [btnView addSubview:addImage];
    [addImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(btnView);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    UIButton *addTitle = [UIButton z_textButton:@"上传一张全景图" fontSize:13 normalColor:[UIColor z_colorWithR:0 G:122 B:255]];
    [addTitle addTarget:self action:@selector(addImageAction) forControlEvents:UIControlEventTouchUpInside];
    [btnView addSubview:addTitle];
    [addTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(addImage.mas_right).offset(4);
        make.top.bottom.equalTo(btnView);
    }];
 
    UIImageView *panoramaImageV = [[UIImageView alloc] init];
    panoramaImageV.userInteractionEnabled = YES;
    [addImageView addSubview:panoramaImageV];
    [panoramaImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(addImageView);
    }];
    [panoramaImageV circleViewWithRadius:6];
    panoramaImageV.hidden = YES;
    
    UIButton *deleteBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"delete_task"]];
    [deleteBtn addTarget:self action:@selector(deleteImage) forControlEvents:UIControlEventTouchUpInside];
    [panoramaImageV addSubview:deleteBtn];
    [deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(panoramaImageV).offset(4);
        make.right.equalTo(panoramaImageV).offset(-4);
        make.size.mas_equalTo(CGSizeMake(24, 24));
    }];
    
    UIView *namebgV = [[UIView alloc] init];
    namebgV.layer.cornerRadius = 6;
    namebgV.layer.borderWidth = 1;
    namebgV.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
    [topView addSubview:namebgV];
    [namebgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addImageView.mas_bottom).offset(10);
        make.left.equalTo(iconImagV);
        make.right.equalTo(topView).offset(-10);
        make.height.equalTo(@40);
    }];
    UILabel *panoramaNameL = [UILabel z_labelWithText:@"图片名称" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
    [namebgV addSubview:panoramaNameL];
    [panoramaNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(namebgV).offset(10);
        make.top.equalTo(namebgV).offset(11);
        make.height.equalTo(@19);
    }];
    UIView *line2 = [[UIView alloc] init];
    line2.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
    [namebgV addSubview:line2];
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(namebgV).offset(10);
        make.bottom.equalTo(namebgV).offset(-10);
        make.width.equalTo(@1);
        make.left.equalTo(namebgV).offset(72);
    }];
    UITextField *panoramaNameTF = [[UITextField alloc] init];
    panoramaNameTF.placeholder = @"图片名称";
    panoramaNameTF.textAlignment= NSTextAlignmentLeft;
    panoramaNameTF.textColor = TitleColor;
    panoramaNameTF.font = [UIFont fontWithName:Coarse size:13.0];
    panoramaNameTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    panoramaNameTF.delegate = self;
    [namebgV addSubview:panoramaNameTF];
    [panoramaNameTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(namebgV);
        make.right.equalTo(namebgV).offset(-12);
        make.left.equalTo(line2).offset(10);
    }];
    
    
    UIView *middleView = [[UIView alloc] init];
    middleView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:middleView];
    [middleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(10);
        make.left.width.equalTo(topView);
        make.height.equalTo(@350);
    }];
    [middleView circleViewWithRadius:6];
    UIImageView *vpiconImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_viewpoint"]];
    [middleView addSubview:vpiconImagV];
    [vpiconImagV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(middleView).offset(13);
        make.left.equalTo(middleView).offset(10);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    UILabel *chooseVpL = [UILabel z_labelWithText:@"选择视点" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
    [middleView addSubview:chooseVpL];
    [chooseVpL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(middleView).offset(10);
        make.left.equalTo(vpiconImagV.mas_right).offset(10);
        make.height.equalTo(@21);
    }];
    PBViewPointScrollView *vpscrollView = [[PBViewPointScrollView alloc] initWithFrame:CGRectMake(0, 31, width, 319) withProjectModel:self.projectModel];
    [middleView addSubview:vpscrollView];
    
  
    UIView *bottomView = [[UIView alloc] init];
    bottomView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(middleView.mas_bottom).offset(10);
        make.left.width.equalTo(topView);
        make.height.equalTo(@286);
    }];
    [bottomView circleViewWithRadius:6];
    
    UIImageView *choosedianImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_selection"]];
    [bottomView addSubview:choosedianImagV];
    [choosedianImagV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomView).offset(13);
        make.left.equalTo(bottomView).offset(10);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    UILabel *choosedianL = [UILabel z_labelWithText:@"辅助选点" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
    [bottomView addSubview:choosedianL];
    [choosedianL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomView).offset(10);
        make.left.equalTo(choosedianImagV.mas_right).offset(10);
        make.height.equalTo(@21);
    }];
    
    NSInteger collectionW = width - 20;
    NSInteger collectionH = 286 - 50;
 
    HJCycleView *cycleview = [[HJCycleView alloc] initWithFrame:CGRectMake(10, 40, collectionW, collectionH) andData:@[]];
    cycleview.backgroundColor = [UIColor whiteColor];
    cycleview.returnBlock = ^(NSInteger index) {
        NSLog(@"点击了%ld",index);
    };
    [bottomView addSubview:cycleview];
    self.cycleview = cycleview;
    
    
    self.tagBtn = tagBtn;
    self.panoramaImageV = panoramaImageV;
    self.vpScrollView = vpscrollView;
    self.nameTF = nameTF;
    self.panoramaNameTF = panoramaNameTF;
    if (_isAddsubset) {
        self.nameTF.text = self.panoramaModel.PbName;
        self.nameTF.enabled = NO;
        [self.tagBtn setTitle:self.panoramaModel.LabelName forState:UIControlStateNormal];
    }
}
// 选择标签
- (void)chooseTag {
    if (self.isAddsubset) {
        return;
    }
    [self.view endEditing:YES];
    [PBKeyWindow addSubview:self.chooseTypeView];
    PBPanoramaModel *panoramaModel = [[PBPanoramaModel alloc] init];
    self.chooseTypeView.panoramaModel = panoramaModel;
    self.chooseTypeView.dateList = self.tagList;
    self.chooseTypeView.ChooseCompleteBlock = ^(BOOL isSelsected, NSInteger index){
        if (isSelsected) {
            self.tagDict = self.tagList[index];
            [self.tagBtn setTitle:[self.tagDict valueForKey:@"LabelName"] forState:UIControlStateNormal];
            [self loadImage];
        }
    };
    [self.chooseTypeView show];
}
//选择全景图
- (void)addImageAction {
    [self takePhotoLibrary];
}
 
- (void)takePhotoLibrary {
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusNotDetermined) {//未作出回应
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            if(status == PHAuthorizationStatusAuthorized) {
                dispatch_async(dispatch_get_main_queue(), ^{//用户点击ok
                    [self pushLFImagePickerController];
                });
            } else {
                dispatch_async(dispatch_get_main_queue(), ^{//点击不允许访问
                    NSLog(@"点击不允许访问");
                });
            }
        }];
    }else if (status == PHAuthorizationStatusRestricted) {//没有被授权访问 可能家长控制
 
    }else if (status == PHAuthorizationStatusDenied) {//已明确否认相册权限
        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"无法访问相册" message:@"请在iPhone的""设置-隐私-相册""中允许访问相册" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if (@available(iOS 10.0, *)) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
            } else {
                NSLog(@"选择取消");
            }
        }];
        [alertController addAction:cancelAction];
        [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];
    }else if (status == PHAuthorizationStatusAuthorized){//有权限访问
        [self pushLFImagePickerController];
    }
}
- (void)pushLFImagePickerController {
    LFImagePickerController *imagePicker = [[LFImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
//    imagePicker.maxVideosCount = 1;
//    imagePicker.allowTakePicture = YES;//内部显示相机
    imagePicker.isSelectOriginalPhoto = YES;//是否选择原图
//    if (self.selectedPhotos.count > 0) {
        imagePicker.allowPickingType = LFPickingMediaTypePhoto;//用户是否可以选择视频
//    }else {
//        imagePicker.allowPickingType = LFPickingMediaTypeALL;//用户是否可以选择视频
//    }
    imagePicker.allowPickingOriginalPhoto = NO;//原图按钮将隐藏,用户将不能发送原图
    imagePicker.maxPhotoBytes = 1024 * 1024 * 100;//最大图片所选字节大小
    if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) {
        imagePicker.syncAlbum = YES; /** 实时同步相册 */
    }
//    imagePicker.selectedAssets = self.selectAssetArr;
    [self presentViewController:imagePicker animated:YES completion:nil];
}
#pragma mark - LFImagePickerControllerDelegate
 
- (void)lf_imagePickerController:(LFImagePickerController *)picker didFinishPickingResult:(NSArray <LFResultObject /* <LFResultImage/LFResultVideo> */*> *)results {
    if(results.count > 0) {
        self.panoramaImageV.hidden = NO;
        LFResultObject *result = results[0];
        LFResultImage *resultImage = (LFResultImage *)result;
        self.panoramaImageV.image = resultImage.thumbnailImage;
        self.imageDate = resultImage.originalData;
        self.panoramaNameTF.text = [result.info.name stringByDeletingPathExtension];
        self.imageExtension = [result.info.name pathExtension];
    }
}
 
- (void)deleteImage {
    self.panoramaImageV.image = nil;
    self.imageDate = nil;
    self.panoramaImageV.hidden = YES;
    self.panoramaNameTF.text = @"";
    self.imageExtension = @"";
}
 
#pragma mark - UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField *)textField{
//    self.unitText = textField.text;
 
}
- (void)setPanoramaModel:(PBPanoramaModel *)panoramaModel {
    _panoramaModel = panoramaModel;
    _isAddsubset = YES;
}
- (void)setProjectModel:(PBProjectModel *)projectModel {
    _projectModel = projectModel;
}
- (void)setTagList:(NSArray *)tagList {
    _tagList = tagList;
}
- (PBChooseType *)chooseTypeView {
    if (_chooseTypeView == nil) {
        _chooseTypeView = [[PBChooseType alloc] initWithFrame:[UIScreen mainScreen].bounds];
        _chooseTypeView.visualViewHeight = 300;
    }
    return _chooseTypeView;;
}
 
/*
#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