Chris il y a 5 ans
Parent
commit
f339916247

+ 4 - 0
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityVideoListModel.swift

@@ -37,6 +37,8 @@ class CommunityVideoItemModel : NSObject, Mappable{
     var collectCount : Int?
     var commentCount : Int?
     var content : String?
+    var descUrl : String?
+    var h5url : String?
     var id : Int?
     var img : String?
     var isCollect : Int?
@@ -64,6 +66,8 @@ class CommunityVideoItemModel : NSObject, Mappable{
         collectCount <- map["collect_count"]
         commentCount <- map["comment_count"]
         content <- map["content"]
+        descUrl <- map["desc_url"]
+        h5url <- map["h5url"]
         id <- map["id"]
         img <- map["img"]
         isCollect <- map["is_collect"]

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -81,7 +81,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     typealias BackClosure = () -> Void
     var backClosure : BackClosure?
     
-    typealias ShareClosure = () -> Void
+    typealias ShareClosure = (_ videoItemMdl: CommunityVideoItemModel) -> Void
     var shareClosure : ShareClosure?
     
     typealias ButtonClickClosure = (_ clickType: videoBtnClickType, _ uid: Int, _ postId: Int) -> Void
@@ -402,7 +402,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         shareBtnRight.rx.tap.subscribe(onNext: {
             [weak self] (data) in
             if let shareClosure = self?.shareClosure {
-                shareClosure()
+                shareClosure(self!.videoItemMdl!)
             }
         }).disposed(by: disposeBag)
         return shareBtnRight
@@ -414,7 +414,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         shareBtnLeft.rx.tap.subscribe(onNext: {
             [weak self] (data) in
             if let shareClosure = self?.shareClosure {
-                shareClosure()
+                shareClosure(self!.videoItemMdl!)
             }
         }).disposed(by: disposeBag)
         return shareBtnLeft

+ 44 - 4
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -147,8 +147,8 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
             self?.navigationController?.popViewController(animated: true)
         }
         cell.shareClosure = {
-            [weak self] in
-            print("------点击了[分享]")
+            [weak self] (videoItemMdl) in
+            self?.share(videoItemMdl)
         }
         cell.followClosure = { (videoItemMdl, followButton) in
             CommunityFollowUserViewModel.shared.follow(communityVideoItemModel: videoItemMdl, button: followButton)
@@ -241,8 +241,48 @@ extension CommunityVideoListController {
         }) {
             [weak self] (payType) in
         }
-        
-       
+    }
+    
+    /// 分享
+    func share(_ videoItemModel: CommunityVideoItemModel) {
+        var title = videoItemModel.title?.prefix(12)
+        if title == nil || title == "" {
+            title = videoItemModel.content?.prefix(12) ?? ""
+        }
+        let shareCommunityView =  ShareCommunityView.shareCommunityView(
+            title: "向好友传递美好生活,送TA 500彩虹豆",
+            detailTitle: "越多好友看到,收获彩虹豆越多",
+            h5Str: (videoItemModel.h5url ?? "" + "\(UserModel.shared().getModel()?.inviteCode ?? "")"),
+            thumbnailImg: videoItemModel.img ?? "",
+            sharedTitle: String(title ?? ""),
+            sharedDetailTitle: kCommunityPostDetailTitleShare,
+            shareCommunityViewType: ShareCommunityViewType.postDetail,
+            completion: {
+                VirusViewModel.shared.forwarVirueRecordAddApi(postId: videoItemModel.id, postAuthorUid: "\(videoItemModel.uid ?? 0)", title: videoItemModel.title, content: videoItemModel.content, postType: videoItemModel.type, postCover: videoItemModel.img)
+        })
+        shareCommunityView.saveCompletion = {
+            [weak self] in
+            let vc = CommunityShareContentViewController()
+            vc.imgUrl = videoItemModel.img
+            let communityPostDetailTopicModel = videoItemModel.topic?[0]
+            vc.topicStr = communityPostDetailTopicModel?.name ?? ""
+            if videoItemModel.title == "" || videoItemModel.title == nil {
+                vc.titleStr =
+                    String(videoItemModel.content?.prefix(20) ?? "")
+            }else {
+                vc.titleStr =                      String(videoItemModel.title?.prefix(20) ?? "")
+
+            }
+            vc.avatarStr = videoItemModel.avatar
+            vc.nameStr = videoItemModel.username
+            vc.H5UrlStr = (videoItemModel.h5url ?? "" + "\(UserModel.shared().getModel()?.inviteCode ?? "")")
+            vc.bean = videoItemModel.willCollectBean
+            vc.postId = videoItemModel.id
+            vc.uid = videoItemModel.uid
+            vc.type = videoItemModel.type
+            vc.contentStr = videoItemModel.content
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
     }
     
 }