Forráskód Böngészése

推荐好友接口调试

桂欢 2 éve
szülő
commit
ec44e87386

+ 6 - 0
SLAiELTS/SLAiELTS.xcodeproj/project.pbxproj

@@ -131,6 +131,7 @@
 		3D6EE45429F2568000B02EBB /* SLRecomFriendsVc.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D6EE45229F2568000B02EBB /* SLRecomFriendsVc.xib */; };
 		3D6EE45829F25AB400B02EBB /* SLRecomFriendsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D6EE45629F25AB400B02EBB /* SLRecomFriendsCell.m */; };
 		3D6EE45929F25AB400B02EBB /* SLRecomFriendsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D6EE45729F25AB400B02EBB /* SLRecomFriendsCell.xib */; };
+		3D6EE45C29F27BCB00B02EBB /* SLRecomFriendModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D6EE45B29F27BCB00B02EBB /* SLRecomFriendModel.m */; };
 		3D796C6C29B8305C00B7B28A /* NSObject+FBKVOController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D796C6929B8305C00B7B28A /* NSObject+FBKVOController.m */; };
 		3D796C6D29B8305C00B7B28A /* FBKVOController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D796C6A29B8305C00B7B28A /* FBKVOController.m */; };
 		3D8515D729CD92A400418BAB /* JXCategoryTitleBackgroundCellModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8515D129CD92A400418BAB /* JXCategoryTitleBackgroundCellModel.m */; };
@@ -481,6 +482,8 @@
 		3D6EE45529F25AB400B02EBB /* SLRecomFriendsCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SLRecomFriendsCell.h; sourceTree = "<group>"; };
 		3D6EE45629F25AB400B02EBB /* SLRecomFriendsCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SLRecomFriendsCell.m; sourceTree = "<group>"; };
 		3D6EE45729F25AB400B02EBB /* SLRecomFriendsCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SLRecomFriendsCell.xib; sourceTree = "<group>"; };
+		3D6EE45A29F27BCB00B02EBB /* SLRecomFriendModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SLRecomFriendModel.h; sourceTree = "<group>"; };
+		3D6EE45B29F27BCB00B02EBB /* SLRecomFriendModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SLRecomFriendModel.m; sourceTree = "<group>"; };
 		3D796C6729B8305C00B7B28A /* KVOController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVOController.h; sourceTree = "<group>"; };
 		3D796C6829B8305C00B7B28A /* FBKVOController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBKVOController.h; sourceTree = "<group>"; };
 		3D796C6929B8305C00B7B28A /* NSObject+FBKVOController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+FBKVOController.m"; sourceTree = "<group>"; };
@@ -708,6 +711,8 @@
 			children = (
 				3D19CBE829E6480E0041A6B8 /* SLFriendsModel.h */,
 				3D19CBE929E6480E0041A6B8 /* SLFriendsModel.m */,
+				3D6EE45A29F27BCB00B02EBB /* SLRecomFriendModel.h */,
+				3D6EE45B29F27BCB00B02EBB /* SLRecomFriendModel.m */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -2076,6 +2081,7 @@
 				3D2D8BFA29DE5AE5009392DA /* UITableView+SCIndexView.m in Sources */,
 				3D1B9CFF29C157620008D01A /* PlaceholderTextView.m in Sources */,
 				3D8C9F8D29AC57F300678283 /* main.m in Sources */,
+				3D6EE45C29F27BCB00B02EBB /* SLRecomFriendModel.m in Sources */,
 				3D25107A29AD8DB0000AE530 /* SLPageControlSlideRound.m in Sources */,
 				3DB97D6B29D6ABC100B12754 /* SDRefreshHeaderView.m in Sources */,
 				3D2510CE29AF375B000AE530 /* SLGlobalInfo.m in Sources */,

+ 28 - 0
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/Model/SLRecomFriendModel.h

@@ -0,0 +1,28 @@
+//
+//  SLRecomFriendModel.h
+//  SLAiELTS
+//
+//  Created by Gusont on 2023/4/21.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface SLRecomFriendModel : NSObject
+
+@property (nonatomic, copy) NSString *userId;
+
+@property (nonatomic, copy) NSString *userHead;
+
+@property (nonatomic, copy) NSString *userName;
+
+@property (nonatomic, copy) NSString *mutualFriends;
+
+@property (nonatomic, copy) NSString *interests;
+
+- (NSString *)getUserHeadUrl;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 17 - 0
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/Model/SLRecomFriendModel.m

