Просмотр исходного кода

[+]补充连线的关注功能

陈文艺 5 месяцев назад
Родитель
Сommit
8faa81a19e

+ 48 - 14
MiMoLive/MiMoLive.xcodeproj/project.pbxproj

@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 56;
+	objectVersion = 70;
 	objects = {
 
 /* Begin PBXBuildFile section */
@@ -1603,7 +1603,7 @@
 		A6FEDB8E2CCCE4CB0054178F /* MORedRainTipView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A6FEDB8D2CCCE4CB0054178F /* MORedRainTipView.xib */; };
 		C63B868DE1BF719B788A335A /* Pods_MiMoLive_Preview.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 816C81B40A7988A9CB2AD910 /* Pods_MiMoLive_Preview.framework */; };
 		D710FA76955C5B00E6D033AB /* Pods_MiMoLive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCF0A923FC4BEAF036C81A51 /* Pods_MiMoLive.framework */; };
-		F5612EBB69D610C1330F566F /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
+		F5612EBB69D610C1330F566F /* (null) in Frameworks */ = {isa = PBXBuildFile; };
 		FB012AD02E88CBB3000770B4 /* MOHttpManager+Line+PK.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB012ACF2E88CBB3000770B4 /* MOHttpManager+Line+PK.swift */; };
 		FB012AD12E88CBB3000770B4 /* MOHttpManager+Line+PK.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB012ACF2E88CBB3000770B4 /* MOHttpManager+Line+PK.swift */; };
 		FB012AD32E88CEF8000770B4 /* MOHttpManager+Common.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB012AD22E88CEF8000770B4 /* MOHttpManager+Common.swift */; };
@@ -3232,6 +3232,10 @@
 		FB6C90882E7C1AB3004DF690 /* MOGiftListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB6C90872E7C1AB3004DF690 /* MOGiftListViewModel.swift */; };
 		FB6C90ED2E7C2F41004DF690 /* Dictionary+Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB6C90EC2E7C2F41004DF690 /* Dictionary+Response.swift */; };
 		FB6C90F02E7C35C4004DF690 /* MOBagCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = FB6C90EF2E7C35C4004DF690 /* MOBagCollectionView.m */; };
+		FB7730212E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB7730202E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift */; };
+		FB7730222E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB7730202E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift */; };
+		FB7730242E9DE8030022E8C8 /* MORelationStatusVo.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB7730232E9DE8030022E8C8 /* MORelationStatusVo.swift */; };
+		FB7730252E9DE8030022E8C8 /* MORelationStatusVo.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB7730232E9DE8030022E8C8 /* MORelationStatusVo.swift */; };
 		FB93FB5A2E85281D00624A7A /* UIFont+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB93FB592E85281D00624A7A /* UIFont+Extension.swift */; };
 		FB93FB5B2E85281D00624A7A /* UIFont+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB93FB592E85281D00624A7A /* UIFont+Extension.swift */; };
 		FB93FB5D2E852A6A00624A7A /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB93FB5C2E852A6A00624A7A /* UIColor+Extension.swift */; };
@@ -6128,6 +6132,8 @@
 		FB6C90EC2E7C2F41004DF690 /* Dictionary+Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Dictionary+Response.swift"; sourceTree = "<group>"; };
 		FB6C90EE2E7C35C4004DF690 /* MOBagCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MOBagCollectionView.h; sourceTree = "<group>"; };
 		FB6C90EF2E7C35C4004DF690 /* MOBagCollectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MOBagCollectionView.m; sourceTree = "<group>"; };
+		FB7730202E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MOHttpManager+Relation.swift"; sourceTree = "<group>"; };
+		FB7730232E9DE8030022E8C8 /* MORelationStatusVo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MORelationStatusVo.swift; sourceTree = "<group>"; };
 		FB93FB592E85281D00624A7A /* UIFont+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Extension.swift"; sourceTree = "<group>"; };
 		FB93FB5C2E852A6A00624A7A /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; };
 		FB93FB5F2E85308E00624A7A /* MOPopupViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MOPopupViewProtocol.swift; sourceTree = "<group>"; };
@@ -6159,17 +6165,7 @@
 /* End PBXFileReference section */
 
 /* Begin PBXFileSystemSynchronizedRootGroup section */
