فهرست منبع

1.修改NPD Model Detail预览,增加视频Item。

Pen Li 9 سال پیش
والد
کامیت
a74ff3c371

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 9
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -4,19 +4,13 @@
    version = "2.0">
    version = "2.0">
    <Breakpoints>
    <Breakpoints>
       <BreakpointProxy
       <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
          <BreakpointContent
          <BreakpointContent
             shouldBeEnabled = "Yes"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             continueAfterRunningActions = "No"
-            filePath = "common/Functions/search+itemsearch/ItemSearchFilterViewController.m"
-            timestampString = "519611782.722609"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "388"
-            endingLineNumber = "388"
-            landmarkName = "-viewDidLoad"
-            landmarkType = "7">
+            scope = "0"
+            stopOnStyle = "0">
          </BreakpointContent>
          </BreakpointContent>
       </BreakpointProxy>
       </BreakpointProxy>
    </Breakpoints>
    </Breakpoints>

+ 7 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -20,6 +20,8 @@
 #import "CustomIOSAlertView.h"
 #import "CustomIOSAlertView.h"
 #import "TextUtils.h"
 #import "TextUtils.h"
 
 
+#import "ContentPreviewController.h"
+
 
 
 @implementation DetailHeaderCell
 @implementation DetailHeaderCell
 @synthesize celldelegate;
 @synthesize celldelegate;
@@ -1131,6 +1133,11 @@
 -(void)photoStackView:(PhotoStackView *)photoStackView didSelectPhotoAtIndex:(NSUInteger)index {
 -(void)photoStackView:(PhotoStackView *)photoStackView didSelectPhotoAtIndex:(NSUInteger)index {
     DebugLog(@"selected %lu", (unsigned long)index);
     DebugLog(@"selected %lu", (unsigned long)index);
     
     
+    ContentPreviewController *preVC = [[UIStoryboard storyboardWithName:@"PhotoList" bundle:nil] instantiateViewControllerWithIdentifier:@"ContentPreviewController"];
+    preVC.content = self.stack_contents;
+    UIViewController *superVC= [RAUtils getViewController:self];
+    [superVC.navigationController pushViewController:preVC animated:true];
+    return;
     
     
     NSDictionary* item= self.stack_contents[[NSString stringWithFormat:@"item_%d",index]];
     NSDictionary* item= self.stack_contents[[NSString stringWithFormat:@"item_%d",index]];
     
     

+ 54 - 0
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -50,6 +50,10 @@
 		42BF67CC1E5179970081F90A /* ERPUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BF67CB1E5179970081F90A /* ERPUtils.m */; };
 		42BF67CC1E5179970081F90A /* ERPUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BF67CB1E5179970081F90A /* ERPUtils.m */; };
 		42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C2E8BB1DB49D02006C0495 /* TearSheet.json */; };
 		42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C2E8BB1DB49D02006C0495 /* TearSheet.json */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
+		42D3A4A11EFA6D36007A54C1 /* ContentPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D3A49B1EFA6D36007A54C1 /* ContentPreviewController.m */; };
+		42D3A4A21EFA6D36007A54C1 /* PhotoList.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42D3A49D1EFA6D36007A54C1 /* PhotoList.storyboard */; };
+		42D3A4A31EFA6D36007A54C1 /* PhotoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D3A4A01EFA6D36007A54C1 /* PhotoPreviewCell.m */; };
+		42D3A4A61EFA7346007A54C1 /* VideoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D3A4A51EFA7346007A54C1 /* VideoPreviewCell.m */; };
 		42D9A0231EB02DA6008AF7AF /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D9A0221EB02DA6008AF7AF /* AdSupport.framework */; };
 		42D9A0231EB02DA6008AF7AF /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D9A0221EB02DA6008AF7AF /* AdSupport.framework */; };
 		42D9A0251EB03994008AF7AF /* libAdIdAccess.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D9A0241EB03994008AF7AF /* libAdIdAccess.a */; };
 		42D9A0251EB03994008AF7AF /* libAdIdAccess.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D9A0241EB03994008AF7AF /* libAdIdAccess.a */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
