Fenix Wang преди 8 години
родител
ревизия
ed5c7ccc03
променени са 44 файла, в които са добавени 1216 реда и са изтрити 246 реда
  1. BIN
      NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/UserInterfaceState.xcuserstate
  2. 18 0
      NIMDemo/NIMDemo.xcodeproj/project.pbxproj
  3. 1 1
      NIMDemo/NIMDemo/AppDelegate.m
  4. 13 8
      NIMDemo/NIMDemo/Base.lproj/Main.storyboard
  5. 3 3
      NIMDemo/NIMDemo/Classes/Common/View/NTESAvatarImageView.m
  6. 1 1
      NIMDemo/NIMDemo/Classes/Sections/Chatroom/View/Cell/NTESChatroomMemberCell.m
  7. 22 2
      NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m
  8. 30 2
      NIMDemo/NIMDemo/CreateGroupViewController.m
  9. 4 4
      NIMDemo/NIMDemo/GiftTopBarItem.m
  10. 13 0
      NIMDemo/NIMDemo/GroupCardViewController.h
  11. 37 0
      NIMDemo/NIMDemo/GroupCardViewController.m
  12. 5 5
      NIMDemo/NIMDemo/GroupTableController.m
  13. 19 1
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.h
  14. 160 0
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.m
  15. 21 0
      NIMDemo/NIMDemo/Images.xcassets/Whosay/avatar_user2.imageset/Contents.json
  16. BIN
      NIMDemo/NIMDemo/Images.xcassets/Whosay/avatar_user2.imageset/avatar_user2.png
  17. 21 0
      NIMDemo/NIMDemo/Images.xcassets/Whosay/发布交易贴.imageset/Contents.json
  18. BIN
      NIMDemo/NIMDemo/Images.xcassets/Whosay/发布交易贴.imageset/发布交易贴.png
  19. 21 0
      NIMDemo/NIMDemo/Images.xcassets/Whosay/设置图标.imageset/Contents.json
  20. BIN
      NIMDemo/NIMDemo/Images.xcassets/Whosay/设置图标.imageset/设置图标.png
  21. 9 34
      NIMDemo/NIMDemo/LoginViewController.m
  22. 32 20
      NIMDemo/NIMDemo/RegisterViewController.m
  23. 2 2
      NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m
  24. 7 0
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.h
  25. 7 0
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m
  26. 6 6
      NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.m
  27. 281 1
      NIMDemo/NIMDemo/SectionTrade/TradeViewController.m
  28. 5 3
      NIMDemo/NIMDemo/SettingTableViewController.m
  29. 1 1
      NIMDemo/NIMDemo/SettingTopTableViewCell.m
  30. 1 1
      NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.m
  31. 3 3
      NIMDemo/NIMDemo/SocialDetailTableViewCell.m
  32. 5 47
      NIMDemo/NIMDemo/SocialTableViewCell.m
  33. 3 1
      NIMDemo/NIMDemo/SocialTableViewController.h
  34. 177 22
      NIMDemo/NIMDemo/SocialTableViewController.m
  35. 17 0
      NIMDemo/NIMDemo/SocialTopTableViewCell.h
  36. 60 0
      NIMDemo/NIMDemo/SocialTopTableViewCell.m
  37. 18 0
      NIMDemo/NIMDemo/TradeTopBarItem.h
  38. 114 0
      NIMDemo/NIMDemo/TradeTopBarItem.m
  39. 7 8
      NIMDemo/NIMDemo/User.h
  40. 17 61
      NIMDemo/NIMDemo/User.m
  41. 4 5
      NIMDemo/NIMDemo/ViewController.m
  42. 1 1
      NIMKit/NIMKit/Classes/Global/NIMKitDataProviderImpl.m
  43. 26 2
      NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m
  44. 24 1
      NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.m

BIN
NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/UserInterfaceState.xcuserstate


+ 18 - 0
NIMDemo/NIMDemo.xcodeproj/project.pbxproj

@@ -209,6 +209,9 @@
 		C482C3071F0B389400EF2B71 /* MyTradeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3061F0B389400EF2B71 /* MyTradeTableViewCell.m */; };
 		C482C30A1F0B857800EF2B71 /* NTESGiftAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3091F0B857800EF2B71 /* NTESGiftAttachment.m */; };
 		C482C30D1F0B923300EF2B71 /* NTESSessionGiftContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C30C1F0B923300EF2B71 /* NTESSessionGiftContentView.m */; };
+		C482C3101F0CAE7300EF2B71 /* TradeTopBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C30F1F0CAE7300EF2B71 /* TradeTopBarItem.m */; };
+		C482C3131F0CD37E00EF2B71 /* SocialTopTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3121F0CD37E00EF2B71 /* SocialTopTableViewCell.m */; };
+		C482C3161F0DD21500EF2B71 /* GroupCardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3151F0DD21500EF2B71 /* GroupCardViewController.m */; };
 		C4A734601EE6BBD300D6489D /* GroupMoreTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4A7345F1EE6BBD300D6489D /* GroupMoreTableViewController.m */; };
 		C4A734631EE6D4DE00D6489D /* GroupMoreTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4A734621EE6D4DE00D6489D /* GroupMoreTableViewCell.m */; };
 		C4A7D3661EE803E7009B5849 /* FriendViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4A7D3651EE803E6009B5849 /* FriendViewController.m */; };
@@ -629,6 +632,12 @@
 		C482C3091F0B857800EF2B71 /* NTESGiftAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NTESGiftAttachment.m; path = ../../../../../../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.m; sourceTree = "<group>"; };
 		C482C30B1F0B923300EF2B71 /* NTESSessionGiftContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NTESSessionGiftContentView.h; path = ../../../../../../../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.h; sourceTree = "<group>"; };
 		C482C30C1F0B923300EF2B71 /* NTESSessionGiftContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NTESSessionGiftContentView.m; path = ../../../../../../../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.m; sourceTree = "<group>"; };
+		C482C30E1F0CAE7300EF2B71 /* TradeTopBarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradeTopBarItem.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/TradeTopBarItem.h; sourceTree = "<group>"; };
+		C482C30F1F0CAE7300EF2B71 /* TradeTopBarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradeTopBarItem.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/TradeTopBarItem.m; sourceTree = "<group>"; };
+		C482C3111F0CD37E00EF2B71 /* SocialTopTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialTopTableViewCell.h; sourceTree = "<group>"; };
+		C482C3121F0CD37E00EF2B71 /* SocialTopTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialTopTableViewCell.m; sourceTree = "<group>"; };
+		C482C3141F0DD21500EF2B71 /* GroupCardViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupCardViewController.h; sourceTree = "<group>"; };
+		C482C3151F0DD21500EF2B71 /* GroupCardViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupCardViewController.m; sourceTree = "<group>"; };
 		C4A7345E1EE6BBD300D6489D /* GroupMoreTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupMoreTableViewController.h; sourceTree = "<group>"; };
 		C4A7345F1EE6BBD300D6489D /* GroupMoreTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupMoreTableViewController.m; sourceTree = "<group>"; };
 		C4A734611EE6D4DE00D6489D /* GroupMoreTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupMoreTableViewCell.h; sourceTree = "<group>"; };
@@ -1753,6 +1762,8 @@
 				C4B639561ED581E2004288FC /* User.m */,
 				C40F4C491EF15BC7002B197A /* GiftTopBarItem.h */,
 				C40F4C4A1EF15BC7002B197A /* GiftTopBarItem.m */,
+				C482C30E1F0CAE7300EF2B71 /* TradeTopBarItem.h */,
+				C482C30F1F0CAE7300EF2B71 /* TradeTopBarItem.m */,
 			);
 			name = User;
 			sourceTree = "<group>";
@@ -1792,6 +1803,8 @@
 				C4A7345F1EE6BBD300D6489D /* GroupMoreTableViewController.m */,
 				C4A734611EE6D4DE00D6489D /* GroupMoreTableViewCell.h */,
 				C4A734621EE6D4DE00D6489D /* GroupMoreTableViewCell.m */,
+				C482C3141F0DD21500EF2B71 /* GroupCardViewController.h */,
+				C482C3151F0DD21500EF2B71 /* GroupCardViewController.m */,
 			);
 			name = SectionGroup;
 			sourceTree = "<group>";