-		A6D34FB22E27469F00E57F79 /* CreateLive */ = {
-			isa = PBXFileSystemSynchronizedRootGroup;
-			exceptions = (
-			);
-			explicitFileTypes = {
-			};
-			explicitFolders = (
-			);
-			path = CreateLive;
-			sourceTree = "<group>";
-		};
+		A6D34FB22E27469F00E57F79 /* CreateLive */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = CreateLive; sourceTree = "<group>"; };
 /* End PBXFileSystemSynchronizedRootGroup section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -6195,7 +6191,7 @@
 				A601BAC92AD7C59D0021CF03 /* SafariServices.framework in Frameworks */,
 				A64A155A2BB1ADD9004719CA /* SystemConfiguration.framework in Frameworks */,
 				A680E9BE2ADEBF3700DDFEC3 /* CoreTelephony.framework in Frameworks */,
-				F5612EBB69D610C1330F566F /* BuildFile in Frameworks */,
+				F5612EBB69D610C1330F566F /* (null) in Frameworks */,
 				A6673B382B43EB16002566A7 /* StoreKit.framework in Frameworks */,
 				D710FA76955C5B00E6D033AB /* Pods_MiMoLive.framework in Frameworks */,
 			);
@@ -6802,6 +6798,7 @@
 		A601BAE52AD7F99E0021CF03 /* NetManager */ = {
 			isa = PBXGroup;
 			children = (
+				FB77301E2E9DE79E0022E8C8 /* Relation */,
 				FB249B942E9CAC4B0063E7FC /* Line+PK */,
 				A601BAE92AD7FB980021CF03 /* MOAPIUrl.h */,
 				A601BAEA2AD8001B0021CF03 /* MONetAPIClient.h */,
@@ -12666,6 +12663,23 @@
 			path = ViewModel;
 			sourceTree = "<group>";
 		};
+		FB77301E2E9DE79E0022E8C8 /* Relation */ = {
+			isa = PBXGroup;
+			children = (
+				FB77301F2E9DE7A90022E8C8 /* Models */,
+				FB7730202E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift */,
+			);
+			path = Relation;
+			sourceTree = "<group>";
+		};
+		FB77301F2E9DE7A90022E8C8 /* Models */ = {
+			isa = PBXGroup;
+			children = (
+				FB7730232E9DE8030022E8C8 /* MORelationStatusVo.swift */,
+			);
+			path = Models;
+			sourceTree = "<group>";
+		};
 		FBC2FEA12E9762B100ACD8F7 /* Models */ = {
 			isa = PBXGroup;
 			children = (
@@ -13755,10 +13769,14 @@
 			inputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-resources-${CONFIGURATION}-input-files.xcfilelist",
 			);
+			inputPaths = (
+			);
 			name = "[CP] Copy Pods Resources";
 			outputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-resources-${CONFIGURATION}-output-files.xcfilelist",
 			);
+			outputPaths = (
+			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-resources.sh\"\n";
@@ -13811,10 +13829,14 @@
 			inputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-frameworks-${CONFIGURATION}-input-files.xcfilelist",
 			);
+			inputPaths = (
+			);
 			name = "[CP] Embed Pods Frameworks";
 			outputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-frameworks-${CONFIGURATION}-output-files.xcfilelist",
 			);
+			outputPaths = (
+			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MiMoLive/Pods-MiMoLive-frameworks.sh\"\n";
@@ -13850,10 +13872,14 @@
 			inputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-frameworks-${CONFIGURATION}-input-files.xcfilelist",
 			);
+			inputPaths = (
+			);
 			name = "[CP] Embed Pods Frameworks";
 			outputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-frameworks-${CONFIGURATION}-output-files.xcfilelist",
 			);
+			outputPaths = (
+			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-frameworks.sh\"\n";
@@ -13867,10 +13893,14 @@
 			inputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-resources-${CONFIGURATION}-input-files.xcfilelist",
 			);
+			inputPaths = (
+			);
 			name = "[CP] Copy Pods Resources";
 			outputFileListPaths = (
 				"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-resources-${CONFIGURATION}-output-files.xcfilelist",
 			);
