南鑫林 5 년 전
부모
커밋
38a572afc4

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -297,6 +297,7 @@
 		A784F2AB234ED15600E49140 /* DatePickerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A784F2AA234ED15600E49140 /* DatePickerManager.swift */; };
 		A784F2AE234F352000E49140 /* BrowsePicturesSaveImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A784F2AD234F352000E49140 /* BrowsePicturesSaveImageView.swift */; };
 		A784F2B12350124200E49140 /* CopyLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A784F2B02350124200E49140 /* CopyLabel.swift */; };
+		A784F2B32350337D00E49140 /* ShareH5LinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A784F2B22350337D00E49140 /* ShareH5LinkView.swift */; };
 		A78A5F7622FAA03800DD1764 /* share_iSpt.gif in Resources */ = {isa = PBXBuildFile; fileRef = A78A5F7522FAA03800DD1764 /* share_iSpt.gif */; };
 		A78A5F7822FAC7F000DD1764 /* SetGenderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78A5F7722FAC7F000DD1764 /* SetGenderModel.swift */; };
 		A78CEE0A22E0864100C512A4 /* BaseLottieAnimateContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78CEE0922E0864100C512A4 /* BaseLottieAnimateContentView.swift */; };
@@ -982,6 +983,7 @@
 		A784F2AA234ED15600E49140 /* DatePickerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerManager.swift; sourceTree = "<group>"; };
 		A784F2AD234F352000E49140 /* BrowsePicturesSaveImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsePicturesSaveImageView.swift; sourceTree = "<group>"; };
 		A784F2B02350124200E49140 /* CopyLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyLabel.swift; sourceTree = "<group>"; };
+		A784F2B22350337D00E49140 /* ShareH5LinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareH5LinkView.swift; sourceTree = "<group>"; };
 		A78A5F7522FAA03800DD1764 /* share_iSpt.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = share_iSpt.gif; sourceTree = "<group>"; };
 		A78A5F7722FAC7F000DD1764 /* SetGenderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetGenderModel.swift; sourceTree = "<group>"; };
 		A78CEE0922E0864100C512A4 /* BaseLottieAnimateContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseLottieAnimateContentView.swift; sourceTree = "<group>"; };
@@ -2661,6 +2663,7 @@
 			children = (
 				A770E60C22D6625700CBD0A4 /* ShareCommunityViewCollectionViewCell.swift */,
 				A770E60D22D6625700CBD0A4 /* ShareCommunityView.swift */,
+				A784F2B22350337D00E49140 /* ShareH5LinkView.swift */,
 			);
 			path = ShareCommunity;
 			sourceTree = "<group>";
@@ -5956,6 +5959,7 @@
 				A76068E722E48DC5008DF18F /* BrowsePictureRouterModuleType.swift in Sources */,
 				A78168DF2341A8FD00033496 /* AliyunVodUptoyouEffectsModel.swift in Sources */,
 				BD12B66922B47D4800AEB10B /* RecommendSubCommentTableViewCell.swift in Sources */,
+				A784F2B32350337D00E49140 /* ShareH5LinkView.swift in Sources */,
 				A7811CD22323D25A00C2D8DE /* PublishNewVideoPhotoView.swift in Sources */,
 				A7931E1822AFC1DF00297D0A /* CommunityFollowViewController.swift in Sources */,
 				BDBC0AF422DDE9BC00CA788E /* PublishRouterModuleType.swift in Sources */,

+ 7 - 0
RainbowPlanet/RainbowPlanet/Manager/WebViewJavascriptBridgeManager/WebViewJavascriptBridgeManager.swift

@@ -120,6 +120,13 @@ class WebViewJavascriptBridgeManager: NSObject {
             }
         }
         