@@ -1801,6 +1814,8 @@
 			children = (
 				C4F1D0E91EF8F1B800A04B28 /* SocialTableViewController.h */,
 				C4F1D0EA1EF8F1B800A04B28 /* SocialTableViewController.m */,
+				C482C3111F0CD37E00EF2B71 /* SocialTopTableViewCell.h */,
+				C482C3121F0CD37E00EF2B71 /* SocialTopTableViewCell.m */,
 				C4F1D0EC1EF8F2E800A04B28 /* SocialTableViewCell.h */,
 				C4F1D0ED1EF8F2E800A04B28 /* SocialTableViewCell.m */,
 				C4F1D0EF1EF8F75400A04B28 /* SocialPublishViewController.h */,
@@ -2054,6 +2069,7 @@
 				61E471451B7D963E00F4A1BF /* NTESGalleryViewController.m in Sources */,
 				61E4715D1B7D963E00F4A1BF /* NTESClientsTableViewController.m in Sources */,
 				C4A734601EE6BBD300D6489D /* GroupMoreTableViewController.m in Sources */,
+				C482C3131F0CD37E00EF2B71 /* SocialTopTableViewCell.m in Sources */,
 				C482C2FE1F0A3B0000EF2B71 /* SettingTopTableViewCell.m in Sources */,
 				6159DF531C45F79D00E32EB4 /* NTESChatroomConfig.m in Sources */,
 				03A4C9FF1AC2B79700E45E03 /* UIAlertView+NTESBlock.m in Sources */,
@@ -2113,6 +2129,7 @@
 				61206EE71C1E607B009E4C78 /* NTESChatroomListCell.m in Sources */,
 				61E471191B7D963E00F4A1BF /* NTESContactUtilCell.m in Sources */,
 				61E471661B7D963E00F4A1BF /* NTESSettingPortraitCell.m in Sources */,
+				C482C3161F0DD21500EF2B71 /* GroupCardViewController.m in Sources */,
 				61E471131B7D963E00F4A1BF /* NTESGroupedContacts.m in Sources */,
 				C4D8F12F1ED48657002F9F3A /* AFURLRequestSerialization.m in Sources */,
 				61E4718D1B7D96AA00F4A1BF /* NTESDemoConfig.m in Sources */,
@@ -2151,6 +2168,7 @@
 				612CACEE1BB1484C00C348B5 /* NTESContactDataMember.m in Sources */,
 				61E471391B7D963E00F4A1BF /* NTESSearchMessageContentCell.m in Sources */,
 				6173AEC91BAAC6CB00854D49 /* NTESGenderSettingViewController.m in Sources */,
+				C482C3101F0CAE7300EF2B71 /* TradeTopBarItem.m in Sources */,
 				E45E17801CA8CBA500C4ED69 /* NTESLogManager.m in Sources */,
 				C4D4C9331ED7C37F00ADD7B7 /* LoginViewController.m in Sources */,
 				61518A4B1CA233390061C4A9 /* NTESNavigationHandler.m in Sources */,

+ 1 - 1
NIMDemo/NIMDemo/AppDelegate.m

@@ -306,7 +306,7 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     viewController.navigationItem.titleView.tintColor = [UIColor whiteColor];
     
     [viewController.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
-    [viewController.navigationController.navigationBar setShadowImage:nil];
+    [viewController.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
     
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
 }

+ 13 - 8
NIMDemo/NIMDemo/Base.lproj/Main.storyboard

@@ -214,21 +214,21 @@
                                 <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
                                 <nil key="textColor"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="18"/>
-                                <textInputTraits key="textInputTraits" keyboardType="phonePad"/>
+                                <textInputTraits key="textInputTraits"/>
                             </textField>
                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="密码(6-12位数字和字母组成)" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="CMg-YG-ALW">
                                 <rect key="frame" x="37" y="216" width="300" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
                                 <nil key="textColor"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="18"/>
-                                <textInputTraits key="textInputTraits" keyboardType="phonePad"/>
+                                <textInputTraits key="textInputTraits"/>
                             </textField>
                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="确认密码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="0TO-fY-Gay">
                                 <rect key="frame" x="37" y="276" width="300" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
                                 <nil key="textColor"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="18"/>
-                                <textInputTraits key="textInputTraits" keyboardType="phonePad"/>
+                                <textInputTraits key="textInputTraits"/>
                             </textField>
                             <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nUC-vV-b1N">
                                 <rect key="frame" x="29" y="342" width="316" height="50"/>
@@ -254,6 +254,7 @@
                         <outlet property="pwdConfirmTextField" destination="0TO-fY-Gay" id="bll-hs-AKm"/>
                         <outlet property="pwdTextField" destination="CMg-YG-ALW" id="Hhd-NC-oDz"/>
                         <outlet property="vcTextField" destination="a82-dS-POP" id="uxO-4w-xjG"/>
+                        <segue destination="ggS-Se-Q5A" kind="show" identifier="register2Tab" id="a1S-sq-Dbc"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="YBw-o3-UHP" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -307,12 +308,15 @@
         <scene sceneID="WAG-Ob-5Qi">
             <objects>
                 <viewController id="Uhr-b8-Pkv" customClass="SocialTableViewController" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="IAL-Aq-vcZ">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="04f-ju-rr5"/>
+                        <viewControllerLayoutGuide type="bottom" id="IBq-8r-LdV"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="pr8-VZ-vuU">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                        <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
-                    </tableView>
+                    </view>
                     <extendedEdge key="edgesForExtendedLayout" top="YES"/>
                     <tabBarItem key="tabBarItem" title="朋友圈" image="五个图标_21" selectedImage="五个图标_09" id="vyo-cF-KS0"/>
                     <simulatedTabBarMetrics key="simulatedBottomBarMetrics" translucent="NO"/>
@@ -854,8 +858,7 @@
                                                 <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Z2h-9J-xFe">
                                                     <rect key="frame" x="16" y="20" width="60" height="60"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
-                                                    <state key="normal" title="+"/>
+                                                    <state key="normal" backgroundImage="创建群_05"/>
                                                     <connections>
                                                         <action selector="addMenber:" destination="5qs-Nf-4Jf" eventType="touchUpInside" id="DGd-32-Niw"/>
                                                     </connections>
@@ -1003,6 +1006,7 @@
         <image name="五个图标_20" width="25" height="25"/>
         <image name="五个图标_21" width="25" height="25"/>
         <image name="五个图标_22" width="25" height="25"/>
+        <image name="创建群_05" width="50" height="50"/>
         <image name="开启通讯录_07" width="333" height="45"/>
         <image name="登录界面_03" width="632" height="90"/>
         <image name="登录界面_06" width="632" height="90"/>
@@ -1011,6 +1015,7 @@
         <image name="选择群组_13" width="20" height="20"/>
     </resources>
     <inferredMetricsTieBreakers>
+        <segue reference="a1S-sq-Dbc"/>
         <segue reference="koG-KY-sGS"/>
         <segue reference="gKG-Mt-Dsc"/>
         <segue reference="L8f-9a-f45"/>

+ 3 - 3
NIMDemo/NIMDemo/Classes/Common/View/NTESAvatarImageView.m

@@ -23,7 +23,7 @@
         self.backgroundColor = [UIColor clearColor];
         self.layer.geometryFlipped = YES;
         self.clipPath = YES;
-        self.defaultImage = [UIImage imageNamed:@"avatar_user"];
+        self.defaultImage = [UIImage imageNamed:@"avatar_user2"];
     }
     return self;
 }
@@ -140,13 +140,13 @@ CGRect CGRectWithCenterAndSize(CGPoint center, CGSize size){
 
 + (instancetype)demoInstance40x40{
     NTESAvatarImageView *avatarImageView = [[NTESAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
-    avatarImageView.image = [UIImage imageNamed:@"avatar_user.png"];
+    avatarImageView.image = [UIImage imageNamed:@"avatar_user2.png"];
     return avatarImageView;
 }
 
 + (instancetype)demoInstance30x30{
     NTESAvatarImageView *avatarImageView = [[NTESAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
-    avatarImageView.image = [UIImage imageNamed:@"avatar_user.png"];
+    avatarImageView.image = [UIImage imageNamed:@"avatar_user2.png"];
     return avatarImageView;
 }
 

+ 1 - 1
NIMDemo/NIMDemo/Classes/Sections/Chatroom/View/Cell/NTESChatroomMemberCell.m

@@ -33,7 +33,7 @@
 
 - (void)refresh:(NIMChatroomMember *)member{
     [self.avatarImageView nim_setImageWithURL:[NSURL URLWithString:member.roomAvatarThumbnail]
-                             placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+                             placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
     self.textLabel.text = member.roomNickname;
     [self.textLabel sizeToFit];
     [self refreshRole:member];

+ 22 - 2
NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m

@@ -859,6 +859,12 @@ TradeInputDelegate>
 //        }
 //    }
     
+    UIButton *enterTeamCard = [UIButton buttonWithType:UIButtonTypeCustom];
+    [enterTeamCard addTarget:self action:@selector(enterTeamCard:) forControlEvents:UIControlEventTouchUpInside];
+    [enterTeamCard setImage:[UIImage imageNamed:@"设置图标"] forState:UIControlStateNormal];
+    [enterTeamCard setFrame:CGRectMake(0, 0, 30, 30)];
+    UIBarButtonItem *enterTeamCardItem = [[UIBarButtonItem alloc] initWithCustomView:enterTeamCard];
+    
     
     UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
     [searchBtn addTarget:self action:@selector(searchChatContent:) forControlEvents:UIControlEventTouchUpInside];
@@ -876,13 +882,27 @@ TradeInputDelegate>
     //UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:searchBtn];
     //UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithCustomView:deleteBtn];
     
-    self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
+    
     
     
     if(self.session.sessionType == NIMSessionTypeTeam)
     {
-        [self.navigationItem.titleView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(enterTeamCard:)]];
+        NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
+        if(team && team.owner && [team.owner isEqualToString:@"10000"])
+        {
+            [self.navigationItem.titleView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(enterTeamCard:)]];
+            self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
+        }
+        else
+        {
+            self.navigationItem.rightBarButtonItems = @[enterTeamCardItem];
+        }
     }
+    else
+    {
+        self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
+    }
+    
 }
 
 - (BOOL)shouldAutorotate{

+ 30 - 2
NIMDemo/NIMDemo/CreateGroupViewController.m

@@ -20,7 +20,12 @@
 #import "UIImage+NIM.h"
 #import "NIMAvatarImageView.h"
 
-@interface CreateGroupViewController () <UIActionSheetDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate>
+@interface CreateGroupViewController ()
+<UIActionSheetDelegate,
+UIImagePickerControllerDelegate,
+UINavigationControllerDelegate,
+UITextFieldDelegate,
+UITextViewDelegate>
 
 
 
@@ -55,6 +60,11 @@ UIActionSheet *_avatarActionSheet;
     [self.avatarContainer addSubview:_avatar];
     [_avatar setImage:[UIImage imageNamed:@"聊天3_10"]];
     
+    _nickTextField.returnKeyType = UIReturnKeyDone;
+    _nickTextField.delegate = self;
+    _descTextView.returnKeyType = UIReturnKeyDone;
+    _descTextView.delegate = self;
+    
     [self showMenbersAvatar];
 }
 
@@ -177,7 +187,7 @@ UIActionSheet *_avatarActionSheet;
             NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userid];
             NSURL *avatarUrl = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
             
-            [avatarView nim_setImageWithURL:avatarUrl placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+            [avatarView nim_setImageWithURL:avatarUrl placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
             
             index++;
         }
@@ -271,4 +281,22 @@ UIActionSheet *_avatarActionSheet;
 }
 
 
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
+{
+    if ([string isEqualToString:@"\n"]) {
+        [textField resignFirstResponder];
+        return NO;
+    }
+    return YES;
+}
+
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
+    if ([text isEqualToString:@"\n"]) {
+        [textView resignFirstResponder];
+        return NO;
+    }
+    return YES;
+}
+
+
 @end

+ 4 - 4
NIMDemo/NIMDemo/GiftTopBarItem.m

@@ -40,7 +40,7 @@
         [self addSubview:container];
         
         _avatarSender = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(10, 5, 20, 20)];
-        [_avatarSender nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarSender nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         [container addSubview:_avatarSender];
         
         _labelSender = [[UILabel alloc] initWithFrame:CGRectMake(_avatarSender.nim_right+2, 5, 65, 20)];
@@ -54,7 +54,7 @@
         [container addSubview:labelGive];
         
         _avatarTarget = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(labelGive.nim_right+5, 5, 20, 20)];
-        [_avatarTarget nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarTarget nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         [container addSubview:_avatarTarget];
         
         _labelTarget = [[UILabel alloc] initWithFrame:CGRectMake(_avatarTarget.nim_right+2, 5, 70, 20)];
@@ -90,7 +90,7 @@
         
         NIMUser *userSender = [users objectAtIndex:0];
         NSURL *url = userSender.userInfo.avatarUrl ? [NSURL URLWithString:userSender.userInfo.avatarUrl] : nil;
-        [_avatarSender nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarSender nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         
         _labelSender.text = userSender.userInfo.nickName && userSender.userInfo.nickName.length > 0 ? userSender.userInfo.nickName : userSender.userId;
     }];
@@ -104,7 +104,7 @@
             
             NIMUser *userTarget = [users objectAtIndex:0];
             NSURL *url = userTarget.userInfo.avatarUrl ? [NSURL URLWithString:userTarget.userInfo.avatarUrl] : nil;
-            [_avatarTarget nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+            [_avatarTarget nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
             
             _labelTarget.text = userTarget.userInfo.nickName && userTarget.userInfo.nickName.length > 0 ? userTarget.userInfo.nickName : userTarget.userId;
         }];

+ 13 - 0
NIMDemo/NIMDemo/GroupCardViewController.h

@@ -0,0 +1,13 @@
+//
+//  GroupCardViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/6.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface GroupCardViewController : UIViewController
+
+@end

+ 37 - 0
NIMDemo/NIMDemo/GroupCardViewController.m

@@ -0,0 +1,37 @@
+//
+//  GroupCardViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/6.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "GroupCardViewController.h"
+
+@interface GroupCardViewController ()
+
+@end
+
+@implementation GroupCardViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 5 - 5
NIMDemo/NIMDemo/GroupTableController.m

@@ -105,7 +105,7 @@
     if(user.districtRoomId && user.firstTimeJoin == YES)
     {
         user.firstTimeJoin = NO;
-        [self startTeamChat:user.districtRoomId];
+        [self startTeamChat:user.districtRoomId animated:NO];
     }
     else
     {
@@ -331,7 +331,7 @@
     
     if([[NIMSDK sharedSDK].teamManager isMyTeam:teamId])
     {
-        [self startTeamChat:teamId];
+        [self startTeamChat:teamId animated:YES];
     }
     else
     {
@@ -339,17 +339,17 @@
             NSLog(@"applyToTeam error %@", error);
             if(!error && applyStatus == NIMTeamApplyStatusAlreadyInTeam)
             {
-                [self startTeamChat:teamId];
+                [self startTeamChat:teamId animated:YES];
             }
         }];
     }
 }
 