@@ -351,6 +355,13 @@
 		42BF67CB1E5179970081F90A /* ERPUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ERPUtils.m; path = common/ERPUtils.m; sourceTree = SOURCE_ROOT; };
 		42BF67CB1E5179970081F90A /* ERPUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ERPUtils.m; path = common/ERPUtils.m; sourceTree = SOURCE_ROOT; };
 		42C2E8BB1DB49D02006C0495 /* TearSheet.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TearSheet.json; sourceTree = "<group>"; };
 		42C2E8BB1DB49D02006C0495 /* TearSheet.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TearSheet.json; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
+		42D3A49A1EFA6D36007A54C1 /* ContentPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentPreviewController.h; sourceTree = "<group>"; };
+		42D3A49B1EFA6D36007A54C1 /* ContentPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContentPreviewController.m; sourceTree = "<group>"; };
+		42D3A49D1EFA6D36007A54C1 /* PhotoList.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = PhotoList.storyboard; sourceTree = "<group>"; };
+		42D3A49F1EFA6D36007A54C1 /* PhotoPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPreviewCell.h; sourceTree = "<group>"; };
+		42D3A4A01EFA6D36007A54C1 /* PhotoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewCell.m; sourceTree = "<group>"; };
+		42D3A4A41EFA7346007A54C1 /* VideoPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPreviewCell.h; sourceTree = "<group>"; };
+		42D3A4A51EFA7346007A54C1 /* VideoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoPreviewCell.m; sourceTree = "<group>"; };
 		42D9A0221EB02DA6008AF7AF /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
 		42D9A0221EB02DA6008AF7AF /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
 		42D9A0241EB03994008AF7AF /* libAdIdAccess.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libAdIdAccess.a; sourceTree = "<group>"; };
 		42D9A0241EB03994008AF7AF /* libAdIdAccess.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libAdIdAccess.a; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
@@ -1021,6 +1032,44 @@
 			name = Frameworks;
 			name = Frameworks;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
+		42D3A4981EFA6D36007A54C1 /* PhotoList */ = {
+			isa = PBXGroup;
+			children = (
+				42D3A4991EFA6D36007A54C1 /* Controller */,
+				42D3A49C1EFA6D36007A54C1 /* Storyboard */,
+				42D3A49E1EFA6D36007A54C1 /* View */,
+			);
+			path = PhotoList;
+			sourceTree = "<group>";
+		};
+		42D3A4991EFA6D36007A54C1 /* Controller */ = {
+			isa = PBXGroup;
+			children = (
+				42D3A49A1EFA6D36007A54C1 /* ContentPreviewController.h */,
+				42D3A49B1EFA6D36007A54C1 /* ContentPreviewController.m */,
+			);
+			path = Controller;
+			sourceTree = "<group>";
+		};
+		42D3A49C1EFA6D36007A54C1 /* Storyboard */ = {
+			isa = PBXGroup;
+			children = (
+				42D3A49D1EFA6D36007A54C1 /* PhotoList.storyboard */,
+			);
+			path = Storyboard;
+			sourceTree = "<group>";
+		};
+		42D3A49E1EFA6D36007A54C1 /* View */ = {
+			isa = PBXGroup;
+			children = (
+				42D3A49F1EFA6D36007A54C1 /* PhotoPreviewCell.h */,
+				42D3A4A01EFA6D36007A54C1 /* PhotoPreviewCell.m */,
+				42D3A4A41EFA7346007A54C1 /* VideoPreviewCell.h */,
+				42D3A4A51EFA7346007A54C1 /* VideoPreviewCell.m */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 		710212821B8D59DE00E1788B /* watchlist */ = {
 		710212821B8D59DE00E1788B /* watchlist */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
@@ -1699,6 +1748,7 @@
 		71DF74311C5757C800F2789C /* CommonUI */ = {
 		71DF74311C5757C800F2789C /* CommonUI */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				42D3A4981EFA6D36007A54C1 /* PhotoList */,
 				71BF32FA1EFA1C0700842CB4 /* youtube player */,
 				71BF32FA1EFA1C0700842CB4 /* youtube player */,
 				4289800E1E24924D005F1BD8 /* sort */,
 				4289800E1E24924D005F1BD8 /* sort */,
 				715EB9A6193866F2006D16A5 /* photoStack */,
 				715EB9A6193866F2006D16A5 /* photoStack */,
@@ -1867,6 +1917,7 @@
 				71E5A0101DC99370005BF655 /* config.plist in Resources */,
 				71E5A0101DC99370005BF655 /* config.plist in Resources */,
 				71DF74951C57614C00F2789C /* PhotoBorder.png in Resources */,
 				71DF74951C57614C00F2789C /* PhotoBorder.png in Resources */,
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
+				42D3A4A21EFA6D36007A54C1 /* PhotoList.storyboard in Resources */,
 				71D46D111CE1D9EF00A081AC /* OLM.storyboard in Resources */,
 				71D46D111CE1D9EF00A081AC /* OLM.storyboard in Resources */,
 				423B49EF1DAC8071004181C2 /* CUL.storyboard in Resources */,
 				423B49EF1DAC8071004181C2 /* CUL.storyboard in Resources */,
 				42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */,
 				42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */,
@@ -2012,6 +2063,7 @@
 				7141DD551C57459B00F7DF59 /* split.c in Sources */,
 				7141DD551C57459B00F7DF59 /* split.c in Sources */,
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
+				42D3A4A61EFA7346007A54C1 /* VideoPreviewCell.m in Sources */,
 				712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */,
 				712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,
@@ -2087,6 +2139,7 @@
 				7141DD631C5747CE00F7DF59 /* NSString+Base64.m in Sources */,
 				7141DD631C5747CE00F7DF59 /* NSString+Base64.m in Sources */,
 				7162A5C41C5873BB00AB630E /* ItemSearchViewController.m in Sources */,
 				7162A5C41C5873BB00AB630E /* ItemSearchViewController.m in Sources */,
 				7162A5481C58719D00AB630E /* RATreeView+TableViewDataSource.m in Sources */,
 				7162A5481C58719D00AB630E /* RATreeView+TableViewDataSource.m in Sources */,
+				42D3A4A31EFA6D36007A54C1 /* PhotoPreviewCell.m in Sources */,
 				7162A5DB1C5876E300AB630E /* CacheViewController.m in Sources */,
 				7162A5DB1C5876E300AB630E /* CacheViewController.m in Sources */,
 				7162A5C21C5873BB00AB630E /* FilterCellValue.m in Sources */,
 				7162A5C21C5873BB00AB630E /* FilterCellValue.m in Sources */,
 				71DF74971C57614C00F2789C /* PhotoStackView.m in Sources */,
 				71DF74971C57614C00F2789C /* PhotoStackView.m in Sources */,
@@ -2103,6 +2156,7 @@
 				71DF748D1C57608F00F2789C /* TouchLabel.m in Sources */,
 				71DF748D1C57608F00F2789C /* TouchLabel.m in Sources */,
 				71BF33031EFA1D6100842CB4 /* YTViewController.m in Sources */,
 				71BF33031EFA1D6100842CB4 /* YTViewController.m in Sources */,
 				428980171E24924D005F1BD8 /* SortItemViewController.m in Sources */,
 				428980171E24924D005F1BD8 /* SortItemViewController.m in Sources */,
+				42D3A4A11EFA6D36007A54C1 /* ContentPreviewController.m in Sources */,
 				7162A5711C58728D00AB630E /* DetailImageCell.m in Sources */,
 				7162A5711C58728D00AB630E /* DetailImageCell.m in Sources */,
 				7162A51A1C58704600AB630E /* ModelItemCell.m in Sources */,
 				7162A51A1C58704600AB630E /* ModelItemCell.m in Sources */,
 				7141DD511C57459B00F7DF59 /* qrencode.c in Sources */,
 				7141DD511C57459B00F7DF59 /* qrencode.c in Sources */,

+ 17 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/Controller/ContentPreviewController.h

@@ -0,0 +1,17 @@
+//
+//  NewPhotoPreviewController.h
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ContentPreviewController : UIViewController
+
+@property (nonatomic,strong) NSDictionary *content;
+
+@property (nonatomic,assign) NSUInteger currentIndex;
+
+@end

+ 299 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/Controller/ContentPreviewController.m

@@ -0,0 +1,299 @@
+//
+//  NewPhotoPreviewController.m
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "ContentPreviewController.h"
+#import "PhotoPreviewCell.h"
+#import "VideoPreviewCell.h"
+
+#import "iSalesDB.h"
+#import "AppDelegate.h"
+
+
+@interface ContentPreviewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
+
+@property (strong, nonatomic) IBOutlet UILabel *indicator;
+@property (strong, nonatomic) IBOutlet UICollectionView *previewContainer;
+
+@property (nonatomic,strong) NSArray *photos;
+
+@property (nonatomic,strong) UIScrollView *mask;
+
+@property (nonatomic,assign) BOOL hideNavigationBar;
+
+@end
+
+@implementation ContentPreviewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+//    self.automaticallyAdjustsScrollViewInsets = NO;
+//    self.navigationController.navigationBar.translucent = NO;
+//    self.edgesForExtendedLayout = UIRectEdgeNone;
+
+    UIView *v = [UIView new];
+    [self.view insertSubview:v atIndex:0];
+    
+    NSMutableArray *tmpArr = [NSMutableArray array];
+    int count = [[self.content objectForKey:@"count"] intValue];
+    for (int i = 0; i < count; i++) {
+        NSDictionary *item = [self.content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
+        [tmpArr addObject:item];
+    }
+    self.photos = [tmpArr copy];
+    
+    self.indicator.layer.cornerRadius = 20;
+    self.indicator.layer.masksToBounds = YES;
+    
+    self.previewContainer.pagingEnabled = YES;
+    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",(unsigned long)self.currentIndex + 1,(unsigned long)self.photos.count];
+    self.indicator.text = offset;
+    
+    
+    self.hideNavigationBar = self.navigationController.isNavigationBarHidden;
+    
+    self.navigationController.navigationBarHidden = YES;
+    
+}
+
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+
+    
+    if (self.currentIndex > 0) {
+        [self.previewContainer scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0] atScrollPosition:16 animated:YES];
+    }
+    
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+}
+
+- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    
+    // 重新布局 Item 大小
+    [self.previewContainer.collectionViewLayout invalidateLayout];
+
+    // 重新布局Item位置
+    [self.previewContainer scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0] atScrollPosition:32 animated:NO];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+#pragma mark - Setter
+
+- (void)setCurrentIndex:(NSUInteger)currentIndex {
+    _currentIndex = currentIndex;
+    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",(unsigned long)self.currentIndex + 1,(unsigned long)self.photos.count];
+    self.indicator.text = offset;
+}
+
+#pragma mark - FlowLayout Delegate
+
+- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
+    return collectionView.bounds.size;
+}
+
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
+    return 0;
+}
+
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
+    return 0;
+}
+
+- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
+    return UIEdgeInsetsZero;
+}
+
+#pragma mark - CollectionView Delegate
+
+- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
+
+    
+    NSDictionary *item = [self.photos objectAtIndex:indexPath.row];
+    NSString *type = [item objectForKey:@"type"];
+    
+    if ([type isEqualToString:@"image"]) {
+        PhotoPreviewCell *preCell = (PhotoPreviewCell *)cell;
+        
+        [self photoCell:preCell loadImage:item];
+        
+//        preCell.scrollView.backgroundColor = [UIColor colorWithRed:(rand() % 255) / 255.0 green:(rand() % 255) / 255.0 blue:(rand() % 255) / 255.0 alpha:1];
+        
+    } else if ([type isEqualToString:@"video"]) {
+        
+        VideoPreviewCell *videoCell = (VideoPreviewCell *)cell;
+        videoCell.item = item;
+//        videoCell.playerView.webView.backgroundColor = [UIColor colorWithRed:(rand() % 255) / 255.0 green:(rand() % 255) / 255.0 blue:(rand() % 255) / 255.0 alpha:1];
+        
+    }
+}
+
+- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSDictionary *item = [self.photos objectAtIndex:indexPath.row];
+    NSString *type = [item objectForKey:@"type"];
+    
+    if ([type isEqualToString:@"image"]) {
+        PhotoPreviewCell *preCell = (PhotoPreviewCell *)cell;
+        UIScrollView *sc = preCell.scrollView;
+        sc.zoomScale = 1;
+        sc.contentSize = CGSizeZero;
+        sc.contentOffset = CGPointZero;
+    } else if ([type isEqualToString:@"video"]) {
+        
+        VideoPreviewCell *videoCell = (VideoPreviewCell *)cell;
+
+        [videoCell.playerView pauseVideo];
+    }
+}
+
+
+#pragma mark - CollectionView DataSource
+
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
+    return self.photos.count;
+}
+
+- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSDictionary *item = [self.photos objectAtIndex:indexPath.row];
+    NSString *type = [item objectForKey:@"type"];
+    
+    if ([type isEqualToString:@"image"]) {
+        
+        PhotoPreviewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PhotoPreviewCell" forIndexPath:indexPath];
+        cell.scrollView.delegate = self;
+        return cell;
+        
+    } else if ([type isEqualToString:@"video"]) {
+        
+        VideoPreviewCell *videoCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"VideoPreviewCell" forIndexPath:indexPath];
+        videoCell.playerView.webView.backgroundColor = [UIColor blackColor];
+        return videoCell;
+    }
+    
+    return nil;
+}
+
+#pragma mark - ScrollView Delegate
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
+    if (scrollView == self.previewContainer) {
+        CGFloat x = scrollView.contentOffset.x / scrollView.frame.size.width;
+        int idx = (int)x;
+        if (idx == x) {
+            if (self.currentIndex != idx) {
+                self.currentIndex = idx;
+            }
+        }
+    }
+}
+
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
+    if (scrollView != self.previewContainer) {
+        return scrollView.subviews.firstObject;
+    }
+    return nil;
+}
+
+- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
+    
+    if (self.previewContainer != scrollView) {
+        
+
+    }
+}
+
+#pragma mark - Private
+
+
+- (void) photoCell:(PhotoPreviewCell *)cell loadImage:(NSDictionary *)item_json {
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    NSString* img_url = [item_json valueForKey:@"s"];
+    NSString* type = item_json[@"type"];
+    
+    NSString* file_name=[img_url lastPathComponent];
+    NSData* img_data=nil;
+    
+    //  加载Image
+    if([type isEqualToString:@"video"])
+    {
+        img_data = UIImagePNGRepresentation([UIImage imageNamed:@"play"]);
+    }
+    else
+    {
+        if([item_json[@"is_localfile"] boolValue])
+            img_data = [NSData dataWithContentsOfFile:img_url];
+        else
+            [iSalesDB load_cached_img:file_name loadFrom:img_url];
+    }
+    
+    // 设置Image
+    if(img_data!=nil)
+    {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            UIImage * img =[UIImage imageWithData:img_data];
+            
+            [cell setPhoto:img];
+            
+        });
+    }
+    else
+    {
+        NSData*  downloadimg_data = nil;
+        if (!appDelegate.offline_mode) {
+            downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+        }
+        dispatch_async(dispatch_get_main_queue(), ^{
+            
+            
+            
+            if(downloadimg_data!=nil)
+            {
+                
+                [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                
+                UIImage * img =[UIImage imageWithData:downloadimg_data];
+                [cell setPhoto:img];
+
+                
+            }
+            else
+            {
+                
+                
+                UIImage * img =[UIImage imageNamed:@"notfound_l"];
+                [cell setPhoto:img];
+
+                
+            }
+            
+        });
+    }
+    
+}
+
+- (IBAction)closeBtnClick:(UIButton *)sender {
+    
+    self.navigationController.navigationBarHidden = self.hideNavigationBar;
+    [self.navigationController popViewControllerAnimated:YES];
+    
+}
+
+
+@end

