Răsfoiți Sursa

增加拍照功能 图片查看大图功能

fancy 5 ani în urmă
părinte
comite
941ed4d217

+ 0 - 53
o2ios/O2Platform.xcodeproj/project.pbxproj

@@ -1030,13 +1030,6 @@
 			remoteGlobalIDString = 5F72A30590D0D18EC2C2BBC2D902C6D1;
 			remoteInfo = BetterSegmentedControl;
 		};
-		B10AC59221058DAE00179587 /* PBXContainerItemProxy */ = {
-			isa = PBXContainerItemProxy;
-			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
-			proxyType = 2;
-			remoteGlobalIDString = E18B1C0DEBD04E12A5DC8B40B7BF5150;
-			remoteInfo = BSGridCollectionViewLayout;
-		};
 		B10AC59421058DAE00179587 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
@@ -1044,13 +1037,6 @@
 			remoteGlobalIDString = D13C7C5DC1991163C85D47D9B72B42DD;
 			remoteInfo = BSImagePicker;
 		};
-		B10AC59621058DAE00179587 /* PBXContainerItemProxy */ = {
-			isa = PBXContainerItemProxy;
-			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
-			proxyType = 2;
-			remoteGlobalIDString = 797083F5F27AFF01045BE4809698B5C1;
-			remoteInfo = "BSImagePicker-BSImagePicker";
-		};
 		B10AC59A21058DAE00179587 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
@@ -1261,13 +1247,6 @@
 			remoteGlobalIDString = 85979644862830BD1DFFD1D60F0D64AE;
 			remoteInfo = RxAtomic;
 		};
-		B1BC8CD5216B1F0B00AF571F /* PBXContainerItemProxy */ = {
-			isa = PBXContainerItemProxy;
-			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
-			proxyType = 2;
-			remoteGlobalIDString = 8B824035EFF627D7343420A8E0BC044B;
-			remoteInfo = BSImageView;
-		};
 		B1F79C77233B5F9B004D0AEE /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = E4E7755421017DB4006ED7FC /* Pods.xcodeproj */;
@@ -2534,10 +2513,7 @@
 				B10AC58D21058DAE00179587 /* AlamofireNetworkActivityIndicator.framework */,
 				B10AC58F21058DAE00179587 /* AlamofireObjectMapper.framework */,
 				B10AC59121058DAE00179587 /* BetterSegmentedControl.framework */,
-				B10AC59321058DAE00179587 /* BSGridCollectionViewLayout.framework */,
 				B10AC59521058DAE00179587 /* BSImagePicker.framework */,
-				B10AC59721058DAE00179587 /* BSImagePicker.bundle */,
-				B1BC8CD6216B1F0B00AF571F /* BSImageView.framework */,
 				B10AC59B21058DAE00179587 /* Charts.framework */,
 				B1F79C78233B5F9B004D0AEE /* Chrysan.framework */,
 				B1F79C7A233B5F9B004D0AEE /* Chrysan.bundle */,
@@ -5197,13 +5173,6 @@
 			remoteRef = B10AC59021058DAE00179587 /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