@@ -0,0 +1,17 @@
+//
+//  SLRecomFriendModel.m
+//  SLAiELTS
+//
+//  Created by Gusont on 2023/4/21.
+//
+
+#import "SLRecomFriendModel.h"
+
+@implementation SLRecomFriendModel
+
+- (NSString *)getUserHeadUrl {
+    NSString *userImg = [NSString stringWithFormat:@"%@%@",[SLHttpCenter SharedInstance].serverUrl, self.userHead];
+    return userImg;
+}
+
+@end

+ 15 - 1
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/SLRecomFriendsVc.m

@@ -8,6 +8,7 @@
 #import "SLRecomFriendsVc.h"
 #import "LeftImageDesignTxtxField.h"
 #import "SLRecomFriendsCell.h"
+#import "SLRecomFriendModel.h"
 
 @interface SLRecomFriendsVc ()<UITableViewDelegate, UITableViewDataSource>
 
@@ -30,14 +31,27 @@
     self.topConst.constant = kNavBarHeight;
     self.navigationBar.separatorHeight = 0.0f;
     self.title = @"推荐好友";
+    [self requestData];
+}
+
+- (void)requestData {
+    [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Contacts/FriendRecommendation" parameter:@{} success:^(id responseObject) {
+        NSArray *dataArr = [responseObject objectForKey:@"data"];
+        self.friendsModel = [SLRecomFriendModel mj_objectArrayWithKeyValuesArray:dataArr];
+        [self.tableView reloadData];
+    } failure:^(SPRequestError *error) {
+        
+    }];
 }
 
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-    return 10;
+    return self.friendsModel.count;
 }
 
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     SLRecomFriendsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(SLRecomFriendsCell.class)];
+    SLRecomFriendModel *model = [self.friendsModel objectAtIndex:indexPath.row];
+    [cell confignRecomFriendCell:model];
     return cell;
 }
 

+ 7 - 0
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/Views/SLRecomFriendsCell.h

@@ -6,11 +6,18 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "SLRecomFriendModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface SLRecomFriendsCell : UITableViewCell
 
+@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
+@property (weak, nonatomic) IBOutlet UILabel *friendNumLabel;
+@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
+
+- (void)confignRecomFriendCell:(SLRecomFriendModel *)model;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 9 - 0
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/Views/SLRecomFriendsCell.m

@@ -20,4 +20,13 @@
     // Configure the view for the selected state
 }
 
+- (void)confignRecomFriendCell:(SLRecomFriendModel *)model {
+    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:[model getUserHeadUrl]]];
+    self.nameLabel.text = model.userName;
+    if (model.mutualFriends && model.mutualFriends.intValue > 0) {
+        self.friendNumLabel.text = [NSString stringWithFormat:@"有%@个共同好友",model.mutualFriends];
+    }
+    
+}
+
 @end

+ 13 - 3
SLAiELTS/SLAiELTS/ViewControllers/AddressBookVC/Views/SLRecomFriendsCell.xib

@@ -23,15 +23,20 @@
                             <constraint firstAttribute="width" constant="48" id="RB0-Hl-vyg"/>
                             <constraint firstAttribute="height" constant="48" id="faa-Gg-xKV"/>
                         </constraints>
+                        <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
+                                <integer key="value" value="24"/>
+                            </userDefinedRuntimeAttribute>
+                        </userDefinedRuntimeAttributes>
                     </imageView>
-                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="有3个共同好友" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C25-qG-NjY">
-                        <rect key="frame" x="80" y="50" width="81.333333333333314" height="14.333333333333329"/>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="C25-qG-NjY">
+                        <rect key="frame" x="80" y="57" width="0.0" height="0.0"/>
                         <fontDescription key="fontDescription" type="system" pointSize="12"/>
                         <color key="textColor" red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="calibratedRGB"/>
                         <nil key="highlightedColor"/>
                     </label>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="用户名称" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XOL-Cc-SRD">
-                        <rect key="frame" x="80" y="26.666666666666671" width="65.333333333333314" height="19.333333333333329"/>
+                        <rect key="frame" x="80" y="33.666666666666664" width="65.333333333333314" height="19.333333333333336"/>
                         <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
                         <nil key="textColor"/>
                         <nil key="highlightedColor"/>
@@ -47,6 +52,11 @@
                 </constraints>
             </tableViewCellContentView>
             <viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
+            <connections>
+                <outlet property="friendNumLabel" destination="C25-qG-NjY" id="NT0-iH-5wq"/>
+                <outlet property="headImageView" destination="Kih-80-ush" id="Zub-Nq-byI"/>
+                <outlet property="nameLabel" destination="XOL-Cc-SRD" id="lj9-0P-JtD"/>
+            </connections>
             <point key="canvasLocation" x="95.384615384615387" y="23.459715639810426"/>
         </tableViewCell>
     </objects>