+ 161 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/Storyboard/PhotoList.storyboard

@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina5_5" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Content Preview Controller-->
+        <scene sceneID="U3N-xr-7Rz">
+            <objects>
+                <viewController storyboardIdentifier="ContentPreviewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="qZK-Vy-gaw" customClass="ContentPreviewController" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="mc4-Qg-2g3"/>
+                        <viewControllerLayoutGuide type="bottom" id="0pB-uU-kJr"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="qtX-co-R7G">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="eUk-3I-LIa">
+                                <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
+                                <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="AhJ-66-sid">
+                                    <size key="itemSize" width="414" height="735"/>
+                                    <size key="headerReferenceSize" width="0.0" height="0.0"/>
+                                    <size key="footerReferenceSize" width="0.0" height="0.0"/>
+                                    <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                </collectionViewFlowLayout>
+                                <cells>
+                                    <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="PhotoPreviewCell" id="eAR-El-bRn" customClass="PhotoPreviewCell">
+                                        <rect key="frame" x="0.0" y="0.66666666666666663" width="414" height="735"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+                                            <rect key="frame" x="0.0" y="0.0" width="414" height="735"/>
+                                            <autoresizingMask key="autoresizingMask"/>
+                                            <subviews>
+                                                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" minimumZoomScale="0.5" maximumZoomScale="3" translatesAutoresizingMaskIntoConstraints="NO" id="5Dl-d3-MLq">
+                                                    <rect key="frame" x="0.0" y="0.0" width="414" height="735"/>
+                                                    <subviews>
+                                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sni-z4-WnW">
+                                                            <rect key="frame" x="0.0" y="0.0" width="414" height="734.66666666666663"/>
+                                                            <subviews>
+                                                                <imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0p1-c6-dGo">
+                                                                    <rect key="frame" x="0.0" y="0.0" width="414" height="734.66666666666663"/>
+                                                                </imageView>
+                                                            </subviews>
+                                                            <constraints>
+                                                                <constraint firstItem="0p1-c6-dGo" firstAttribute="centerY" secondItem="sni-z4-WnW" secondAttribute="centerY" id="8UX-6e-CRi"/>
+                                                                <constraint firstItem="0p1-c6-dGo" firstAttribute="centerX" secondItem="sni-z4-WnW" secondAttribute="centerX" id="Cw9-JE-ar8"/>
+                                                                <constraint firstItem="0p1-c6-dGo" firstAttribute="width" secondItem="sni-z4-WnW" secondAttribute="width" id="d0G-UK-DXO"/>
+                                                                <constraint firstItem="0p1-c6-dGo" firstAttribute="height" secondItem="sni-z4-WnW" secondAttribute="height" id="pjY-2k-kdy"/>
+                                                            </constraints>
+                                                        </view>
+                                                    </subviews>
+                                                    <constraints>
+                                                        <constraint firstItem="sni-z4-WnW" firstAttribute="top" secondItem="5Dl-d3-MLq" secondAttribute="top" id="3mP-Sy-8ZJ"/>
+                                                        <constraint firstItem="sni-z4-WnW" firstAttribute="centerX" secondItem="5Dl-d3-MLq" secondAttribute="centerX" id="4c9-Zy-NsD"/>
+                                                        <constraint firstItem="sni-z4-WnW" firstAttribute="centerY" secondItem="5Dl-d3-MLq" secondAttribute="centerY" id="GGY-7p-nOf"/>
+                                                        <constraint firstAttribute="trailing" secondItem="sni-z4-WnW" secondAttribute="trailing" id="PVO-l2-aPm"/>
+                                                        <constraint firstAttribute="bottom" secondItem="sni-z4-WnW" secondAttribute="bottom" id="WIV-ve-oT1"/>
+                                                        <constraint firstItem="sni-z4-WnW" firstAttribute="leading" secondItem="5Dl-d3-MLq" secondAttribute="leading" id="rd8-QD-VTS"/>
+                                                    </constraints>
+                                                </scrollView>
+                                            </subviews>
+                                        </view>
+                                        <constraints>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="width" secondItem="eAR-El-bRn" secondAttribute="width" id="OwB-eR-E1R"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="centerY" secondItem="eAR-El-bRn" secondAttribute="centerY" id="hQv-Uz-CBO"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="centerX" secondItem="eAR-El-bRn" secondAttribute="centerX" id="nsu-Oh-hQQ"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="height" secondItem="eAR-El-bRn" secondAttribute="height" id="wst-oN-7pA"/>
+                                        </constraints>
+                                        <size key="customSize" width="414" height="735"/>
+                                        <connections>
+                                            <outlet property="photoView" destination="0p1-c6-dGo" id="FII-Mz-9Qt"/>
+                                            <outlet property="scrollContentView" destination="sni-z4-WnW" id="hob-7H-hG5"/>
+                                            <outlet property="scrollView" destination="5Dl-d3-MLq" id="2Gj-Oc-6rO"/>
+                                        </connections>
+                                    </collectionViewCell>
+                                    <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="VideoPreviewCell" id="fb9-eB-NDG" customClass="VideoPreviewCell">
+                                        <rect key="frame" x="424" y="0.66666666666666663" width="414" height="735"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+                                            <rect key="frame" x="0.0" y="0.0" width="414" height="735"/>
+                                            <autoresizingMask key="autoresizingMask"/>
+                                            <subviews>
+                                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="g1h-px-8Fa" customClass="YTPlayerView">
+                                                    <rect key="frame" x="0.0" y="-0.33333333333331439" width="414" height="735.33333333333326"/>
+                                                    <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                                </view>
+                                            </subviews>
+                                        </view>
+                                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                        <constraints>
+                                            <constraint firstItem="g1h-px-8Fa" firstAttribute="centerY" secondItem="fb9-eB-NDG" secondAttribute="centerY" id="EEY-c6-vl9"/>
+                                            <constraint firstItem="g1h-px-8Fa" firstAttribute="height" secondItem="fb9-eB-NDG" secondAttribute="height" id="SKL-jo-Lzt"/>
+                                            <constraint firstItem="g1h-px-8Fa" firstAttribute="centerX" secondItem="fb9-eB-NDG" secondAttribute="centerX" id="h5h-8v-rGk"/>
+                                            <constraint firstItem="g1h-px-8Fa" firstAttribute="width" secondItem="fb9-eB-NDG" secondAttribute="width" id="k9d-ie-GeL"/>
+                                        </constraints>
+                                        <size key="customSize" width="414" height="735"/>
+                                        <connections>
+                                            <outlet property="playerView" destination="g1h-px-8Fa" id="Ydw-01-j1F"/>
+                                        </connections>
+                                    </collectionViewCell>
+                                </cells>
+                                <connections>
+                                    <outlet property="dataSource" destination="qZK-Vy-gaw" id="2qY-wX-LI0"/>
+                                    <outlet property="delegate" destination="qZK-Vy-gaw" id="Fnz-nQ-4PE"/>
+                                </connections>
+                            </collectionView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1 / 8" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="x3F-Hb-jne">
+                                <rect key="frame" x="167" y="30" width="80" height="40"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="80" id="4nS-MH-dz0"/>
+                                    <constraint firstAttribute="height" constant="40" id="jTZ-mK-h0Z"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0RT-6b-F9T">
+                                <rect key="frame" x="374" y="20" width="30" height="30"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="30" id="EfS-6B-vnU"/>
+                                    <constraint firstAttribute="width" constant="30" id="Usq-qx-7G1"/>
+                                </constraints>
+                                <state key="normal" image="iv_close"/>
+                                <connections>
+                                    <action selector="closeBtnClick:" destination="qZK-Vy-gaw" eventType="touchUpInside" id="JTL-8z-Gma"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstAttribute="trailing" secondItem="0RT-6b-F9T" secondAttribute="trailing" constant="10" id="1bv-tN-nCS"/>
+                            <constraint firstItem="0RT-6b-F9T" firstAttribute="top" secondItem="mc4-Qg-2g3" secondAttribute="bottom" id="7h0-ww-k6I"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="centerX" secondItem="qtX-co-R7G" secondAttribute="centerX" id="Occ-gY-Cbn"/>
+                            <constraint firstItem="x3F-Hb-jne" firstAttribute="top" secondItem="mc4-Qg-2g3" secondAttribute="bottom" constant="10" id="PCn-1c-2Pu"/>
+                            <constraint firstItem="x3F-Hb-jne" firstAttribute="centerX" secondItem="qtX-co-R7G" secondAttribute="centerX" id="Vpc-xd-gDa"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="height" secondItem="qtX-co-R7G" secondAttribute="height" id="dad-0B-yAf"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="width" secondItem="qtX-co-R7G" secondAttribute="width" id="nY6-mM-Sjc"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="centerY" secondItem="qtX-co-R7G" secondAttribute="centerY" id="ygr-Ka-rvN"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="indicator" destination="x3F-Hb-jne" id="JGA-vq-BPK"/>
+                        <outlet property="previewContainer" destination="eUk-3I-LIa" id="TYz-ym-JNG"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="sWf-Id-XaR" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1871.0144927536232" y="50.54347826086957"/>
+        </scene>
+    </scenes>
+    <resources>
+        <image name="iv_close" width="32" height="32"/>
+    </resources>
+</document>