+        // 日期
+        if wvjbModel?.modelType  == .shareLink {
+            ShareH5LinkView.shareH5LinkView(h5Str:wvjbModel?.params?.link ?? "", thumbnailImg: UIImage.imageUrl(wvjbModel?.params?.imgUrl ?? ""), sharedTitle: wvjbModel?.params?.title ?? "", sharedDetailTitle: wvjbModel?.params?.desc ?? "") {
+                
+            }
+        }
+        
         // 跳转原生
         if wvjbModel?.modelType  == .view {
             // 发布

+ 18 - 2
RainbowPlanet/RainbowPlanet/Model/WVJBModel/WVJBModel.swift

@@ -16,6 +16,7 @@ import ObjectMapper
 /// - preview: 预览图片
 /// - follow: 关注
 /// - datepicker: 时间picker
+/// - datepicker: 分享链接
 enum WVJBModelType : String {
     case none = ""
     case share = "share"
@@ -27,6 +28,7 @@ enum WVJBModelType : String {
     case follow = "follow"
     case back = "back"
     case datepicker = "datepicker"
+    case shareLink = "shareLink"
 }
 /// WebViewJavascriptBridgeModel 简写 WVJBModel
 class WVJBModel:NSObject,Mappable{
@@ -103,9 +105,11 @@ class WVJBParamsModel:NSObject,Mappable {
     /// 交互类型参数
     var paramsModelType : WVJBParamsModelType?
     
-    // datePicker
-    /// 时间的标示
+    // datePicker/shareLink
+    /// 时间的标示 / 标题
     var title : String?
+    
+    // datePicker
     /// 时间戳
     var timeStamp : String? {
         didSet {
@@ -113,6 +117,15 @@ class WVJBParamsModel:NSObject,Mappable {
         }
     }
     
+    /// 描述
+    var desc : String?
+    
+    /// 链接地址
+    var link : String?
+    
+    /// 图片
+    var imgUrl : String?
+    
     var type : String? {
         didSet {
             paramsModelType = WVJBParamsModelType(rawValue: type ?? "") ?? WVJBParamsModelType.none
@@ -148,6 +161,9 @@ class WVJBParamsModel:NSObject,Mappable {
         payload <- map["payload"]
         title <- map["title"]
         timeStamp <- map["timestamp"]
+        desc <- map["desc"]
+        link <- map["link"]
+        imgUrl <- map["imgUrl"]
     }
 
 }

+ 15 - 14
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/FeaturedTopics/FeaturedTopicsCollectionViewCell.swift

@@ -39,14 +39,10 @@ class FeaturedTopicsCollectionViewCell: UICollectionViewCell {
         addSubview(picImageView)
         addSubview(iconImageView)
         addSubview(topicLabel)
-        addSubview(numberPeopleLable)
+        picImageView.addSubview(numberPeopleLable)
     }
     
     private func setupLayouts() {
-        picImageView.snp.makeConstraints { (make) in
-            make.top.left.right.equalToSuperview()
-            make.height.equalTo(130)
-        }
         iconImageView.snp.makeConstraints { (make) in
             make.left.equalToSuperview()
             make.top.equalTo(picImageView.snp.bottom).offset(10)
@@ -55,22 +51,28 @@ class FeaturedTopicsCollectionViewCell: UICollectionViewCell {
         topicLabel.snp.makeConstraints { (make) in
             make.centerY.equalTo(iconImageView)
             make.left.equalTo(iconImageView.snp.right).offset(2)
-            make.right.lessThanOrEqualTo(numberPeopleLable.snp.left).offset(-10)
+            make.right.equalTo(-10)
             make.height.equalTo(23)
         }
         numberPeopleLable.snp.makeConstraints { (make) in
-            make.centerY.equalTo(iconImageView)
-            make.right.equalToSuperview()
-            make.height.equalTo(23)
+            make.left.equalTo(6)
+            make.bottom.right.equalTo(-6)
         }
     }
     
     private lazy var picImageView : UIImageView = {
-        let picImageView = UIImageView()
+        let picImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 130, height: 130))
         picImageView.image = kImage(name: "default_pic")
         picImageView.cornerRadius = 4
         picImageView.masksToBounds = true
         picImageView.contentMode = .scaleAspectFill
+        let bgLayer1 = CAGradientLayer()
+        bgLayer1.colors = [UIColor(red: 0, green: 0, blue: 0, alpha: 0).cgColor, UIColor(red: 0, green: 0, blue: 0, alpha: 0.4).cgColor]
+        bgLayer1.locations = [0, 1]
+        bgLayer1.frame = picImageView.bounds
+        bgLayer1.startPoint = CGPoint(x: 0.5, y: 0)
+        bgLayer1.endPoint = CGPoint(x: 1, y: 1)
+        picImageView.layer.addSublayer(bgLayer1)
         return picImageView
     }()
     
@@ -82,23 +84,22 @@ class FeaturedTopicsCollectionViewCell: UICollectionViewCell {
     
     private lazy var topicLabel: UILabel = {
         let topicLabel = UILabel()
-        topicLabel.text = "吃出你的好身材"
         topicLabel.textColor = k333333Color
-        topicLabel.font = kMediumFont16
+        topicLabel.font = kMediumFont14
         return topicLabel
     }()
     
     private lazy var numberPeopleLable: UILabel = {
         let numberPeopleLable = UILabel()
         numberPeopleLable.text = "0人参与"
-        numberPeopleLable.textColor = k999999Color
+        numberPeopleLable.textColor = kffffffColor
         numberPeopleLable.font = kRegularFont12
         return numberPeopleLable
     }()
     
     var communityRecommendTypeDataModel : CommunityRecommendTypeDataModel? {
         didSet {
-            picImageView.kf.setImage(with: kURLThumbnailsImage(name: communityRecommendTypeDataModel?.img ?? "",size: CGSize(width: self.width, height: 130)), placeholder: kImage(name: "default_pic"))
+            picImageView.kf.setImage(with: kURLThumbnailsImage(name: communityRecommendTypeDataModel?.img ?? "",size: CGSize(width: 130, height: 130)), placeholder: kImage(name: "default_pic"))
 
             topicLabel.text = communityRecommendTypeDataModel?.name
             numberPeopleLable.text = "\(communityRecommendTypeDataModel?.followCount ?? "0")人参与"

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/FeaturedTopics/FeaturedTopicsTableViewCell.swift

@@ -98,7 +98,7 @@ extension FeaturedTopicsTableViewCell: UICollectionViewDelegateFlowLayout,UIColl
     }
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
-        return CGSize(width:231, height: 163)
+        return CGSize(width:130, height: 163)
     }
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {

+ 234 - 0
RainbowPlanet/RainbowPlanet/Modules/ShareModules/ShareCommunityModule/ShareCommunity/ShareH5LinkView.swift

@@ -0,0 +1,234 @@
+//
+//  ShareH5LinkView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/10/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import Foundation
+
+import FWPopupView
+import RxSwift
+import SwiftyMediator
+
+
+class ShareH5LinkView: FWPopupView {
+    
+    let disposeBag = DisposeBag()
+    
+    let platformTitles = ["微信","朋友圈","QQ","微博","复制链接"]
+    let platformImages = ["edit_pic_wechat","edit_pic_moments","edit_pic_qq","edit_pic_sina","edit_pic_link"]
+    
+    private var title : String?
+    private var detailTitle : String?
+    private var sharedTitle : String?
+    private var sharedDetailTitle : String?
+    private var h5Str : String?
+    private var thumbnailImg : UIImage?
+    
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+    }
+    
+    typealias Completion = (() -> Void)
+    var completion : Completion?
+    init(title:String,detailTitle:String,h5Str:String,thumbnailImg:UIImage?,sharedTitle:String,sharedDetailTitle:String) {
+        self.init()
+        self.title = title
+        self.detailTitle = detailTitle
+        self.h5Str = h5Str
+        self.thumbnailImg = thumbnailImg
+        self.sharedTitle = sharedTitle
+        self.sharedDetailTitle = sharedDetailTitle
+        frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: 209 + kSafeTabBarHeight)
+        configRectCorner(corner: [.topLeft,.topRight], radii: CGSize(width: 8, height: 8))
+        setupViews()
+        setupLayouts()
+        setupData()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    func setupViews() {
+        addSubview(titleLabel)
+        addSubview(detailTitleLabel)
+        addSubview(collectionView)
+        addSubview(lineLabel)
+        addSubview(cancelButton)
+        
+    }
+    
+    func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(20)
+            make.right.equalTo(-20)
+            make.left.equalTo(20)
+            make.height.equalTo(18)
+        }
+        detailTitleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp.bottom).offset(10)
+            make.right.equalTo(-30)
+            make.left.equalTo(30)
+            make.height.equalTo(18)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(detailTitleLabel.snp.bottom).offset(20)
+            make.height.equalTo(69)
+            make.left.right.equalToSuperview()
+        }
+        lineLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(collectionView.snp.bottom).offset(10)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(0.5)
+        }
+        cancelButton.snp.makeConstraints { (make) in
+            make.top.equalTo(lineLabel.snp.bottom)
+            make.height.equalTo(44)
+            make.left.right.equalToSuperview()
+        }
+    }
+    
+    lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = title
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kRegularFont15
+        titleLabel.textAlignment = .center
+        return titleLabel
+    }()
+    
+    lazy var detailTitleLabel: UILabel = {
+        let detailTitleLabel = UILabel()
+        detailTitleLabel.text = detailTitle
+        detailTitleLabel.textColor = k333333Color
+        detailTitleLabel.font = kRegularFont15
+        detailTitleLabel.textAlignment = .center
+        return detailTitleLabel
+    }()
+    
+    private lazy var collectionView: UICollectionView = {
+        let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
+        collectionView.backgroundColor = UIColor.white
+        collectionView.delegate = self;
+        collectionView.dataSource = self;
+        collectionView.showsVerticalScrollIndicator = false
+        collectionView.showsHorizontalScrollIndicator = false
+        return collectionView
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewFlowLayout.init()
+        collectionViewLayout.minimumLineSpacing = 20
+        collectionViewLayout.minimumInteritemSpacing = 0
+        collectionViewLayout.scrollDirection = .horizontal
+        return collectionViewLayout
+    }()
+    
+    lazy var lineLabel: UILabel = {
+        let lineLabel = UILabel()
+        lineLabel.backgroundColor = kDDDDDDColor
+        return lineLabel
+    }()
+    
+    lazy var cancelButton: UIButton = {
+        let cancelButton = UIButton(type: UIButton.ButtonType.custom)
+        cancelButton.setTitle("取消", for: UIControl.State.normal)
+        cancelButton.setTitleColor(k333333Color, for: UIControl.State.normal)
+        cancelButton.titleLabel?.font = kRegularFont16
+        return cancelButton
+    }()
+    
+    func setupData() {
+        cancelButton.rx.tap.subscribe(onNext: {
+            [weak self] _ in
+            self?.hide()
+        }).disposed(by: disposeBag)
+    }
+    
+    
+    /// 分享内容
+    class func shareH5LinkView(title:String = kCommunityPostTitle,detailTitle:String = kCommunityPostDetailTitle, h5Str:String,thumbnailImg:UIImage?,sharedTitle:String,sharedDetailTitle:String,completion: @escaping Completion) {
+        let view = ShareH5LinkView(
+            title:title,
+            detailTitle: detailTitle,
+            h5Str: h5Str,
+            thumbnailImg : thumbnailImg,
+            sharedTitle: sharedTitle,
+            sharedDetailTitle:sharedDetailTitle)
+        view.completion = {
+            completion()
+        }
+        let vProperty = FWPopupViewProperty()
+        vProperty.popupCustomAlignment = .bottomCenter
+        vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+        vProperty.popupAnimationType = .frame
+        vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
+        vProperty.touchWildToHide = "1"
+        view.vProperty = vProperty
+        view.show()
+    }
+    
+}
+
+extension ShareH5LinkView: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return platformTitles.count
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = ShareCommunityViewCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.titleIcon(title: platformTitles[indexPath.row], iconStr: platformImages[indexPath.row], textColor: k333333Color)
+        return cell
+        
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        switch indexPath.row {
+        case 0:
+            UMManager.shared.shareWebPage(to: UMSocialPlatformType.wechatSession, viewController: findViewController(), title: sharedTitle ?? "", descr: sharedDetailTitle ?? "", thumbImage: thumbnailImg as Any, webpageUrl: h5Str ?? "", completion: {
+                self.completion!()
+            })
+            break
+        case 1:
+            UMManager.shared.shareWebPage(to: UMSocialPlatformType.wechatTimeLine, viewController: findViewController(), title: sharedTitle ?? "", descr: sharedDetailTitle ?? "", thumbImage: thumbnailImg as Any, webpageUrl: h5Str ?? "",completion: {
+                self.completion!()
+            })
+            
+            break
+        case 2:
+            UMManager.shared.shareWebPage(to: UMSocialPlatformType.QQ, viewController: findViewController(), title: sharedTitle ?? "", descr: sharedDetailTitle ?? "", thumbImage: thumbnailImg as Any, webpageUrl: h5Str ?? "",completion: {
+                self.completion!()
+            })
+            
+            break
+        case 3:
+            UMManager.shared.shareWebPage(to: UMSocialPlatformType.sina, viewController: findViewController(), title: sharedTitle ?? "", descr: sharedDetailTitle ?? "", thumbImage: thumbnailImg as Any, webpageUrl: h5Str ?? "",completion: {
+                self.completion!()
+            })
+            break
+        case 4:
+            commonCopy(string: h5Str ?? "")
+            break
+        default:
+            break
+        }
+        self.hide()
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+        return CGSize(width:50, height: 69)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
+        return UIEdgeInsets(top: 0, left: 23, bottom: 0, right: 23)
+    }
+    
+}
+