+			outputPaths = (
+			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
 			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MiMoLive_Preview/Pods-MiMoLive_Preview-resources.sh\"\n";
@@ -14317,6 +14347,7 @@
 				A61D70D12C103E1700B28B16 /* MODurationTask.m in Sources */,
 				A61A8D222D22881A00D71489 /* QGHWDMetalRenderer.m in Sources */,
 				A6A08FB62B3933D900ECE79D /* MOMedalList.m in Sources */,
+				FB7730252E9DE8030022E8C8 /* MORelationStatusVo.swift in Sources */,
 				A6FC20F82B3D8C75001F4CC0 /* UIImageView+BarrageView.m in Sources */,
 				3A8A063B2E7A96430081C87A /* MOSystemAlertView.m in Sources */,
 				3A1FDD9F2D58B2EB0042DDF2 /* UIImage+Extension.m in Sources */,
@@ -14558,6 +14589,7 @@
 				A60963DC2B5E97D1009C9D4D /* MOFamilyTaskListCell.m in Sources */,
 				A608EBAB2AE653FC0092317D /* MOBacklogTimeSelectView.m in Sources */,
 				A6733DA82AF2777A00F57852 /* MOFamilyApplyAvatarCell.m in Sources */,
+				FB7730212E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift in Sources */,
 				A63664BF2AF13DA3002C0BFC /* MOFamilySecondCell.m in Sources */,
 				A6DAC83F2B29B95E0064AFFD /* MOLiveWishGift.m in Sources */,
 				A61944062AE53B4D00D2878F /* MOModifyNickNameVC.m in Sources */,
@@ -15500,6 +15532,7 @@
 				FB069CD62E82B3FB00A3CD51 /* MOOpenGLRenderHelper.m in Sources */,
 				FB069CD72E82B3FB00A3CD51 /* MOGLUtils.m in Sources */,
 				FB069CD82E82B3FB00A3CD51 /* MODynmicResourceConfig.m in Sources */,
+				FB7730222E9DE7BD0022E8C8 /* MOHttpManager+Relation.swift in Sources */,
 				FB069CD92E82B3FB00A3CD51 /* MOEffectResourceHelper.m in Sources */,
 				FB069CDA2E82B3FB00A3CD51 /* MOLicenseHelper.mm in Sources */,
 				FB069CDB2E82B3FB00A3CD51 /* MOImageUtils.m in Sources */,
@@ -16057,6 +16090,7 @@
 				FB069EEB2E82B3FB00A3CD51 /* MORoomGiftMenuCell.m in Sources */,
 				FB069EEC2E82B3FB00A3CD51 /* MOLivePkRewardCell.m in Sources */,
 				FB069EED2E82B3FB00A3CD51 /* MOPkRankListCell.m in Sources */,
+				FB7730242E9DE8030022E8C8 /* MORelationStatusVo.swift in Sources */,
 				FB069EEE2E82B3FB00A3CD51 /* QGAnimatedImageDecodeManager.m in Sources */,
 				FB069EEF2E82B3FB00A3CD51 /* MONoMoreDataView.m in Sources */,
 				FB069EF02E82B3FB00A3CD51 /* MOEidtNameplateVC.m in Sources */,

+ 44 - 6
MiMoLive/MiMoLive/Classes/Live/View/MOPKListView/MOLinePeerHostInfoView.swift

@@ -7,11 +7,15 @@
 
 import Foundation
 import UIKit
+import SnapKit
 
 class MOLinePeerHostInfoView: UIView {
     private let avatar = UIImageView()
     private let nameLabel = UILabel()
     private let followBtn = UIButton()
+    private var followShow: Constraint? = nil
+    
+    private var userId: String? = nil
     
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -23,16 +27,48 @@ class MOLinePeerHostInfoView: UIView {
         fatalError("init(coder:) has not been implemented")
     }
     
-    func update(_ avatar: String, _ name: String, _ hasFollow: Bool) {
+    func update(_ userId: String, _ avatar: String, _ name: String) {
+        self.userId = userId
         self.avatar.sd_setImage(with: URL(string: avatar))
         nameLabel.text = name
-        if hasFollow {
-            followBtn.removeFromSuperview()
+        checkFollowState()
+    }
+}
+
+extension MOLinePeerHostInfoView {
+    private func checkFollowState() {
+        guard let userId else { return }
+        MOHttpManager.shared().checkFollowStatus(uid: userId) { [weak self] follow, error in
+            guard let self else { return }
+            guard error == nil else { return }
+            showFollow(!follow)
+        }
+    }
+    
+    private func followUser() {
+        guard let userId else { return }
+        let roomId = MOLiveManager.curRoomId
+        followBtn.isEnabled = false
+        MOHttpManager.shared().followUser(uid: userId, roomId) { [weak self] error in
+            guard let self else { return }
+            followBtn.isEnabled = true
+            guard error == nil else { return }
+            showFollow(false)
         }
     }
 }
 
 extension MOLinePeerHostInfoView {
+    private func showFollow(_ show: Bool) {
+        if show {
+            followShow?.update(priority: .low)
+            followBtn.isHidden = false
+        } else {
+            followShow?.update(priority: .high)
+            followBtn.isHidden = true
+        }
+    }
+    
     private func setupViews() {
         backgroundColor = .black.withAlphaComponent(0.2)
         layer.cornerRadius = 12
@@ -48,23 +84,25 @@ extension MOLinePeerHostInfoView {
         }
         
         nameLabel.font = .poppinsMediumFont(11)
+        nameLabel.text = "name"
         nameLabel.textColor = .white
         addSubview(nameLabel)
         nameLabel.snp.makeConstraints { make in
             make.centerY.equalToSuperview()
             make.leading.equalTo(avatar.snp.trailing).offset(4)
-            make.trailing.equalToSuperview().offset(-8).priority(.low)
+            followShow = make.trailing.equalToSuperview().offset(-8).priority(.high).constraint
         }
         
         followBtn.layer.cornerRadius = 7
         followBtn.clipsToBounds = true
         followBtn.setImage(.init(named: "icon_follow_white_jia"), for: .normal)
         followBtn.setBackgroundImage(commonGradientBg, for: .normal)
+        followBtn.isHidden = true
         addSubview(followBtn)
         followBtn.snp.makeConstraints { make in
             make.centerY.equalToSuperview()
             make.trailing.equalToSuperview().offset(-4)
-            make.leading.equalTo(nameLabel.snp.trailing).offset(4)
+            make.leading.equalTo(nameLabel.snp.trailing).offset(4).priority(.medium)
             make.width.equalTo(18)
             make.height.equalTo(14)
         }
@@ -92,4 +130,4 @@ extension MOLinePeerHostInfoView {
 //#Preview {
 //    MOLinePeerHostInfoViewPreview()
 //}
-
+//

+ 1 - 1
MiMoLive/MiMoLive/Classes/Live/View/MOPKListView/MOLineView.swift

@@ -128,7 +128,7 @@ extension MOLineView {
         }
         if let peerInfo = lineViewModel.curPeerInfo {
             peerBeanView.update(peerInfo.goldenBeanOnLink)
-            peerInfoView.update(peerInfo.avatar, peerInfo.userNickName, peerInfo.isMe)
+            peerInfoView.update(peerInfo.userId, peerInfo.avatar, peerInfo.userNickName)
         }
     }
 }

+ 43 - 0
MiMoLive/MiMoLive/Global/NetManager/Relation/MOHttpManager+Relation.swift

@@ -0,0 +1,43 @@
+//
+//  MOHttpManager+Relation.swift
+//  MiMoLive
+//
+//  Created by OneeChan on 2025/10/14.
+//
+
+import Foundation
+
+let kNetPath_CheckContactFollow = "/contact/follow/check"
+let kNetPath_FollowSubmit = "/contact/follow/submit"
+
+extension MOHttpManager {
+    func checkFollowStatus(uids: [String], handler: @escaping (MORelationStatusVo?, String?) -> Void) {
+        sendPostRequest(path: kNetPath_CheckContactFollow, params: ["list": uids], handler: handler)
+    }
+    func checkFollowStatus(uid: String, handler: @escaping (Bool, String?) -> Void) {
+        checkFollowStatus(uids: [uid]) { list, error in
+            handler(list?.list.contains(uid) ?? false, error)
+        }
+    }
+    
+    private func submitFollow(uids: [String], type: Int, roomId: String? = nil, handler: @escaping (String?) -> Void) {
+        var dic: MOHttpManagerParam = ["type": type, // 类型(1=关注,2=取关)
+                                       "target": uids]
+        if let roomId {
+            dic["roomId"] = roomId
+        }
+        sendPostRequest(path: kNetPath_FollowSubmit, params: dic, handler: handler)
+    }
+    func followUsers(uids: [String], _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
+        submitFollow(uids: uids, type: 1, roomId: roomId, handler: handler)
+    }
+    func followUser(uid: String, _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
+        followUsers(uids: [uid], roomId, handler: handler)
+    }
+    func unfollowUsers(uids: [String], _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
+        submitFollow(uids: uids, type: 2, roomId: roomId, handler: handler)
+    }
+    func unfollowUser(uid: String, _ roomId: String? = nil, handler: @escaping (String?) -> Void) {
+        unfollowUsers(uids: [uid], roomId, handler: handler)
+    }
+}

+ 15 - 0
MiMoLive/MiMoLive/Global/NetManager/Relation/Models/MORelationStatusVo.swift

@@ -0,0 +1,15 @@
+//
+//  MORelationStatusVo.swift
+//  MiMoLive
+//
+//  Created by OneeChan on 2025/10/14.
+//
+
+import Foundation
+import AutoCodable
+
+
+@AutoCodable
+class MORelationStatusVo: Decodable {
+    var list: [String] = []
+}