-- (void)startTeamChat:(NSString *)teamId
+- (void)startTeamChat:(NSString *)teamId animated:(BOOL)animated
 {
     NIMSession *session = [NIMSession session:teamId type:NIMSessionTypeTeam];
     NTESSessionViewController *vc = [[NTESSessionViewController alloc] initWithSession:session];
-    [self.navigationController pushViewController:vc animated:YES];
+    [self.navigationController pushViewController:vc animated:animated];
 }
 
 - (void)relocaltion{

+ 19 - 1
NIMDemo/NIMDemo/HttpRequest/HttpRequest.h

@@ -16,8 +16,23 @@
 + (instancetype _Nonnull )shared;
 
 
+//register
+- (void)registerAccount:(NSString *_Nullable)mobile
+                   code:(NSString *_Nullable)code
+               password:(NSString *_Nullable)password
+                success:(void (^_Nullable)())success
+                failure:(void (^_Nullable)())failure;
+
+//login
+- (void)loginAccount:(NSString *_Nullable)mobile
+           password:(NSString *_Nullable)password
+            success:(void (^_Nullable)())success
+            failure:(void (^_Nullable)())failure;
 
-
+- (void)loginNIM:(NSString *_Nullable)uid
+           token:(NSString *_Nullable)token
+         success:(void (^_Nullable)())success
+         failure:(void (^_Nullable)(NSError * _Nullable error))failure;
 
 
 
@@ -69,6 +84,9 @@
           success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
           failure:(void (^_Nullable)())failure;
 
+- (void)tradeLatestList:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
+                failure:(void (^_Nullable)())failure;
+
 - (void)tradeFollow:(NSString *_Nullable)tradeId
             success:(void (^_Nullable)())success
             failure:(void (^_Nullable)())failure;

+ 160 - 0
NIMDemo/NIMDemo/HttpRequest/HttpRequest.m

@@ -10,11 +10,17 @@
 #import "AFHTTPSessionManager.h"
 #import "UIAlertView+NTESBlock.h"
 #import "User.h"
+#import "NTESService.h"
+#import "NTESLoginManager.h"
 
 
 @interface HttpRequest()
 
 @property (nonatomic, strong) NSString *urlRoot;
+
+@property (nonatomic, strong) NSString *urlLogin;
+@property (nonatomic, strong) NSString *urlRegister;
+
 @property (nonatomic, strong) NSString *urlSocialDataList;
 @property (nonatomic, strong) NSString *urlSocialLike;
 @property (nonatomic, strong) NSString *urlSocialLikeList;
@@ -25,6 +31,7 @@
 @property (nonatomic, strong) NSString *urlTradeEdit;
 @property (nonatomic, strong) NSString *urlTradeDelete;
 @property (nonatomic, strong) NSString *urlTradeDataList;
+@property (nonatomic, strong) NSString *urlTradeLatestDataList;
 @property (nonatomic, strong) NSString *urlTradeFollow;
 @property (nonatomic, strong) NSString *urlTradeDeleteFollow;
 
@@ -49,6 +56,10 @@
     if(self)
     {
         self.urlRoot = @"http://whosay.dashgame.com/";
+        
+        self.urlRegister = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=register"];
+        self.urlLogin = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=login"];
+        
         self.urlSocialDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=lists"];
         self.urlSocialLike = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like"];
         self.urlSocialLikeList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like_list"];
@@ -59,6 +70,7 @@
         self.urlTradeEdit = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=edit"];
         self.urlTradeDelete = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete"];
         self.urlTradeDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=lists"];
+        self.urlTradeLatestDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=latest_lists"];
         self.urlTradeFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=follow"];
         self.urlTradeDeleteFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete_follow"];
     }
@@ -138,6 +150,110 @@
 
 
 
+
+
+
+
+//register
+- (void)registerAccount:(NSString *_Nullable)mobile
+                   code:(NSString *_Nullable)code
+               password:(NSString *_Nullable)password
+                success:(void (^_Nullable)())success
+                failure:(void (^_Nullable)())failure{
+    
+    NSDictionary *parameters = @{@"mobile":mobile,
+                                 @"pwd":password,
+                                 @"code":code
+                                 };
+    
+    [self request:_urlRegister parameters:parameters progress:nil success:^(id jsonData) {
+        if(success)
+            success();
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+//login
+- (void)loginAccount:(NSString *_Nullable)mobile
+            password:(NSString *_Nullable)password
+             success:(void (^_Nullable)())success
+             failure:(void (^_Nullable)())failure{
+    
+    
+    NSDictionary *parameters = @{@"mobile":mobile,
+                                 @"pwd":password
+                                 };
+    
+    [self request:_urlLogin parameters:parameters progress:nil success:^(id data) {
+        
+        User *user = [User sharedInfo];
+        user.userId = [[data valueForKey:@"id"] intValue];
+        user.mobile = [data valueForKey:@"mobile"];
+        user.token = [data valueForKey:@"token"];
+        user.nick = [data valueForKey:@"nick"];
+        user.coin = [[data valueForKey:@"coin"] intValue];
+        user.latitude = [[data valueForKey:@"latitude"] doubleValue];
+        user.longitude = [[data valueForKey:@"longitude"] doubleValue];
+        user.province = [data valueForKey:@"province"];
+        user.city = [data valueForKey:@"city"];
+        user.district = [data valueForKey:@"district"];
+        
+        user.countryRoomId = [data valueForKey:@"country_room_id"];
+        user.provinceRoomId = [data valueForKey:@"province_room_id"];
+        user.cityRoomId = [data valueForKey:@"city_room_id"];
+        user.districtRoomId = [data valueForKey:@"district_room_id"];
+        user.firstTimeJoin = YES;
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+- (void)loginNIM:(NSString *_Nullable)uid
+           token:(NSString *_Nullable)token
+         success:(void (^_Nullable)())success
+         failure:(void (^_Nullable)(NSError * _Nullable error))failure{
+    
+    [[[NIMSDK sharedSDK] loginManager] login:uid
+                                       token:token
+                                  completion:^(NSError *error) {
+                                      
+                                      NSLog(@"Login Error %@", error);
+                                      
+                                      if(!error)
+                                      {
+                                          NSString *userID = [NIMSDK sharedSDK].loginManager.currentAccount;
+                                          NSLog(@"Login success, userId : %@", userID);
+                                          
+                                          LoginData *sdkData = [[LoginData alloc] init];
+                                          sdkData.account   = uid;
+                                          sdkData.token     = token;
+                                          [[NTESLoginManager sharedManager] setCurrentLoginData:sdkData];
+                                          
+                                          [[NTESServiceManager sharedManager] start];
+                                          
+                                          if(success)
+                                              success();
+                                      }
+                                      else
+                                      {
+                                          if(failure)
+                                              failure(error);
+                                      }
+                                  }];
+}
+
+
+
+
+
 - (void)getSocialDataList:(NSString *)lastId
                   success:(void (^_Nullable)(NSMutableArray *dataList))success
                   failure:(void (^_Nullable)())failure{
@@ -449,6 +565,50 @@
 
 
 
+- (void)tradeLatestList:(void (^_Nullable)(NSMutableArray *dataList))success
+                failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    
+    NSString *province = user.province ? user.province : @"";
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:province forKey:@"province"];
+    [parameters setValue:userId forKey:@"user_id"];
+    
+    
+    [self request:_urlTradeLatestDataList parameters:parameters progress:nil success:^(id jsonData) {
+        
+        NSMutableArray *userIds = [[NSMutableArray alloc] init];
+        
+        NSMutableArray *jsonList = [jsonData objectForKey:@"list"];
+        NSMutableArray *list = [[NSMutableArray alloc] init];
+        
+        for(int i=0; i<jsonList.count; i++)
+        {
+            NSDictionary *json = [jsonList objectAtIndex:i];
+            TradeData *data = [[TradeData alloc] init];
+            [data setData:json];
+            [list addObject:data];
+            
+            [userIds addObject:data.userId];
+        }
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:userIds completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(jsonList);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+
+
 - (void)tradeFollow:(NSString *)tradeId
             success:(void (^_Nullable)())success
             failure:(void (^_Nullable)())failure{

+ 21 - 0
NIMDemo/NIMDemo/Images.xcassets/Whosay/avatar_user2.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "avatar_user2.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
NIMDemo/NIMDemo/Images.xcassets/Whosay/avatar_user2.imageset/avatar_user2.png


+ 21 - 0
NIMDemo/NIMDemo/Images.xcassets/Whosay/发布交易贴.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "发布交易贴.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
NIMDemo/NIMDemo/Images.xcassets/Whosay/发布交易贴.imageset/发布交易贴.png


+ 21 - 0
NIMDemo/NIMDemo/Images.xcassets/Whosay/设置图标.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "设置图标.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
NIMDemo/NIMDemo/Images.xcassets/Whosay/设置图标.imageset/设置图标.png


+ 9 - 34
NIMDemo/NIMDemo/LoginViewController.m

@@ -13,9 +13,8 @@
 #import "AFNetworking/AFNetworking.h"
 #import "User.h"
 #import "SVProgressHUD.h"
-#import "NTESService.h"
-#import "NTESLoginManager.h"
 #import "UIView+Toast.h"
+#import "HttpRequest.h"
 
 @interface LoginViewController ()
 @property (weak, nonatomic) IBOutlet UITextField *mobileTextField;
@@ -64,44 +63,20 @@
     NSString *mobile = self.mobileTextField.text;
     NSString *pwd = self.pwdTextField.text;
     
-    [[User sharedInfo] login:mobile pwd:pwd sucCallBack:^{
-        
+    [[HttpRequest shared] loginAccount:mobile password:pwd success:^{
         User *user = [User sharedInfo];
         [self loginNIM:[NSString stringWithFormat:@"%d", user.userId] token:user.token];
-        
-    } failCallBack:^(NSError * _Nullable error) {
-        
+    } failure:^{
+        [self.view makeToast:@"登录谁说失败" duration:2.0 position:CSToastPositionCenter];
     }];
 }
 
 - (void)loginNIM:(NSString *)uid token:(NSString *)token{
-    NSLog(@"Login with %@ %@", uid, token);
-    [[[NIMSDK sharedSDK] loginManager] login:uid
-                                       token:token
-                                  completion:^(NSError *error) {
-                                      
-                                      NSLog(@"Login Error %@", error);
-                                      
-                                      if(!error)
-                                      {
-                                          NSString *userID = [NIMSDK sharedSDK].loginManager.currentAccount;
-                                          NSLog(@"Login success, userId : %@", userID);
-                                          
-                                          LoginData *sdkData = [[LoginData alloc] init];
-                                          sdkData.account   = uid;
-                                          sdkData.token     = token;
-                                          [[NTESLoginManager sharedManager] setCurrentLoginData:sdkData];
-                                          
-                                          [[NTESServiceManager sharedManager] start];
-                                          
-                                          [self showTabBarView];
-                                      }
-                                      else
-                                      {
-                                          NSString *toast = [NSString stringWithFormat:@"登录失败 code: %zd",error.code];
-                                          [self.view makeToast:toast duration:2.0 position:CSToastPositionCenter];
-                                      }
-                                  }];
+    [[HttpRequest shared] loginNIM:uid token:token success:^{
+        [self showTabBarView];
+    } failure:^(NSError * _Nullable error) {
+        [self.view makeToast:[NSString stringWithFormat:@"进入聊天失败 error:%@", error] duration:2.0 position:CSToastPositionCenter];
+    }];
 }
 
 - (void)showTabBarView{

+ 32 - 20
NIMDemo/NIMDemo/RegisterViewController.m

@@ -8,7 +8,10 @@
 
 #import "AppDelegate.h"
 #import "RegisterViewController.h"
-#import "AFNetworking/AFNetworking.h"
+#import "HttpRequest.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+#import "User.h"
 
 @interface RegisterViewController ()
 @property (weak, nonatomic) IBOutlet UITextField *mobileTextField;
@@ -57,26 +60,35 @@
 - (IBAction)registerClick:(id)sender {
     NSString *mobile = self.mobileTextField.text;
     NSString *password = self.pwdTextField.text;
+    NSString *code = self.vcTextField.text;
     
-    NSDictionary *parameters = @{@"mobile":mobile,
-                                 @"pwd":password
-                                 };
-//    NSDictionary *parameters = @{};
-    NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=index&a=register";
-    //请求的managers
-    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
-    manager.responseSerializer = [AFJSONResponseSerializer new];
-    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
-    //请求的方式:POST
-    [manager POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
-        NSLog(@"请求成功,服务器返回的信息%@", responseObject);
-        NSDictionary * dic = responseObject;
-        int code = [[dic valueForKey:@"c"] intValue];
-        NSString *info = (NSString *)[dic objectForKey:@"d"];
-        info = [info stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-        NSLog(@"Json解析结果 = %d   %@", code, info);
-    } failure:^(NSURLSessionDataTask *task, NSError * error) {
-        NSLog(@"请求失败,服务器返回的错误信息%@",error);
+    
+    [SVProgressHUD show];
+    [[HttpRequest shared] registerAccount:mobile code:code password:password success:^{
+        
+        [self login:mobile password:password];
+        
+    } failure:^{
+        [SVProgressHUD dismiss];
+    }];
+}
+
+- (void)login:(NSString *)mobile password:(NSString *)password{
+    [[HttpRequest shared] loginAccount:mobile password:password success:^{
+        User *user = [User sharedInfo];
+        [self loginNIM:[NSString stringWithFormat:@"%d", user.userId] token:user.token];
+    } failure:^{
+        [SVProgressHUD dismiss];
+    }];
+}
+
+- (void)loginNIM:(NSString *)uid token:(NSString *)token{
+    [[HttpRequest shared] loginNIM:uid token:token success:^{
+        [self performSegueWithIdentifier:@"register2Tab" sender:self];
+        [SVProgressHUD dismiss];
+    } failure:^(NSError * _Nullable error) {
+        [self.view makeToast:[NSString stringWithFormat:@"进入聊天失败 error:%@", error] duration:2.0 position:CSToastPositionCenter];
+        [SVProgressHUD dismiss];
     }];
 }
 

+ 2 - 2
NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m

@@ -71,7 +71,7 @@
     
     _followContainer = [[UIView alloc] initWithFrame:CGRectMake(cellWidth-padding-40, padding, 50, 40)];
     [_followContainer addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchFollow:)]];
-    [self.contentView addSubview:_followContainer];
+    //[self.contentView addSubview:_followContainer];
     
     UIImageView *followIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 20, 20)];
     [followIcon setImage:[UIImage imageNamed:@"交易帖_03"]];
@@ -129,7 +129,7 @@
     if(user)
     {
         NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         _avatarView.tag = [data.userId intValue];
         
         

+ 7 - 0
NIMDemo/NIMDemo/SectionTrade/TradePublishManager.h

@@ -9,8 +9,15 @@
 #import <Foundation/Foundation.h>
 #import "NIMInputView.h"
 
+@protocol TradePublishDelegate <NSObject>
+
+- (void)tradePublishResult:(BOOL)success;
+
+@end
+
 @interface TradePublishManager : NSObject
 
+@property (nonatomic, weak, nullable) id<TradePublishDelegate>  delegate;
 @property (nonatomic, weak) NIMInputView            * _Nullable inputView;
 
 - (void)tradePublish:(NSString *_Nullable)msg

+ 7 - 0
NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m

@@ -134,6 +134,9 @@
             [_inputView.giftContainer tradePublished];
         }
         
+        if ([_delegate respondsToSelector:@selector(tradePublishResult:)]){
+            [_delegate tradePublishResult:YES];
+        }
     } failure:^{
         
         [SVProgressHUD dismiss];
@@ -141,6 +144,10 @@
         {
             [_inputView.superview makeToast:@"发布失败" duration:2.0 position:CSToastPositionCenter];
         }
+        
+        if ([_delegate respondsToSelector:@selector(tradePublishResult:)]){
+            [_delegate tradePublishResult:NO];
+        }
     }];
 
 }

+ 6 - 6
NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.m

@@ -122,7 +122,7 @@ return self;
     if(user)
     {
         NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         _avatarView.tag = [data.userId intValue];
         
         
@@ -146,7 +146,7 @@ return self;
     _msgTextView.height = _msgTextView.contentSize.height;
     
     _imgContainer.top = _msgTextView.bottom + 5;
-    float imgPadding = 2;
+    float imgPadding = 5;
     float imgSize = (_imgContainer.width - imgPadding * 2) / 3;
     float imgContainerHeight = 0;
     int i=0;
@@ -202,21 +202,21 @@ return self;
     if(_data.followed)
     {
         [[HttpRequest shared] tradeDeleteFollow:_data.tradeId success:^{
-            [self makeToast:@"取消关注成功"];
+            [self.viewController.view makeToast:@"取消关注成功" duration:2 position:CSToastPositionCenter];
             _data.followed = NO;
             [self updateFollow];
         } failure:^{
-            [self makeToast:@"取消关注失败"];
+            [self.viewController.view makeToast:@"取消关注失败" duration:2 position:CSToastPositionCenter];
         }];
     }
     else
     {
         [[HttpRequest shared] tradeFollow:_data.tradeId success:^{
-            [self makeToast:@"关注成功"];
+            [self.viewController.view makeToast:@"关注成功" duration:2 position:CSToastPositionCenter];
             _data.followed = YES;
             [self updateFollow];
         } failure:^{
-            [self makeToast:@"关注失败"];
+            [self.viewController.view makeToast:@"关注失败" duration:2 position:CSToastPositionCenter];
         }];
     }
 }

+ 281 - 1
NIMDemo/NIMDemo/SectionTrade/TradeViewController.m

@@ -13,8 +13,13 @@
 #import "HttpRequest.h"
 #import "UIActionSheet+NTESBlock.h"
 #import "User.h"
+#import "TradeInputContainer.h"
+#import "TradePublishManager.h"
+#import "UIView+Toast.h"
+#import "TradeTopBarItem.h"
 
-@interface TradeViewController () <UIScrollViewDelegate>
+
+@interface TradeViewController () <UIScrollViewDelegate, TradeInputDelegate, TradePublishDelegate>
 
 @property (nonatomic, strong) NSMutableArray            *dataList;
 @property (nonatomic, assign) BOOL                      isFetching;
@@ -24,6 +29,19 @@
 
 @property (nonatomic, strong) NSString                  *district;
 
+@property (nonatomic, strong) UIView                    *tradePublishView;
+@property (nonatomic, strong) UIView                    *tradeContainer;
+@property (nonatomic, strong) TradeInputContainer       *tradeInput;
+@property (nonatomic, strong) UIButton                  *supplyBtn;
+@property (nonatomic, strong) UIButton                  *demandBtn;
+@property (nonatomic, strong) UILabel                   *balanceLabel;
+@property (nonatomic, strong) UIButton                  *balanceBtn;
+
+
+@property (nonatomic,strong)  TradeTopBarItem           *tradeItem1;
+@property (nonatomic,strong)  TradeTopBarItem           *tradeItem2;
+@property (nonatomic,strong)  NSTimer                   *timer;
+
 @end
 
 @implementation TradeViewController
@@ -33,16 +51,126 @@ float postHeight = 30;
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
+    
+    [self tableView];
+    
+    UIButton *showInputBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    showInputBtn.frame = CGRectMake(self.view.width - 65, self.view.height-115, 40, 40);
+    [showInputBtn setImage:[UIImage imageNamed:@"发布交易贴"] forState:UIControlStateNormal];
+    [showInputBtn addTarget:self action:@selector(showTradeInput:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:showInputBtn];
+    
+    
+    
+    _tradePublishView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
+    [self.view addSubview:_tradePublishView];
+    
+    UIButton *btnMask = [UIButton buttonWithType:UIButtonTypeCustom];
+    btnMask.backgroundColor = UIColorFromRGBA(0x000000, 0.5);
+    btnMask.frame = CGRectMake(0, 0, self.view.width, self.view.height);
+    [btnMask addTarget:self action:@selector(hideTradeInput:) forControlEvents:UIControlEventTouchUpInside];
+    [_tradePublishView addSubview:btnMask];
+    
+    
+    float tabbarHeight = self.tabBarController.tabBar.frame.size.height;
+    _tradeContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _tradePublishView.width, 272)];
+    _tradeContainer.bottom = _tradePublishView.bottom - tabbarHeight;
+    [_tradePublishView addSubview:_tradeContainer];
+    
+    
+    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
+    btn.backgroundColor = UIColor.whiteColor;
+    btn.frame = CGRectMake(0, 0, _tradeContainer.width, _tradeContainer.height);
+    [btn addTarget:self action:@selector(hideTradeInput:) forControlEvents:UIControlEventTouchUpInside];
+    [_tradeContainer addSubview:btn];
+
+    
+    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 100, 30)];
+    titleLabel.text = @"需求/礼物赠送";
+    titleLabel.textColor = UIColor.grayColor;
+    [titleLabel setFont:[UIFont systemFontOfSize:14]];
+    [_tradeContainer addSubview:titleLabel];
+    
+    UIButton *rechargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    rechargeBtn.frame = CGRectMake(_tradeContainer.width - 10 - 50, 8, 50, 30);
+    rechargeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [rechargeBtn setTitle:@"充值" forState:UIControlStateNormal];
+    UIColor *rechargeBtnColor = [UIColor colorWithRed:(51.0 / 255.0) green:(205.0 / 255.0) blue:(153.0 / 255.0) alpha:1.0];
+    [rechargeBtn setTitleColor:rechargeBtnColor forState:UIControlStateNormal];
+    [rechargeBtn addTarget:self action:@selector(showRecharge:) forControlEvents:UIControlEventTouchUpInside];
+    [_tradeContainer addSubview:rechargeBtn];
+    
+    
+    _balanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_tradeContainer.width - 10 - 50 - 120, 8, 120, 30)];
+    _balanceLabel.font = [UIFont systemFontOfSize:14];
+    _balanceLabel.textAlignment = NSTextAlignmentRight;
+    [_tradeContainer addSubview:_balanceLabel];
+    
+    
+    
+    UIView *sep1 = [[UIView alloc] initWithFrame:CGRectMake(0, 45, _tradeContainer.width, .5)];
+    sep1.backgroundColor = UIColor.lightGrayColor;
+    [_tradeContainer addSubview:sep1];
+    
+    
+    _demandBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _demandBtn.frame = CGRectMake(_tradeContainer.centerX - 80, 50, 60, 35);
+    [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+    [_demandBtn setTitle:@" 需求" forState:UIControlStateNormal];
+    [_demandBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
+    [_demandBtn setTitleColor:UIColor.grayColor forState:UIControlStateNormal];
+    [_demandBtn addTarget:self action:@selector(toggleDemand:) forControlEvents:UIControlEventTouchUpInside];
+    [_tradeContainer addSubview:_demandBtn];
+    
+    
+    _supplyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _supplyBtn.frame = CGRectMake(_tradeContainer.centerX+20, 50, 60, 35);
+    [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+    [_supplyBtn setTitle:@" 供求" forState:UIControlStateNormal];
+    [_supplyBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
+    [_supplyBtn setTitleColor:UIColor.grayColor forState:UIControlStateNormal];
+    [_supplyBtn addTarget:self action:@selector(toggleSupply:) forControlEvents:UIControlEventTouchUpInside];
+    [_tradeContainer addSubview:_supplyBtn];
+    
+    
+    
+    UIView *sep2 = [[UIView alloc] initWithFrame:CGRectMake(0, 89, _tradeContainer.width, .5)];
+    sep2.backgroundColor = UIColor.lightGrayColor;
+    [_tradeContainer addSubview:sep2];
+    
+    
+    _tradeInput = [[TradeInputContainer alloc] initWithFrame:CGRectMake(0, 90, _tradeContainer.width, _tradeContainer.height - 90)];
+    _tradeInput.delegate = self;
+    [_tradeContainer addSubview:_tradeInput];
+    
+    
+    [self hideTradeInput:nil];
+    
+    
+    
+    
+    _tradeItem1 = [[TradeTopBarItem alloc] initWithFrame:CGRectMake(0, 64, self.view.width, 40)];
+    _tradeItem1.hidden = YES;
+    [self.view addSubview:_tradeItem1];
+    _tradeItem2 = [[TradeTopBarItem alloc] initWithFrame:CGRectMake(0, _tradeItem1.bottom-5, self.view.width, 40)];
+    _tradeItem2.hidden = YES;
+    [self.view addSubview:_tradeItem2];
+    
+    _timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(requestLastTradeDataList) userInfo:nil repeats:YES];
 }
 
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
+    
+    [_timer invalidate];
 }
 
 - (void)viewWillAppear:(BOOL)animated{
     [super viewWillAppear:animated];
     
+    [_timer setFireDate:[NSDate distantPast]];
+    
     User *user = [User sharedInfo];
     
     if((_district && ![_district isEqualToString:user.district]) || (!_district && user.district))
@@ -109,9 +237,18 @@ float postHeight = 30;
     UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(onTouchSearch:)];
     
     [navItem setRightBarButtonItems:@[rightItem, searchItem]];
+    
+    
+    
+    _balanceLabel.text = [NSString stringWithFormat:@"余额:%d", [User sharedInfo].coin];
 }
 
 
+- (void)viewWillDisappear:(BOOL)animated{
+    [super viewWillDisappear:animated];
+    [_timer setFireDate:[NSDate distantFuture]];
+}
+
 - (void)relocaltion{
     UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
     UIViewController *next = (UIViewController *)[board instantiateViewControllerWithIdentifier:@"CityPicker"];
@@ -328,4 +465,147 @@ float postHeight = 30;
     
 }
 
+
+- (void)showRecharge:(int)sender
+{
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    UIViewController *next = [board instantiateViewControllerWithIdentifier:@"Recharge"];
+    [self.navigationController pushViewController:next animated:YES];
+}
+
+
+- (void)showTradeInput:(id)sender{
+    [_tradePublishView setHidden:NO];
+    [_tradeInput reset];
+    [self toggleDemand:nil];
+}
+
+- (void)hideTradeInput:(id)sender{
+    [_tradePublishView setHidden:YES];
+}
+
+
+- (void)toggleDemand:(id)sender{
+    
+    _tradeInput.tradeType = (int)TradeTypeDemand;
+    [_demandBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+    [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+
+}
+
+- (void)toggleSupply:(id)sender{
+    
+    _tradeInput.tradeType = (int)TradeTypeSupply;
+    [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+    [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+    
+}
+
+
+- (void)sendTrade:(NSString *)msg picArr:(NSMutableArray *)picArr priority:(int)priority type:(int)type{
+    
+    if((!msg || msg.length == 0) && picArr.count == 0)
+    {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"你还什么都没说呢" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+        [alert show];
+        return;
+    }
+    
+    TradePublishManager *tradePublishManager = [[TradePublishManager alloc] init];
+    tradePublishManager.delegate = self;
+    [tradePublishManager tradePublish:msg picArr:picArr priority:priority tradeType:type];
+    
+    [self hideTradeInput:nil];
+}
+
+- (void)tradePublishResult:(BOOL)success{
+    if(success)
+    {
+        [self reset];
+        [self fetchDataList];
+        [self.view makeToast:@"发布成功" duration:2 position:CSToastPositionCenter];
+    }
+    else
+    {
+        [self.view makeToast:@"发布失败" duration:2 position:CSToastPositionCenter];
+    }
+}
+
+
+
+- (void)requestLastTradeDataList{
+    NSLog(@"updateGiftTopItem");
+    
+    [[HttpRequest shared] tradeLatestList:^(NSMutableArray * _Nullable dataList) {
+        
+        for(int i=0; i<dataList.count; i++)
+        {
+            NSMutableDictionary *data = [dataList objectAtIndex:i];
+            NSString *province = [data objectForKey:@"province"];
+            NSString *tradeId = [data objectForKey:@"id"];
+            
+            if([[User sharedInfo] isNewTradeGot:province dataId:tradeId]){
+                
+                if(!_tradeItem1.isHidden && !_tradeItem2.isHidden)
+                {
+                    [_tradeItem1 setInfo:_tradeItem2.infoDict];
+                    _tradeItem1.timeCount = _tradeItem2.timeCount;
+                    
+                    [_tradeItem2 setInfo:data];
+                    _tradeItem2.timeCount = 0;
+                }
+                else if(!_tradeItem1.isHidden && _tradeItem2.isHidden)
+                {
+                    [_tradeItem2 setInfo:data];
+                    [_tradeItem2 setHidden:NO];
+                    _tradeItem2.timeCount = 0;
+                }
+                else
+                {
+                    [_tradeItem1 setInfo:data];
+                    [_tradeItem1 setHidden:NO];
+                    _tradeItem1.timeCount = 0;
+                }
+                
+            }
+        }
+        
+        
+        [self updateTradeTopItem];
+    } failure:^{
+        [self updateTradeTopItem];
+    }];
+}
+
+- (void)updateTradeTopItem{
+    
+    NSLog(@"updateGiftTopItem");
+    
+    int hideTimeCount = 1;
+    
+    if(!_tradeItem1.isHidden){
+        _tradeItem1.timeCount++;
+        if(_tradeItem1.timeCount > hideTimeCount)
+        {
+            [_tradeItem1 setHidden:YES];
+        }
+    }
+    if(!_tradeItem2.isHidden){
+        _tradeItem2.timeCount++;
+        if(_tradeItem2.timeCount > hideTimeCount)
+        {
+            [_tradeItem2 setHidden:YES];
+        }
+    }
+    
+    
+    if(!_tradeItem2.isHidden && _tradeItem1.isHidden)
+    {
+        [_tradeItem1 setInfo:_tradeItem2.infoDict];
+        _tradeItem1.timeCount = _tradeItem2.timeCount;
+        [_tradeItem1 setHidden:NO];
+        
+        [_tradeItem2 setHidden:YES];
+    }
+}
 @end

+ 5 - 3
NIMDemo/NIMDemo/SettingTableViewController.m

@@ -15,6 +15,7 @@
 #import "SettingTopTableViewCell.h"
 #import "AppDelegate.h"
 #import "SettingOptionTableViewCell.h"
+#import "NTESUserInfoSettingViewController.h"
 
 @interface SettingTableViewController ()
 
@@ -73,9 +74,9 @@
     
     
     UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-    [addBtn setImage:[UIImage imageNamed:@"创建群_07"] forState:UIControlStateNormal];
+    [addBtn setImage:[UIImage imageNamed:@"设置图标"] forState:UIControlStateNormal];
     [addBtn addTarget:self action:@selector(onTouchSetting:) forControlEvents:UIControlEventTouchUpInside];
-    [addBtn sizeToFit];
+    [addBtn setFrame:CGRectMake(0, 0, 30, 30)];
     UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithCustomView:addBtn];
     
     [navItem setRightBarButtonItems:@[addItem]];
@@ -143,7 +144,8 @@
 
 
 - (void)onTouchSetting:(id)sender{
-    
+    NTESUserInfoSettingViewController *vc = [[NTESUserInfoSettingViewController alloc] initWithNibName:nil bundle:nil];
+    [self.navigationController pushViewController:vc animated:YES];
 }
 
 

+ 1 - 1
NIMDemo/NIMDemo/SettingTopTableViewCell.m

@@ -50,7 +50,7 @@
     _avatarImg.centerY = _topImgView.bottom;
     
     NSURL *url = nimUser.userInfo.avatarUrl ? [NSURL URLWithString:nimUser.userInfo.avatarUrl] : nil;
-    [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+    [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
     [self addSubview:_avatarImg];
     
     _genderImg = [[UIImageView alloc] initWithFrame:CGRectMake(_avatarImg.right-20, _avatarImg.bottom-20, 20, 20)];

+ 1 - 1
NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.m

@@ -80,7 +80,7 @@
     NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:socialCommentData.userId];
     
     NSURL *url = user && user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-    [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+    [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
     _avatarView.tag = [socialCommentData.userId intValue];
     
     _timeLabel.text = socialCommentData.time;

+ 3 - 3
NIMDemo/NIMDemo/SocialDetailTableViewCell.m

@@ -125,7 +125,7 @@
     _viewsBtn.titleLabel.font = [UIFont systemFontOfSize:14];
     [_viewsBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
     [_viewsBtn setImage:[UIImage imageNamed:@"朋友圈_03"] forState:UIControlStateNormal];
-    [_actionContainer addSubview:_viewsBtn];
+    //[_actionContainer addSubview:_viewsBtn];
     
     
     //like title
@@ -176,7 +176,7 @@
     if(user)
     {
         NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         _avatarView.tag = [data.userId intValue];
         
         
@@ -288,7 +288,7 @@
             [avatar addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
             
             NSURL *url = user && user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-            [avatar nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+            [avatar nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
             [_likeContainer addSubview:avatar];
         }
         

+ 5 - 47
NIMDemo/NIMDemo/SocialTableViewCell.m

@@ -31,9 +31,6 @@
 @property (nonatomic, strong) UIButton                  *likeBtn;
 @property (nonatomic, strong) UIButton                  *commentBtn;
 
-@property (nonatomic, strong) NSString                  *replyId;
-@property (nonatomic, strong) UITextField               *textFiled;
-
 @property (nonatomic, strong) UIView                    *likesContainer;
 @property (nonatomic, strong) UITextView                *likeUserNames;
 
@@ -123,14 +120,7 @@
     _viewsBtn.titleLabel.font = [UIFont systemFontOfSize:14];
     [_viewsBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
     [_viewsBtn setImage:[UIImage imageNamed:@"朋友圈_03"] forState:UIControlStateNormal];
-    [_actionContainer addSubview:_viewsBtn];
-    
-    
-    _textFiled = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 0, _actionContainer.height)];
-    _textFiled.right = _actionContainer.width;
-    _textFiled.returnKeyType = UIReturnKeyDone;
-    _textFiled.delegate = self;
-    [_actionContainer addSubview:_textFiled];
+    //[_actionContainer addSubview:_viewsBtn];
     
     
     _likesContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, 0, cellWidth - contentX - 10, 30)];
@@ -184,7 +174,7 @@
     if(user)
     {
         NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-        [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
 
         
         NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : data.userId;
@@ -358,7 +348,7 @@
         NIMAvatarImageView *avatar = [commentView.subviews objectAtIndex:0];
         NIMUser *sender = [[NIMSDK sharedSDK].userManager userInfo:commentData.userId];
         NSURL *url = sender && sender.userInfo.avatarUrl ? [NSURL URLWithString:sender.userInfo.avatarUrl] : nil;
-        [avatar nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        [avatar nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         [avatar addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
         avatar.tag = [commentData.userId intValue];
         
@@ -512,47 +502,15 @@
 }
 
 - (void)onTouchComment:(int)sender{
-    _replyId = @"";
-    _textFiled.text = @"";
-    [_textFiled becomeFirstResponder];
+    [((SocialTableViewController *)self.viewController) inputComment:_data.socialId targetId:nil];
 }
 
 - (void)replyTo:(NSString *)userId{
     NSLog(@"replyTo  %@", userId);
-    _replyId = userId;
-    _textFiled.text = @"";
-    [_textFiled becomeFirstResponder];
+    [((SocialTableViewController *)self.viewController) inputComment:_data.socialId targetId:userId];
 }
 
-- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
-{
-    if ([string isEqualToString:@"\n"]) {
-        [self sendComment:textField.text replyId:_replyId];
-        [textField resignFirstResponder];
-        return NO;
-    }
-    return YES;
-}
 
-- (void)sendComment:(NSString *)comment replyId:(NSString *)replyId{
-    NSLog(@"sender %@", comment);
-    
-    [[HttpRequest shared] socialComment:_data.socialId replyId:replyId comment:comment success:^(SocialCommentData * _Nullable commentData, int commentCount) {
-        
-        if(commentData)
-        {
-            _data.comments = commentCount;
-            [_data.commentArr addObject:commentData];
-            [self setData:_data];
-            
-            
-            [((SocialTableViewController *)self.viewController).tableView reloadData];
-        }
-        
-    } failure:^{
-        
-    }];
-}
 
 
 - (void)showAllComments:(int)sender{

+ 3 - 1
NIMDemo/NIMDemo/SocialTableViewController.h

@@ -8,6 +8,8 @@
 
 #import <UIKit/UIKit.h>
 
-@interface SocialTableViewController : UITableViewController
+@interface SocialTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
+
+- (void)inputComment:(NSString *)socialId targetId:(NSString *)targetId;
 
 @end

+ 177 - 22
NIMDemo/NIMDemo/SocialTableViewController.m

@@ -9,15 +9,26 @@
 #import "SocialTableViewController.h"
 #import "SocialPublishViewController.h"
 #import "SocialTableViewCell.h"
+#import "SocialTopTableViewCell.h"
 #import "HttpRequest.h"
 #import "UIView+NTES.h"
+#import "User.h"
 
-@interface SocialTableViewController () <UIScrollViewDelegate>
+@interface SocialTableViewController () <UIScrollViewDelegate, UITextFieldDelegate>
 
 @property (nonatomic, strong) NSMutableArray    *dataList;
 @property (nonatomic, assign) BOOL              isFetching;
 @property (nonatomic, assign) BOOL              flagRefresh;
 
+@property (nonatomic, strong) UIView                    *commentContainer;
+@property (nonatomic, strong) UITextField               *commentTextField;
+@property (nonatomic, strong) UIButton                  *commentBtn;
+
+@property (nonatomic, strong) NSString          *commentSocialId;
+@property (nonatomic, strong) NSString          *commentTargetId;
+
+@property (nonatomic, strong) UITableView               *tableView;
+
 @end
 
 @implementation SocialTableViewController
@@ -25,13 +36,37 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
-    // Uncomment the following line to preserve selection between presentations.
-    // self.clearsSelectionOnViewWillAppear = NO;
-    
-    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
-    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
+    [self.view addSubview:[self tableView]];
     _flagRefresh = NO;
+    
+    _dataList = [[NSMutableArray alloc] init];
+    [_dataList addObject:[User sharedInfo]];
+    
     [self fetchDataList];
+    
+    
+    _commentContainer = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.height - 50, self.view.width, 50)];
+    _commentContainer.backgroundColor = UIColor.whiteColor;
+    [self.view addSubview:_commentContainer];
+    
+    _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _commentBtn.frame = CGRectMake(_commentContainer.width - 50, 0, 50, _commentContainer.height);
+    [_commentBtn setImage:[UIImage imageNamed:@"朋友圈详情_07"] forState:UIControlStateNormal];
+    [_commentBtn addTarget:self action:@selector(onTouchComment:) forControlEvents:UIControlEventTouchUpInside];
+    [_commentContainer addSubview:_commentBtn];
+    
+    UIView *txtBg = [[UIView alloc] initWithFrame:CGRectMake(10, 8, _commentContainer.width - 50 - 10, _commentContainer.height-16)];
+    txtBg.backgroundColor = UIColorFromRGB(0xeeeeee);
+    txtBg.layer.cornerRadius = 3;
+    [_commentContainer addSubview:txtBg];
+    
+    _commentTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, txtBg.width - 20, txtBg.height)];
+    _commentTextField.font = [UIFont systemFontOfSize:15];
+    _commentTextField.placeholder = @"我要评论";
+    _commentTextField.delegate = self;
+    [txtBg addSubview:_commentTextField];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
 }
 
 - (void)didReceiveMemoryWarning {
@@ -65,6 +100,24 @@
     [navItem setRightBarButtonItems:@[rightItem]];
 }
 
+- (UITableView *)tableView
+{
+    if (!self.isViewLoaded) {
+        return nil;
+    }
+    if (!_tableView) {
+        float startY = [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height;
+        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height) style:UITableViewStylePlain];
+        _tableView.contentInset = UIEdgeInsetsMake(startY, 0, 0, 0);
+        _tableView.backgroundColor  = [UIColor clearColor];
+        _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+        _tableView.dataSource = self;
+        _tableView.delegate   = self;
+    }
+    return _tableView;
+}
+
 
 - (void)fetchDataList{
     
@@ -75,8 +128,9 @@
     
     NSString *lastId = nil;
     if(self.dataList && self.dataList.count){
-        SocialItemData *lastData = [self.dataList lastObject];
-        lastId = lastData.socialId;
+        NSObject *lastData = [self.dataList lastObject];
+        if([lastData isKindOfClass:[SocialItemData class]])
+            lastId = ((SocialItemData *)lastData).socialId;
     }
         
     
@@ -98,12 +152,10 @@
 #pragma mark - Table view data source
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-#warning Incomplete implementation, return the number of sections
     return 1;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-#warning Incomplete implementation, return the number of rows
     if(_dataList)
         return _dataList.count;
     return 0;
@@ -112,24 +164,46 @@
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     
-    NSString *cellId = @"social";
-    SocialTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
-    if(!cell)
+    NSObject *data = [_dataList objectAtIndex:indexPath.row];
+    UITableViewCell *baseCell = nil;
+    if([data isKindOfClass:[SocialItemData class]])
     {
-        cell = [[SocialTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
-        [cell initWidth:self.view.frame.size.width];
+        NSString *cellId = @"social";
+        SocialTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        if(!cell)
+        {
+            cell = [[SocialTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initWidth:self.view.frame.size.width];
+        }
+        
+        SocialItemData *data = [_dataList objectAtIndex:indexPath.row];
+        [cell setData:data];
+        baseCell = cell;
     }
-    
-    SocialItemData *data = [_dataList objectAtIndex:indexPath.row];
-    [cell setData:data];
-    
-    return cell;
+    else if([data isKindOfClass:[User class]])
+    {
+        NSString *cellId = @"user";
+        SocialTopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        if(!cell)
+        {
+            cell = [[SocialTopTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initSize:self.view.frame.size.width cellHeight:160];
+        }
+        
+        [cell setData:[User sharedInfo]];
+        baseCell = cell;
+    }
+    return baseCell;
 }
 
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     
-    SocialItemData *data = [self.dataList objectAtIndex:indexPath.row];
-    return data.cellHeight;
+    NSObject *data = [_dataList objectAtIndex:indexPath.row];
+    if([data isKindOfClass:[SocialItemData class]])
+    {
+        return ((SocialItemData *)data).cellHeight;
+    }
+    return 160;
 }
 
 /*
@@ -211,7 +285,88 @@
             [self fetchDataList];
         }
     }
+}
+
+
+
+- (void)onTouchComment:(id)sender{
+    [self sendComment:_commentTextField.text];
+}
+
+- (void)inputComment:(NSString *)socialId targetId:(NSString *)targetId{
+    self.commentSocialId = socialId;
+    self.commentTargetId = targetId;
+    
+    [_commentContainer setHidden:NO];
+    _commentTextField.text = @"";
+    
+    if(targetId)
+    {
+        NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:targetId];
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : targetId;
+        _commentTextField.placeholder = [NSString stringWithFormat:@"回复%@:", nick];
+    }
+    else
+    {
+        _commentTextField.placeholder = @"我要评论";
+    }
+    
+    [_commentTextField becomeFirstResponder];
+}
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
+{
+    if ([string isEqualToString:@"\n"]) {
+        [self sendComment:textField.text];
+        return NO;
+    }
+    return YES;
+}
+
+- (void)sendComment:(NSString *)comment{
+    
+    NSLog(@"sender %@", comment);
+    
+    if(comment && ![comment isEqualToString:@""])
+    {
+        [[HttpRequest shared] socialComment:_commentSocialId replyId:_commentTargetId comment:comment success:^(SocialCommentData * _Nullable commentData, int commentCount) {
+            
+            for(int i=0; i<_dataList.count; i++)
+            {
+                NSObject *data = [_dataList objectAtIndex:i];
+                if([data isKindOfClass:[SocialItemData class]])
+                {
+                    SocialItemData *socialData = (SocialItemData *)data;
+                    if([socialData.socialId isEqualToString:commentData.socialId])
+                    {
+                        [socialData.commentArr addObject:commentData];
+                        socialData.comments = commentCount;
+                        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
+                        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
+                        break;
+                    }
+                }
+            }
+            
+        } failure:^{
+            
+        }];
+    }
+    
+    _commentTextField.text = @"";
+    [_commentTextField resignFirstResponder];
+}
+
+- (void)keyboardWillChangeFrame:(NSNotification *)notification
+{
+    
+    NSDictionary *userInfo = notification.userInfo;
+    CGRect endFrame   = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    //CGRect beginFrame = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
     
+    float keyBoardFrameTop = endFrame.origin.y;
+    _commentContainer.bottom = keyBoardFrameTop;
+    _commentContainer.hidden = endFrame.origin.y == self.view.height;
 }
 
 @end

+ 17 - 0
NIMDemo/NIMDemo/SocialTopTableViewCell.h

@@ -0,0 +1,17 @@
+//
+//  SocialTopTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/5.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "User.h"
+
+@interface SocialTopTableViewCell : UITableViewCell
+
+- (void)initSize:(CGFloat)cellWidth cellHeight:(CGFloat)cellHeight;
+- (void)setData:(User *)user;
+
+@end

+ 60 - 0
NIMDemo/NIMDemo/SocialTopTableViewCell.m

@@ -0,0 +1,60 @@
+//
+//  SocialTopTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/5.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialTopTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+#import "User.h"
+
+@interface SocialTopTableViewCell()
+
+@property (nonatomic, strong) UIImageView           *imgBg;
+@property (nonatomic, strong) NIMAvatarImageView    *avatarImg;
+@property (nonatomic, strong) UILabel               *nameLabel;
+
+@end
+
+@implementation SocialTopTableViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)initSize:(CGFloat)cellWidth cellHeight:(CGFloat)cellHeight{
+    
+    _imgBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, cellWidth, cellHeight)];
+    [_imgBg setImage:[UIImage imageNamed:@"群资料_01"]];
+    [self addSubview:_imgBg];
+    
+    
+    _avatarImg = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(15, cellHeight - 70, 60, 60)];
+    [_avatarImg nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
+    [self addSubview:_avatarImg];
+    
+    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_avatarImg.right+10, _avatarImg.centerY-15, 200, 30)];
+    _nameLabel.textColor = UIColor.whiteColor;
+    [self addSubview:_nameLabel];
+}
+
+- (void)setData:(User *)user{
+    
+    NSString *userId = [NIMSDK sharedSDK].loginManager.currentAccount;
+    NIMUser *nimUser = [[NIMSDK sharedSDK].userManager userInfo:userId];
+    NSURL *url = nimUser && nimUser.userInfo.avatarUrl ? [NSURL URLWithString:nimUser.userInfo.avatarUrl] : nil;
+    [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
+    
+    _nameLabel.text = nimUser && nimUser.userInfo.nickName ? nimUser.userInfo.nickName : userId;
+}
+
+@end

+ 18 - 0
NIMDemo/NIMDemo/TradeTopBarItem.h

@@ -0,0 +1,18 @@
+//
+//  TradeTopBarItem.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/5.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface TradeTopBarItem : UIView
+
+@property (nonatomic, assign) int timeCount;
+@property (nonatomic, strong) NSMutableDictionary *infoDict;
+
+-(void)setInfo:(NSMutableDictionary *)infoDict;
+
+@end

+ 114 - 0
NIMDemo/NIMDemo/TradeTopBarItem.m

@@ -0,0 +1,114 @@
+//
+//  TradeTopBarItem.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/5.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradeTopBarItem.h"
+#import "UIView+NTES.h"
+#import "NIMKit.h"
+#import "NIMKitUtil.h"
+#import "User.h"
+
+@interface TradeTopBarItem()
+
+@property (nonatomic, strong) UIImageView       *icon;
+@property (nonatomic, strong) UILabel           *label;
+
+@end
+
+@implementation TradeTopBarItem
+
+- (instancetype)initWithFrame:(CGRect)frame{
+    self = [super initWithFrame:frame];
+    if(self)
+    {
+        [self setUpComponent];
+    }
+    return self;
+}
+
+
+- (void)setUpComponent{
+    self.backgroundColor = NIMKit_UIColorFromRGB(0xe4e7ec);
+    
+    UIView *container = [[UIView alloc] initWithFrame:CGRectMake(20, 5, self.width-40, 30)];
+    container.backgroundColor = UIColor.whiteColor;
+    container.layer.cornerRadius = 15;
+    [self addSubview:container];
+    
+    _icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 20, 20)];
+    [container addSubview:_icon];
+    
+    _label = [[UILabel alloc] initWithFrame:CGRectMake(_icon.right+5, 3, self.width-_icon.right-10, 24)];
+    [container addSubview:_label];
+}
+
+
+- (void) setInfo:(NSMutableDictionary *)infoDict
+{
+    _infoDict = infoDict;
+    
+    NSString *province = [infoDict objectForKey:@"province"];
+    NSString *city = [infoDict objectForKey:@"city"];
+    NSString *district = [infoDict objectForKey:@"district"];
+    NSString *userId = [infoDict objectForKey:@"user_id"];
+    NSString *msg = [infoDict objectForKey:@"msg"];
+    
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+    NSString *userName = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+    
+
+    
+    UIColor *color = UIColor.whiteColor;
+    NSString *text = @"";
+    if(district.length > 0)
+    {
+        color = User.orangeColor;
+        text = @"[区县] ";
+        [_icon setImage:[UIImage imageNamed:@"交易帖_06"]];
+    }
+    else if(city.length > 0 || province.length > 0)
+    {
+        color = User.orangeColor;
+        text = @"[省市] ";
+        [_icon setImage:[UIImage imageNamed:@"交易帖_06"]];
+    }
+    else
+    {
+        color = User.greenColor;
+        text = @"[国家] ";
+        [_icon setImage:[UIImage imageNamed:@"交易帖_03 (3)"]];
+    }
+    
+    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init];
+    
+    NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                           [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                           color, NSForegroundColorAttributeName, nil];
+    NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:text attributes:attrs];
+    [attrString appendAttributedString:appendString];
+    
+    //append user name label
+    text = [NSString stringWithFormat:@"%@ : ", userName];
+    attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+             [UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+    appendString = [[NSMutableAttributedString alloc] initWithString:text attributes:attrs];
+    [attrString appendAttributedString:appendString];
+    
+    //append comment
+    attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+             [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+             UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+    appendString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", msg] attributes:attrs];
+    [attrString appendAttributedString:appendString];
+    
+    _label.attributedText = attrString;
+    
+}
+
+
+@end

+ 7 - 8
NIMDemo/NIMDemo/User.h

@@ -34,12 +34,13 @@
 @property (nonatomic, assign)   int      newCreateTeamId;
 @property (nonatomic, assign)   BOOL     firstTimeJoin;
 
-@property (nonatomic, strong)   NSMutableDictionary * _Nonnull giftGotDict;
+@property (nonatomic, strong, nonnull)   NSMutableDictionary * giftGotDict;
+@property (nonatomic, strong, nonnull)   NSMutableDictionary * tradeGotDict;
 
 
 
-@property (nonatomic, strong) NSMutableArray *picArr;
-@property (nonatomic, strong) NSMutableArray *thumbArr;
+@property (nonatomic, strong, nonnull)  NSMutableArray *picArr;
+@property (nonatomic, strong, nonnull)  NSMutableArray *thumbArr;
 
 
 @property (nonatomic, nullable, strong) NSString *currentChatRoomId;
@@ -49,11 +50,6 @@
 + (UIColor *_Nonnull)orangeColor;
 
 
-- (void)login:(NSString *_Nonnull)mobile
-          pwd:(NSString *_Nonnull)pwd
-  sucCallBack:(void (^_Nullable)())sucCallBack
- failCallBack:(void (^_Nullable)(NSError * _Nullable error))failCallBack;
-
 - (void)requestGiftList:(void (^_Nullable)(NSMutableArray * _Nullable list))success
                 failure:(void (^_Nullable)(NSError * _Nullable error))failure;
 
@@ -79,6 +75,9 @@
 
 
 
+- (BOOL)isNewTradeGot:(NSString *_Nullable)key dataId:(NSString *_Nullable)dataId;
+
+
 
 + (NSString *_Nonnull)distance:(double)originLat originLng:(double)originLng targetLat:(double)targetLat targetLng:(double)targetLng;
 

+ 17 - 61
NIMDemo/NIMDemo/User.m

@@ -47,6 +47,7 @@ int newCreateTeamId;
     dispatch_once(&onceToken, ^{
         sharedInfo = [[User alloc] init];
         sharedInfo.giftGotDict = [[NSMutableDictionary alloc] init];
+        sharedInfo.tradeGotDict = [[NSMutableDictionary alloc] init];
     });
     return sharedInfo;
 }
@@ -74,67 +75,6 @@ int newCreateTeamId;
 
 
 
-- (void)login:(NSString *)mobile
-          pwd:(NSString *)pwd
-  sucCallBack:(void (^_Nullable)())sucCallBack
- failCallBack:(void (^_Nullable)(NSError * _Nullable error))failCallBack
-{
-    NSDictionary *parameters = @{@"mobile":mobile,
-                                 @"pwd":pwd
-                                 };
-
-    NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=index&a=login";
-    //请求的managers
-    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
-    manager.responseSerializer = [AFJSONResponseSerializer new];
-    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
-    
-    NSLog(@"请求参数 %@", parameters);
-    //请求的方式:POST
-    [manager POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
-        NSLog(@"请求成功,服务器返回的信息%@", responseObject);
-        NSDictionary * dic = responseObject;
-        int code = [[dic valueForKey:@"c"] intValue];
-        if(code == 0)
-        {
-            NSDictionary *data = (NSDictionary *)[dic objectForKey:@"d"];
-            
-            User *user = [User sharedInfo];
-            user.userId = [[data valueForKey:@"id"] intValue];
-            user.mobile = [data valueForKey:@"mobile"];
-            user.token = [data valueForKey:@"token"];
-            user.nick = [data valueForKey:@"nick"];
-            user.coin = [[data valueForKey:@"coin"] intValue];
-            user.latitude = [[data valueForKey:@"latitude"] doubleValue];
-            user.longitude = [[data valueForKey:@"longitude"] doubleValue];
-            user.province = [data valueForKey:@"province"];
-            user.city = [data valueForKey:@"city"];
-            user.district = [data valueForKey:@"district"];
-            
-            user.countryRoomId = [data valueForKey:@"country_room_id"];
-            user.provinceRoomId = [data valueForKey:@"province_room_id"];
-            user.cityRoomId = [data valueForKey:@"city_room_id"];
-            user.districtRoomId = [data valueForKey:@"district_room_id"];
-            user.firstTimeJoin = YES;
-            
-            if(sucCallBack)
-                sucCallBack();
-        }
-        else
-        {
-            if(failCallBack)
-                failCallBack(nil);
-        }
-        
-    } failure:^(NSURLSessionDataTask *task, NSError * error) {
-        NSLog(@"请求失败,服务器返回的错误信息%@",error);
-        
-        if(failCallBack)
-            failCallBack(error);
-    }];
-    
-}
-
 
 
 - (void)requestGiftList:(void (^_Nullable)(NSMutableArray * _Nullable list))sucCallBack
@@ -218,6 +158,22 @@ int newCreateTeamId;
 }
 
 
+
+- (BOOL)isNewTradeGot:(NSString *)key dataId:(NSString *)dataId
+{
+    NSString *existDataId = [self.tradeGotDict objectForKey:key];
+    int existId = existDataId ? [existDataId intValue] : 0;
+    int currentId = [dataId intValue];
+    if(currentId > existId)
+    {
+        [self.tradeGotDict setValue:[NSString stringWithFormat:@"%d", currentId] forKey:key];
+        return YES;
+    }
+    return NO;
+}
+
+
+
 - (GiftData *_Nullable)getGiftData:(NSString *)giftId{
     
     if(self.giftList)

+ 4 - 5
NIMDemo/NIMDemo/ViewController.m

@@ -15,6 +15,7 @@
 #import "User.h"
 #import "NTESService.h"
 #import "NTESLoginManager.h"
+#import "HttpRequest.h"
 
 @interface ViewController ()
 
@@ -54,14 +55,12 @@
         [[[NIMSDK sharedSDK] loginManager] autoLogin:loginData];
         [[NTESServiceManager sharedManager] start];
         
-        [[User sharedInfo] login:account pwd:token sucCallBack:^{
-            
+        [[HttpRequest shared] loginAccount:account password:token success:^{
             UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
             UIViewController *next = [board instantiateViewControllerWithIdentifier:@"TabBarView"];
-            [self.navigationController pushViewController:next animated:YES];
+            [self.navigationController pushViewController:next animated:NO];
+        } failure:^{
             
-        } failCallBack:^(NSError * _Nullable error) {
-            //[self setupLoginViewController];
         }];
     }
     else

+ 1 - 1
NIMKit/NIMKit/Classes/Global/NIMKitDataProviderImpl.m

@@ -34,7 +34,7 @@
 - (instancetype)init{
     self = [super init];
     if (self) {
-        _defaultUserAvatar = [UIImage imageNamed:@"avatar_user"];
+        _defaultUserAvatar = [UIImage imageNamed:@"avatar_user2"];
         _defaultTeamAvatar = [UIImage imageNamed:@"avatar_team"];
         _request = [[NIMKitDataRequest alloc] init];
         _request.maxMergeCount = 20;

+ 26 - 2
NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m

@@ -57,6 +57,8 @@ NSInteger TradeTypeDemand = 2;
 {
     if (self = [super initWithFrame:frame]) {
         [self loadUIComponents];
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
     }
     return self;
 }
@@ -240,7 +242,7 @@ NSInteger TradeTypeDemand = 2;
     
     
     _inputTextBkgImage = [[UIView alloc] initWithFrame:CGRectMake(20, 100, self.nim_width - 40, 40)];
-    _inputTextBkgImage.backgroundColor = UIColor.lightGrayColor;
+    _inputTextBkgImage.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
     _inputTextBkgImage.layer.cornerRadius = 20;
     _inputTextBkgImage.userInteractionEnabled = NO;
     [_sendGiftView addSubview:_inputTextBkgImage];
@@ -475,7 +477,7 @@ NSInteger TradeTypeDemand = 2;
             wself.avatarId = [uids objectAtIndex:0];
             NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:wself.avatarId];
             NSURL *avatarUrl = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-            [wself.avatarView nim_setImageWithURL:avatarUrl placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+            [wself.avatarView nim_setImageWithURL:avatarUrl placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
         }
         else
         {
@@ -604,4 +606,26 @@ NSInteger TradeTypeDemand = 2;
     [self setHidden:YES];
     
 }
+
+
+- (void)keyboardWillChangeFrame:(NSNotification *)notification
+{
+    
+    NSDictionary *userInfo = notification.userInfo;
+    CGRect endFrame   = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    //CGRect beginFrame = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
+    
+    float keyBoardFrameTop = endFrame.origin.y;
+    
+    if(keyBoardFrameTop == self.nim_viewController.view.nim_height)
+    {
+        _inputTextBkgImage.nim_top = 100;
+        _inputTextView.nim_top = 102;
+    }
+    else
+    {
+        _inputTextBkgImage.nim_top = 100 - endFrame.size.height + 120;
+        _inputTextView.nim_top = 102 - endFrame.size.height + 120;
+    }
+}
 @end

+ 24 - 1
NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.m

@@ -41,6 +41,8 @@
 {
     if (self = [super initWithFrame:frame]) {
         [self loadUIComponents];
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
     }
     return self;
 }
@@ -55,6 +57,10 @@
     [btn setTitle:@"" forState:UIControlStateNormal];
     [self addSubview:btn];
     
+    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 100, 40)];
+    titleLabel.text = @"置顶";
+    [self addSubview:titleLabel];
+    
     _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nim_width - 150, 5, 100, 40)];
     _countLabel.textAlignment = NSTextAlignmentRight;
     [self addSubview:_countLabel];
@@ -255,7 +261,24 @@
 
 }
 
-
+- (void)keyboardWillChangeFrame:(NSNotification *)notification
+{
+    
+    NSDictionary *userInfo = notification.userInfo;
+    CGRect endFrame   = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    //CGRect beginFrame = [userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
+    
+    float keyBoardFrameTop = endFrame.origin.y;
+    
+    if(keyBoardFrameTop == self.nim_viewController.view.nim_height)
+    {
+        _textViewContainer.nim_top = 80;
+    }
+    else
+    {
+        _textViewContainer.nim_top = 80 - endFrame.size.height + 110;
+    }
+}