-		B10AC59321058DAE00179587 /* BSGridCollectionViewLayout.framework */ = {
-			isa = PBXReferenceProxy;
-			fileType = wrapper.framework;
-			path = BSGridCollectionViewLayout.framework;
-			remoteRef = B10AC59221058DAE00179587 /* PBXContainerItemProxy */;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
 		B10AC59521058DAE00179587 /* BSImagePicker.framework */ = {
 			isa = PBXReferenceProxy;
 			fileType = wrapper.framework;
@@ -5211,13 +5180,6 @@
 			remoteRef = B10AC59421058DAE00179587 /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
-		B10AC59721058DAE00179587 /* BSImagePicker.bundle */ = {
-			isa = PBXReferenceProxy;
-			fileType = wrapper.cfbundle;
-			path = BSImagePicker.bundle;
-			remoteRef = B10AC59621058DAE00179587 /* PBXContainerItemProxy */;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
 		B10AC59B21058DAE00179587 /* Charts.framework */ = {
 			isa = PBXReferenceProxy;
 			fileType = wrapper.framework;
@@ -5428,13 +5390,6 @@
 			remoteRef = B1AE4E6321A3F53A00183FCD /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
-		B1BC8CD6216B1F0B00AF571F /* BSImageView.framework */ = {
-			isa = PBXReferenceProxy;
-			fileType = wrapper.framework;
-			path = BSImageView.framework;
-			remoteRef = B1BC8CD5216B1F0B00AF571F /* PBXContainerItemProxy */;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
 		B1F79C78233B5F9B004D0AEE /* Chrysan.framework */ = {
 			isa = PBXReferenceProxy;
 			fileType = wrapper.framework;
@@ -5722,9 +5677,7 @@
 				"${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework",
 				"${BUILT_PRODUCTS_DIR}/AlamofireNetworkActivityIndicator/AlamofireNetworkActivityIndicator.framework",
 				"${BUILT_PRODUCTS_DIR}/AlamofireObjectMapper/AlamofireObjectMapper.framework",
-				"${BUILT_PRODUCTS_DIR}/BSGridCollectionViewLayout/BSGridCollectionViewLayout.framework",
 				"${BUILT_PRODUCTS_DIR}/BSImagePicker/BSImagePicker.framework",
-				"${BUILT_PRODUCTS_DIR}/BSImageView/BSImageView.framework",
 				"${BUILT_PRODUCTS_DIR}/BetterSegmentedControl/BetterSegmentedControl.framework",
 				"${BUILT_PRODUCTS_DIR}/Charts/Charts.framework",
 				"${BUILT_PRODUCTS_DIR}/Chrysan/Chrysan.framework",
@@ -5765,9 +5718,7 @@
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireImage.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireNetworkActivityIndicator.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireObjectMapper.framework",
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSGridCollectionViewLayout.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSImagePicker.framework",
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSImageView.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BetterSegmentedControl.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Charts.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Chrysan.framework",
@@ -6801,8 +6752,6 @@
 					"-framework",
 					"\"AlamofireObjectMapper\"",
 					"-framework",
-					"\"BSGridCollectionViewLayout\"",
-					"-framework",
 					"\"BSImagePicker\"",
 					"-framework",
 					"\"Charts\"",
@@ -6916,8 +6865,6 @@
 					"-framework",
 					"\"AlamofireObjectMapper\"",
 					"-framework",
-					"\"BSGridCollectionViewLayout\"",
-					"-framework",
 					"\"BSImagePicker\"",
 					"-framework",
 					"\"Charts\"",

+ 4 - 6
o2ios/O2Platform/App/Cms-内容管理/c/CMSItemDetailViewController.swift

@@ -306,9 +306,8 @@ extension CMSItemDetailViewController: O2WKScriptMessageHandlerImplement {
         self.uploadAttachment(site, uploadURL: updloadURL!)
     }
     private func uploadAttachment(_ site:String,uploadURL url:String){
-        let vc = FileBSImagePickerViewController()
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in
@@ -509,9 +508,8 @@ extension CMSItemDetailViewController: O2WKScriptMessageHandlerImplement {
     
     
     private func replaceAttachment(_ site:String,_ attachmentId:String,replaceURL url:String){
-        let vc = FileBSImagePickerViewController()
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in

+ 47 - 28
o2ios/O2Platform/App/File-云盘/c/FileBSImagePickerViewController.swift

@@ -9,34 +9,53 @@
 import UIKit
 import BSImagePicker
 
-class FileBSImagePickerViewController: BSImagePickerViewController {
- 
-    var defaultmaxNumberOfSelections = 1
-    var defaultTakePhotos = true
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        self.navigationBar.isTranslucent = false
-        self.navigationBar.barTintColor = navbar_barTint_color
-        self.navigationBar.tintColor = navbar_tint_color
-        self.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:navbar_text_font,NSAttributedString.Key.foregroundColor:navbar_tint_color]
-        self.albumButton.setTitleColor(navbar_tint_color, for: .normal)
-        self.settings.maxNumberOfSelections = defaultmaxNumberOfSelections
-        self.settings.takePhotos = defaultTakePhotos
-        
-        
-        //隐藏返回按钮文字
-        let barItem = UIBarButtonItem.appearance()
-        let offset = UIOffset(horizontal: -200, vertical: 0)
-        barItem.setBackButtonTitlePositionAdjustment(offset, for: .default)
-        barItem.setTitleTextAttributes([NSAttributedString.Key.font:navbar_item_font,NSAttributedString.Key.foregroundColor:navbar_tint_color], for:UIControl.State())
-
-        // Do any additional setup after loading the view.
-    }
+struct FileBSImagePickerViewController {
     
-    override var preferredStatusBarStyle : UIStatusBarStyle {
-        return .lightContent
+    func bsImagePicker() -> BSImagePicker.ImagePickerController {
+        let picker = BSImagePicker.ImagePickerController()
+        picker.albumButton.setTitleColor(navbar_tint_color, for: .normal)
+        picker.settings.selection.max = 1
+        picker.settings.theme.selectionStyle = .checked
+        picker.settings.selection.unselectOnReachingMax = true
+        picker.navigationBar.isTranslucent = false
+        picker.navigationBar.barTintColor = navbar_barTint_color
+        picker.navigationBar.tintColor = navbar_tint_color
+        picker.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:navbar_text_font,NSAttributedString.Key.foregroundColor:navbar_tint_color]
+        
+        return picker
     }
-    
-    
-
 }
+
+//class FileBSImagePickerViewController: BSImagePicker.ImagePickerController {
+//
+//    var defaultmaxNumberOfSelections = 1
+//    var defaultTakePhotos = true
+//    override func viewDidLoad() {
+//        super.viewDidLoad()
+//        self.navigationBar.isTranslucent = false
+//        self.navigationBar.barTintColor = navbar_barTint_color
+//        self.navigationBar.tintColor = navbar_tint_color
+//        self.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:navbar_text_font,NSAttributedString.Key.foregroundColor:navbar_tint_color]
+//
+////        self.albumButton.setTitleColor(navbar_tint_color, for: .normal)
+////        self.settings.maxNumberOfSelections = defaultmaxNumberOfSelections
+////        self.settings.takePhotos = defaultTakePhotos
+//
+//
+//
+//        //隐藏返回按钮文字
+//        let barItem = UIBarButtonItem.appearance()
+//        let offset = UIOffset(horizontal: -200, vertical: 0)
+//        barItem.setBackButtonTitlePositionAdjustment(offset, for: .default)
+//        barItem.setTitleTextAttributes([NSAttributedString.Key.font:navbar_item_font,NSAttributedString.Key.foregroundColor:navbar_tint_color], for:UIControl.State())
+//
+//        // Do any additional setup after loading the view.
+//    }
+//
+//    override var preferredStatusBarStyle : UIStatusBarStyle {
+//        return .lightContent
+//    }
+//
+//
+//
+//}

+ 2 - 3
o2ios/O2Platform/App/File-云盘/c/MainFileViewController.swift

@@ -285,7 +285,6 @@ class MainFileViewController: UIViewController {
     }
     
     func uploadFile(){
-        let vc = FileBSImagePickerViewController()
         var url = ""
         if self.folderQueue.count == 0 {
             url = AppDelegate.o2Collect.generateURLWithAppContextKey(FileContext.fileContextKey, query: FileContext.fileUploadTopQuery, parameter: nil,coverted: true)!
@@ -293,8 +292,8 @@ class MainFileViewController: UIViewController {
             url = AppDelegate.o2Collect.generateURLWithAppContextKey(FileContext.fileContextKey, query: FileContext.fileUploadSubQuery, parameter: ["##id##":(self.folderQueue.last?.id!)! as AnyObject],coverted: true)!
         }
         url = url.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in

+ 336 - 251
o2ios/O2Platform/App/IM-聊天/IMChatViewController.swift

@@ -14,6 +14,7 @@ import Photos
 import Alamofire
 import AlamofireImage
 import SwiftyJSON
+import QuickLook
 
 class IMChatViewController: UIViewController {
 
@@ -34,6 +35,10 @@ class IMChatViewController: UIViewController {
         view.frame = CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: emojiBarHeight.toCGFloat)
         return view
     }()
+    //预览文件
+    private lazy var previewVC: CloudFilePreviewController = {
+        return CloudFilePreviewController()
+    }()
 
     private lazy var viewModel: IMViewModel = {
         return IMViewModel()
@@ -74,309 +79,389 @@ class IMChatViewController: UIViewController {
                     if p != O2AuthSDK.shared.myInfo()?.distinguishedName {
                         person = p
                     }
-                    })
-                    if !person.isEmpty {
-                        self.title = person.split("@").first ?? ""
-                    }
+                })
+                if !person.isEmpty {
+                    self.title = person.split("@").first ?? ""
                 }
-            } else {
-                self.title = self.conversation?.title
             }
-            //获取聊天数据
-            self.loadMsgList(page: page)
-            //阅读
-            self.viewModel.readConversation(conversationId: self.conversation?.id)
+        } else {
+            self.title = self.conversation?.title
         }
+        //获取聊天数据
+        self.loadMsgList(page: page)
+        //阅读
+        self.viewModel.readConversation(conversationId: self.conversation?.id)
+    }
 
-        override func viewWillAppear(_ animated: Bool) {
-            NotificationCenter.default.addObserver(self, selector: #selector(receiveMessageFromWs(notice:)), name: OONotification.websocket.notificationName, object: nil)
-        }
-        override func viewWillDisappear(_ animated: Bool) {
-            NotificationCenter.default.removeObserver(self)
-        }
+    override func viewWillAppear(_ animated: Bool) {
+        NotificationCenter.default.addObserver(self, selector: #selector(receiveMessageFromWs(notice:)), name: OONotification.websocket.notificationName, object: nil)
+    }
+    override func viewWillDisappear(_ animated: Bool) {
+        NotificationCenter.default.removeObserver(self)
+    }
 
 
-        @objc private func receiveMessageFromWs(notice: Notification) {
-            DDLogDebug("接收到websocket im 消息")
-            if let message = notice.object as? IMMessageInfo {
-                if message.conversationId == self.conversation?.id {
-                    self.chatMessageList.append(message)
-                    self.scrollMessageToBottom()
-                    self.viewModel.readConversation(conversationId: self.conversation?.id)
-                }
+    @objc private func receiveMessageFromWs(notice: Notification) {
+        DDLogDebug("接收到websocket im 消息")
+        if let message = notice.object as? IMMessageInfo {
+            if message.conversationId == self.conversation?.id {
+                self.chatMessageList.append(message)
+                self.scrollMessageToBottom()
+                self.viewModel.readConversation(conversationId: self.conversation?.id)
             }
         }
+    }
 
-        //获取消息
-        private func loadMsgList(page: Int) {
-            if let c = self.conversation, let id = c.id {
-                self.viewModel.myMsgPageList(page: page, conversationId: id).then { (list) in
-                    self.chatMessageList = list
-                    self.scrollMessageToBottom()
-                }
-            } else {
-                self.showError(title: "参数错误!!!")
+    //获取消息
+    private func loadMsgList(page: Int) {
+        if let c = self.conversation, let id = c.id {
+            self.viewModel.myMsgPageList(page: page, conversationId: id).then { (list) in
+                self.chatMessageList = list
+                self.scrollMessageToBottom()
             }
+        } else {
+            self.showError(title: "参数错误!!!")
         }
-        //刷新tableview 滚动到底部
-        private func scrollMessageToBottom() {
-            DispatchQueue.main.async {
-                self.tableView.reloadData()
-                if self.chatMessageList.count > 0 {
-                    self.tableView.scrollToRow(at: IndexPath(row: self.chatMessageList.count - 1, section: 0), at: .bottom, animated: true)
-                }
+    }
+    //刷新tableview 滚动到底部
+    private func scrollMessageToBottom() {
+        DispatchQueue.main.async {
+            self.tableView.reloadData()
+            if self.chatMessageList.count > 0 {
+                self.tableView.scrollToRow(at: IndexPath(row: self.chatMessageList.count - 1, section: 0), at: .bottom, animated: true)
             }
         }
+    }
 
-        //发送文本消息
-        private func sendTextMessage() {
-            guard let msg = self.messageInputView.text else {
-                return
-            }
-            self.messageInputView.text = ""
-            let body = IMMessageBodyInfo()
-            body.type = o2_im_msg_type_text
-            body.body = msg
-            sendMessage(body: body)
-        }
-        //发送表情消息
-        private func sendEmojiMessage(emoji: String) {
-            let body = IMMessageBodyInfo()
-            body.type = o2_im_msg_type_emoji
-            body.body = emoji
-            sendMessage(body: body)
+    //发送文本消息
+    private func sendTextMessage() {
+        guard let msg = self.messageInputView.text else {
+            return
         }
+        self.messageInputView.text = ""
+        let body = IMMessageBodyInfo()
+        body.type = o2_im_msg_type_text
+        body.body = msg
+        sendMessage(body: body)
+    }
+    //发送表情消息
+    private func sendEmojiMessage(emoji: String) {
+        let body = IMMessageBodyInfo()
+        body.type = o2_im_msg_type_emoji
+        body.body = emoji
+        sendMessage(body: body)
+    }
 
+    //发送消息到服务器
+    private func sendMessage(body: IMMessageBodyInfo) {
+        let message = IMMessageInfo()
+        message.body = body.toJSONString()
+        message.id = UUID().uuidString
+        message.conversationId = self.conversation?.id
+        message.createPerson = O2AuthSDK.shared.myInfo()?.distinguishedName
+        message.createTime = Date().formatterDate(formatter: "yyyy-MM-dd HH:mm:ss")
+        //添加到界面
+        self.chatMessageList.append(message)
+        self.scrollMessageToBottom()
         //发送消息到服务器
-        private func sendMessage(body: IMMessageBodyInfo) {
-            let message = IMMessageInfo()
-            message.body = body.toJSONString()
-            message.id = UUID().uuidString
-            message.conversationId = self.conversation?.id
-            message.createPerson = O2AuthSDK.shared.myInfo()?.distinguishedName
-            message.createTime = Date().formatterDate(formatter: "yyyy-MM-dd HH:mm:ss")
-            //添加到界面
-            self.chatMessageList.append(message)
-            self.scrollMessageToBottom()
-            //发送消息到服务器
-            self.viewModel.sendMsg(msg: message)
-                .then { (result) in
-                    DDLogDebug("发送消息成功 \(result)")
-                    self.viewModel.readConversation(conversationId: self.conversation?.id)
-                }.catch { (error) in
-                    DDLogError(error.localizedDescription)
-                    self.showError(title: "发送消息失败!")
-            }
+        self.viewModel.sendMsg(msg: message)
+            .then { (result) in
+                DDLogDebug("发送消息成功 \(result)")
+                self.viewModel.readConversation(conversationId: self.conversation?.id)
+            }.catch { (error) in
+                DDLogError(error.localizedDescription)
+                self.showError(title: "发送消息失败!")
         }
+    }
 
-        //选择照片
-        private func chooseImageOrTakePhoto() {
-            let vc = FileBSImagePickerViewController()
-            bs_presentImagePickerController(vc, animated: true, select: { (asset) in
-                //选中一个
-            }, deselect: { (asset) in
-                    //取消选中一个
-                }, cancel: { (assets) in
-                    //取消
-                }, finish: { (assets) in
-                    //结果
-                    if assets.count > 0 {
-                        switch assets[0].mediaType {
-                        case .image:
-                            let options = PHImageRequestOptions()
-                            options.isSynchronous = true
-                            options.deliveryMode = .fastFormat
-                            options.resizeMode = .none
-                            PHImageManager.default().requestImageData(for: assets[0], options: options) { (imageData, result, imageOrientation, dict) in
-                                guard let data = imageData else {
-                                    return
-                                }
-                                var newData = data
-                                //处理图片旋转的问题
-                                if imageOrientation != UIImage.Orientation.up {
-                                    let newImage = UIImage(data: data)?.fixOrientation()
-                                    if newImage != nil {
-                                        newData = newImage!.pngData()!
-                                    }
-                                }
-                                var fileName = ""
-                                if dict?["PHImageFileURLKey"] != nil {
-                                    let fileURL = dict?["PHImageFileURLKey"] as! URL
-                                    fileName = fileURL.lastPathComponent
-                                } else {
-                                    fileName = "\(UUID().uuidString).png"
+    //选择照片
+    private func chooseImage() {
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        vc.settings.fetch.assets.supportedMediaTypes = [.image]
+
+        presentImagePicker(vc, select: { (asset) in
+            //选中一个
+        }, deselect: { (asset) in
+                //取消选中一个
+            }, cancel: { (assets) in
+                //取消
+            }, finish: { (assets) in
+                //结果
+                if assets.count > 0 {
+                    switch assets[0].mediaType {
+                    case .image:
+                        let options = PHImageRequestOptions()
+                        options.isSynchronous = true
+                        options.deliveryMode = .fastFormat
+                        options.resizeMode = .none
+                        PHImageManager.default().requestImageData(for: assets[0], options: options) { (imageData, result, imageOrientation, dict) in
+                            guard let data = imageData else {
+                                return
+                            }
+                            var newData = data
+                            //处理图片旋转的问题
+                            if imageOrientation != UIImage.Orientation.up {
+                                let newImage = UIImage(data: data)?.fixOrientation()
+                                if newImage != nil {
+                                    newData = newImage!.pngData()!
                                 }
-                                let localFilePath = self.storageLocalImage(imageData: newData, fileName: fileName)
-                                let msgId = self.prepareForSendImageMsg(filePath: localFilePath)
-                                self.uploadImageAndSendMsg(messageId: msgId, imageData: newData, fileName: fileName)
                             }
-                            break
-                        default:
-                            //
-                            DDLogError("不支持的类型")
-                            self.showError(title: "不支持的类型!")
-                            break
+                            var fileName = ""
+                            if dict?["PHImageFileURLKey"] != nil {
+                                let fileURL = dict?["PHImageFileURLKey"] as! URL
+                                fileName = fileURL.lastPathComponent
+                            } else {
+                                fileName = "\(UUID().uuidString).png"
+                            }
+                            let localFilePath = self.storageLocalImage(imageData: newData, fileName: fileName)
+                            let msgId = self.prepareForSendImageMsg(filePath: localFilePath)
+                            self.uploadImageAndSendMsg(messageId: msgId, imageData: newData, fileName: fileName)
                         }
+                        break
+                    default:
+                        //
+                        DDLogError("不支持的类型")
+                        self.showError(title: "不支持的类型!")
+                        break
                     }
-                }, completion: nil)
-        }
-        //临时存储本地
-        private func storageLocalImage(imageData: Data, fileName: String) -> String {
-            let fileTempPath = FileUtil.share.cacheDir().appendingPathComponent(fileName)
-            do {
-                try imageData.write(to: fileTempPath)
-                return fileTempPath.path
-            } catch {
-                print(error.localizedDescription)
-                return fileTempPath.path
-            }
-        }
-        //发送消息前 先载入界面
-        private func prepareForSendImageMsg(filePath: String) -> String {
-            let body = IMMessageBodyInfo()
-            body.type = o2_im_msg_type_image
-            body.body = o2_im_msg_body_image
-            body.fileTempPath = filePath
-            let message = IMMessageInfo()
-            let msgId = UUID().uuidString
-            message.body = body.toJSONString()
-            message.id = msgId
-            message.conversationId = self.conversation?.id
-            message.createPerson = O2AuthSDK.shared.myInfo()?.distinguishedName
-            message.createTime = Date().formatterDate(formatter: "yyyy-MM-dd HH:mm:ss")
-            //添加到界面
-            self.chatMessageList.append(message)
-            self.scrollMessageToBottom()
-            return msgId
+                }
+            }, completion: nil)
+    }
+    //临时存储本地
+    private func storageLocalImage(imageData: Data, fileName: String) -> String {
+        let fileTempPath = FileUtil.share.cacheDir().appendingPathComponent(fileName)
+        do {
+            try imageData.write(to: fileTempPath)
+            return fileTempPath.path
+        } catch {
+            print(error.localizedDescription)
+            return fileTempPath.path
         }
+    }
+    //发送消息前 先载入界面
+    private func prepareForSendImageMsg(filePath: String) -> String {
+        let body = IMMessageBodyInfo()
+        body.type = o2_im_msg_type_image
+        body.body = o2_im_msg_body_image
+        body.fileTempPath = filePath
+        let message = IMMessageInfo()
+        let msgId = UUID().uuidString
+        message.body = body.toJSONString()
+        message.id = msgId
+        message.conversationId = self.conversation?.id
+        message.createPerson = O2AuthSDK.shared.myInfo()?.distinguishedName
+        message.createTime = Date().formatterDate(formatter: "yyyy-MM-dd HH:mm:ss")
+        //添加到界面
+        self.chatMessageList.append(message)
+        self.scrollMessageToBottom()
+        return msgId
+    }
 
-        //上传图片到服务器并发送消息
-        private func uploadImageAndSendMsg(messageId: String, imageData: Data, fileName: String) {
-            guard let cId = self.conversation?.id else {
+    //上传图片到服务器并发送消息
+    private func uploadImageAndSendMsg(messageId: String, imageData: Data, fileName: String) {
+        guard let cId = self.conversation?.id else {
+            return
+        }
+        self.viewModel.uploadFile(conversationId: cId, type: o2_im_msg_type_image, fileName: fileName, file: imageData).then { attachId in
+            DDLogDebug("上传图片成功: \(attachId)")
+            guard let message = self.chatMessageList.first (where: { (info) -> Bool in
+                return info.id == messageId
+            }) else {
+                DDLogDebug("没有找到对应的消息")
                 return
             }
-            self.viewModel.uploadFile(conversationId: cId, type:o2_im_msg_type_image, fileName: fileName, file: imageData).then{ attachId in
-                DDLogDebug("上传图片成功: \(attachId)")
-                 guard let message = self.chatMessageList.first (where: { (info) -> Bool in
-                     return info.id == messageId
-                 }) else {
-                    DDLogDebug("没有找到对应的消息")
-                     return
-                 }
-                 let body = IMMessageBodyInfo.deserialize(from: message.body)
-                 body?.fileId = attachId
-                 body?.fileTempPath = nil
-                 message.body = body?.toJSONString()
-                 //发送消息到服务器
-                 self.viewModel.sendMsg(msg: message)
-                     .then { (result) in
-                         DDLogDebug("图片消息 发送成功 \(result)")
-                         self.viewModel.readConversation(conversationId: self.conversation?.id)
-                     }.catch { (error) in
-                         DDLogError(error.localizedDescription)
-                         self.showError(title: "发送消息失败!")
-                 }
-            }.catch { err in
-                self.showError(title: "上传错误,\(err.localizedDescription)")
+            let body = IMMessageBodyInfo.deserialize(from: message.body)
+            body?.fileId = attachId
+            body?.fileTempPath = nil
+            message.body = body?.toJSONString()
+            //发送消息到服务器
+            self.viewModel.sendMsg(msg: message)
+                .then { (result) in
+                    DDLogDebug("图片消息 发送成功 \(result)")
+                    self.viewModel.readConversation(conversationId: self.conversation?.id)
+                }.catch { (error) in
+                    DDLogError(error.localizedDescription)
+                    self.showError(title: "发送消息失败!")
             }
-            
-           
+        }.catch { err in
+            self.showError(title: "上传错误,\(err.localizedDescription)")
         }
 
 
-        // MARK: - IBAction
-        //点击表情按钮
-        @IBAction func clickEmojiBtn(_ sender: UIButton) {
-            self.isShowEmoji.toggle()
-            self.view.endEditing(true)
-            if self.isShowEmoji {
-                self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat + self.emojiBarHeight.toCGFloat
-                self.emojiBar.delegate = self
-                self.emojiBar.translatesAutoresizingMaskIntoConstraints = false
-                self.bottomBar.addSubview(self.emojiBar)
-                let top = NSLayoutConstraint(item: self.emojiBar, attribute: .top, relatedBy: .equal, toItem: self.emojiBar.superview!, attribute: .top, multiplier: 1, constant: CGFloat(self.bottomBarHeight))
-                let width = NSLayoutConstraint(item: self.emojiBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: SCREEN_WIDTH)
-                let height = NSLayoutConstraint(item: self.emojiBar, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: self.emojiBarHeight.toCGFloat)
-                NSLayoutConstraint.activate([top, width, height])
-            } else {
-                self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat
-                self.emojiBar.removeFromSuperview()
-            }
-            self.view.layoutIfNeeded()
-        }
+    }
 
-        @IBAction func micBtnClick(_ sender: UIButton) {
-            DDLogDebug("点击了麦克风按钮")
-        }
 
-        @IBAction func imgBtnClick(_ sender: UIButton) {
-            DDLogDebug("点击了图片按钮")
-            self.chooseImageOrTakePhoto()
-        }
-        @IBAction func cameraBtnClick(_ sender: UIButton) {
-            DDLogDebug("点击了相机按钮")
-        }
-        @IBAction func locationBtnClick(_ sender: UIButton) {
-            DDLogDebug("点击了位置按钮")
+    // MARK: - IBAction
+    //点击表情按钮
+    @IBAction func clickEmojiBtn(_ sender: UIButton) {
+        self.isShowEmoji.toggle()
+        self.view.endEditing(true)
+        if self.isShowEmoji {
+            self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat + self.emojiBarHeight.toCGFloat
+            self.emojiBar.delegate = self
+            self.emojiBar.translatesAutoresizingMaskIntoConstraints = false
+            self.bottomBar.addSubview(self.emojiBar)
+            let top = NSLayoutConstraint(item: self.emojiBar, attribute: .top, relatedBy: .equal, toItem: self.emojiBar.superview!, attribute: .top, multiplier: 1, constant: CGFloat(self.bottomBarHeight))
+            let width = NSLayoutConstraint(item: self.emojiBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: SCREEN_WIDTH)
+            let height = NSLayoutConstraint(item: self.emojiBar, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: self.emojiBarHeight.toCGFloat)
+            NSLayoutConstraint.activate([top, width, height])
+        } else {
+            self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat
+            self.emojiBar.removeFromSuperview()
         }
+        self.view.layoutIfNeeded()
+    }
 
-
+    @IBAction func micBtnClick(_ sender: UIButton) {
+        DDLogDebug("点击了麦克风按钮")
     }
 
-// MARK: - 表情点击 delegate
-    extension IMChatViewController: IMChatEmojiBarClickDelegate {
-        func clickEmoji(emoji: String) {
-            DDLogDebug("发送表情消息 \(emoji)")
-            self.sendEmojiMessage(emoji: emoji)
-        }
+    @IBAction func imgBtnClick(_ sender: UIButton) {
+        DDLogDebug("点击了图片按钮")
+        self.chooseImage()
+    }
+    @IBAction func cameraBtnClick(_ sender: UIButton) {
+        DDLogDebug("点击了相机按钮")
+        self.takePhoto(delegate: self)
+    }
+    @IBAction func locationBtnClick(_ sender: UIButton) {
+        DDLogDebug("点击了位置按钮")
     }
 
-// MARK: - tableview delegate
-    extension IMChatViewController: UITableViewDelegate, UITableViewDataSource {
 
-        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-            return self.chatMessageList.count
+}
+
+// MARK: - 拍照delegate
+extension IMChatViewController: UIImagePickerControllerDelegate & UINavigationControllerDelegate {
+
+    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
+        if let image = info[.editedImage] as? UIImage {
+            let fileName = "\(UUID().uuidString).png"
+            let newData = image.pngData()!
+            let localFilePath = self.storageLocalImage(imageData: newData, fileName: fileName)
+            let msgId = self.prepareForSendImageMsg(filePath: localFilePath)
+            self.uploadImageAndSendMsg(messageId: msgId, imageData: newData, fileName: fileName)
+        } else {
+            DDLogError("没有选择到图片!")
         }
+        picker.dismiss(animated: true, completion: nil)
+//        var newData = data
+//        //处理图片旋转的问题
+//        if imageOrientation != UIImage.Orientation.up {
+//            let newImage = UIImage(data: data)?.fixOrientation()
+//            if newImage != nil {
+//                newData = newImage!.pngData()!
+//            }
+//        }
+//        var fileName = ""
+//        if dict?["PHImageFileURLKey"] != nil {
+//            let fileURL = dict?["PHImageFileURLKey"] as! URL
+//            fileName = fileURL.lastPathComponent
+//        } else {
+//            fileName = "\(UUID().uuidString).png"
+//        }
+    }
 
-        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-            let msg = self.chatMessageList[indexPath.row]
-            if msg.createPerson == O2AuthSDK.shared.myInfo()?.distinguishedName { //发送者
-                if let cell = tableView.dequeueReusableCell(withIdentifier: "IMChatMessageSendViewCell", for: indexPath) as? IMChatMessageSendViewCell {
-                    cell.setContent(item: self.chatMessageList[indexPath.row])
-                    return cell
+}
+
+// MARK: - 图片消息点击 delegate
+extension IMChatViewController: IMChatMessageDelegate {
+    func clickImageMessage(fileId: String?, tempPath: String?) {
+        if let id = fileId {
+            self.showLoading()
+            O2IMFileManager.shared
+                .getFileLocalUrl(fileId: id)
+                .always {
+                    self.hideLoading()
+                }.then { (path) in
+                    let currentURL = NSURL(fileURLWithPath: path.path)
+                    DDLogDebug(currentURL.description)
+                    DDLogDebug(path.path)
+                    if QLPreviewController.canPreview(currentURL) {
+                        self.previewVC.currentFileURLS.removeAll()
+                        self.previewVC.currentFileURLS.append(currentURL)
+                        self.previewVC.reloadData()
+                        self.pushVC(self.previewVC)
+                    } else {
+                        self.showError(title: "当前文件类型不支持预览!")
+                    }
                 }
+                .catch { (error) in
+                    DDLogError(error.localizedDescription)
+                    self.showError(title: "获取文件异常!")
+            }
+        }else if let temp = tempPath {
+            let currentURL = NSURL(fileURLWithPath: temp)
+            DDLogDebug(currentURL.description)
+            DDLogDebug(temp)
+            if QLPreviewController.canPreview(currentURL) {
+                self.previewVC.currentFileURLS.removeAll()
+                self.previewVC.currentFileURLS.append(currentURL)
+                self.previewVC.reloadData()
+                self.pushVC(self.previewVC)
             } else {
-                if let cell = tableView.dequeueReusableCell(withIdentifier: "IMChatMessageViewCell", for: indexPath) as? IMChatMessageViewCell {
-                    cell.setContent(item: self.chatMessageList[indexPath.row])
-                    return cell
-                }
+                self.showError(title: "当前文件类型不支持预览!")
             }
-            return UITableViewCell()
         }
+    }
+}
+
+// MARK: - 表情点击 delegate
+extension IMChatViewController: IMChatEmojiBarClickDelegate {
+    func clickEmoji(emoji: String) {
+        DDLogDebug("发送表情消息 \(emoji)")
+        self.sendEmojiMessage(emoji: emoji)
+    }
+}
+
+// MARK: - tableview delegate
+extension IMChatViewController: UITableViewDelegate, UITableViewDataSource {
+
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return self.chatMessageList.count
+    }
 
-        func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-            tableView.deselectRow(at: indexPath, animated: false)
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let msg = self.chatMessageList[indexPath.row]
+        if msg.createPerson == O2AuthSDK.shared.myInfo()?.distinguishedName { //发送者
+            if let cell = tableView.dequeueReusableCell(withIdentifier: "IMChatMessageSendViewCell", for: indexPath) as? IMChatMessageSendViewCell {
+                cell.setContent(item: self.chatMessageList[indexPath.row])
+                cell.delegate = self
+                return cell
+            }
+        } else {
+            if let cell = tableView.dequeueReusableCell(withIdentifier: "IMChatMessageViewCell", for: indexPath) as? IMChatMessageViewCell {
+                cell.setContent(item: self.chatMessageList[indexPath.row])
+                cell.delegate = self
+                return cell
+            }
         }
+        return UITableViewCell()
+    }
 
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: false)
     }
 
+}
+
 // MARK: - textField delegate
-    extension IMChatViewController: UITextFieldDelegate {
-        func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
-            DDLogDebug("准备开始输入......")
-            closeEmoji()
-            return true
-        }
+extension IMChatViewController: UITextFieldDelegate {
+    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
+        DDLogDebug("准备开始输入......")
+        closeEmoji()
+        return true
+    }
 
-        private func closeEmoji() {
-            self.isShowEmoji = false
-            self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat
-            self.view.layoutIfNeeded()
-        }
+    private func closeEmoji() {
+        self.isShowEmoji = false
+        self.bottomBarHeightConstraint.constant = self.bottomBarHeight.toCGFloat
+        self.view.layoutIfNeeded()
+    }
 
-        func textFieldShouldReturn(_ textField: UITextField) -> Bool {
-            DDLogDebug("回车。。。。")
-            self.sendTextMessage()
-            return true
-        }
+    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
+        DDLogDebug("回车。。。。")
+        self.sendTextMessage()
+        return true
     }
+}

+ 42 - 0
o2ios/O2Platform/App/IM-聊天/O2IM.swift

@@ -7,6 +7,8 @@
 //
 
 import Foundation
+import Promises
+import CocoaLumberjack
 
 //心跳消息
 let o2_im_ws_heartbeat = "heartbeat"
@@ -33,3 +35,43 @@ func o2ImEmojiPath(emojiBody: String) -> String {
     }
     return ""
 }
+
+class O2IMFileManager {
+    static let shared: O2IMFileManager = {
+        return O2IMFileManager()
+    }()
+
+    private let communicateAPI = {
+        return OOMoyaProvider<CommunicateAPI>()
+    }()
+
+    private init() { }
+    //根据id下载文件,并返回文件的本地url
+    func getFileLocalUrl(fileId: String) -> Promise<URL> {
+        return Promise { fulfill, reject in
+            let url = self.localFilePath(fileId: fileId)
+            if FileUtil.share.fileExist(filePath: url.path) {
+                fulfill(url)
+            } else {
+                self.communicateAPI.request(.imDownloadFullFile(fileId), completion: { result in
+                        switch result {
+                        case .success(_):
+                            DDLogError("下载成功。。。。。\(fileId)")
+                            fulfill(url)
+                            break
+                        case .failure(let err):
+                            DDLogError(err.localizedDescription)
+                            reject(err)
+                            break
+                        }
+                    })
+            }
+        }
+
+    }
+
+    func localFilePath(fileId: String) -> URL {
+        return FileUtil.share.cacheDir().appendingPathComponent("\(fileId).png")
+    }
+
+}

+ 4 - 1
o2ios/O2Platform/App/IM-聊天/View/IMChatMessageSendViewCell.swift

@@ -17,7 +17,7 @@ class IMChatMessageSendViewCell: UITableViewCell {
     @IBOutlet weak var messageBgWidth: NSLayoutConstraint!
     @IBOutlet weak var messageBgHeight: NSLayoutConstraint!
     
-    
+    var delegate: IMChatMessageDelegate?
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -88,6 +88,9 @@ class IMChatMessageSendViewCell: UITableViewCell {
         }
         imageView.translatesAutoresizingMaskIntoConstraints = false
         self.messageBackgroundView.addSubview(imageView)
+        imageView.addTapGesture { (tap) in
+            self.delegate?.clickImageMessage(fileId: info.fileId, tempPath: info.fileTempPath)
+        }
         let top = NSLayoutConstraint(item: imageView, attribute: .top, relatedBy: .equal, toItem: imageView.superview!, attribute: .top, multiplier: 1, constant: 10)
         let bottom = NSLayoutConstraint(item: imageView.superview!, attribute: .bottom, relatedBy: .equal, toItem: imageView, attribute: .bottom, multiplier: 1, constant: 10)
         let left = NSLayoutConstraint(item: imageView, attribute: .leading, relatedBy: .equal, toItem: imageView.superview!, attribute: .leading, multiplier: 1, constant: 10)

+ 9 - 0
o2ios/O2Platform/App/IM-聊天/View/IMChatMessageViewCell.swift

@@ -9,6 +9,10 @@
 import UIKit
 import CocoaLumberjack
 
+protocol IMChatMessageDelegate {
+    func clickImageMessage(fileId: String?, tempPath: String?)
+}
+
 class IMChatMessageViewCell: UITableViewCell {
 
     @IBOutlet weak var avatarImage: UIImageView!
@@ -18,6 +22,8 @@ class IMChatMessageViewCell: UITableViewCell {
     @IBOutlet weak var messageBackgroundWidth: NSLayoutConstraint!
     @IBOutlet weak var messageBackgroundHeight: NSLayoutConstraint!
     private let messageWidth = 176
+    
+    var delegate: IMChatMessageDelegate?
 
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -140,6 +146,9 @@ class IMChatMessageViewCell: UITableViewCell {
         }
         imageView.translatesAutoresizingMaskIntoConstraints = false
         self.messageBackgroundView.addSubview(imageView)
+        imageView.addTapGesture { (tap) in
+            self.delegate?.clickImageMessage(fileId: info.fileId, tempPath: info.fileTempPath)
+        }
         let top = NSLayoutConstraint(item: imageView, attribute: .top, relatedBy: .equal, toItem: imageView.superview!, attribute: .top, multiplier: 1, constant: 10)
         let bottom = NSLayoutConstraint(item: imageView.superview!, attribute: .bottom, relatedBy: .equal, toItem: imageView, attribute: .bottom, multiplier: 1, constant: 10)
         let left = NSLayoutConstraint(item: imageView, attribute: .leading, relatedBy: .equal, toItem: imageView.superview!, attribute: .leading, multiplier: 1, constant: 10)

+ 4 - 6
o2ios/O2Platform/App/Work-工作/c/TodoTaskDetailViewController.swift

@@ -869,9 +869,8 @@ extension TodoTaskDetailViewController: O2WKScriptMessageHandlerImplement {
         self.uploadAttachment(site, uploadURL: updloadURL!)
     }
     private func uploadAttachment(_ site:String,uploadURL url:String){
-        let vc = FileBSImagePickerViewController()
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in
@@ -1056,9 +1055,8 @@ extension TodoTaskDetailViewController: O2WKScriptMessageHandlerImplement {
     }
     
     private func replaceAttachment(_ site:String,_ attachmentId:String,replaceURL url:String){
-        let vc = FileBSImagePickerViewController()
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in

+ 15 - 2
o2ios/O2Platform/Extension/UIViewController+Extension.swift

@@ -325,10 +325,23 @@ extension UIViewController {
 // MARK: - 业务工具
 extension UIViewController {
     
+    
+    func takePhoto(delegate: (UIImagePickerControllerDelegate & UINavigationControllerDelegate)?) {
+        var sourceType = UIImagePickerController.SourceType.camera
+        if !UIImagePickerController.isSourceTypeAvailable(sourceType) {
+            sourceType = .photoLibrary
+        }
+        let picker = UIImagePickerController()
+        picker.allowsEditing = true
+        picker.sourceType = sourceType
+        picker.delegate = delegate
+        self.present(picker, animated:true, completion:nil)//进入照相界面
+    }
+    
     //照片选择器
     func choosePhotoWithImagePicker(callback: @escaping (String, Data)-> Void) {
-        let chooseImage = FileBSImagePickerViewController()
-        self.bs_presentImagePickerController(chooseImage, animated: true, select: nil, deselect: nil, cancel: nil, finish: {
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: nil, deselect: nil, cancel: nil, finish: {
             (arr) in
             let count = arr.count
             print("选择了照片数量:\(count)")

+ 2 - 5
o2ios/O2Platform/Framework/JMessage/ChatModule/Chat/ViewController/JCChatViewController.swift

@@ -677,11 +677,8 @@ extension JCChatViewController: SAIToolboxInputViewDataSource, SAIToolboxInputVi
 //        present(vc, animated: true)
         
         
-        let vc = FileBSImagePickerViewController()
-        vc.defaultmaxNumberOfSelections = 9
-        vc.defaultTakePhotos = false
-        bs_presentImagePickerController(vc, animated: true,
-                                        select: { (asset: PHAsset) -> Void in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        presentImagePicker(vc, select: { (asset: PHAsset) -> Void in
                                             // User selected an asset.
                                             // Do something with it, start upload perhaps?
         }, deselect: { (asset: PHAsset) -> Void in

+ 12 - 1
o2ios/O2Platform/Framework/O2API/Communicate/CommunicateAPI.swift

@@ -19,6 +19,7 @@ enum CommunicateAPI {
     case instantMessageList(Int)
     case createConversation(IMConversationInfo)
     case imUploadFile(String, String, String, Data)
+    case imDownloadFullFile(String)
     
     
 }
@@ -60,12 +61,14 @@ extension CommunicateAPI: TargetType {
             return "/jaxrs/im/conversation"
         case .imUploadFile(let conversationId, let type, _, _):
             return "/jaxrs/im/msg/upload/\(conversationId)/type/\(type)"
+        case .imDownloadFullFile(let id):
+            return "/jaxrs/im/msg/download/\(id)"
         }
     }
     
     var method: Moya.Method {
         switch self {
-        case .myConversationList, .instantMessageList(_):
+        case .myConversationList, .instantMessageList(_), .imDownloadFullFile(_):
             return .get
         case .msgListByPaging(_, _, _), .sendMsg(_), .createConversation(_), .imUploadFile(_, _, _, _):
             return .post
@@ -97,11 +100,19 @@ extension CommunicateAPI: TargetType {
             //文件类型
             let fileData = MultipartFormData(provider: .data(data), name: "file", fileName: fileName)
             return .uploadMultipart([fileData, fileNameData])
+        case .imDownloadFullFile(let id):
+            let myDest:DownloadDestination = { temporaryURL, response in
+                //本地存储
+                return (O2IMFileManager.shared.localFilePath(fileId: id), [.removePreviousFile, .createIntermediateDirectories])
+            }
+            return .downloadDestination(myDest)
         }
     }
     
     var headers: [String : String]? {
         return nil
     }
+    
+     
    
 }

+ 2 - 2
o2ios/O2Platform/UI/o2JsApi/O2BaseJsMessageHandler.swift

@@ -266,8 +266,8 @@ class O2BaseJsMessageHandler: O2WKScriptMessageHandlerImplement {
             return
         }
         data.scale = 800
-        let chooseImage = FileBSImagePickerViewController()
-        self.viewController.bs_presentImagePickerController(chooseImage, animated: true, select: nil, deselect: nil, cancel: nil, finish: { (arr) in
+        let vc = FileBSImagePickerViewController().bsImagePicker()
+        self.viewController.presentImagePicker(vc, select: nil, deselect: nil, cancel: nil, finish: { (arr) in
             let count = arr.count
             DDLogDebug("选择了照片数量:\(count)")
             if count > 0 {

+ 1 - 1
o2ios/Podfile

@@ -57,7 +57,7 @@ target 'O2Platform' do
     
     pod 'SDWebImage', '~>4.0'
     
-    pod 'BSImagePicker'
+    pod 'BSImagePicker', '~> 3.1.0'
     pod 'Eureka', '~> 5.2.1'
     pod 'SwiftyTimer'
 

+ 4 - 12
o2ios/Podfile.lock

@@ -10,11 +10,7 @@ PODS:
   - BaiduMapKit (5.2.0)
   - BetterSegmentedControl (1.2.1)
   - BMKLocationKit (1.8.5)
-  - BSGridCollectionViewLayout (1.2.2)
-  - BSImagePicker (2.9.0):
-    - BSGridCollectionViewLayout (= 1.2.2)
-    - BSImageView (= 1.0.2)
-  - BSImageView (1.0.2)
+  - BSImagePicker (3.1.1)
   - Bugly (2.5.0)
   - Charts (3.2.1):
     - Charts/Core (= 3.2.1)
@@ -87,7 +83,7 @@ DEPENDENCIES:
   - BaiduMapKit
   - BetterSegmentedControl (~> 1.2)
   - BMKLocationKit
-  - BSImagePicker
+  - BSImagePicker (~> 3.1.0)
   - Bugly
   - Charts
   - Chrysan
@@ -131,9 +127,7 @@ SPEC REPOS:
     - BaiduMapKit
     - BetterSegmentedControl
     - BMKLocationKit
-    - BSGridCollectionViewLayout
     - BSImagePicker
-    - BSImageView
     - Bugly
     - Charts
     - Chrysan
@@ -188,9 +182,7 @@ SPEC CHECKSUMS:
   BaiduMapKit: 075465cf7134d0ebf81796b93a59d504c350d9a4
   BetterSegmentedControl: b27bddbdff29b6cae988678d6cd106858986cd03
   BMKLocationKit: fd3d6b4a9a3a1a2763819f56b780bda5fc5b8726
-  BSGridCollectionViewLayout: 3e6f23b3a2b4f0ca9afae09ca01389d1057f7b32
-  BSImagePicker: 553707de1adaad42eac252e0b84d20dbdba83fe9
-  BSImageView: ab22ff8cae61f1ae17a3c9efeeb216af3cf84a09
+  BSImagePicker: 86f28e0f63b78d35fec7c6f0174b7af9e6f1431e
   Bugly: 3ca9f255c01025582df26f9222893b383c7e4b4e
   Charts: f122fb70b19847fa5817d018b77d6c5a2296ab25
   Chrysan: 6bf6682adb2db76f7f5c103930a8c6670f54eebe
@@ -228,6 +220,6 @@ SPEC CHECKSUMS:
   YHPhotoKit: e88368af1fca0a110d41b88417088f7e49876981
   YHPopupView: 96d9c05c79a2a17cf69c3def09e5305cfae9e8e8
 
-PODFILE CHECKSUM: c9dd30b0987ffddb95ec8f9c0af2a4134a03ae69
+PODFILE CHECKSUM: 7994fed5103facb0bfff5a065e5612ebe4b411a2
 
 COCOAPODS: 1.8.4