+ 19 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/View/PhotoPreviewCell.h

@@ -0,0 +1,19 @@
+//
+//  PhotoPreviewCell.h
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PhotoPreviewCell : UICollectionViewCell
+
+@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
+@property (strong, nonatomic) IBOutlet UIView *scrollContentView;
+@property (nonatomic,strong) IBOutlet UIImageView *photoView;
+
+- (void)setPhoto:(UIImage *)image;
+
+@end

+ 39 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/View/PhotoPreviewCell.m

@@ -0,0 +1,39 @@
+//
+//  PhotoPreviewCell.m
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "PhotoPreviewCell.h"
+
+@implementation PhotoPreviewCell
+
+- (void)setPhoto:(UIImage *)image {
+    if (self.photoView) {
+        
+//        CGFloat width = self.bounds.size.width;
+//        CGFloat height = self.bounds.size.height;
+//        
+//        CGFloat w = image.size.width;
+//        CGFloat h = image.size.height;
+//        // 根据图片大小和ScrollView大小等比缩放,使ScrollView容得下图片
+//        float factor = width / w;
+//        w = w * factor;
+//        h = h * factor;
+//        CGRect frame = CGRectMake(0, (height - h) * 0.5, w, h);
+//
+//        self.photoView.frame = frame;
+        
+        self.photoView.image = image;
+    }
+}
+
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    
+}
+
+
+@end

+ 18 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/View/VideoPreviewCell.h

@@ -0,0 +1,18 @@
+//
+//  VideoPreviewCell.h
+//  iSales-NPD
+//
+//  Created by Jack on 2017/6/21.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "YTPlayerView.h"
+
+@interface VideoPreviewCell : UICollectionViewCell
+
+@property (nonatomic,strong) NSDictionary *item;
+
+@property (strong, nonatomic) IBOutlet YTPlayerView *playerView;
+
+@end

+ 35 - 0
RedAnt ERP Mobile/iSales-NPD/PhotoList/View/VideoPreviewCell.m

@@ -0,0 +1,35 @@
+//
+//  VideoPreviewCell.m
+//  iSales-NPD
+//
+//  Created by Jack on 2017/6/21.
+//  Copyright © 2017年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "VideoPreviewCell.h"
+
+@implementation VideoPreviewCell
+
+- (void)setItem:(NSDictionary *)item {
+    _item = item;
+    if (item) {
+        NSString* video_code=item[@"code"];
+
+        NSString* video_id=[self.playerView Embed2VID:video_code];
+        
+        NSDictionary *playerVars = @{
+                                     @"playsinline" : @1,
+                                     @"autoplay" : @(1),
+                                     @"rel":@0,
+                                     @"showinfo": @0,
+                                     @"modestbranding":@0,
+                                     @"enablejsapi":@1
+                                     };
+        
+        [self.playerView loadWithVideoId:video_id playerVars:playerVars];
+        
+        self.playerView.webView.allowsPictureInPictureMediaPlayback=false;
+    }
+}
+
+@end