Browse Source

no message

Fenix Wang 8 years ago
parent
commit
3433285d18
73 changed files with 6080 additions and 365 deletions
  1. BIN
      NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/UserInterfaceState.xcuserstate
  2. 18 0
      NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 158 0
      NIMDemo/NIMDemo.xcodeproj/project.pbxproj
  4. 1 0
      NIMDemo/NIMDemo/AppDelegate.h
  5. 23 0
      NIMDemo/NIMDemo/AppDelegate.m
  6. 43 228
      NIMDemo/NIMDemo/Base.lproj/Main.storyboard
  7. 2 1
      NIMDemo/NIMDemo/Classes/LayoutConfig/NTESCellLayoutConfig.m
  8. 10 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESCustomAttachmentDecoder.m
  9. 1 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESCustomAttachmentDefines.h
  10. 27 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.h
  11. 107 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.m
  12. 3 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESSessionMsgConverter.h
  13. 10 0
      NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESSessionMsgConverter.m
  14. 13 0
      NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.h
  15. 86 0
      NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.m
  16. 3 0
      NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.h
  17. 173 49
      NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m
  18. 6 1
      NIMDemo/NIMDemo/Classes/Sections/SessionList/ViewController/NTESSessionListViewController.m
  19. 6 1
      NIMDemo/NIMDemo/FriendViewController.m
  20. 4 1
      NIMDemo/NIMDemo/GiftTopBarItem.h
  21. 4 11
      NIMDemo/NIMDemo/GiftTopBarItem.m
  22. 3 7
      NIMDemo/NIMDemo/GroupTableController.m
  23. 80 0
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.h
  24. 506 0
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.m
  25. 15 0
      NIMDemo/NIMDemo/ImagePagerViewController.h
  26. 114 0
      NIMDemo/NIMDemo/ImagePagerViewController.m
  27. 17 0
      NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.h
  28. 292 0
      NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m
  29. 15 0
      NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.h
  30. 358 0
      NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.m
  31. 46 0
      NIMDemo/NIMDemo/SectionTrade/TradeData.h
  32. 30 0
      NIMDemo/NIMDemo/SectionTrade/TradeData.m
  33. 13 0
      NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.h
  34. 24 0
      NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.m
  35. 21 0
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.h
  36. 149 0
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m
  37. 17 0
      NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.h
  38. 266 0
      NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.m
  39. 15 0
      NIMDemo/NIMDemo/SectionTrade/TradeViewController.h
  40. 331 0
      NIMDemo/NIMDemo/SectionTrade/TradeViewController.m
  41. 16 0
      NIMDemo/NIMDemo/SettingOptionTableViewCell.h
  42. 101 0
      NIMDemo/NIMDemo/SettingOptionTableViewCell.m
  43. 104 38
      NIMDemo/NIMDemo/SettingTableViewController.m
  44. 15 0
      NIMDemo/NIMDemo/SettingTopTableViewCell.h
  45. 93 0
      NIMDemo/NIMDemo/SettingTopTableViewCell.m
  46. 23 0
      NIMDemo/NIMDemo/SocialCommentData.h
  47. 22 0
      NIMDemo/NIMDemo/SocialCommentData.m
  48. 17 0
      NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.h
  49. 170 0
      NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.m
  50. 19 0
      NIMDemo/NIMDemo/SocialDetailTableViewCell.h
  51. 348 0
      NIMDemo/NIMDemo/SocialDetailTableViewCell.m
  52. 17 0
      NIMDemo/NIMDemo/SocialDetailViewController.h
  53. 317 0
      NIMDemo/NIMDemo/SocialDetailViewController.m
  54. 32 0
      NIMDemo/NIMDemo/SocialItemData.h
  55. 55 0
      NIMDemo/NIMDemo/SocialItemData.m
  56. 13 0
      NIMDemo/NIMDemo/SocialPublishViewController.h
  57. 387 0
      NIMDemo/NIMDemo/SocialPublishViewController.m
  58. 17 0
      NIMDemo/NIMDemo/SocialTableViewCell.h
  59. 582 0
      NIMDemo/NIMDemo/SocialTableViewCell.m
  60. 13 0
      NIMDemo/NIMDemo/SocialTableViewController.h
  61. 217 0
      NIMDemo/NIMDemo/SocialTableViewController.m
  62. 1 1
      NIMDemo/NIMDemo/Supporting Files/nim_debug.xcconfig
  63. 1 1
      NIMDemo/NIMDemo/Supporting Files/nim_release.xcconfig
  64. 17 2
      NIMDemo/NIMDemo/User.h
  65. 52 19
      NIMDemo/NIMDemo/User.m
  66. 0 3
      NIMDemo/NIMDemo/ViewController.m
  67. 4 1
      NIMDemo/Pods/Toast/Toast/Toast/UIView+Toast.m
  68. 6 0
      NIMKit/NIMKit.xcodeproj/project.pbxproj
  69. 1 0
      NIMKit/NIMKit/Classes/Sections/Common/NIMPageView.m
  70. 4 0
      NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.h
  71. 116 1
      NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m
  72. 27 0
      NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.h
  73. 263 0
      NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.m

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


+ 18 - 0
NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,4 +2,22 @@
 <Bucket
    type = "0"
    version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "../../../../Fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/Classes/Sections/Session/Config/NTESSessionConfig.m"
+            timestampString = "520852838.293649"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "87"
+            endingLineNumber = "87"
+            landmarkName = "-shouldHandleReceiptForMessage:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
 </Bucket>

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

@@ -198,6 +198,17 @@
 		C40F4C4B1EF15BC7002B197A /* GiftTopBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F4C4A1EF15BC7002B197A /* GiftTopBarItem.m */; };
 		C41B6EF81EEFB30D00AD1F53 /* RechargeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C41B6EF71EEFB30D00AD1F53 /* RechargeViewController.m */; };
 		C41B6EFC1EEFB67500AD1F53 /* RechargeItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C41B6EFB1EEFB67500AD1F53 /* RechargeItem.m */; };
+		C4246CF11F075D08008CD291 /* TradeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4246CF01F075D08008CD291 /* TradeViewController.m */; };
+		C4246CF41F075D58008CD291 /* TradeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4246CF31F075D58008CD291 /* TradeTableViewCell.m */; };
+		C4246CF71F075F59008CD291 /* TradeData.m in Sources */ = {isa = PBXBuildFile; fileRef = C4246CF61F075F59008CD291 /* TradeData.m */; };
+		C482C2F51F09DAA800EF2B71 /* TradePublishManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C2F41F09DAA800EF2B71 /* TradePublishManager.m */; };
+		C482C2FB1F0A110E00EF2B71 /* TradePostTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C2FA1F0A110E00EF2B71 /* TradePostTableViewCell.m */; };
+		C482C2FE1F0A3B0000EF2B71 /* SettingTopTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C2FD1F0A3B0000EF2B71 /* SettingTopTableViewCell.m */; };
+		C482C3011F0A792300EF2B71 /* SettingOptionTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3001F0A792300EF2B71 /* SettingOptionTableViewCell.m */; };
+		C482C3041F0A7E8400EF2B71 /* MyTradeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C3031F0A7E8400EF2B71 /* MyTradeViewController.m */; };
+		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 */; };
 		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 */; };
@@ -224,6 +235,16 @@
 		C4D8F1311ED48658002F9F3A /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C4D8F12B1ED48657002F9F3A /* AFURLSessionManager.m */; };
 		C4D8F1511ED48840002F9F3A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4D8F14D1ED4883F002F9F3A /* LaunchScreen.storyboard */; };
 		C4D8F1521ED48840002F9F3A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4D8F14F1ED48840002F9F3A /* Main.storyboard */; };
+		C4F1D0EB1EF8F1B800A04B28 /* SocialTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0EA1EF8F1B800A04B28 /* SocialTableViewController.m */; };
+		C4F1D0EE1EF8F2E800A04B28 /* SocialTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0ED1EF8F2E800A04B28 /* SocialTableViewCell.m */; };
+		C4F1D0F11EF8F75400A04B28 /* SocialPublishViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0F01EF8F75400A04B28 /* SocialPublishViewController.m */; };
+		C4F1D0F51EFA17DF00A04B28 /* HttpRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0F41EFA17DF00A04B28 /* HttpRequest.m */; };
+		C4F1D0F81EFA197300A04B28 /* SocialItemData.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0F71EFA197300A04B28 /* SocialItemData.m */; };
+		C4F1D0FE1F010E1D00A04B28 /* SocialCommentData.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D0FD1F010E1D00A04B28 /* SocialCommentData.m */; };
+		C4F1D1531F03891700A04B28 /* SocialDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D1521F03891700A04B28 /* SocialDetailViewController.m */; };
+		C4F1D1571F0389AA00A04B28 /* ImagePagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D1561F0389AA00A04B28 /* ImagePagerViewController.m */; };
+		C4F1D15D1F03DDCA00A04B28 /* SocialDetailTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D15C1F03DDCA00A04B28 /* SocialDetailTableViewCell.m */; };
+		C4F1D1601F03DDE500A04B28 /* SocialCommentDetailTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F1D15F1F03DDE500A04B28 /* SocialCommentDetailTableViewCell.m */; };
 		E4168E291B6A364800F3D35D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4168E281B6A364800F3D35D /* AudioToolbox.framework */; };
 		E4168E2B1B6A364F00F3D35D /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4168E2A1B6A364F00F3D35D /* CoreMedia.framework */; };
 		E4562D8B1CE0855A00D66909 /* NTESSDKConfigDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E4562D8A1CE0855A00D66909 /* NTESSDKConfigDelegate.m */; };
@@ -586,6 +607,28 @@
 		C41B6EF71EEFB30D00AD1F53 /* RechargeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RechargeViewController.m; sourceTree = "<group>"; };
 		C41B6EFA1EEFB67500AD1F53 /* RechargeItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RechargeItem.h; sourceTree = "<group>"; };
 		C41B6EFB1EEFB67500AD1F53 /* RechargeItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RechargeItem.m; sourceTree = "<group>"; };
+		C4246CEF1F075D08008CD291 /* TradeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradeViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeViewController.h; sourceTree = "<group>"; };
+		C4246CF01F075D08008CD291 /* TradeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradeViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeViewController.m; sourceTree = "<group>"; };
+		C4246CF21F075D58008CD291 /* TradeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradeTableViewCell.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.h; sourceTree = "<group>"; };
+		C4246CF31F075D58008CD291 /* TradeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradeTableViewCell.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.m; sourceTree = "<group>"; };
+		C4246CF51F075F59008CD291 /* TradeData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradeData.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeData.h; sourceTree = "<group>"; };
+		C4246CF61F075F59008CD291 /* TradeData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradeData.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradeData.m; sourceTree = "<group>"; };
+		C482C2F31F09DAA800EF2B71 /* TradePublishManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradePublishManager.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradePublishManager.h; sourceTree = "<group>"; };
+		C482C2F41F09DAA800EF2B71 /* TradePublishManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradePublishManager.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m; sourceTree = "<group>"; };
+		C482C2F91F0A110E00EF2B71 /* TradePostTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TradePostTableViewCell.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.h; sourceTree = "<group>"; };
+		C482C2FA1F0A110E00EF2B71 /* TradePostTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TradePostTableViewCell.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.m; sourceTree = "<group>"; };
+		C482C2FC1F0A3B0000EF2B71 /* SettingTopTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SettingTopTableViewCell.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SettingTopTableViewCell.h; sourceTree = "<group>"; };
+		C482C2FD1F0A3B0000EF2B71 /* SettingTopTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SettingTopTableViewCell.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SettingTopTableViewCell.m; sourceTree = "<group>"; };
+		C482C2FF1F0A792300EF2B71 /* SettingOptionTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingOptionTableViewCell.h; sourceTree = "<group>"; };
+		C482C3001F0A792300EF2B71 /* SettingOptionTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingOptionTableViewCell.m; sourceTree = "<group>"; };
+		C482C3021F0A7E8400EF2B71 /* MyTradeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyTradeViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.h; sourceTree = "<group>"; };
+		C482C3031F0A7E8400EF2B71 /* MyTradeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyTradeViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.m; sourceTree = "<group>"; };
+		C482C3051F0B389400EF2B71 /* MyTradeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyTradeTableViewCell.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.h; sourceTree = "<group>"; };
+		C482C3061F0B389400EF2B71 /* MyTradeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyTradeTableViewCell.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m; sourceTree = "<group>"; };
+		C482C3081F0B857800EF2B71 /* NTESGiftAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NTESGiftAttachment.h; path = ../../../../../../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.h; sourceTree = "<group>"; };
+		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>"; };
 		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>"; };
@@ -635,6 +678,26 @@
 		C4D8F12B1ED48657002F9F3A /* AFURLSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = "<group>"; };
 		C4D8F14E1ED48840002F9F3A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		C4D8F1501ED48840002F9F3A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
+		C4F1D0E91EF8F1B800A04B28 /* SocialTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocialTableViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SocialTableViewController.h; sourceTree = "<group>"; };
+		C4F1D0EA1EF8F1B800A04B28 /* SocialTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SocialTableViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SocialTableViewController.m; sourceTree = "<group>"; };
+		C4F1D0EC1EF8F2E800A04B28 /* SocialTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialTableViewCell.h; sourceTree = "<group>"; };
+		C4F1D0ED1EF8F2E800A04B28 /* SocialTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialTableViewCell.m; sourceTree = "<group>"; };
+		C4F1D0EF1EF8F75400A04B28 /* SocialPublishViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialPublishViewController.h; sourceTree = "<group>"; };
+		C4F1D0F01EF8F75400A04B28 /* SocialPublishViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialPublishViewController.m; sourceTree = "<group>"; };
+		C4F1D0F31EFA17DF00A04B28 /* HttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HttpRequest.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/HttpRequest/HttpRequest.h; sourceTree = "<group>"; };
+		C4F1D0F41EFA17DF00A04B28 /* HttpRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HttpRequest.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/HttpRequest/HttpRequest.m; sourceTree = "<group>"; };
+		C4F1D0F61EFA197300A04B28 /* SocialItemData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocialItemData.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SocialItemData.h; sourceTree = "<group>"; };
+		C4F1D0F71EFA197300A04B28 /* SocialItemData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SocialItemData.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SocialItemData.m; sourceTree = "<group>"; };
+		C4F1D0FC1F010E1D00A04B28 /* SocialCommentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialCommentData.h; sourceTree = "<group>"; };
+		C4F1D0FD1F010E1D00A04B28 /* SocialCommentData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialCommentData.m; sourceTree = "<group>"; };
+		C4F1D1511F03891700A04B28 /* SocialDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialDetailViewController.h; sourceTree = "<group>"; };
+		C4F1D1521F03891700A04B28 /* SocialDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialDetailViewController.m; sourceTree = "<group>"; };
+		C4F1D1551F0389AA00A04B28 /* ImagePagerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImagePagerViewController.h; sourceTree = "<group>"; };
+		C4F1D1561F0389AA00A04B28 /* ImagePagerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImagePagerViewController.m; sourceTree = "<group>"; };
+		C4F1D15B1F03DDCA00A04B28 /* SocialDetailTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialDetailTableViewCell.h; sourceTree = "<group>"; };
+		C4F1D15C1F03DDCA00A04B28 /* SocialDetailTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialDetailTableViewCell.m; sourceTree = "<group>"; };
+		C4F1D15E1F03DDE500A04B28 /* SocialCommentDetailTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialCommentDetailTableViewCell.h; sourceTree = "<group>"; };
+		C4F1D15F1F03DDE500A04B28 /* SocialCommentDetailTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialCommentDetailTableViewCell.m; sourceTree = "<group>"; };
 		C716F6793D5D6D1604893032 /* Pods-NIMDemo-NIM.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NIMDemo-NIM.release.xcconfig"; path = "Pods/Target Support Files/Pods-NIMDemo-NIM/Pods-NIMDemo-NIM.release.xcconfig"; sourceTree = "<group>"; };
 		E4168E281B6A364800F3D35D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
 		E4168E2A1B6A364F00F3D35D /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
@@ -1150,6 +1213,8 @@
 				61E4707F1B7D963E00F4A1BF /* NTESSnapchatAttachment.m */,
 				61E470801B7D963E00F4A1BF /* NTESWhiteboardAttachment.h */,
 				61E470811B7D963E00F4A1BF /* NTESWhiteboardAttachment.m */,
+				C482C3081F0B857800EF2B71 /* NTESGiftAttachment.h */,
+				C482C3091F0B857800EF2B71 /* NTESGiftAttachment.m */,
 			);
 			path = Object;
 			sourceTree = "<group>";
@@ -1196,6 +1261,8 @@
 				61E470971B7D963E00F4A1BF /* NTESSessionWhiteBoardContentView.m */,
 				61E7B5861DCF39E200F19E83 /* NTESSessionTipContentView.h */,
 				61E7B5871DCF39E200F19E83 /* NTESSessionTipContentView.m */,
+				C482C30B1F0B923300EF2B71 /* NTESSessionGiftContentView.h */,
+				C482C30C1F0B923300EF2B71 /* NTESSessionGiftContentView.m */,
 			);
 			path = SessionContentView;
 			sourceTree = "<group>";
@@ -1546,6 +1613,8 @@
 		AE5882E71A6F47E10070536A /* whosay */ = {
 			isa = PBXGroup;
 			children = (
+				C4F1D1541F03897F00A04B28 /* Utils */,
+				C4F1D0F21EFA177C00A04B28 /* Network */,
 				C41B6EF91EEFB64900AD1F53 /* Recharge */,
 				C4D4C9271ED7C37F00ADD7B7 /* AppDelegate.h */,
 				C4D4C9281ED7C37F00ADD7B7 /* AppDelegate.m */,
@@ -1561,8 +1630,10 @@
 				C4B639531ED57DBB004288FC /* CityPicker */,
 				C4D8F14D1ED4883F002F9F3A /* LaunchScreen.storyboard */,
 				C4D8F14F1ED48840002F9F3A /* Main.storyboard */,
+				C4246CEE1F075CCB008CD291 /* SectionTrade */,
 				C4D8F14A1ED486F2002F9F3A /* SectionGroup */,
 				C4A7D3631EE80338009B5849 /* SectionFriend */,
+				C4F1D0E81EF8F17E00A04B28 /* SectionSocial */,
 				C4B146331EF2333900819893 /* SectionSetting */,
 				C4D8F1321ED48660002F9F3A /* AFNetworking */,
 				61F728281A7B23A40076C096 /* Classes */,
@@ -1620,6 +1691,27 @@
 			name = Recharge;
 			sourceTree = "<group>";
 		};
+		C4246CEE1F075CCB008CD291 /* SectionTrade */ = {
+			isa = PBXGroup;
+			children = (
+				C482C2F31F09DAA800EF2B71 /* TradePublishManager.h */,
+				C482C2F41F09DAA800EF2B71 /* TradePublishManager.m */,
+				C4246CEF1F075D08008CD291 /* TradeViewController.h */,
+				C4246CF01F075D08008CD291 /* TradeViewController.m */,
+				C4246CF21F075D58008CD291 /* TradeTableViewCell.h */,
+				C4246CF31F075D58008CD291 /* TradeTableViewCell.m */,
+				C482C2F91F0A110E00EF2B71 /* TradePostTableViewCell.h */,
+				C482C2FA1F0A110E00EF2B71 /* TradePostTableViewCell.m */,
+				C4246CF51F075F59008CD291 /* TradeData.h */,
+				C4246CF61F075F59008CD291 /* TradeData.m */,
+				C482C3021F0A7E8400EF2B71 /* MyTradeViewController.h */,
+				C482C3031F0A7E8400EF2B71 /* MyTradeViewController.m */,
+				C482C3051F0B389400EF2B71 /* MyTradeTableViewCell.h */,
+				C482C3061F0B389400EF2B71 /* MyTradeTableViewCell.m */,
+			);
+			name = SectionTrade;
+			sourceTree = "<group>";
+		};
 		C4A7D3631EE80338009B5849 /* SectionFriend */ = {
 			isa = PBXGroup;
 			children = (
@@ -1636,6 +1728,10 @@
 				C4B146381EF2351900819893 /* SettingTableViewController.m */,
 				C4B1463A1EF24E6300819893 /* SettingAccountViewController.h */,
 				C4B1463B1EF24E6300819893 /* SettingAccountViewController.m */,
+				C482C2FC1F0A3B0000EF2B71 /* SettingTopTableViewCell.h */,
+				C482C2FD1F0A3B0000EF2B71 /* SettingTopTableViewCell.m */,
+				C482C2FF1F0A792300EF2B71 /* SettingOptionTableViewCell.h */,
+				C482C3001F0A792300EF2B71 /* SettingOptionTableViewCell.m */,
 			);
 			name = SectionSetting;
 			sourceTree = "<group>";
@@ -1700,6 +1796,47 @@
 			name = SectionGroup;
 			sourceTree = "<group>";
 		};
+		C4F1D0E81EF8F17E00A04B28 /* SectionSocial */ = {
+			isa = PBXGroup;
+			children = (
+				C4F1D0E91EF8F1B800A04B28 /* SocialTableViewController.h */,
+				C4F1D0EA1EF8F1B800A04B28 /* SocialTableViewController.m */,
+				C4F1D0EC1EF8F2E800A04B28 /* SocialTableViewCell.h */,
+				C4F1D0ED1EF8F2E800A04B28 /* SocialTableViewCell.m */,
+				C4F1D0EF1EF8F75400A04B28 /* SocialPublishViewController.h */,
+				C4F1D0F01EF8F75400A04B28 /* SocialPublishViewController.m */,
+				C4F1D0F61EFA197300A04B28 /* SocialItemData.h */,
+				C4F1D0F71EFA197300A04B28 /* SocialItemData.m */,
+				C4F1D0FC1F010E1D00A04B28 /* SocialCommentData.h */,
+				C4F1D0FD1F010E1D00A04B28 /* SocialCommentData.m */,
+				C4F1D1511F03891700A04B28 /* SocialDetailViewController.h */,
+				C4F1D1521F03891700A04B28 /* SocialDetailViewController.m */,
+				C4F1D15B1F03DDCA00A04B28 /* SocialDetailTableViewCell.h */,
+				C4F1D15C1F03DDCA00A04B28 /* SocialDetailTableViewCell.m */,
+				C4F1D15E1F03DDE500A04B28 /* SocialCommentDetailTableViewCell.h */,
+				C4F1D15F1F03DDE500A04B28 /* SocialCommentDetailTableViewCell.m */,
+			);
+			name = SectionSocial;
+			sourceTree = "<group>";
+		};
+		C4F1D0F21EFA177C00A04B28 /* Network */ = {
+			isa = PBXGroup;
+			children = (
+				C4F1D0F31EFA17DF00A04B28 /* HttpRequest.h */,
+				C4F1D0F41EFA17DF00A04B28 /* HttpRequest.m */,
+			);
+			name = Network;
+			sourceTree = "<group>";
+		};
+		C4F1D1541F03897F00A04B28 /* Utils */ = {
+			isa = PBXGroup;
+			children = (
+				C4F1D1551F0389AA00A04B28 /* ImagePagerViewController.h */,
+				C4F1D1561F0389AA00A04B28 /* ImagePagerViewController.m */,
+			);
+			name = Utils;
+			sourceTree = "<group>";
+		};
 		E45E17771CA8CB6200C4ED69 /* Log */ = {
 			isa = PBXGroup;
 			children = (
@@ -1902,6 +2039,7 @@
 				6118F5AA1C5A0FC1009AF01E /* UIViewController+Swizzling.m in Sources */,
 				6118F5A71C5A0FC1009AF01E /* UINavigationController+Swizzling.m in Sources */,
 				C4D4C9321ED7C37F00ADD7B7 /* AppDelegate.m in Sources */,
+				C4F1D0FE1F010E1D00A04B28 /* SocialCommentData.m in Sources */,
 				61E4719C1B7D9C8300F4A1BF /* NTESSessionViewController.m in Sources */,
 				61E4712F1B7D963E00F4A1BF /* NTESChartletAttachment.m in Sources */,
 				8351CB721E977D9000DF4866 /* NTESContactDataCell.m in Sources */,
@@ -1916,6 +2054,7 @@
 				61E471451B7D963E00F4A1BF /* NTESGalleryViewController.m in Sources */,
 				61E4715D1B7D963E00F4A1BF /* NTESClientsTableViewController.m in Sources */,
 				C4A734601EE6BBD300D6489D /* GroupMoreTableViewController.m in Sources */,
+				C482C2FE1F0A3B0000EF2B71 /* SettingTopTableViewCell.m in Sources */,
 				6159DF531C45F79D00E32EB4 /* NTESChatroomConfig.m in Sources */,
 				03A4C9FF1AC2B79700E45E03 /* UIAlertView+NTESBlock.m in Sources */,
 				6173AECE1BAAC70200854D49 /* NTESBirthSettingViewController.m in Sources */,
@@ -1932,6 +2071,7 @@
 				61EAD9151B82FEE9005DC715 /* NTESPersonalCardViewController.m in Sources */,
 				C4D8F12D1ED48657002F9F3A /* AFNetworkReachabilityManager.m in Sources */,
 				61A8EF341BB67F0900033FB8 /* UIResponder+NTESFirstResponder.m in Sources */,
+				C4F1D1531F03891700A04B28 /* SocialDetailViewController.m in Sources */,
 				61EEE7701C22865D00022315 /* NTESLiveInfoViewController.m in Sources */,
 				61E471521B7D963E00F4A1BF /* NTESAudioChatViewController.m in Sources */,
 				61E4712E1B7D963E00F4A1BF /* NTESSessionConfig.m in Sources */,
@@ -1962,11 +2102,13 @@
 				6118F5A61C5A0FC1009AF01E /* UINavigationBar+Swizzling.m in Sources */,
 				C4D4C9401ED81F2100ADD7B7 /* CityPickerViewController.m in Sources */,
 				C41B6EF81EEFB30D00AD1F53 /* RechargeViewController.m in Sources */,
+				C4246CF11F075D08008CD291 /* TradeViewController.m in Sources */,
 				BDB02D261E09172F00262A50 /* NTESNetDetectViewController.m in Sources */,
 				61AEC12A1BD69C6E00B00F02 /* NTESSessionCardViewController.m in Sources */,
 				61AF8CE11C55170900BFC84F /* UIScrollView+NTESDirection.m in Sources */,
 				6118F5A81C5A0FC1009AF01E /* UINavigationItem+Swizzling.m in Sources */,
 				C4A734631EE6D4DE00D6489D /* GroupMoreTableViewCell.m in Sources */,
+				C482C3041F0A7E8400EF2B71 /* MyTradeViewController.m in Sources */,
 				61E471231B7D963E00F4A1BF /* NTESSystemNotificationCell.m in Sources */,
 				61206EE71C1E607B009E4C78 /* NTESChatroomListCell.m in Sources */,
 				61E471191B7D963E00F4A1BF /* NTESContactUtilCell.m in Sources */,
@@ -1980,6 +2122,7 @@
 				61E471201B7D963E00F4A1BF /* NTESCustomNotificationObject.m in Sources */,
 				C4A7D3661EE803E7009B5849 /* FriendViewController.m in Sources */,
 				6173AEC41BAAB94400854D49 /* NTESUserInfoSettingViewController.m in Sources */,
+				C4F1D1601F03DDE500A04B28 /* SocialCommentDetailTableViewCell.m in Sources */,
 				61B2AEFD1BB9530F0093F532 /* NTESCardPortraitCell.m in Sources */,
 				C4D8F1301ED48658002F9F3A /* AFURLResponseSerialization.m in Sources */,
 				61E4711D1B7D963E00F4A1BF /* NTESContactViewController.m in Sources */,
@@ -1991,14 +2134,18 @@
 				61C2CE521C489F0D00D76104 /* NTESChatroomManager.m in Sources */,
 				61E4713C1B7D963E00F4A1BF /* NTESSessionJankenponContentView.m in Sources */,
 				61E471971B7D96AA00F4A1BF /* NTESPinyinConverter.m in Sources */,
+				C4246CF41F075D58008CD291 /* TradeTableViewCell.m in Sources */,
 				613A2FEA1C21016600508990 /* NTESChatroomSegmentedControl.m in Sources */,
 				E4562D8B1CE0855A00D66909 /* NTESSDKConfigDelegate.m in Sources */,
 				C4B639571ED581E2004288FC /* User.m in Sources */,
+				C4F1D0F81EFA197300A04B28 /* SocialItemData.m in Sources */,
 				6117562E1BEB6978006A1589 /* NTESAliasSettingViewController.m in Sources */,
+				C482C3071F0B389400EF2B71 /* MyTradeTableViewCell.m in Sources */,
 				61E4712C1B7D963E00F4A1BF /* NTESRegisterViewController.m in Sources */,
 				619087091BABE5D400F3A0C7 /* NTESDevice.m in Sources */,
 				61B5D7EB1C21331600B52DBF /* NTESPageView.m in Sources */,
 				C4D4C93D1ED7C3DE00ADD7B7 /* GroupTableController.m in Sources */,
+				C4F1D1571F0389AA00A04B28 /* ImagePagerViewController.m in Sources */,
 				61E4713D1B7D963E00F4A1BF /* NTESSessionSnapchatContentView.m in Sources */,
 				61E471281B7D963E00F4A1BF /* NTESLoginManager.m in Sources */,
 				612CACEE1BB1484C00C348B5 /* NTESContactDataMember.m in Sources */,
@@ -2012,6 +2159,7 @@
 				611ABF011B3CF4FC00B8706C /* NTESBadgeView.m in Sources */,
 				611FE9EE1BB02320005E8E45 /* (null) in Sources */,
 				C4B146391EF2351900819893 /* SettingTableViewController.m in Sources */,
+				C482C30A1F0B857800EF2B71 /* NTESGiftAttachment.m in Sources */,
 				61E7B5881DCF39E200F19E83 /* NTESSessionTipContentView.m in Sources */,
 				61EEE7791C22AEB300022315 /* NTESLiveBroadcastView.m in Sources */,
 				BDB0FC691BA7E6D30066654D /* NTESGLView.m in Sources */,
@@ -2019,11 +2167,14 @@
 				E48988EE1DE4263D001CF6C5 /* NTESChatroomTextContentConfig.m in Sources */,
 				C4D4C93C1ED7C3DE00ADD7B7 /* CreateGroupViewController.m in Sources */,
 				C4D4C9261ED7C2A900ADD7B7 /* GroupTableViewCell.m in Sources */,
+				C4F1D0EB1EF8F1B800A04B28 /* SocialTableViewController.m in Sources */,
+				C4F1D0F11EF8F75400A04B28 /* SocialPublishViewController.m in Sources */,
 				61E4713A1B7D963E00F4A1BF /* NTESSearchMessageEntraceCell.m in Sources */,
 				61A1422F1AD7B02E00DCAD88 /* NSDictionary+NTESJson.m in Sources */,
 				61E471351B7D963E00F4A1BF /* NTESSnapchatAttachment.m in Sources */,
 				61E1311D1C1A6778009AFEF1 /* NTESChatroomViewController.m in Sources */,
 				61E4714C1B7D963E00F4A1BF /* NTESWhiteboardViewController.m in Sources */,
+				C482C2FB1F0A110E00EF2B71 /* TradePostTableViewCell.m in Sources */,
 				611ABF001B3CF4FC00B8706C /* NTESAvatarImageView.m in Sources */,
 				C4B1463C1EF24E6300819893 /* SettingAccountViewController.m in Sources */,
 				61E471611B7D963E00F4A1BF /* NTESNoDisturbTimeCell.m in Sources */,
@@ -2033,6 +2184,7 @@
 				61E4718B1B7D96AA00F4A1BF /* NTESClientUtil.m in Sources */,
 				61E471071B7D963E00F4A1BF /* NTESSearchTeamViewController.m in Sources */,
 				61E471671B7D963E00F4A1BF /* NTESSettingSwitcherCell.m in Sources */,
+				C482C3011F0A792300EF2B71 /* SettingOptionTableViewCell.m in Sources */,
 				61E4710C1B7D963E00F4A1BF /* NTESTeamListViewController.m in Sources */,
 				61E4718A1B7D96AA00F4A1BF /* NTESBundleSetting.m in Sources */,
 				AE2AA6851A7CD35C00CFF013 /* UIView+NTES.m in Sources */,
@@ -2043,17 +2195,21 @@
 				61E4714A1B7D963E00F4A1BF /* NTESSessionRemoteHistoryViewController.m in Sources */,
 				61E4711F1B7D963E00F4A1BF /* NTESCustomNotificationDB.m in Sources */,
 				61E471951B7D96AA00F4A1BF /* NTESSessionUtil.m in Sources */,
+				C4F1D0EE1EF8F2E800A04B28 /* SocialTableViewCell.m in Sources */,
+				C4F1D0F51EFA17DF00A04B28 /* HttpRequest.m in Sources */,
 				611ABF041B3CF4FC00B8706C /* NTESMarginButton.m in Sources */,
 				61E4715E1B7D963E00F4A1BF /* NTESSessionListViewController.m in Sources */,
 				61E471251B7D963E00F4A1BF /* NTESSystemNotificationViewController.m in Sources */,
 				61E4715F1B7D963E00F4A1BF /* NTESNoDisturbSettingViewController.m in Sources */,
 				83F32B731E94EFE200E594E0 /* NTESSubscribeManager.m in Sources */,
+				C4246CF71F075F59008CD291 /* TradeData.m in Sources */,
 				61E471641B7D963E00F4A1BF /* NTESSettingViewController.m in Sources */,
 				C4D4C9341ED7C37F00ADD7B7 /* main.m in Sources */,
 				6173AED51BAAC8E700854D49 /* NTESEmailSettingViewController.m in Sources */,
 				03A4CA001AC2B79700E45E03 /* UIActionSheet+NTESBlock.m in Sources */,
 				61E471431B7D963E00F4A1BF /* NTESFileTransSelectViewController.m in Sources */,
 				61E4713E1B7D963E00F4A1BF /* NTESSessionWhiteBoardContentView.m in Sources */,
+				C482C2F51F09DAA800EF2B71 /* TradePublishManager.m in Sources */,
 				6118F5A91C5A0FC1009AF01E /* UIView+Swizzling.m in Sources */,
 				6110D8A91C23E76D00805BA4 /* NTESChatroomMemberCell.m in Sources */,
 				E48988EB1DE42391001CF6C5 /* NTESSessionCustomContentConfig.m in Sources */,
@@ -2061,11 +2217,13 @@
 				61E471311B7D963E00F4A1BF /* NTESJanKenPonAttachment.m in Sources */,
 				61E471981B7D96AA00F4A1BF /* NTESSpellingCenter.m in Sources */,
 				61FB27711C4E70AA0086E0EB /* NTESChatroomMaker.m in Sources */,
+				C482C30D1F0B923300EF2B71 /* NTESSessionGiftContentView.m in Sources */,
 				BD52DB3E1B8F300E00434D0E /* NTESCADisplayLinkHolder.m in Sources */,
 				61EAD91B1B834E72005DC715 /* NTESUserListCell.m in Sources */,
 				61E471511B7D963E00F4A1BF /* NetCallChatInfo.m in Sources */,
 				E49D53C11B451C7400A869AC /* NSData+NTES.m in Sources */,
 				61EEE7761C22964500022315 /* NTESLiveMasterInfoView.m in Sources */,
+				C4F1D15D1F03DDCA00A04B28 /* SocialDetailTableViewCell.m in Sources */,
 				61EEE7731C22917400022315 /* NTESChatroomMemberListViewController.m in Sources */,
 				617D015D1AEDE03900C6DB77 /* UIImage+NTESColor.m in Sources */,
 				61EAD9081B82D0A2005DC715 /* NTESTextSettingCell.m in Sources */,

+ 1 - 0
NIMDemo/NIMDemo/AppDelegate.h

@@ -15,6 +15,7 @@
 -(void) noNavBar:(UIViewController *)viewController;
 -(void) whiteNavBar:(UIViewController *)viewController;
 -(void) orangeNavBar:(UIViewController *)viewController;
+-(void) transparentNavBar:(UIViewController *)viewController;
 
 @end
 

+ 23 - 0
NIMDemo/NIMDemo/AppDelegate.m

@@ -19,6 +19,9 @@
 #import "NTESCellLayoutConfig.h"
 #import "NTESSessionUtil.h"
 #import "User.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+
 
 NSString *NTESNotificationLogout = @"NTESNotificationLogout";
 @interface AppDelegate ()<NIMLoginManagerDelegate>
@@ -40,6 +43,8 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     
     [self setupMainViewController];
     
+    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
+    
     return YES;
 }
 
@@ -259,11 +264,13 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
 
 
 - (void)noNavBar:(UIViewController *)viewController{
+    [viewController.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
     [viewController.navigationController.navigationBar setHidden:YES];
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
 }
 
 - (void)whiteNavBar:(UIViewController *)viewController{
+    [viewController.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
     [viewController.navigationController.navigationBar setHidden:NO];
     viewController.navigationController.navigationBar.tintColor = [UIColor blackColor];
     [viewController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
@@ -276,6 +283,7 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
 }
 
 - (void)orangeNavBar:(UIViewController *)viewController{
+    [viewController.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
     [viewController.navigationController.navigationBar setHidden:NO];
     viewController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
     [viewController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
@@ -288,4 +296,19 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
 }
 
+- (void)transparentNavBar:(UIViewController *)viewController{
+    [viewController.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
+    [viewController.navigationController.navigationBar setHidden:NO];
+    viewController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
+    [viewController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
+    viewController.navigationController.navigationBar.barTintColor = nil;
+    viewController.navigationController.navigationBar.backgroundColor = nil;
+    viewController.navigationItem.titleView.tintColor = [UIColor whiteColor];
+    
+    [viewController.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
+    [viewController.navigationController.navigationBar setShadowImage:nil];
+    
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
+}
+
 @end

+ 43 - 228
NIMDemo/NIMDemo/Base.lproj/Main.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F2073" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ryW-gA-XNT">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F2073" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ryW-gA-XNT">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -13,7 +13,7 @@
         <scene sceneID="fAe-M1-am2">
             <objects>
                 <navigationController storyboardIdentifier="NavController" id="ryW-gA-XNT" sceneMemberID="viewController">
-                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="Hk7-II-cEF">
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="Hk7-II-cEF">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </navigationBar>
@@ -287,7 +287,7 @@
         <!--交易帖-->
         <scene sceneID="xe7-yV-wsZ">
             <objects>
-                <viewController id="DfF-9d-fkt" sceneMemberID="viewController">
+                <viewController id="DfF-9d-fkt" customClass="TradeViewController" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="MMB-8h-3h3"/>
                         <viewControllerLayoutGuide type="bottom" id="9Z2-IW-BWK"/>
@@ -306,237 +306,57 @@
         <!--朋友圈-->
         <scene sceneID="WAG-Ob-5Qi">
             <objects>
-                <viewController id="Uhr-b8-Pkv" sceneMemberID="viewController">
+                <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">
+                        <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>
+                    <extendedEdge key="edgesForExtendedLayout" top="YES"/>
+                    <tabBarItem key="tabBarItem" title="朋友圈" image="五个图标_21" selectedImage="五个图标_09" id="vyo-cF-KS0"/>
+                    <simulatedTabBarMetrics key="simulatedBottomBarMetrics" translucent="NO"/>
+                    <connections>
+                        <segue destination="jTY-s6-0cu" kind="show" id="DYC-lK-7aV"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="ten-yh-4ue" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="2517.5999999999999" y="1115.8920539730136"/>
+        </scene>
+        <!--Social Detail View Controller-->
+        <scene sceneID="Ngl-cU-iEY">
+            <objects>
+                <viewController storyboardIdentifier="SocialDetail" id="jTY-s6-0cu" customClass="SocialDetailViewController" sceneMemberID="viewController">
                     <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="IIn-iL-1z2"/>
-                        <viewControllerLayoutGuide type="bottom" id="UGq-Un-6f2"/>
+                        <viewControllerLayoutGuide type="top" id="1SU-db-9fL"/>
+                        <viewControllerLayoutGuide type="bottom" id="40q-Lt-J1V"/>
                     </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="19c-KI-w62">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                    <view key="view" contentMode="scaleToFill" id="Y5T-9y-R8C">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                     </view>
-                    <tabBarItem key="tabBarItem" title="朋友圈" image="五个图标_21" selectedImage="五个图标_09" id="vyo-cF-KS0"/>
                 </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="ten-yh-4ue" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="VSl-SO-dfb" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="2518" y="1116"/>
+            <point key="canvasLocation" x="3370" y="1116"/>
         </scene>
         <!--我的-->
         <scene sceneID="Ixr-fZ-phM">
             <objects>
                 <tableViewController title="我的" id="jFP-5S-Sx6" customClass="SettingTableViewController" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="QkO-9q-JjT">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="QkO-9q-JjT">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="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"/>
-                        <sections>
-                            <tableViewSection id="I3k-ak-7uh">
-                                <cells>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="300" id="skT-k4-pey">
-                                        <rect key="frame" x="0.0" y="0.0" width="375" height="300"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="skT-k4-pey" id="7sA-Tb-G76">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="300"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <subviews>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" layoutMarginsFollowReadableWidth="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IfL-77-v8x">
-                                                    <rect key="frame" x="0.0" y="0.0" width="375" height="180"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <state key="normal" title="点击更换背景" backgroundImage="群资料_01">
-                                                        <color key="titleColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
-                                                        <color key="titleShadowColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
-                                                    </state>
-                                                </button>
-                                                <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nlv-Sx-RuL" customClass="NIMAvatarImageView">
-                                                    <rect key="frame" x="136" y="130" width="100" height="100"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                                                </view>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="我的_07 (3)" translatesAutoresizingMaskIntoConstraints="NO" id="3Vj-yy-uIj">
-                                                    <rect key="frame" x="205" y="195" width="30" height="30"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="ID:213123" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ur1-2W-LD0">
-                                                    <rect key="frame" x="72.5" y="258" width="230" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
-                                                    <nil key="highlightedColor"/>
-                                                </label>
-                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="前世情人" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6fr-nf-quH">
-                                                    <rect key="frame" x="72.5" y="238" width="230" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <nil key="textColor"/>
-                                                    <nil key="highlightedColor"/>
-                                                </label>
-                                            </subviews>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="50" id="QQI-1I-3Iq">
-                                        <rect key="frame" x="0.0" y="300" width="375" height="50"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="QQI-1I-3Iq" id="QJk-OW-b17">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <subviews>
-                                                <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="S5g-Fw-Axc">
-                                                    <rect key="frame" x="0.0" y="0.0" width="375" height="214"/>
-                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
-                                                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                                                </view>
-                                            </subviews>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="10" id="OJt-pZ-mTE">
-                                        <rect key="frame" x="0.0" y="350" width="375" height="10"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OJt-pZ-mTE" id="aML-OK-pvE">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="10"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <color key="backgroundColor" red="0.90210087435233155" green="0.90210087435233155" blue="0.90210087435233155" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="Zfh-lz-oAm">
-                                        <rect key="frame" x="0.0" y="360" width="375" height="44"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Zfh-lz-oAm" id="3Sg-Fx-PvB">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <subviews>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="我的_07" translatesAutoresizingMaskIntoConstraints="NO" id="N5U-oJ-BKW">
-                                                    <rect key="frame" x="15" y="8" width="30" height="30"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="设置_03" translatesAutoresizingMaskIntoConstraints="NO" id="jo3-AL-V4P">
-                                                    <rect key="frame" x="350" y="12" width="10" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="附近的人" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kz2-op-bVo">
-                                                    <rect key="frame" x="55" y="12" width="198" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <nil key="textColor"/>
-                                                    <nil key="highlightedColor"/>
-                                                </label>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1Z6-gG-Hss">
-                                                    <rect key="frame" x="0.0" y="0.0" width="408" height="44.5"/>
-                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                                    <connections>
-                                                        <action selector="onTouchNear:" destination="jFP-5S-Sx6" eventType="touchUpInside" id="bNi-CT-DGT"/>
-                                                    </connections>
-                                                </button>
-                                            </subviews>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="1" id="8Kd-fJ-d1u">
-                                        <rect key="frame" x="0.0" y="404" width="375" height="1"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8Kd-fJ-d1u" id="bsA-zS-EWk">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="1"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <color key="backgroundColor" red="0.90210087439999997" green="0.90210087439999997" blue="0.90210087439999997" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="KVb-vl-idH">
-                                        <rect key="frame" x="0.0" y="405" width="375" height="44"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KVb-vl-idH" id="7fO-8e-wXq">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <subviews>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="我的_10" translatesAutoresizingMaskIntoConstraints="NO" id="S0x-lA-3J7">
-                                                    <rect key="frame" x="15" y="6" width="30" height="30"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="我的供需" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cpK-MC-qWg">
-                                                    <rect key="frame" x="55" y="12" width="198" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <nil key="textColor"/>
-                                                    <nil key="highlightedColor"/>
-                                                </label>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="设置_03" translatesAutoresizingMaskIntoConstraints="NO" id="7P8-Ft-E8l">
-                                                    <rect key="frame" x="350" y="12" width="10" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VJL-lD-5KH">
-                                                    <rect key="frame" x="0.0" y="0.0" width="408" height="44.5"/>
-                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                                    <connections>
-                                                        <action selector="onTouchSupply:" destination="jFP-5S-Sx6" eventType="touchUpInside" id="9g5-8Q-Dvl"/>
-                                                    </connections>
-                                                </button>
-                                            </subviews>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="1" id="gNo-0w-wVK">
-                                        <rect key="frame" x="0.0" y="449" width="375" height="1"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="gNo-0w-wVK" id="tXq-Bb-NhH">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="1"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <color key="backgroundColor" red="0.90210087439999997" green="0.90210087439999997" blue="0.90210087439999997" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="m8w-k2-CrD">
-                                        <rect key="frame" x="0.0" y="450" width="375" height="44"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="m8w-k2-CrD" id="E2I-M3-bif">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <subviews>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="我的_17" translatesAutoresizingMaskIntoConstraints="NO" id="85V-vW-s0k">
-                                                    <rect key="frame" x="15" y="5" width="30" height="30"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="设置" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yhk-5I-zBn">
-                                                    <rect key="frame" x="55" y="12" width="198" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <nil key="textColor"/>
-                                                    <nil key="highlightedColor"/>
-                                                </label>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5TP-Gc-bul">
-                                                    <rect key="frame" x="0.0" y="0.0" width="408" height="44.5"/>
-                                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                                    <connections>
-                                                        <action selector="onTouchSetting:" destination="jFP-5S-Sx6" eventType="touchUpInside" id="e5q-Hf-XQC"/>
-                                                        <segue destination="rUO-gt-PPj" kind="show" id="WdG-eP-qVZ"/>
-                                                    </connections>
-                                                </button>
-                                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="设置_03" translatesAutoresizingMaskIntoConstraints="NO" id="PqK-A3-rQN">
-                                                    <rect key="frame" x="350" y="12" width="10" height="21"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
-                                                </imageView>
-                                            </subviews>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" rowHeight="1" id="sIC-9L-HZD">
-                                        <rect key="frame" x="0.0" y="494" width="375" height="1"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="sIC-9L-HZD" id="AAr-aA-V3Q">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="1"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                            <color key="backgroundColor" red="0.90210087439999997" green="0.90210087439999997" blue="0.90210087439999997" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
-                                </cells>
-                            </tableViewSection>
-                        </sections>
+                        <sections/>
                     </tableView>
-                    <extendedEdge key="edgesForExtendedLayout" top="YES"/>
+                    <extendedEdge key="edgesForExtendedLayout"/>
                     <tabBarItem key="tabBarItem" title="我的" image="五个图标_22" selectedImage="五个图标_11" id="lsN-GL-pin"/>
+                    <nil key="simulatedTopBarMetrics"/>
                     <simulatedTabBarMetrics key="simulatedBottomBarMetrics" translucent="NO"/>
-                    <connections>
-                        <outlet property="avatarImg" destination="nlv-Sx-RuL" id="Yjx-CW-OwS"/>
-                        <outlet property="genderImg" destination="3Vj-yy-uIj" id="y3V-OG-3EZ"/>
-                        <outlet property="topBgBtn" destination="IfL-77-v8x" id="jf8-U1-9L5"/>
-                        <outlet property="userIdLabel" destination="Ur1-2W-LD0" id="Kkl-rn-aPe"/>
-                        <outlet property="userNameLabel" destination="6fr-nf-quH" id="Gqm-oo-dON"/>
-                    </connections>
                 </tableViewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="a35-Ef-GXn" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
@@ -545,7 +365,7 @@
         <!--Setting Account View Controller-->
         <scene sceneID="TDU-IJ-Itb">
             <objects>
-                <viewController id="rUO-gt-PPj" customClass="SettingAccountViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="AccountSetting" id="rUO-gt-PPj" customClass="SettingAccountViewController" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="pQW-9x-68V"/>
                         <viewControllerLayoutGuide type="bottom" id="kdV-Os-LUa"/>
@@ -864,17 +684,17 @@
         <!--City Picker View Controller-->
         <scene sceneID="L3u-fg-i0c">
             <objects>
-                <viewController id="M3Y-Uu-1Gu" customClass="CityPickerViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="CityPicker" id="M3Y-Uu-1Gu" customClass="CityPickerViewController" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="cHy-Ne-olc"/>
                         <viewControllerLayoutGuide type="bottom" id="mtU-Zy-ar1"/>
                     </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="KfJ-My-GKX">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4zt-pf-brs" customClass="PSCityPickerView">
-                                <rect key="frame" x="0.0" y="64" width="375" height="554"/>
+                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             </pickerView>
                         </subviews>
@@ -1088,7 +908,7 @@
             <objects>
                 <tableViewController storyboardIdentifier="GroupMore" id="Pzn-rE-rHS" customClass="GroupMoreTableViewController" sceneMemberID="viewController">
                     <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="80" sectionHeaderHeight="28" sectionFooterHeight="28" id="cp8-AT-t8S">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="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"/>
@@ -1184,20 +1004,15 @@
         <image name="五个图标_21" width="25" height="25"/>
         <image name="五个图标_22" width="25" height="25"/>
         <image name="开启通讯录_07" width="333" height="45"/>
-        <image name="我的_07" width="50" height="50"/>
-        <image name="我的_07 (3)" width="36" height="36"/>
-        <image name="我的_10" width="50" height="50"/>
-        <image name="我的_17" width="50" height="50"/>
         <image name="登录界面_03" width="632" height="90"/>
         <image name="登录界面_06" width="632" height="90"/>
-        <image name="群资料_01" width="375" height="203"/>
         <image name="设置_03" width="7" height="13"/>
         <image name="选择群组_10" width="20" height="20"/>
         <image name="选择群组_13" width="20" height="20"/>
     </resources>
     <inferredMetricsTieBreakers>
-        <segue reference="ZPf-qf-Bgx"/>
+        <segue reference="koG-KY-sGS"/>
         <segue reference="gKG-Mt-Dsc"/>
-        <segue reference="crz-lb-2c2"/>
+        <segue reference="L8f-9a-f45"/>
     </inferredMetricsTieBreakers>
 </document>

+ 2 - 1
NIMDemo/NIMDemo/Classes/LayoutConfig/NTESCellLayoutConfig.m

@@ -27,7 +27,8 @@
                    @"NTESJanKenPonAttachment",
                    @"NTESSnapchatAttachment",
                    @"NTESChartletAttachment",
-                   @"NTESWhiteboardAttachment"
+                   @"NTESWhiteboardAttachment",
+                   @"NTESGiftAttachment"
                    ];
         _sessionCustomconfig = [[NTESSessionCustomContentConfig alloc] init];
         _chatroomTextConfig = [[NTESChatroomTextContentConfig alloc] init];

+ 10 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESCustomAttachmentDecoder.m

@@ -11,6 +11,7 @@
 #import "NTESJanKenPonAttachment.h"
 #import "NTESSnapchatAttachment.h"
 #import "NTESChartletAttachment.h"
+#import "NTESGiftAttachment.h"
 #import "NTESWhiteboardAttachment.h"
 #import "NSDictionary+NTESJson.h"
 #import "NTESSessionUtil.h"
@@ -57,6 +58,12 @@
                     ((NTESWhiteboardAttachment *)attachment).flag = [data jsonInteger:CMFlag];
                 }
                     break;
+                case CustomMessageTypeGift:
+                {
+                    attachment = [[NTESGiftAttachment alloc] init];
+                    [((NTESGiftAttachment *)attachment) handleGiftMessage:data];
+                }
+                    break;
                 default:
                     break;
             }
@@ -85,6 +92,9 @@
         NSInteger flag = [((NTESWhiteboardAttachment *)attachment) flag];
         check = ((flag >= CustomWhiteboardFlagInvite) && (flag <= CustomWhiteboardFlagClose)) ? YES : NO;
     }
+    else if ([attachment isKindOfClass:[NTESGiftAttachment class]]) {
+        check = YES;
+    }
     return check;
 }
 @end

+ 1 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESCustomAttachmentDefines.h

@@ -16,6 +16,7 @@ typedef NS_ENUM(NSInteger,NTESCustomMessageType){
     CustomMessageTypeSnapchat   = 2, //阅后即焚
     CustomMessageTypeChartlet   = 3, //贴图表情
     CustomMessageTypeWhiteboard = 4,  //白板会话
+    CustomMessageTypeGift       = 5, //送礼物
 };
 
 

+ 27 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.h

@@ -0,0 +1,27 @@
+//
+//  NTESGiftAttachment.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "NTESCustomAttachmentDefines.h"
+
+@interface NTESGiftAttachment : NSObject<NIMCustomAttachment,NTESCustomAttachmentInfo>
+
+@property (nonatomic, strong) NSString *giftId;
+@property (nonatomic, strong) NSString *senderId;
+@property (nonatomic, strong) NSString *teamId;
+@property (nonatomic, strong) NSString *targetId;
+@property (nonatomic, strong) NSString *count;
+@property (nonatomic, strong) NSString *msg;
+@property (nonatomic, strong) NSString *iconURL;
+@property (nonatomic, strong) NSString *movieURL;
+
+@property (nonatomic, strong) UITextView *showTextView;
+
+- (void)handleGiftMessage:(NSDictionary *)data;
+
+@end

+ 107 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESGiftAttachment.m

@@ -0,0 +1,107 @@
+//
+//  NTESGiftAttachment.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "NTESGiftAttachment.h"
+#import "NTESSessionUtil.h"
+#import "UIView+NTES.h"
+#import "AppDelegate.h"
+#import "NSDictionary+NTESJson.h"
+#import "NTESSessionViewController.h"
+
+@implementation NTESGiftAttachment
+
+- (NSString *)encodeAttachment
+{
+    NSDictionary *dict = @{CMType : @(CustomMessageTypeGift),
+                           CMData : @{CMValue:self.msg,
+                                      CMURL:self.movieURL,
+                                      @"iconURL":self.iconURL,
+                                      @"giftId":self.giftId,
+                                      @"senderId":self.senderId,
+                                      @"teamId":self.teamId,
+                                      @"targetId":self.targetId,
+                                      @"count":self.count}};
+    NSData *data = [NSJSONSerialization dataWithJSONObject:dict
+                                                   options:0
+                                                     error:nil];
+    NSString *content = nil;
+    if (data) {
+        content = [[NSString alloc] initWithData:data
+                                        encoding:NSUTF8StringEncoding];
+    }
+    return content;
+}
+
+
+- (NSString *)cellContent:(NIMMessage *)message{
+    return @"NTESSessionGiftContentView";
+}
+
+- (CGSize)contentSize:(NIMMessage *)message cellWidth:(CGFloat)width{
+    
+    self.showTextView.width = width - 80 - 30;
+    [self.showTextView sizeToFit];
+    CGSize size = self.showTextView.contentSize;
+    size.width += 30;
+    return size;
+}
+
+- (UIEdgeInsets)contentViewInsets:(NIMMessage *)message
+{
+    if (message.session.sessionType == NIMSessionTypeChatroom)
+    {
+        CGFloat bubbleMarginTopForImage  = 15.f;
+        CGFloat bubbleMarginLeftForImage = 12.f;
+        return  UIEdgeInsetsMake(bubbleMarginTopForImage,bubbleMarginLeftForImage,0,0);
+    }
+    else
+    {
+        CGFloat bubbleMarginForImage    = 3.f;
+        CGFloat bubbleArrowWidthForImage = 5.f;
+        if (message.isOutgoingMsg) {
+            return  UIEdgeInsetsMake(bubbleMarginForImage,bubbleMarginForImage,bubbleMarginForImage,bubbleMarginForImage + bubbleArrowWidthForImage);
+        }else{
+            return  UIEdgeInsetsMake(bubbleMarginForImage,bubbleMarginForImage + bubbleArrowWidthForImage, bubbleMarginForImage,bubbleMarginForImage);
+        }
+    }
+}
+
+- (UITextView *)showTextView
+{
+    if (_showTextView == nil)
+    {
+        _showTextView = [[UITextView alloc] init];
+        _showTextView.font = [UIFont systemFontOfSize:15];
+        _showTextView.text = self.msg;
+    }
+    return _showTextView;
+}
+
+- (void)handleGiftMessage:(NSDictionary *)data{
+    
+    self.movieURL = [data jsonString:CMURL];
+    self.iconURL = [data jsonString:@"iconURL"];
+    self.msg = [data jsonString:CMValue];
+    self.giftId = [data jsonString:@"giftId"];
+    self.senderId = [data jsonString:@"senderId"];
+    self.teamId = [data jsonString:@"teamId"];
+    self.targetId = [data jsonString:@"targetId"];
+    self.count = [data jsonString:@"count"];
+    
+    AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    UINavigationController* navController = (UINavigationController *)appdelegate.window.rootViewController;
+    UIViewController *topViewController = navController.topViewController;
+    NSLog(@"%@", topViewController);
+    
+    if([topViewController isKindOfClass:[NTESSessionViewController class]])
+    {
+        [(NTESSessionViewController *)topViewController handleGiftMessage:self];
+    }
+}
+
+@end

+ 3 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESSessionMsgConverter.h

@@ -13,6 +13,7 @@
 @class NTESSnapchatAttachment;
 @class NTESChartletAttachment;
 @class NTESWhiteboardAttachment;
+@class NTESGiftAttachment;
 
 @interface NTESSessionMsgConverter : NSObject
 
@@ -40,4 +41,6 @@
 
 + (NIMMessage *)msgWithTip:(NSString *)tip;
 
++ (NIMMessage*)msgWithGift:(NTESGiftAttachment *)attachment;
+
 @end

+ 10 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/Model/Object/NTESSessionMsgConverter.m

@@ -12,6 +12,7 @@
 #import "NTESSnapchatAttachment.h"
 #import "NTESChartletAttachment.h"
 #import "NTESWhiteboardAttachment.h"
+#import "NTESGiftAttachment.h"
 
 
 @implementation NTESSessionMsgConverter
@@ -166,5 +167,14 @@
     return message;
 }
 
++ (NIMMessage*)msgWithGift:(NTESGiftAttachment *)attachment
+{
+    NIMMessage *message               = [[NIMMessage alloc] init];
+    NIMCustomObject *customObject     = [[NIMCustomObject alloc] init];
+    customObject.attachment           = attachment;
+    message.messageObject             = customObject;
+    message.apnsContent = @"发来了礼物信息";
+    return message;
+}
 
 @end

+ 13 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.h

@@ -0,0 +1,13 @@
+//
+//  NTESSessionGiftContentView.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "NIMSessionMessageContentView.h"
+
+@interface NTESSessionGiftContentView : NIMSessionMessageContentView
+
+@end

+ 86 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/View/SessionCell/SessionContentView/NTESSessionGiftContentView.m

@@ -0,0 +1,86 @@
+//
+//  NTESSessionGiftContentView.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "NTESSessionGiftContentView.h"
+#import "NTESGiftAttachment.h"
+
+@interface NTESSessionGiftContentView()
+
+@property (nonatomic, strong, readwrite) UIImageView *iconView;
+@property (nonatomic, strong, readwrite) UITextView *textView;
+
+@end
+
+@implementation NTESSessionGiftContentView
+
+- (instancetype)initSessionMessageContentView{
+    self = [super initSessionMessageContentView];
+    if (self) {
+        self.opaque = YES;
+        
+        _iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
+        [_iconView setImage:[UIImage imageNamed:@"聊天-_23"]];
+        [self addSubview:_iconView];
+        
+        _textView  = [[UITextView alloc] initWithFrame:CGRectZero];
+        _textView.backgroundColor = UIColor.clearColor;
+        _textView.font = [UIFont systemFontOfSize:15];
+        _textView.userInteractionEnabled = NO;
+        [self addSubview:_textView];
+    }
+    return self;
+}
+
+- (void)refresh:(NIMMessageModel *)data{
+    [super refresh:data];
+    NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
+    id attachment = customObject.attachment;
+    if ([attachment isKindOfClass:[NTESGiftAttachment class]]) {
+        
+        NTESGiftAttachment *at = (NTESGiftAttachment *)attachment;
+        if(data.message.isOutgoingMsg)
+        {
+            _textView.textColor = UIColor.whiteColor;
+        }
+        else
+        {
+            _textView.textColor = UIColor.blackColor;
+        }
+        self.textView.text = at.msg;
+        [self.textView sizeToFit];
+    }
+}
+
+- (void)layoutSubviews{
+    [super layoutSubviews];
+    UIEdgeInsets contentInsets = self.model.contentViewInsets;
+    CGSize contentSize = self.model.contentSize;
+    
+    CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentSize.width, contentSize.height);
+    imageViewFrame.origin.x += 30;
+    imageViewFrame.size.width -= 30;
+    self.textView.frame  = imageViewFrame;
+    
+    self.iconView.frame = CGRectMake(contentInsets.left, contentInsets.top, 30, 30);
+    
+    CALayer *maskLayer = [CALayer layer];
+    maskLayer.cornerRadius = 13.0;
+    maskLayer.backgroundColor = [UIColor blackColor].CGColor;
+    maskLayer.frame = self.textView.bounds;
+    self.textView.layer.mask = maskLayer;
+}
+
+
+- (UIImage *)chatBubbleImageForState:(UIControlState)state outgoing:(BOOL)outgoing{
+    if (self.model.message.session.sessionType == NIMSessionTypeChatroom) {
+        return nil;
+    }
+    return [super chatBubbleImageForState:state outgoing:outgoing];
+}
+
+@end

+ 3 - 0
NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.h

@@ -7,6 +7,7 @@
 //
 
 #import "NIMSessionViewController.h"
+#import "NTESGiftAttachment.h"
 
 @interface NTESSessionViewController : NIMSessionViewController
 
@@ -14,4 +15,6 @@
 
 @property (nonatomic,assign) BOOL disableOnlineState;  //需要在导航条上显示在线状态
 
+- (void)handleGiftMessage:(NTESGiftAttachment *)giftAttachment;
+
 @end

+ 173 - 49
NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m

@@ -54,6 +54,11 @@
 #import "GiftInputContainer.h"
 #import "GiftTopBarItem.h"
 #import "UIImageView+WebCache.h"
+#import "AFHTTPSessionManager.h"
+#import "TradePublishManager.h"
+#import "TradeInputContainer.h"
+#import "NIMMessageMaker.h"
+
 
 @interface NTESSessionViewController ()
 <UIImagePickerControllerDelegate,
@@ -63,7 +68,8 @@ NIMMediaManagerDelegate,
 NTESTimerHolderDelegate,
 NIMContactSelectDelegate,
 NIMEventSubscribeManagerDelegate,
-GiftDataSourceDelegate>
+GiftDataSourceDelegate,
+TradeInputDelegate>
 
 @property (nonatomic,strong)    NTESCustomSysNotificationSender *notificaionSender;
 @property (nonatomic,strong)    NTESSessionConfig       *sessionConfig;
@@ -79,6 +85,8 @@ GiftDataSourceDelegate>
 @property (nonatomic,strong)    UIImageView    *giftMovie;
 @property (nonatomic,strong)    NSTimer        *timer;
 
+@property (nonatomic,assign)    BOOL           displayed;
+
 @end
 
 
@@ -114,6 +122,19 @@ GiftDataSourceDelegate>
     //删除最近会话列表中有人@你的标记
     [NTESSessionUtil removeRecentSessionAtMark:self.session];
     
+    
+    //record chat room id
+    if(self.session.sessionType == NIMSessionTypeTeam)
+    {
+        [User sharedInfo].currentChatRoomId = self.session.sessionId;
+    }
+    else
+    {
+        [User sharedInfo].currentChatRoomId = nil;
+    }
+    
+    
+    
     self.sessionInputView.giftContainer.delegate = self;
     
     _giftItem1 = [[GiftTopBarItem alloc] initWithFrame:CGRectMake(0, 64, self.view.width, 40)];
@@ -138,7 +159,10 @@ GiftDataSourceDelegate>
     [self.view bringSubviewToFront:self.sessionInputView];
     [self.view bringSubviewToFront:self.sessionInputView.tabContainer];
     
-    _timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(requestGift) userInfo:nil repeats:YES];
+    _timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateGiftTopItem) userInfo:nil repeats:YES];
+    
+    
+    self.sessionInputView.giftContainer.tradeContainer.delegate = self;
 }
 
 - (void)dealloc
@@ -150,6 +174,7 @@ GiftDataSourceDelegate>
         [[NTESSubscribeManager sharedInstance] unsubscribeTempUserOnlineState:self.session.sessionId];
     }
     [_fpsLabel invalidate];
+    [_timer invalidate];
 }
 
 - (void)viewDidLayoutSubviews{
@@ -171,6 +196,11 @@ GiftDataSourceDelegate>
     {
         [giftInput setTeamId:nil];
     }
+}
+
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    self.displayed = YES;
     
     [_timer setFireDate:[NSDate distantPast]];
 }
@@ -180,7 +210,12 @@ GiftDataSourceDelegate>
     [[NIMSDK sharedSDK].mediaManager stopRecord];
     [[NIMSDK sharedSDK].mediaManager stopPlay];
     
-    [_timer invalidate];
+    [_timer setFireDate:[NSDate distantFuture]];
+}
+
+- (void)viewDidDisappear:(BOOL)animated{
+    [super viewDidDisappear:animated];
+    self.displayed = NO;
 }
 
 - (id<NIMSessionConfig>)sessionConfig
@@ -842,6 +877,12 @@ GiftDataSourceDelegate>
     //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:)]];
+    }
 }
 
 - (BOOL)shouldAutorotate{
@@ -875,7 +916,7 @@ GiftDataSourceDelegate>
     __weak typeof(self) wself = self;
     
     User *user = [User sharedInfo];
-    [user sendGif:giftData count:count teamId:teamId targetId:menberId msg:msg success:^(NSString * _Nullable info){
+    [user sendGif:giftData count:count teamId:teamId targetId:menberId msg:msg success:^(NSString * _Nullable giftId, NSString * _Nullable info){
         
         [wself.sessionInputView.giftContainer setBalance:user.coin];
         
@@ -896,17 +937,17 @@ GiftDataSourceDelegate>
                 {
                     NIMUser *u = [users objectAtIndex:0];
                     NSString *content = [NSString stringWithFormat:@"@%@ %@", u.userInfo.nickName ? u.userInfo.nickName : u.userId, msg];
-                    [wself onSendText:content atUsers:atUsers];
+                    [wself onSendGiftText:content atUsers:atUsers giftData:giftData giftId:giftId count:count teamId:teamId targetId:menberId];
                 }
             }];
         }
-        else if(msg && msg.length)
+        else
         {
             NSString *content = [NSString stringWithFormat:@"%@%@", @"", msg];
-            [wself onSendText:content atUsers:atUsers];
+            [wself onSendGiftText:content atUsers:atUsers giftData:giftData giftId:giftId count:count teamId:teamId targetId:menberId];
         }
         
-        [wself requestGift];
+        //[wself requestGift];
         
     } failure:^(NSError * _Nullable error) {
         //
@@ -916,66 +957,119 @@ GiftDataSourceDelegate>
     [self.sessionInputView unselectedTabBarItem];
 }
 
-- (void)requestGift
+- (void)onSendGiftText:(NSString *)text atUsers:(NSArray *)atUsers giftData:(GiftData *)giftData giftId:(NSString *)giftId count:(int)count teamId:(NSString *)teamId targetId:(NSString *)targetId
 {
+    NTESGiftAttachment *attachment = [[NTESGiftAttachment alloc] init];
+    attachment.giftId = giftId;
+    attachment.senderId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    attachment.teamId = teamId;
+    attachment.targetId = targetId;
+    attachment.count = [NSString stringWithFormat:@"%d", count];
+    attachment.msg = text;
+    attachment.movieURL = giftData.movieURL;
+    attachment.iconURL = giftData.iconURL;
     
-    User *user = [User sharedInfo];
-    
-    NSString *senderId = [NSString stringWithFormat:@"%d", user.userId];
-    NSString *teamId = nil;
-    NSString *targetId = nil;
-    if(self.session.sessionType == NIMSessionTypeTeam)
-    {
-        teamId = self.session.sessionId;
+    NIMMessage *message = [NTESSessionMsgConverter msgWithGift:attachment];
+    if (atUsers.count) {
+        NIMMessageApnsMemberOption *apnsOption = [[NIMMessageApnsMemberOption alloc] init];
+        apnsOption.userIds = atUsers;
+        apnsOption.forcePush = YES;
+        
+        NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
+        option.session = self.session;
+        
+        NSString *me = [[NIMKit sharedKit].provider infoByUser:[NIMSDK sharedSDK].loginManager.currentAccount option:option].showName;
+        apnsOption.apnsContent = [NSString stringWithFormat:@"%@在群里@了你",me];
+        message.apnsMemberOption = apnsOption;
     }
-    else if(self.session.sessionType == NIMSessionTypeP2P)
+    [self sendMessage:message];
+    
+    [self handleGiftMessage:attachment];
+}
+
+- (void)handleGiftMessage:(NTESGiftAttachment *)giftAttachment{
+    
+    
+    NSString *giftId = giftAttachment.giftId;
+    NSString *senderId = giftAttachment.senderId;
+    NSString *teamId = giftAttachment.teamId;
+    NSString *targetId = giftAttachment.targetId;
+    
+    NSString *key = teamId ? teamId : targetId;
+    
+    if(!self.displayed)
     {
-        targetId = self.session.sessionId;
+        [[User sharedInfo] initGiftGot:key dataId:giftId];
+        return;
     }
     
-    [user requestGif:senderId targetId:targetId teamId:teamId success:^(NSMutableArray * _Nonnull giftArr) {
+    if([[User sharedInfo] isNewGiftGot:key dataId:giftId])
+    {
+        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
+        [dict setValue:senderId forKey:@"sender"];
+        [dict setValue:giftAttachment.iconURL forKey:@"gift"];
+        [dict setValue:teamId forKey:@"team"];
+        [dict setValue:targetId forKey:@"target"];
+        [dict setValue:giftAttachment.count forKey:@"count"];
         
-        if(giftArr.count > 0)
+        if(!_giftItem1.isHidden && !_giftItem2.isHidden)
         {
-            NSDictionary *data = [giftArr objectAtIndex:0];
+            [_giftItem1 setInfo:_giftItem2.infoDict];
+            _giftItem1.timeCount = _giftItem2.timeCount;
             
-            _giftItem1.hidden = NO;
-            [_giftItem1 setInfo:data];
-            
-            if(!_giftItem1.isHidden)
-            {
-                NSString *newId = [data objectForKey:@"id"];
-                if([user isNewGiftGot:teamId ? teamId : targetId dataId:newId])
-                {
-                    NSString *giftId = [data objectForKey:@"gift"];
-                    GiftData *giftData = [user getGiftData:giftId];
-                    if(giftData){
-                        NSURL *url = [NSURL URLWithString:giftData.movieURL];
-                        [_giftMovie sd_setImageWithURL:url placeholderImage:nil];
-                        [_giftMovieContainer setHidden:NO];
-                    }
-                }
-            }
+            [_giftItem2 setInfo:dict];
+            _giftItem2.timeCount = 0;
+        }
+        else if(!_giftItem1.isHidden && _giftItem2.isHidden)
+        {
+            [_giftItem2 setInfo:dict];
+            [_giftItem2 setHidden:NO];
+            _giftItem2.timeCount = 0;
         }
         else
         {
-            [user isNewGiftGot:teamId ? teamId : targetId dataId:nil];
-            _giftItem1.hidden = YES;
+            [_giftItem1 setInfo:dict];
+            [_giftItem1 setHidden:NO];
+            _giftItem1.timeCount = 0;
         }
         
-        if(giftArr.count > 1)
+        NSURL *url = [NSURL URLWithString:giftAttachment.movieURL];
+        [_giftMovie sd_setImageWithURL:url placeholderImage:nil];
+        [_giftMovieContainer setHidden:NO];
+    }
+    
+}
+
+- (void)updateGiftTopItem{
+    
+    NSLog(@"updateGiftTopItem");
+    
+    int hideTimeCount = 2;
+
+    if(!_giftItem1.isHidden){
+        _giftItem1.timeCount++;
+        if(_giftItem1.timeCount > hideTimeCount)
         {
-            _giftItem2.hidden = NO;
-            [_giftItem2 setInfo:[giftArr objectAtIndex:1]];
+            [_giftItem1 setHidden:YES];
         }
-        else
+    }
+    if(!_giftItem2.isHidden){
+        _giftItem2.timeCount++;
+        if(_giftItem2.timeCount > hideTimeCount)
         {
-            _giftItem2.hidden = YES;
+            [_giftItem2 setHidden:YES];
         }
+    }
+    
+    
+    if(!_giftItem2.isHidden && _giftItem1.isHidden)
+    {
+        [_giftItem1 setInfo:_giftItem2.infoDict];
+        _giftItem1.timeCount = _giftItem2.timeCount;
+        [_giftItem1 setHidden:NO];
         
-    } failure:^(NSError * _Nullable error) {
-        
-    }];
+        [_giftItem2 setHidden:YES];
+    }
 }
 
 
@@ -1003,4 +1097,34 @@ GiftDataSourceDelegate>
     [self.navigationController pushViewController:vc animated:YES];
 }
 
+
+
+
+
+
+
+
+
+
+
+
+- (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.inputView = self.sessionInputView;
+    [tradePublishManager tradePublish:msg picArr:picArr priority:priority tradeType:type];
+    
+}
+
+
+
+
+
 @end

+ 6 - 1
NIMDemo/NIMDemo/Classes/Sections/SessionList/ViewController/NTESSessionListViewController.m

@@ -17,6 +17,7 @@
 #import "NTESJanKenPonAttachment.h"
 #import "NTESChartletAttachment.h"
 #import "NTESWhiteboardAttachment.h"
+#import "NTESGiftAttachment.h"
 #import "NTESSessionUtil.h"
 #import "NTESPersonalCardViewController.h"
 
@@ -277,7 +278,11 @@
         }
         else if ([object.attachment isKindOfClass:[NTESWhiteboardAttachment class]]) {
             text = @"[白板]";
-        }else{
+        }
+        else if ([object.attachment isKindOfClass:[NTESGiftAttachment class]]) {
+            text = @"[礼物]";
+        }
+        else{
             text = @"[未知消息]";
         }
         if (recent.session.sessionType != NIMSessionTypeP2P)

+ 6 - 1
NIMDemo/NIMDemo/FriendViewController.m

@@ -17,6 +17,7 @@
 #import "NTESJanKenPonAttachment.h"
 #import "NTESChartletAttachment.h"
 #import "NTESWhiteboardAttachment.h"
+#import "NTESGiftAttachment.h"
 #import "NTESSessionUtil.h"
 #import "NTESPersonalCardViewController.h"
 #import "NTESContactViewController.h"
@@ -313,7 +314,11 @@
         }
         else if ([object.attachment isKindOfClass:[NTESWhiteboardAttachment class]]) {
             text = @"[白板]";
-        }else{
+        }
+        else if ([object.attachment isKindOfClass:[NTESGiftAttachment class]]) {
+            text = @"[礼物]";
+        }
+        else{
             text = @"[未知消息]";
         }
         if (recent.session.sessionType != NIMSessionTypeP2P)

+ 4 - 1
NIMDemo/NIMDemo/GiftTopBarItem.h

@@ -10,6 +10,9 @@
 
 @interface GiftTopBarItem : UIView
 
--(void)setInfo:(NSDictionary *)infoDict;
+@property (nonatomic, assign) int timeCount;
+@property (nonatomic, strong) NSMutableDictionary *infoDict;
+
+-(void)setInfo:(NSMutableDictionary *)infoDict;
 
 @end

+ 4 - 11
NIMDemo/NIMDemo/GiftTopBarItem.m

@@ -73,23 +73,16 @@
     return self;
 }
 
-- (void) setInfo:(NSDictionary *)infoDict
+- (void) setInfo:(NSMutableDictionary *)infoDict
 {
+    _infoDict = infoDict;
     
-    NSString *giftId = [infoDict objectForKey:@"gift"];
+    NSString *icon = [infoDict objectForKey:@"gift"];
     NSString *sender = [infoDict objectForKey:@"sender"];
     NSString *teamId = [infoDict objectForKey:@"team"];
     NSString *target = [infoDict objectForKey:@"target"];
     NSString *count = [infoDict objectForKey:@"count"];
     
-    
-    User *user = [User sharedInfo];
-    GiftData *giftData = [user getGiftData:giftId];
-    if(!giftData){
-        [self setHidden:YES];
-        return;
-    }
-    
     [[NIMSDK sharedSDK].userManager fetchUserInfos:@[sender] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
         
         if(error || !users || users.count == 0)
@@ -130,7 +123,7 @@
     }
     
     
-    [_giftIcon sd_setImageWithURL:[NSURL URLWithString:giftData.iconURL]];
+    [_giftIcon sd_setImageWithURL:[NSURL URLWithString:icon]];
     _labelCount.text = [NSString stringWithFormat:@"x%@", count];
 }
 

+ 3 - 7
NIMDemo/NIMDemo/GroupTableController.m

@@ -395,13 +395,9 @@
 {
     User *user = [User sharedInfo];
     
-    NSDictionary *parameters = @{@"longitude":[NSString stringWithFormat:@"%F", user.longitude],
-                                 @"latitude":[NSString stringWithFormat:@"%F", user.latitude]
-                                 };
-    
-    parameters = @{@"id":[NSString stringWithFormat:@"%d", user.userId],
-                   @"longitude":@"106.443076",
-                   @"latitude":@"29.833546"
+    NSDictionary *parameters = @{@"id":[NSString stringWithFormat:@"%d", user.userId],
+                   @"longitude":[NSString stringWithFormat:@"%F", user.longitude],
+                   @"latitude":[NSString stringWithFormat:@"%F", user.latitude]
                    };
     
     NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=index&a=coordinate_2_location";

+ 80 - 0
NIMDemo/NIMDemo/HttpRequest/HttpRequest.h

@@ -0,0 +1,80 @@
+//
+//  HttpRequest.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/21.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SocialItemData.h"
+#import "SocialCommentData.h"
+#import "TradeData.h"
+
+@interface HttpRequest : NSObject
+
++ (instancetype _Nonnull )shared;
+
+
+
+
+
+
+
+- (void)getSocialDataList:(NSString *_Nullable)lastId
+                  success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
+                  failure:(void (^_Nullable)())failure;
+
+- (void)socialLike:(NSString *_Nullable)socialId
+           success:(void (^_Nullable)(NSString * _Nullable socialId, int currentLikes))success
+           failure:(void (^_Nullable)())failure;
+
+- (void)socialLikeList:(NSString *_Nullable)socialId
+               success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
+               failure:(void (^_Nullable)())failure;
+
+- (void)socialComment:(NSString *_Nullable)socialId
+              replyId:(NSString *_Nullable)replyId
+              comment:(NSString *_Nullable)comment
+              success:(void (^_Nullable)(SocialCommentData * _Nullable commentData, int commentCount))success
+              failure:(void (^_Nullable)())failure;
+
+- (void)socialCommentList:(NSString *_Nullable)socialId
+                   lastId:(NSString *_Nullable)lastId
+                  success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
+                  failure:(void (^_Nullable)())failure;
+
+
+
+- (void)tradePublish:(NSString *_Nullable)msg
+              picArr:(NSMutableArray *_Nullable)picArr
+                type:(int)type
+            priority:(int)priority
+             success:(void (^_Nullable)())success
+             failure:(void (^_Nullable)())failure;
+
+- (void)tradeEdit:(NSString *_Nullable)tradeId
+              msg:(NSString *_Nullable)msg
+           picArr:(NSMutableArray *_Nullable)picArr
+         priority:(int)priority
+          success:(void (^_Nullable)())success
+          failure:(void (^_Nullable)())failure;
+
+- (void)tradeDelete:(NSString *_Nullable)tradeId
+            success:(void (^_Nullable)())success
+            failure:(void (^_Nullable)())failure;
+
+- (void)tradeList:(TradeSort)tradeSort
+             page:(int)page
+          success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
+          failure:(void (^_Nullable)())failure;
+
+- (void)tradeFollow:(NSString *_Nullable)tradeId
+            success:(void (^_Nullable)())success
+            failure:(void (^_Nullable)())failure;
+
+- (void)tradeDeleteFollow:(NSString *_Nullable)tradeId
+                  success:(void (^_Nullable)())success
+                  failure:(void (^_Nullable)())failure;
+
+@end

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

@@ -0,0 +1,506 @@
+//
+//  HttpRequest.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/21.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "HttpRequest.h"
+#import "AFHTTPSessionManager.h"
+#import "UIAlertView+NTESBlock.h"
+#import "User.h"
+
+
+@interface HttpRequest()
+
+@property (nonatomic, strong) NSString *urlRoot;
+@property (nonatomic, strong) NSString *urlSocialDataList;
+@property (nonatomic, strong) NSString *urlSocialLike;
+@property (nonatomic, strong) NSString *urlSocialLikeList;
+@property (nonatomic, strong) NSString *urlSocialComment;
+@property (nonatomic, strong) NSString *urlSocialCommentList;
+
+@property (nonatomic, strong) NSString *urlTradePublish;
+@property (nonatomic, strong) NSString *urlTradeEdit;
+@property (nonatomic, strong) NSString *urlTradeDelete;
+@property (nonatomic, strong) NSString *urlTradeDataList;
+@property (nonatomic, strong) NSString *urlTradeFollow;
+@property (nonatomic, strong) NSString *urlTradeDeleteFollow;
+
+
+@end
+
+@implementation HttpRequest
+
++ (instancetype)shared
+{
+    static HttpRequest *shared = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        shared = [[HttpRequest alloc] init];
+    });
+    return shared;
+}
+
+
+- (instancetype)init{
+    self = [super init];
+    if(self)
+    {
+        self.urlRoot = @"http://whosay.dashgame.com/";
+        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"];
+        self.urlSocialComment = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment"];
+        self.urlSocialCommentList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment_list"];
+        
+        self.urlTradePublish = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=publish"];
+        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.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"];
+    }
+    return self;
+}
+
+
+
+- (void)request:(NSString *)URLString
+                   parameters:(id)parameters
+                     progress:(void (^)(NSProgress * _Nonnull))uploadProgress
+                      success:(void (^)(id _Nullable))success
+                      failure:(void (^)())failure
+{
+    //请求的managers
+    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
+    //manager.responseSerializer = [AFJSONResponseSerializer new];
+    //manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
+    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
+    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/html", nil];
+    
+    //请求的方式:POST
+    
+    NSLog(@"请求地址 %@", URLString);
+    NSLog(@"请求参数 %@", parameters);
+    
+    [manager POST:URLString parameters:parameters progress:uploadProgress success:^(NSURLSessionDataTask *task, id responseObject) {
+        
+        NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+        NSLog(@"请求成功,服务器返回的信息%@", string);
+        
+        NSError* error = nil;
+        NSData *strData = [string dataUsingEncoding:NSASCIIStringEncoding];
+        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:strData
+                                                        options:NSJSONReadingAllowFragments
+                                                          error:&error];
+        
+        NSString *errorInfo = nil;
+        
+        if (dic != nil && error == nil){
+            int code = [[dic valueForKey:@"c"] intValue];
+            if(code == 0)
+            {
+                NSDictionary *data = (NSDictionary *)[dic objectForKey:@"d"];
+                if(success)
+                    success(data);
+            }
+            else
+            {
+                errorInfo = [dic objectForKey:@"d"];
+            }
+        }else{
+            errorInfo = error.description;
+        }
+        
+        if(errorInfo)
+        {
+            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:errorInfo delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+            [alert showAlertWithCompletionHandler:^(NSInteger index) {
+                if(failure)
+                    failure();
+            }];
+        }
+        
+    } failure:^(NSURLSessionDataTask *task, NSError * error) {
+        NSLog(@"请求失败,服务器返回的错误信息%@", error);
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:error.description delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+        [alert showAlertWithCompletionHandler:^(NSInteger index) {
+            if(failure)
+                failure();
+        }];
+    }];
+    
+}
+
+
+
+
+
+- (void)getSocialDataList:(NSString *)lastId
+                  success:(void (^_Nullable)(NSMutableArray *dataList))success
+                  failure:(void (^_Nullable)())failure{
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    lastId = lastId ? lastId : @"";
+    NSDictionary *parameters = @{@"user_id":userId, @"last_id":lastId};
+    
+    [self request:_urlSocialDataList 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];
+            SocialItemData *data = [[SocialItemData alloc] init];
+            [data setData:json];
+            [list addObject:data];
+            
+            
+            [userIds addObjectsFromArray:data.likeArr];
+            
+            for(int j=0; j<data.commentArr.count; j++)
+            {
+                SocialCommentData *commentData = [data.commentArr objectAtIndex:j];
+                [userIds addObject:commentData.userId];
+                [userIds addObject:commentData.replyId];
+            }
+        }
+        
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:userIds completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(list);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+- (void)socialLike:(NSString *)socialId
+           success:(void (^_Nullable)(NSString *socialId, int currentLikes))success
+           failure:(void (^_Nullable)())failure{
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    NSDictionary *parameters = @{@"user_id":userId, @"social_id":socialId};
+    
+    [self request:_urlSocialLike parameters:parameters progress:nil success:^(id jsonData) {
+        
+        NSString *sid = [jsonData objectForKey:@"social_id"];
+        int likes = [[jsonData objectForKey:@"likes"] intValue];
+        
+        if(success)
+            success(sid, likes);
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+
+- (void)socialLikeList:(NSString *)socialId
+                  success:(void (^_Nullable)(NSMutableArray *dataList))success
+                  failure:(void (^_Nullable)())failure{
+    
+    NSDictionary *parameters = @{@"social_id":socialId};
+    
+    [self request:_urlSocialLikeList parameters:parameters progress:nil success:^(id jsonData) {
+        
+        NSMutableArray *jsonList = [jsonData objectForKey:@"list"];
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:jsonList completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(jsonList);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+
+- (void)socialComment:(NSString *)socialId
+              replyId:(NSString *)replyId
+              comment:(NSString *)comment
+           success:(void (^_Nullable)(SocialCommentData *commentData, int commentCount))success
+           failure:(void (^_Nullable)())failure{
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    replyId = replyId ? replyId : @"";
+    
+    if(!comment || [comment isEqualToString:@""])
+    {
+        if(failure)
+            failure();
+        return;
+    }
+    
+    NSDictionary *parameters = @{@"user_id":userId, @"social_id":socialId, @"reply_id":replyId, @"comment":comment};
+    
+    [self request:_urlSocialComment parameters:parameters progress:nil success:^(id jsonData) {
+        
+        SocialCommentData *commentData = [[SocialCommentData alloc] init];
+        [commentData setData:jsonData];
+        int commentCount = [[jsonData objectForKey:@"comment_count"] intValue];
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:@[commentData.userId, commentData.replyId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(commentData, commentCount);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+
+- (void)socialCommentList:(NSString *)socialId
+                   lastId:(NSString *)lastId
+                  success:(void (^_Nullable)(NSMutableArray *dataList))success
+                  failure:(void (^_Nullable)())failure{
+
+    lastId = lastId ? lastId : @"";
+    NSDictionary *parameters = @{@"social_id":socialId, @"last_id":lastId};
+    
+    [self request:_urlSocialCommentList 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];
+            SocialCommentData *data = [[SocialCommentData alloc] init];
+            [data setData:json];
+            [list addObject:data];
+            
+            [userIds addObject:data.userId];
+            [userIds addObject:data.replyId];
+        }
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:userIds completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(list);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+
+}
+
+
+
+
+
+
+
+- (void)tradePublish:(NSString *)msg
+              picArr:(NSMutableArray *)picArr
+                type:(int)type
+            priority:(int)priority
+             success:(void (^_Nullable)())success
+             failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    NSString *roomId = user.currentChatRoomId ? user.currentChatRoomId : @"";
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:userId forKey:@"user_id"];
+    [parameters setValue:[NSString stringWithFormat:@"%d", type] forKey:@"type"];
+    [parameters setValue:msg forKey:@"msg"];
+    [parameters setValue:picArr forKey:@"pic"];
+    [parameters setValue:[NSString stringWithFormat:@"%d", priority] forKey:@"priority"];
+    [parameters setObject:roomId forKey:@"room_id"];
+    
+    [self request:_urlTradePublish parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+    
+}
+
+- (void)tradeEdit:(NSString *)tradeId
+              msg:(NSString *)msg
+           picArr:(NSMutableArray *)picArr
+         priority:(int)priority
+          success:(void (^_Nullable)())success
+          failure:(void (^_Nullable)())failure{
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:tradeId forKey:@"id"];
+    if(msg)
+        [parameters setValue:msg forKey:@"msg"];
+    if(picArr)
+        [parameters setValue:picArr forKey:@"pic"];
+    if(priority)
+        [parameters setValue:[NSString stringWithFormat:@"%d", priority] forKey:@"priority"];
+    
+    [self request:_urlTradeEdit parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+    
+}
+
+
+- (void)tradeDelete:(NSString *)tradeId
+             success:(void (^_Nullable)())success
+             failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:userId forKey:@"user_id"];
+    [parameters setValue:tradeId forKey:@"trade_id"];
+    
+    [self request:_urlTradeDelete parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+    
+}
+
+
+- (void)tradeList:(TradeSort)tradeSort
+             page:(int)page
+          success:(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:[NSString stringWithFormat:@"%ld", (long)tradeSort] forKey:@"sort"];
+    [parameters setValue:[NSString stringWithFormat:@"%d", page] forKey:@"page"];
+    [parameters setValue:province forKey:@"province"];
+    [parameters setValue:userId forKey:@"user_id"];
+    
+    
+    [self request:_urlTradeDataList 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(list);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+
+
+- (void)tradeFollow:(NSString *)tradeId
+            success:(void (^_Nullable)())success
+            failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:userId forKey:@"user_id"];
+    [parameters setValue:tradeId forKey:@"trade_id"];
+    
+    [self request:_urlTradeFollow parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+    
+}
+
+
+- (void)tradeDeleteFollow:(NSString *)tradeId
+            success:(void (^_Nullable)())success
+            failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:userId forKey:@"user_id"];
+    [parameters setValue:tradeId forKey:@"trade_id"];
+    
+    [self request:_urlTradeDeleteFollow parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+    
+}
+
+
+@end

+ 15 - 0
NIMDemo/NIMDemo/ImagePagerViewController.h

@@ -0,0 +1,15 @@
+//
+//  ImagePagerViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ImagePagerViewController : UIViewController
+
+- (void)setImages:(NSArray *)images thumbs:(NSArray *)thumbs startIndex:(int)startIndex;
+
+@end

+ 114 - 0
NIMDemo/NIMDemo/ImagePagerViewController.m

@@ -0,0 +1,114 @@
+//
+//  ImagePagerViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ImagePagerViewController.h"
+#import "NIMPageView.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+
+@interface ImagePagerViewController ()<NIMPageViewDataSource,NIMPageViewDelegate>
+
+@property (nonatomic, strong) NSArray                   *images;
+@property (nonatomic, strong) NSArray                   *thumbs;
+@property (nonatomic, assign) int                       currentIndex;
+
+@property (nonatomic, strong) NIMPageView               *pageView;
+@property (nonatomic, strong) UIPageControl             *pageControl;
+
+@end
+
+@implementation ImagePagerViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    //self.navigationController.navigationBar.translucent = NO;
+    
+    self.view.backgroundColor = UIColor.blackColor;
+    
+    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
+        self.edgesForExtendedLayout = UIRectEdgeNone;
+    
+    
+    float startY = [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height;
+    
+    UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-startY)];
+    [self.view addSubview:container];
+    
+    _pageView                  = [[NIMPageView alloc] initWithFrame:CGRectMake(0, 0, container.width, container.height)];
+    _pageView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+    _pageView.dataSource       = self;
+    _pageView.pageViewDelegate = self;
+    [container addSubview:_pageView];
+    
+    
+    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, container.bottom - 30, container.width, 30)];
+    _pageControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+    _pageControl.pageIndicatorTintColor = [UIColor grayColor];
+    _pageControl.currentPageIndicatorTintColor = [UIColor lightGrayColor];
+    _pageControl.hidesForSinglePage = YES;
+    [_pageControl setUserInteractionEnabled:NO];
+    [self.view addSubview:_pageControl];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    [self.pageView scrollToPage:self.currentIndex];
+}
+
+- (NSInteger)numberOfPages: (NIMPageView *)pageView
+{
+    return _images.count;
+}
+
+- (UIView *)pageView:(NIMPageView *)pageView viewInPage:(NSInteger)index
+{
+    UIView *subView = [[UIView alloc] init];
+    
+    NSString *imagePath = [_images objectAtIndex:index];
+    NSString *thumbPath = [_thumbs objectAtIndex:index];
+    NSURL *imageUrl = [NSURL URLWithString:imagePath];
+    NSURL *thumbUrl = [NSURL URLWithString:thumbPath];
+    
+    UIImageView *thumbView = [[UIImageView alloc] initWithFrame:CGRectMake(_pageView.width/2 - 64, _pageView.height/2 - 64, 128, 128)];
+    [thumbView sd_setImageWithURL:thumbUrl];
+    [subView addSubview:thumbView];
+    
+    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _pageView.width, _pageView.height)];
+    [imgView sd_setImageWithURL:imageUrl];
+    imgView.contentMode =  UIViewContentModeScaleAspectFit;
+    [subView addSubview:imgView];
+    
+    return subView;
+}
+
+- (void)pageViewScrollEnd: (NIMPageView *)pageView
+             currentIndex: (NSInteger)index
+               totolPages: (NSInteger)pages{
+    
+    self.pageControl.numberOfPages = pages;
+    self.pageControl.currentPage = index;
+}
+
+
+- (void)setImages:(NSArray *)images thumbs:(NSArray *)thumbs startIndex:(int)startIndex{
+    
+    self.images = images;
+    self.thumbs = thumbs;
+    self.currentIndex = startIndex;
+
+}
+
+@end

+ 17 - 0
NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.h

@@ -0,0 +1,17 @@
+//
+//  MyTradeTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "TradeData.h"
+
+@interface MyTradeTableViewCell : UITableViewCell
+
+- (void)initWidth:(CGFloat)cellWidth;
+- (void)setData:(TradeData *)data tradeSort:(TradeSort)tradeSort;
+
+@end

+ 292 - 0
NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m

@@ -0,0 +1,292 @@
+//
+//  MyTradeTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/4.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "MyTradeTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "UIView+Toast.h"
+#import "UIImageView+WebCache.h"
+#import "User.h"
+#import "ImagePagerViewController.h"
+#import "HttpRequest.h"
+
+@interface MyTradeTableViewCell() <UITextViewDelegate>
+
+@property (nonatomic, strong) NIMAvatarImageView            *avatarView;
+@property (nonatomic, strong) UITextView                    *nickTextView;
+@property (nonatomic, strong) UILabel                       *timeLabel;
+@property (nonatomic, strong) UIView                        *followContainer;
+@property (nonatomic, strong) UILabel                       *followLabel;
+@property (nonatomic, strong) UITextView                    *msgTextView;
+@property (nonatomic, strong) UIView                        *imgContainer;
+@property (nonatomic, strong) UIView                        *actionContainer;
+@property (nonatomic, strong) UIButton                      *priorityBtn;
+@property (nonatomic, strong) UILabel                       *followCountLabel;
+
+@property (nonatomic, strong) TradeData                     *data;
+
+@end
+
+@implementation MyTradeTableViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    
+    float padding = 10;
+    
+    //avatar
+    _avatarView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(padding, padding, 40, 40)];
+    [_avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    [self.contentView addSubview:_avatarView];
+    
+    //nick name
+    _nickTextView = [[UITextView alloc] initWithFrame:CGRectMake(_avatarView.right + 5, padding, 200, 25)];
+    _nickTextView.backgroundColor = UIColor.clearColor;
+    _nickTextView.scrollEnabled = NO;
+    _nickTextView.editable = NO;
+    _nickTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    _nickTextView.delegate = self;
+    _nickTextView.textAlignment = NSTextAlignmentLeft;
+    [self.contentView addSubview:_nickTextView];
+    
+    //time
+    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nickTextView.left + 5, _nickTextView.bottom, 200, 15)];
+    _timeLabel.font = [UIFont systemFontOfSize:14];
+    _timeLabel.textColor = UIColor.lightGrayColor;
+    [self.contentView addSubview:_timeLabel];
+    
+    
+    _followContainer = [[UIView alloc] initWithFrame:CGRectMake(cellWidth-padding-40, padding, 50, 40)];
+    [_followContainer addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchFollow:)]];
+    [self.contentView addSubview:_followContainer];
+    
+    UIImageView *followIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 20, 20)];
+    [followIcon setImage:[UIImage imageNamed:@"交易帖_03"]];
+    [_followContainer addSubview:followIcon];
+    
+    _followLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, _followContainer.width, 20)];
+    _followLabel.font = [UIFont systemFontOfSize:13];
+    _followLabel.textColor = UIColor.lightGrayColor;
+    _followLabel.textAlignment = NSTextAlignmentCenter;
+    [_followContainer addSubview:_followLabel];
+    
+    
+    //message
+    _msgTextView = [[UITextView alloc] initWithFrame:CGRectMake(padding, _avatarView.bottom+5, cellWidth - padding * 2, 0)];
+    _msgTextView.font = [UIFont systemFontOfSize:15];
+    _msgTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    [self.contentView addSubview:_msgTextView];
+    
+    //image container
+    _imgContainer = [[UIView alloc] initWithFrame:CGRectMake(padding, _msgTextView.bottom, cellWidth - padding * 2, 0)];
+    _imgContainer.backgroundColor = UIColor.whiteColor;
+    [_imgContainer setClipsToBounds:YES];
+    [self.contentView addSubview:_imgContainer];
+    
+    //action buttons
+    _actionContainer = [[UIView alloc] initWithFrame:CGRectMake(0, _imgContainer.bottom, cellWidth, 40)];
+    [self.contentView addSubview:_actionContainer];
+    
+    _priorityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _priorityBtn.frame = CGRectMake(padding, 8, 80, 24);
+    _priorityBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    _priorityBtn.layer.cornerRadius = 12;
+    _priorityBtn.layer.borderWidth = 1;
+    _priorityBtn.layer.borderColor = UIColor.lightGrayColor.CGColor;
+    [_priorityBtn setTitleColor:User.greenColor forState:UIControlStateNormal];
+    [_actionContainer addSubview:_priorityBtn];
+    
+    _followCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(cellWidth-90, 8, 80, 24)];
+    _followCountLabel.textColor = UIColor.lightGrayColor;
+    _followCountLabel.font = [UIFont systemFontOfSize:15];
+    _followCountLabel.textAlignment = NSTextAlignmentRight;
+    [_actionContainer addSubview:_followCountLabel];
+    
+    UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, 39, cellWidth, 0.5)];
+    step.backgroundColor = UIColor.lightGrayColor;
+    [_actionContainer addSubview:step];
+}
+
+
+- (void)setData:(TradeData *)data tradeSort:(TradeSort)tradeSort{
+    
+    _data = data;
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:data.userId];
+    if(user)
+    {
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        _avatarView.tag = [data.userId intValue];
+        
+        
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : data.userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        _nickTextView.attributedText = appendString;
+    }
+    
+    
+    
+    [self updateFollow];
+    
+    
+    
+    _timeLabel.text = data.time;
+    _msgTextView.text = data.msg;
+    
+    _msgTextView.height = _msgTextView.contentSize.height;
+    
+    _imgContainer.top = _msgTextView.bottom + 5;
+    float imgPadding = 2;
+    float imgSize = (_imgContainer.width - imgPadding * 2) / 3;
+    float imgContainerHeight = 0;
+    int i=0;
+    for(i=0; i<data.thumbArr.count; i++)
+    {
+        float startX = (i % 3) * (imgSize + imgPadding);
+        float startY = (i / 3) * (imgSize + imgPadding);
+        imgContainerHeight = startY + imgSize;
+        UIImageView *img = nil;
+        
+        if(i >= _imgContainer.subviews.count)
+        {
+            img = [[UIImageView alloc] init];
+            img.userInteractionEnabled = true;
+            [_imgContainer addSubview:img];
+        }
+        else
+        {
+            img = [_imgContainer.subviews objectAtIndex:i];
+        }
+        
+        img.frame = CGRectMake(startX, startY, imgSize, imgSize);
+        [img setHidden:NO];
+        
+        NSString *path = [data.thumbArr objectAtIndex:i];
+        NSURL *url = [NSURL URLWithString:path];
+        [img sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"聊天-_17"]];
+        img.tag = i;
+        
+        [img addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchImage:)]];
+    }
+    
+    for(int j=i; j<_imgContainer.subviews.count; j++)
+    {
+        [[_imgContainer.subviews objectAtIndex:j] setHidden:YES];
+    }
+    
+    _imgContainer.height = imgContainerHeight;
+    _actionContainer.top = _imgContainer.bottom;
+    
+    [_priorityBtn setTitle:[NSString stringWithFormat:@"置顶%d", data.priority] forState:UIControlStateNormal];
+    [_priorityBtn sizeToFit];
+    _priorityBtn.width = _priorityBtn.width + 12;
+    _priorityBtn.height = 24;
+    [_priorityBtn setHidden: tradeSort == TradeSortMyPublished ? NO : YES];
+    
+    _followCountLabel.text = [NSString stringWithFormat:@"关注%d", data.followCount];
+    [_followCountLabel setHidden: tradeSort == TradeSortMyPublished ? NO : YES];
+    
+    data.cellHeight = _actionContainer.bottom;
+    
+    [self setNeedsLayout];
+    
+}
+
+
+- (void)onTouchFollow:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    if(_data.followed)
+    {
+        [[HttpRequest shared] tradeDeleteFollow:_data.tradeId success:^{
+            [self makeToast:@"取消关注成功"];
+            _data.followed = NO;
+            [self updateFollow];
+        } failure:^{
+            [self makeToast:@"取消关注失败"];
+        }];
+    }
+    else
+    {
+        [[HttpRequest shared] tradeFollow:_data.tradeId success:^{
+            [self makeToast:@"关注成功"];
+            _data.followed = YES;
+            [self updateFollow];
+        } failure:^{
+            [self makeToast:@"关注失败"];
+        }];
+    }
+}
+
+- (void)updateFollow{
+    
+    if(_data.followed)
+    {
+        _followLabel.text = @"已关注";
+    }
+    else
+    {
+        _followLabel.text = @"关注";
+    }
+    
+}
+
+- (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    [User showUserInfo:[NSString stringWithFormat:@"%ld", (long)viewClicked.tag]];
+    
+}
+
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
+{
+    [User showUserInfo:url.absoluteString];
+    return NO;
+}
+
+- (void)onTouchImage:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    
+    NSLog(@"show image %ld", (long)viewClicked.tag);
+    
+    ImagePagerViewController *imagePageVC = [[ImagePagerViewController alloc] init];
+    [imagePageVC setImages:_data.picArr thumbs:_data.thumbArr startIndex:(int)viewClicked.tag];
+    
+    [self.viewController.navigationController pushViewController:imagePageVC animated:YES];
+}
+
+
+
+- (void)layoutSubviews
+{
+    [super layoutSubviews];
+    float padding = 10;
+    _msgTextView.width = self.contentView.width - padding * 2;
+    _followContainer.right = self.contentView.width - padding;
+    _followCountLabel.right = self.contentView.width - padding;
+    _imgContainer.width = self.contentView.width - padding * 2;
+    
+}
+
+
+
+@end

+ 15 - 0
NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.h

@@ -0,0 +1,15 @@
+//
+//  MyTradeViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface MyTradeViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
+
+@property (nonatomic, strong) UITableView       *tableView;
+
+@end

+ 358 - 0
NIMDemo/NIMDemo/SectionTrade/MyTradeViewController.m

@@ -0,0 +1,358 @@
+//
+//  MyTradeViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "MyTradeViewController.h"
+#import "UIView+NTES.h"
+#import "TradeData.h"
+#import "MyTradeTableViewCell.h"
+#import "HttpRequest.h"
+#import "UIActionSheet+NTESBlock.h"
+#import "User.h"
+
+@interface MyTradeViewController ()<UIScrollViewDelegate>
+
+@property (nonatomic, strong) UIButton                  *editBtn;
+
+@property (nonatomic, strong) UIButton                  *myPublishBtn;
+@property (nonatomic, strong) UIView                    *myPublishBg;
+@property (nonatomic, strong) UIButton                  *myFollowBtn;
+@property (nonatomic, strong) UIView                    *myFollowBg;
+
+@property (nonatomic, strong) NSMutableArray            *publishDataList;
+@property (nonatomic, strong) NSMutableArray            *followDataList;
+@property (nonatomic, assign) BOOL                      isFetching;
+@property (nonatomic, assign) BOOL                      flagRefresh;
+@property (nonatomic, assign) TradeSort                 tradeSort;
+@property (nonatomic, assign) int                       publishPage;
+@property (nonatomic, assign) int                       followPage;
+
+@end
+
+@implementation MyTradeViewController
+
+- (void)viewDidLoad{
+    [super viewDidLoad];
+    
+    self.view.backgroundColor = UIColor.whiteColor;
+    
+    float startY = [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height;
+    
+    UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, startY+39.5, self.view.width, 0.5)];
+    step.backgroundColor = UIColor.lightGrayColor;
+    [self.view addSubview:step];
+    
+    _myPublishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _myPublishBtn.frame = CGRectMake(0, startY, self.view.width/2, 40);
+    [_myPublishBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
+    [_myPublishBtn setTitle:@"我的发布" forState:UIControlStateNormal];
+    [_myPublishBtn addTarget:self action:@selector(onTouchPublish:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:_myPublishBtn];
+    
+    _myPublishBg = [[UIView alloc] initWithFrame:CGRectMake(0, startY+38, 60, 2)];
+    _myPublishBg.centerX = self.view.width / 4;
+    _myPublishBg.backgroundColor = User.orangeColor;
+    [self.view addSubview:_myPublishBg];
+    
+    
+    
+    _myFollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _myFollowBtn.frame = CGRectMake(self.view.width/2, startY, self.view.width/2, 40);
+    [_myFollowBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
+    [_myFollowBtn setTitle:@"我的关注" forState:UIControlStateNormal];
+    [_myFollowBtn addTarget:self action:@selector(onTouchFollow:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:_myFollowBtn];
+    
+    _myFollowBg = [[UIView alloc] initWithFrame:CGRectMake(0, startY+38, 60, 2)];
+    _myFollowBg.centerX = self.view.width * 3 / 4;
+    _myFollowBg.backgroundColor = User.orangeColor;
+    [self.view addSubview:_myPublishBg];
+    
+    
+    
+    [self setTradeSort:TradeSortMyPublished];
+}
+
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    UINavigationItem *navItem = self.navigationItem;
+    
+    navItem.title = @"我的供需";
+    
+    _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_editBtn setTitle:@"编辑" forState:UIControlStateNormal];
+    [_editBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [_editBtn addTarget:self action:@selector(onTouchEdit:) forControlEvents:UIControlEventTouchUpInside];
+    [_editBtn sizeToFit];
+    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:_editBtn];
+    
+    [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 + 40;
+        float tabbarHeight = self.tabBarController.tabBar.frame.size.height;
+        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, startY, self.view.width, self.view.height-tabbarHeight-40) style:UITableViewStylePlain];
+        _tableView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
+        _tableView.backgroundColor  = [UIColor clearColor];
+        _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+        _tableView.dataSource = self;
+        _tableView.delegate   = self;
+        [self.view addSubview:_tableView];
+    }
+    return _tableView;
+}
+
+
+- (void)onTouchEdit:(int)sender{
+    NSLog(@"onTouchSearch");
+    
+    if(self.tableView.editing)
+    {
+        [self.tableView setEditing:NO animated:YES];
+        [_editBtn setTitle:@"编辑" forState:UIControlStateNormal];
+    }
+    else
+    {
+        [self.tableView setEditing:YES animated:YES];
+        [_editBtn setTitle:@"完成" forState:UIControlStateNormal];
+    }
+}
+
+
+
+
+
+- (void)onTouchPublish:(id)sender{
+    [self setTradeSort:TradeSortMyPublished];
+}
+
+- (void)onTouchFollow:(id)sender{
+    [self setTradeSort:TradeSortMyFollowed];
+}
+
+
+- (void)setTradeSort:(TradeSort)tradeSort{
+    
+    TradeSort oldSort = _tradeSort;
+    
+    _tradeSort = tradeSort;
+    
+    if(tradeSort == TradeSortMyPublished)
+    {
+        [_myPublishBtn setTitleColor:User.orangeColor forState:UIControlStateNormal];
+        [_myPublishBg setHidden:NO];
+        
+        [_myFollowBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
+        [_myFollowBg setHidden:YES];
+    }
+    else if(tradeSort == TradeSortMyFollowed)
+    {
+        [_myPublishBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
+        [_myPublishBg setHidden:YES];
+        
+        [_myFollowBtn setTitleColor:User.orangeColor forState:UIControlStateNormal];
+        [_myFollowBg setHidden:NO];
+    }
+    
+    if(oldSort != tradeSort)
+    {
+        [self reset];
+        [self fetchDataList];
+    }
+}
+
+- (void)reset{
+    
+    _publishPage = _followPage = 1;
+    _publishDataList = nil;
+    _followDataList = nil;
+    
+}
+
+- (void)fetchDataList{
+    
+    if(_isFetching)
+        return;
+    
+    _isFetching = YES;
+    
+    int page = 1;
+    TradeSort sort = _tradeSort;
+    
+    if(sort == TradeSortMyPublished)
+        page = _publishPage = MAX(1, _publishPage);
+    else if(sort == TradeSortMyFollowed)
+        page = _followPage = MAX(1, _followPage);
+    
+    [[HttpRequest shared] tradeList:sort page:page success:^(NSMutableArray * _Nullable dataList) {
+        
+        if(sort == TradeSortMyPublished)
+        {
+            if(!self.publishDataList)
+                self.publishDataList = dataList;
+            else
+                [self.publishDataList addObjectsFromArray:dataList];
+            
+            [self.tableView reloadData];
+            
+            if(dataList.count > 0)
+                _publishPage++;
+        }
+        else if(sort == TradeSortMyFollowed)
+        {
+            if(!self.followDataList)
+                self.followDataList = dataList;
+            else
+                [self.followDataList addObjectsFromArray:dataList];
+            
+            [self.tableView reloadData];
+            
+            if(dataList.count > 0)
+                _followPage++;
+        }
+
+        _isFetching = NO;
+    } failure:^{
+        _isFetching = NO;
+    }];
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(_tradeSort == TradeSortMyPublished)
+    {
+        if(_publishDataList)
+            return _publishDataList.count;
+    }
+    else if(_tradeSort == TradeSortMyFollowed)
+    {
+        if(_followDataList)
+            return _followDataList.count;
+    }
+    return 0;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSMutableArray *dataList = _tradeSort == TradeSortMyFollowed ? _followDataList : _publishDataList;
+    
+    NSObject *dataObj = [dataList objectAtIndex:indexPath.row];
+    
+    UITableViewCell *baseCell = nil;
+    
+    NSString *cellId = @"trade";
+    MyTradeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+    
+    if(!cell)
+    {
+        cell = [[MyTradeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+        [cell initWidth:self.view.frame.size.width];
+    }
+    
+    [cell setData:(TradeData *)dataObj tradeSort:_tradeSort];
+    baseCell = cell;
+    
+    return baseCell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSMutableArray *dataList = _tradeSort == TradeSortMyFollowed ? _followDataList : _publishDataList;
+    
+    NSObject *dataObj = [dataList objectAtIndex:indexPath.row];
+    
+    if([dataObj isKindOfClass:[TradeData class]])
+    {
+        TradeData *tradeData = (TradeData *)dataObj;
+        return tradeData.cellHeight;
+    }
+    
+    return 30;
+}
+
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    if(tableView.editing)
+        return YES;
+    return NO;
+}
+
+- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    return UITableViewCellEditingStyleDelete;
+}
+
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    if (editingStyle == UITableViewCellEditingStyleDelete) {
+        // 1. 更新数据
+        if(_tradeSort == TradeSortMyPublished)
+            [_publishDataList removeObjectAtIndex:indexPath.row];
+        else if(_tradeSort == TradeSortMyFollowed)
+            [_followDataList removeObjectAtIndex:indexPath.row];
+        
+        NSLog(@"commitEditingStyle %ld", (long)indexPath.row);
+        
+        // 2. 更新UI
+        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
+    }
+    
+}
+
+
+
+
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
+    //康海涛测试Ok的
+    CGPoint offset1 = scrollView.contentOffset;
+    CGRect bounds1 = scrollView.bounds;
+    CGSize size1 = scrollView.contentSize;
+    UIEdgeInsets inset1 = scrollView.contentInset;
+    float y1 = offset1.y + bounds1.size.height - inset1.bottom;
+    float h1 = size1.height;
+    
+    //NSLog(@"%f %f %i %f", y1, h1, _flagRefresh, bounds1.size.height);
+    
+    if(h1 < bounds1.size.height)
+        return;
+    
+    if (y1 > h1 + 50) {
+        _flagRefresh = YES;
+    }
+    else if (y1 == h1) {
+        if(_flagRefresh)
+        {
+            _flagRefresh = NO;
+            NSLog(@"下拉刷新");
+            [self fetchDataList];
+        }
+    }
+    
+}
+
+
+@end

+ 46 - 0
NIMDemo/NIMDemo/SectionTrade/TradeData.h

@@ -0,0 +1,46 @@
+//
+//  TradeData.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/1.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+typedef NS_ENUM(NSInteger, TradeType) {
+    TradeTypeNone = 0,
+    TradeTypeSupply = 1,
+    TradeTypeDemand = 2
+};
+
+typedef NS_ENUM(NSInteger, TradeSort) {
+    TradeSortNone = 0,
+    TradeSortSupply = 1,
+    TradeSortDemand = 2,
+    TradeSortRecent = 3,
+    TradeSortMyPublished = 4,
+    TradeSortMyFollowed = 5
+};
+
+@interface TradeData : NSObject
+
+@property (nonatomic, strong) NSString              *tradeId;
+@property (nonatomic, strong) NSString              *userId;
+@property (nonatomic, assign) int                   type;
+@property (nonatomic, strong) NSString              *province;
+@property (nonatomic, strong) NSString              *city;
+@property (nonatomic, strong) NSString              *district;
+@property (nonatomic, strong) NSString              *msg;
+@property (nonatomic, strong) NSMutableArray        *picArr;
+@property (nonatomic, strong) NSMutableArray        *thumbArr;
+@property (nonatomic, assign) int                   priority;
+@property (nonatomic, strong) NSString              *time;
+@property (nonatomic, assign) BOOL                  followed;
+@property (nonatomic, assign) int                   followCount;
+
+@property (nonatomic, assign) float                 cellHeight;
+
+- (void)setData:(NSDictionary *)data;
+
+@end

+ 30 - 0
NIMDemo/NIMDemo/SectionTrade/TradeData.m

@@ -0,0 +1,30 @@
+//
+//  TradeData.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/1.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradeData.h"
+
+@implementation TradeData
+
+- (void)setData:(NSDictionary *)data{
+    _tradeId = [data objectForKey:@"id"];
+    _userId  = [data objectForKey:@"user_id"];
+    _type = [[data objectForKey:@"type"] intValue];
+    
+    _msg = [data objectForKey:@"msg"];
+    
+    _picArr = [data objectForKey:@"pics"];
+    _thumbArr = [data objectForKey:@"thumbs"];
+    
+    _priority = [[data objectForKey:@"priority"] intValue];
+    _time = [data objectForKey:@"inputtime"];
+    
+    _followed = [[data objectForKey:@"follow"] intValue] > 0 ? YES : NO;
+    _followCount = [[data objectForKey:@"follow_count"] intValue];
+}
+
+@end

+ 13 - 0
NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.h

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

+ 24 - 0
NIMDemo/NIMDemo/SectionTrade/TradePostTableViewCell.m

@@ -0,0 +1,24 @@
+//
+//  TradePostTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradePostTableViewCell.h"
+
+@implementation TradePostTableViewCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+@end

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

@@ -0,0 +1,21 @@
+//
+//  TradePublishManager.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/2.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "NIMInputView.h"
+
+@interface TradePublishManager : NSObject
+
+@property (nonatomic, weak) NIMInputView            * _Nullable inputView;
+
+- (void)tradePublish:(NSString *_Nullable)msg
+              picArr:(NSMutableArray *_Nullable)picArr
+            priority:(int)priority
+           tradeType:(int)tradeType;
+
+@end

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

@@ -0,0 +1,149 @@
+//
+//  TradePublishManager.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/2.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradePublishManager.h"
+#import "AFHTTPSessionManager.h"
+#import "User.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+#import "HttpRequest.h"
+
+@interface TradePublishManager()
+
+@property (nonatomic, strong) NSString              *msg;
+@property (nonatomic, strong) NSMutableArray        *picArr;
+@property (nonatomic, strong) NSMutableArray        *picDataArr;
+@property (nonatomic, assign) int                   uploadIndex;
+@property (nonatomic, assign) int                   priority;
+@property (nonatomic, assign) int                   tradeType;
+
+@end
+
+@implementation TradePublishManager
+
+- (void)tradePublish:(NSString *)msg
+              picArr:(NSMutableArray *)picArr
+            priority:(int)priority
+           tradeType:(int)tradeType{
+    
+    self.msg = msg;
+    self.picArr = picArr;
+    self.priority = priority;
+    self.tradeType = tradeType;
+    
+    self.picDataArr = [[NSMutableArray alloc] init];
+    self.uploadIndex = 0;
+    
+    [SVProgressHUD show];
+    
+    [self uploadPicture];
+}
+
+
+- (void)uploadPicture{
+    
+    if(_uploadIndex >= _picArr.count)
+    {
+        [self publish];
+        return;
+    }
+    
+    UIImage *image = [_picArr objectAtIndex:_uploadIndex];
+    NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    NSDictionary *dict = @{@"user_id":userId};
+    
+    NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=trade&a=upload";
+    
+    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
+    manager.responseSerializer = [AFJSONResponseSerializer serializer];
+    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/html", nil];
+    
+    [manager POST:urlString parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
+        
+        NSData *data = UIImageJPEGRepresentation(image, 1);
+        [formData appendPartWithFileData:data name:@"upload" fileName:[NSString stringWithFormat:@"image_%d.jpg", _uploadIndex] mimeType:@"image/jpg"];
+        
+    } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
+        
+        //NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+        //NSLog(@"请求成功,服务器返回的信息%@", string);
+        
+        NSLog(@"请求成功,服务器返回的信息%@", responseObject);
+        
+        int code = [[responseObject objectForKey:@"c"] intValue];
+        if(code == 0)
+        {
+            NSDictionary *data = [responseObject objectForKey:@"d"];
+            NSString *aid = [data objectForKey:@"aid"];
+            
+            if(_uploadIndex >= _picDataArr.count)
+            {
+                [_picDataArr addObject:aid];
+            }
+            else
+            {
+                [_picDataArr setObject:aid atIndexedSubscript:_uploadIndex];
+            }
+            
+            _uploadIndex++;
+            [self uploadPicture];
+        }
+        else{
+            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[responseObject objectForKey:@"d"] delegate:self cancelButtonTitle:@"放弃" otherButtonTitles:@"重试", nil];
+            [alert show];
+        }
+        
+    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
+        NSLog(@"请求失败,服务器返回的错误信息%@",error);
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"上传图片失败" delegate:self cancelButtonTitle:@"放弃" otherButtonTitles:@"重试", nil];
+        [alert show];
+    }];
+}
+
+- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
+    switch (buttonIndex) {
+//        case 0:
+//            [self.navigationController popViewControllerAnimated:YES];
+//            break;
+        case 1:
+            [self uploadPicture];
+            break;
+        default:
+            break;
+    }
+}
+
+- (void)publish{
+    
+    NSString *sendMsg = _msg ? _msg : @"";
+    
+    
+    [[HttpRequest shared] tradePublish:sendMsg picArr:_picDataArr type:_tradeType priority:_priority success:^{
+        
+        [SVProgressHUD dismiss];
+        if(_inputView)
+        {
+            [_inputView.superview makeToast:@"发布成功" duration:2.0 position:CSToastPositionCenter];
+            [_inputView endEditing:YES];
+            [_inputView unselectedTabBarItem];
+            [_inputView.giftContainer tradePublished];
+        }
+        
+    } failure:^{
+        
+        [SVProgressHUD dismiss];
+        if(_inputView)
+        {
+            [_inputView.superview makeToast:@"发布失败" duration:2.0 position:CSToastPositionCenter];
+        }
+    }];
+
+}
+
+
+@end

+ 17 - 0
NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.h

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

+ 266 - 0
NIMDemo/NIMDemo/SectionTrade/TradeTableViewCell.m

@@ -0,0 +1,266 @@
+//
+//  TradeTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/1.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradeTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "UIView+Toast.h"
+#import "UIImageView+WebCache.h"
+#import "User.h"
+#import "ImagePagerViewController.h"
+#import "HttpRequest.h"
+
+
+@interface TradeTableViewCell() <UITextViewDelegate>
+
+@property (nonatomic, strong) NIMAvatarImageView            *avatarView;
+@property (nonatomic, strong) UITextView                    *nickTextView;
+@property (nonatomic, strong) UILabel                       *timeLabel;
+@property (nonatomic, strong) UIView                        *followContainer;
+@property (nonatomic, strong) UILabel                       *followLabel;
+@property (nonatomic, strong) UITextView                    *msgTextView;
+@property (nonatomic, strong) UIView                        *imgContainer;
+@property (nonatomic, strong) UIView                        *actionContainer;
+@property (nonatomic, strong) UIButton                      *priorityBtn;
+
+
+@property (nonatomic, strong) TradeData                     *data;
+
+@end
+
+@implementation TradeTableViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+if(self)
+{
+    [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+}
+return self;
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    
+    float padding = 10;
+    
+    //avatar
+    _avatarView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(padding, padding, 40, 40)];
+    [_avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    [self addSubview:_avatarView];
+    
+    //nick name
+    _nickTextView = [[UITextView alloc] initWithFrame:CGRectMake(_avatarView.right + 5, padding, 200, 25)];
+    _nickTextView.backgroundColor = UIColor.clearColor;
+    _nickTextView.scrollEnabled = NO;
+    _nickTextView.editable = NO;
+    _nickTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    _nickTextView.delegate = self;
+    _nickTextView.textAlignment = NSTextAlignmentLeft;
+    [self addSubview:_nickTextView];
+    
+    //time
+    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nickTextView.left + 5, _nickTextView.bottom, 200, 15)];
+    _timeLabel.font = [UIFont systemFontOfSize:14];
+    _timeLabel.textColor = UIColor.lightGrayColor;
+    [self addSubview:_timeLabel];
+    
+    
+    _followContainer = [[UIView alloc] initWithFrame:CGRectMake(cellWidth-padding-40, padding, 50, 40)];
+    [_followContainer addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchFollow:)]];
+    [self addSubview:_followContainer];
+    
+    UIImageView *followIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 20, 20)];
+    [followIcon setImage:[UIImage imageNamed:@"交易帖_03"]];
+    [_followContainer addSubview:followIcon];
+    
+    _followLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, _followContainer.width, 20)];
+    _followLabel.font = [UIFont systemFontOfSize:13];
+    _followLabel.textColor = UIColor.lightGrayColor;
+    _followLabel.textAlignment = NSTextAlignmentCenter;
+    [_followContainer addSubview:_followLabel];
+    
+    
+    //message
+    _msgTextView = [[UITextView alloc] initWithFrame:CGRectMake(padding, _avatarView.bottom+5, cellWidth - padding * 2, 0)];
+    _msgTextView.font = [UIFont systemFontOfSize:15];
+    _msgTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    [self addSubview:_msgTextView];
+    
+    //image container
+    _imgContainer = [[UIView alloc] initWithFrame:CGRectMake(padding, _msgTextView.bottom, cellWidth - padding * 2, 0)];
+    [self addSubview:_imgContainer];
+    
+    //action buttons
+    _actionContainer = [[UIView alloc] initWithFrame:CGRectMake(0, _imgContainer.bottom, cellWidth, 40)];
+    [self addSubview:_actionContainer];
+    
+    _priorityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _priorityBtn.frame = CGRectMake(padding, 8, 80, 24);
+    _priorityBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    _priorityBtn.layer.cornerRadius = 12;
+    _priorityBtn.layer.borderWidth = 1;
+    _priorityBtn.layer.borderColor = UIColor.lightGrayColor.CGColor;
+    [_priorityBtn setTitleColor:User.greenColor forState:UIControlStateNormal];
+    [_actionContainer addSubview:_priorityBtn];
+    
+    UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, 39, cellWidth, 0.5)];
+    step.backgroundColor = UIColor.lightGrayColor;
+    [_actionContainer addSubview:step];
+}
+
+
+- (void)setData:(TradeData *)data{
+    
+    _data = data;
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:data.userId];
+    if(user)
+    {
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        _avatarView.tag = [data.userId intValue];
+        
+        
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : data.userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        _nickTextView.attributedText = appendString;
+    }
+    
+    [self updateFollow];
+    
+    
+    
+    _timeLabel.text = data.time;
+    _msgTextView.text = data.msg;
+    
+    _msgTextView.height = _msgTextView.contentSize.height;
+    
+    _imgContainer.top = _msgTextView.bottom + 5;
+    float imgPadding = 2;
+    float imgSize = (_imgContainer.width - imgPadding * 2) / 3;
+    float imgContainerHeight = 0;
+    int i=0;
+    for(i=0; i<data.thumbArr.count; i++)
+    {
+        float startX = (i % 3) * (imgSize + imgPadding);
+        float startY = (i / 3) * (imgSize + imgPadding);
+        imgContainerHeight = startY + imgSize;
+        UIImageView *img = nil;
+        
+        if(i >= _imgContainer.subviews.count)
+        {
+            img = [[UIImageView alloc] init];
+            img.userInteractionEnabled = YES;
+            [img addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchImage:)]];
+            [_imgContainer addSubview:img];
+        }
+        else
+        {
+            img = [_imgContainer.subviews objectAtIndex:i];
+        }
+        
+        [img setHidden:NO];
+        img.frame = CGRectMake(startX, startY, imgSize, imgSize);
+
+        NSString *path = [data.thumbArr objectAtIndex:i];
+        NSURL *url = [NSURL URLWithString:path];
+        [img sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"聊天-_17"]];
+        [img setTag:i];
+        
+        
+    }
+    
+    for(int j=i; j<_imgContainer.subviews.count; j++)
+    {
+        [[_imgContainer.subviews objectAtIndex:j] setHidden:YES];
+    }
+    
+    _imgContainer.height = imgContainerHeight;
+    
+    _actionContainer.top = _imgContainer.bottom;
+    [_priorityBtn setTitle:[NSString stringWithFormat:@"置顶%d", data.priority] forState:UIControlStateNormal];
+    [_priorityBtn sizeToFit];
+    _priorityBtn.width = _priorityBtn.width + 12;
+    _priorityBtn.height = 24;
+    
+    data.cellHeight = _actionContainer.bottom + 10;
+}
+
+
+- (void)onTouchFollow:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    if(_data.followed)
+    {
+        [[HttpRequest shared] tradeDeleteFollow:_data.tradeId success:^{
+            [self makeToast:@"取消关注成功"];
+            _data.followed = NO;
+            [self updateFollow];
+        } failure:^{
+            [self makeToast:@"取消关注失败"];
+        }];
+    }
+    else
+    {
+        [[HttpRequest shared] tradeFollow:_data.tradeId success:^{
+            [self makeToast:@"关注成功"];
+            _data.followed = YES;
+            [self updateFollow];
+        } failure:^{
+            [self makeToast:@"关注失败"];
+        }];
+    }
+}
+
+- (void)updateFollow{
+    
+    if(_data.followed)
+    {
+        _followLabel.text = @"已关注";
+    }
+    else
+    {
+        _followLabel.text = @"关注";
+    }
+    
+}
+
+- (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    [User showUserInfo:[NSString stringWithFormat:@"%ld", (long)viewClicked.tag]];
+    
+}
+
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
+{
+    [User showUserInfo:url.absoluteString];
+    return NO;
+}
+
+- (void)onTouchImage:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    
+    NSLog(@"show image %ld", (long)viewClicked.tag);
+    
+    ImagePagerViewController *imagePageVC = [[ImagePagerViewController alloc] init];
+    [imagePageVC setImages:_data.picArr thumbs:_data.thumbArr startIndex:(int)viewClicked.tag];
+    
+    [self.viewController.navigationController pushViewController:imagePageVC animated:YES];
+}
+
+
+
+
+
+@end

+ 15 - 0
NIMDemo/NIMDemo/SectionTrade/TradeViewController.h

@@ -0,0 +1,15 @@
+//
+//  TradeViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/1.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface TradeViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
+
+@property (nonatomic, strong) UITableView       *tableView;
+
+@end

+ 331 - 0
NIMDemo/NIMDemo/SectionTrade/TradeViewController.m

@@ -0,0 +1,331 @@
+//
+//  TradeViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/1.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "TradeViewController.h"
+#import "UIView+NTES.h"
+#import "TradeData.h"
+#import "TradeTableViewCell.h"
+#import "HttpRequest.h"
+#import "UIActionSheet+NTESBlock.h"
+#import "User.h"
+
+@interface TradeViewController () <UIScrollViewDelegate>
+
+@property (nonatomic, strong) NSMutableArray            *dataList;
+@property (nonatomic, assign) BOOL                      isFetching;
+@property (nonatomic, assign) BOOL                      flagRefresh;
+@property (nonatomic, assign) TradeSort                 tradeSort;
+@property (nonatomic, assign) int                       page;
+
+@property (nonatomic, strong) NSString                  *district;
+
+@end
+
+@implementation TradeViewController
+
+float postHeight = 30;
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    User *user = [User sharedInfo];
+    
+    if((_district && ![_district isEqualToString:user.district]) || (!_district && user.district))
+    {
+        _district = user.district;
+        [self reset];
+        [self fetchDataList];
+    }
+    
+    
+    
+    UINavigationItem *navItem = self.parentViewController.navigationItem;
+    
+    navItem.title = @"交易贴";
+    
+    
+    NSString *title = @"请重试定位";
+    if(![user.district isEqualToString:@""])
+    {
+        if([user.city isEqualToString:user.district])
+            title = user.city;
+        else
+            title = [NSString stringWithFormat:@"%@%@", user.city, user.district];
+        
+        if(title.length > 6)
+        {
+            title = [NSString stringWithFormat:@"%@%@", [title substringWithRange:NSMakeRange(0, 6)], @"..."];
+        }
+    }
+    
+    UIButton *localBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [localBtn setTitle:title forState:UIControlStateNormal];
+    [localBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [localBtn addTarget:self action:@selector(relocaltion) forControlEvents:UIControlEventTouchUpInside];
+    [localBtn setImage:[UIImage imageNamed:@"交易帖_03 (4)"] forState:UIControlStateNormal];
+    localBtn.imageEdgeInsets = UIEdgeInsetsMake(2, -5, 2, 5);
+    localBtn.titleLabel.font = [UIFont systemFontOfSize: 15.0];
+    [localBtn sizeToFit];
+    
+    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+    spacer.width = -5;
+    
+    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:localBtn];
+    [navItem setLeftBarButtonItems:@[spacer, leftItem]];
+    
+    
+    
+    
+    UIButton *sortBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [sortBtn setTitle:@"筛选" forState:UIControlStateNormal];
+    [sortBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [sortBtn addTarget:self action:@selector(onTouchSort:) forControlEvents:UIControlEventTouchUpInside];
+    [sortBtn sizeToFit];
+    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:sortBtn];
+    
+//    UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+//    [searchBtn setImage:[UIImage imageNamed:@"查找聊天内容_03"] forState:UIControlStateNormal];
+//    [searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+//    [searchBtn addTarget:self action:@selector(onTouchSearch:) forControlEvents:UIControlEventTouchUpInside];
+//    [searchBtn setTintColor:UIColor.whiteColor];
+//    [searchBtn sizeToFit];
+//    UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:searchBtn];
+    
+    UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(onTouchSearch:)];
+    
+    [navItem setRightBarButtonItems:@[rightItem, searchItem]];
+}
+
+
+- (void)relocaltion{
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    UIViewController *next = (UIViewController *)[board instantiateViewControllerWithIdentifier:@"CityPicker"];
+    [self.navigationController pushViewController:next animated:YES];
+}
+
+
+
+
+
+- (UITableView *)tableView
+{
+    if (!self.isViewLoaded) {
+        return nil;
+    }
+    if (!_tableView) {
+        float startY = [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height;
+        float tabbarHeight = self.tabBarController.tabBar.frame.size.height;
+        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, startY, self.view.width, self.view.height-tabbarHeight) style:UITableViewStylePlain];
+        _tableView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
+        _tableView.backgroundColor  = [UIColor clearColor];
+        _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+        _tableView.dataSource = self;
+        _tableView.delegate   = self;
+        [self.view addSubview:_tableView];
+    }
+    return _tableView;
+}
+
+
+- (void)onTouchSort:(int)sender{
+    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"选择操作" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"全部",@"最近",@"供求",@"需求", nil];
+    __weak typeof(self) wself = self;
+    TradeSort oldTradeSort = _tradeSort;
+    [sheet showInView:self.view completionHandler:^(NSInteger index) {
+        switch (index) {
+            case 0:
+                wself.tradeSort = TradeSortNone;
+                break;
+            case 1:{
+                wself.tradeSort = TradeSortRecent;
+                break;
+            }
+            case 2:{
+                wself.tradeSort = TradeSortSupply;
+                break;
+            }
+            case 3:{
+                wself.tradeSort = TradeSortDemand;
+                break;
+            }
+            default:
+                break;
+        }
+        
+        if(wself.tradeSort != oldTradeSort)
+        {
+            [wself reset];
+            [wself fetchDataList];
+        }
+    }];
+}
+
+
+- (void)onTouchSearch:(int)sender{
+    NSLog(@"onTouchSearch");
+    
+    
+}
+
+
+- (void)reset{
+    
+    _page = 1;
+    _dataList = nil;
+    
+}
+
+- (void)fetchDataList{
+    
+    if(_isFetching)
+        return;
+    
+    _isFetching = YES;
+    
+    _page = MAX(1, _page);
+    
+    
+    [[HttpRequest shared] tradeList:_tradeSort page:_page success:^(NSMutableArray * _Nullable dataList) {
+        if(!self.dataList)
+            self.dataList = dataList;
+        else
+            [self.dataList addObjectsFromArray:dataList];
+        
+        [self.tableView reloadData];
+        
+        if(dataList.count > 0)
+            _page++;
+        
+        _isFetching = NO;
+    } failure:^{
+        _isFetching = NO;
+    }];
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(_dataList)
+        return _dataList.count;
+    return 0;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSObject *dataObj = [_dataList objectAtIndex:indexPath.row];
+    
+    UITableViewCell *baseCell = nil;
+    
+//    if([dataObj isKindOfClass:[SocialItemData class]])
+//    {
+//        NSString *cellId = @"social";
+//        SocialDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+//        
+//        if(!cell)
+//        {
+//            cell = [[SocialDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+//            [cell initWidth:self.view.frame.size.width];
+//        }
+//        
+//        [cell setSocialData:(SocialItemData *)dataObj];
+//        _infoHeight = cell.cellHeight;
+//        
+//        baseCell = cell;
+//    }
+//    else if([dataObj isKindOfClass:[SocialCommentData class]])
+//    {
+//        NSString *cellId = @"comment";
+//        SocialCommentDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+//        
+//        if(!cell)
+//        {
+//            cell = [[SocialCommentDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+//            [cell initWidth:self.view.frame.size.width];
+//        }
+//        
+//        [cell setSocialCommentData:(SocialCommentData *)dataObj];
+//        baseCell = cell;
+//    }
+    
+    if(true)
+    {
+        NSString *cellId = @"trade";
+        TradeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+
+        if(!cell)
+        {
+            cell = [[TradeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initWidth:self.view.frame.size.width];
+        }
+
+        [cell setData:(TradeData *)dataObj];
+        baseCell = cell;
+    }
+    
+    return baseCell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSObject *dataObj = [_dataList objectAtIndex:indexPath.row];
+    
+    if([dataObj isKindOfClass:[TradeData class]])
+    {
+        TradeData *tradeData = (TradeData *)dataObj;
+        return tradeData.cellHeight;
+    }
+    
+    return postHeight;
+}
+
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
+    //康海涛测试Ok的
+    CGPoint offset1 = scrollView.contentOffset;
+    CGRect bounds1 = scrollView.bounds;
+    CGSize size1 = scrollView.contentSize;
+    UIEdgeInsets inset1 = scrollView.contentInset;
+    float y1 = offset1.y + bounds1.size.height - inset1.bottom;
+    float h1 = size1.height;
+    
+    //NSLog(@"%f %f %i %f", y1, h1, _flagRefresh, bounds1.size.height);
+    
+    if(h1 < bounds1.size.height)
+        return;
+    
+    if (y1 > h1 + 50) {
+        _flagRefresh = YES;
+    }
+    else if (y1 == h1) {
+        if(_flagRefresh)
+        {
+            _flagRefresh = NO;
+            NSLog(@"下拉刷新");
+            [self fetchDataList];
+        }
+    }
+    
+}
+
+@end

+ 16 - 0
NIMDemo/NIMDemo/SettingOptionTableViewCell.h

@@ -0,0 +1,16 @@
+//
+//  SettingOptionTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface SettingOptionTableViewCell : UITableViewCell
+
+- (void)initWidth:(CGFloat)cellWidth;
+- (void)setData:(NSDictionary *)data;
+
+@end

+ 101 - 0
NIMDemo/NIMDemo/SettingOptionTableViewCell.m

@@ -0,0 +1,101 @@
+//
+//  SettingOptionTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SettingOptionTableViewCell.h"
+#import "UIView+NTES.h"
+#import "MyTradeViewController.h"
+
+@interface SettingOptionTableViewCell()
+
+@property (strong, nonatomic) UIImageView             *iconView;
+@property (strong, nonatomic) UIImageView             *arrowView;
+@property (strong, nonatomic) UILabel                 *titleLabel;
+
+@property (strong, nonatomic) NSDictionary            *data;
+
+@end
+
+@implementation SettingOptionTableViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    
+    _iconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 7, 30, 30)];
+    [_iconView setImage:[UIImage imageNamed:@"我的_07"]];
+    [self addSubview:_iconView];
+    
+    _arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(cellWidth - 20 - 10, 10, 8, 16)];
+    [_arrowView setImage:[UIImage imageNamed:@"设置_03"]];
+    [self addSubview:_arrowView];
+    
+    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_iconView.right+10, 7, 150, 30)];
+    _titleLabel.textColor = UIColor.blackColor;
+    [self addSubview:_titleLabel];
+    
+    UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, 43.5, cellWidth, 0.5)];
+    step.backgroundColor = UIColor.lightGrayColor;
+    [self addSubview:step];
+    
+    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
+    btn.frame = CGRectMake(0, 0, cellWidth, 44);
+    [btn addTarget:self action:@selector(onTouchBtn:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:btn];
+}
+
+- (void)setData:(NSDictionary *)data{
+    
+    _data = data;
+    
+    NSString *type = [data objectForKey:@"type"];
+    if([type isEqualToString:@"near"])
+    {
+        [_iconView setImage:[UIImage imageNamed:@"我的_07"]];
+        [_titleLabel setText:@"附近的人"];
+    }
+    else if([type isEqualToString:@"trade"])
+    {
+        [_iconView setImage:[UIImage imageNamed:@"我的_10"]];
+        [_titleLabel setText:@"我的供需"];
+    }
+    else if([type isEqualToString:@"setting"])
+    {
+        [_iconView setImage:[UIImage imageNamed:@"我的_17"]];
+        [_titleLabel setText:@"设置"];
+    }
+}
+
+- (void)onTouchBtn:(id)sender{
+    
+    NSString *type = [_data objectForKey:@"type"];
+    if([type isEqualToString:@"near"])
+    {
+        
+    }
+    else if([type isEqualToString:@"trade"])
+    {
+        UIViewController *next = [[MyTradeViewController alloc] init];
+        [self.viewController.navigationController pushViewController:next animated:YES];
+    }
+    else if([type isEqualToString:@"setting"])
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        UIViewController *next = (UIViewController *)[board instantiateViewControllerWithIdentifier:@"AccountSetting"];
+        [self.viewController.navigationController pushViewController:next animated:YES];
+    }
+    
+}
+
+@end

+ 104 - 38
NIMDemo/NIMDemo/SettingTableViewController.m

@@ -10,14 +10,15 @@
 #import "NIMAvatarImageView.h"
 #import "User.h"
 #import "NIMSDK/NIMSDK.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+#import "SettingTopTableViewCell.h"
+#import "AppDelegate.h"
+#import "SettingOptionTableViewCell.h"
 
 @interface SettingTableViewController ()
-@property (weak, nonatomic) IBOutlet UIButton *topBgBtn;
-@property (weak, nonatomic) IBOutlet NIMAvatarImageView *avatarImg;
-@property (weak, nonatomic) IBOutlet UIImageView *genderImg;
-@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
-@property (weak, nonatomic) IBOutlet UILabel *userIdLabel;
 
+@property (nonatomic, strong) NSMutableArray                *dataArr;
 
 @end
 
@@ -25,6 +26,27 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    
+    _dataArr = [[NSMutableArray alloc] init];
+    
+    [_dataArr addObject:@{@"cellId":@"top",
+                          @"height":@"300"}];
+    
+    [_dataArr addObject:@{@"cellId":@"option",
+                          @"type":@"near",
+                          @"height":@"44"}];
+    
+    [_dataArr addObject:@{@"cellId":@"option",
+                          @"type":@"trade",
+                          @"height":@"44"}];
+    
+    [_dataArr addObject:@{@"cellId":@"option",
+                          @"type":@"setting",
+                          @"height":@"44"}];
+    
+    
+    
+    self.tableView.contentInset = UIEdgeInsetsMake(-69, 0, 0, 0);
 }
 
 - (void)didReceiveMemoryWarning {
@@ -32,55 +54,99 @@
 }
 
 - (void)viewWillAppear:(BOOL)animated{
-
     [super viewWillAppear:animated];
     
-    self.parentViewController.navigationItem.title = @"";
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    [appDelegate transparentNavBar:self.parentViewController];
+    
     
     UINavigationItem *navItem = self.parentViewController.navigationItem;
     
     [navItem setTitle:@""];
-    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
-    [navItem setLeftBarButtonItems:@[spacer]];
     
-    UIBarButtonItem *spacer2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
-    [navItem setRightBarButtonItems:@[spacer2]];
+    UIButton *emptyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [emptyBtn setTitle:@"" forState:UIControlStateNormal];
+    [emptyBtn sizeToFit];
+    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:emptyBtn];
     
-    NSString *myUserId = [NIMSDK sharedSDK].loginManager.currentAccount;
-    [[NIMSDK sharedSDK].userManager fetchUserInfos:@[myUserId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
-        if(!error && users && users.count > 0)
-        {
-            NIMUser *user = [users objectAtIndex:0];
-            
-            NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
-            [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_team"]];
-            _userNameLabel.text = user.userInfo.nickName;
-            _userIdLabel.text = myUserId;
-            
-            if(user.userInfo.gender == NIMUserGenderFemale)
-            {
-                [_genderImg setImage:[UIImage imageNamed:@"我的_07 (4)"]];
-            }
-            else
-            {
-                [_genderImg setImage:[UIImage imageNamed:@"我的_07 (3)"]];
-            }
-        }
-    }];
+    [navItem setLeftBarButtonItems:@[leftItem]];
+    
+    
+    UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [addBtn setImage:[UIImage imageNamed:@"创建群_07"] forState:UIControlStateNormal];
+    [addBtn addTarget:self action:@selector(onTouchSetting:) forControlEvents:UIControlEventTouchUpInside];
+    [addBtn sizeToFit];
+    UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithCustomView:addBtn];
+    
+    [navItem setRightBarButtonItems:@[addItem]];
     
 }
 
-- (IBAction)onTouchNear:(id)sender {
-    NSLog(@"onTouchNear");
+- (void)viewWillDisappear:(BOOL)animated{
+    [super viewWillDisappear:animated];
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    [appDelegate orangeNavBar:self.parentViewController];
 }
 
-- (IBAction)onTouchSupply:(id)sender {
-    NSLog(@"onTouchSupply");
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(_dataArr)
+        return _dataArr.count;
+    return 0;
 }
 
-- (IBAction)onTouchSetting:(id)sender {
-    NSLog(@"onTouchSetting");
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     
+    NSDictionary *dataObj = [_dataArr objectAtIndex:indexPath.row];
+    NSString *cellId = [dataObj objectForKey:@"cellId"];
+    
+    UITableViewCell *baseCell = nil;
+    
+    if([cellId isEqualToString:@"top"])
+    {
+        SettingTopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        if(!cell)
+        {
+            cell = [[SettingTopTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initSize:self.view.width cellHeight:[[dataObj objectForKey:@"height"] floatValue]];
+        }
+        baseCell = cell;
+    }
+    else if([cellId isEqualToString:@"option"])
+    {
+        SettingOptionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        if(!cell)
+        {
+            cell = [[SettingOptionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initWidth:self.view.width];
+        }
+        [cell setData:dataObj];
+        baseCell = cell;
+    }
+    
+    return baseCell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSDictionary *dataObj = [_dataArr objectAtIndex:indexPath.row];
+    float height = [[dataObj objectForKey:@"height"] floatValue];
+    
+    return height;
+}
+
+
+- (void)onTouchSetting:(id)sender{
     
 }
+
+
+
+
 @end

+ 15 - 0
NIMDemo/NIMDemo/SettingTopTableViewCell.h

@@ -0,0 +1,15 @@
+//
+//  SettingTopTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface SettingTopTableViewCell : UITableViewCell
+
+- (void)initSize:(CGFloat)cellWidth cellHeight:(CGFloat)cellHeight;
+
+@end

+ 93 - 0
NIMDemo/NIMDemo/SettingTopTableViewCell.m

@@ -0,0 +1,93 @@
+//
+//  SettingTopTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/3.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SettingTopTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "User.h"
+#import "NIMSDK/NIMSDK.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+
+@interface SettingTopTableViewCell()
+
+@property (strong, nonatomic) UIImageView             *topImgView;
+@property (strong, nonatomic) NIMAvatarImageView      *avatarImg;
+@property (strong, nonatomic) UIImageView             *genderImg;
+@property (strong, nonatomic) UILabel                 *userNameLabel;
+@property (strong, nonatomic) UILabel                 *userIdLabel;
+
+@end
+
+@implementation SettingTopTableViewCell
+
+- (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{
+    
+    NSString *userId = [NIMSDK sharedSDK].loginManager.currentAccount;
+    NIMUser *nimUser = [[NIMSDK sharedSDK].userManager userInfo:userId];
+    
+    _topImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, cellWidth, 180)];
+    _topImgView.userInteractionEnabled = YES;
+    [_topImgView setImage:[UIImage imageNamed:@"群资料_01"]];
+    [_topImgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchTopImage:)]];
+    [self addSubview:_topImgView];
+    
+    _avatarImg = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
+    _avatarImg.centerX = cellWidth / 2;
+    _avatarImg.centerY = _topImgView.bottom;
+    
+    NSURL *url = nimUser.userInfo.avatarUrl ? [NSURL URLWithString:nimUser.userInfo.avatarUrl] : nil;
+    [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+    [self addSubview:_avatarImg];
+    
+    _genderImg = [[UIImageView alloc] initWithFrame:CGRectMake(_avatarImg.right-20, _avatarImg.bottom-20, 20, 20)];
+    if(nimUser.userInfo.gender == NIMUserGenderMale || nimUser.userInfo.gender == NIMUserGenderUnknown)
+    {
+        [_genderImg setImage:[UIImage imageNamed:@"我的_07 (3)"]];
+    }
+    else if(nimUser.userInfo.gender == NIMUserGenderFemale)
+    {
+        [_genderImg setImage:[UIImage imageNamed:@"我的_07 (4)"]];
+    }
+    [self addSubview:_genderImg];
+    
+    _userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _avatarImg.bottom + 10, cellWidth, 20)];
+    _userNameLabel.text = nimUser.userInfo.nickName ? nimUser.userInfo.nickName : userId;
+    _userNameLabel.textAlignment = NSTextAlignmentCenter;
+    [_userNameLabel setTextColor:UIColor.blackColor];
+    [self addSubview:_userNameLabel];
+    
+    _userIdLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _userNameLabel.bottom, cellWidth, 20)];
+    _userIdLabel.text = [NSString stringWithFormat:@"ID:%@", userId];
+    _userIdLabel.textAlignment = NSTextAlignmentCenter;
+    _userIdLabel.font = [UIFont systemFontOfSize:15];
+    [_userIdLabel setTextColor:UIColor.lightGrayColor];
+    [self addSubview:_userIdLabel];
+    
+    
+    UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, cellHeight-0.5, cellWidth, 0.5)];
+    step.backgroundColor = UIColor.lightGrayColor;
+    [self addSubview:step];
+    
+}
+
+- (void)onTouchTopImage:(id)sender{
+    
+    
+    
+}
+
+@end

+ 23 - 0
NIMDemo/NIMDemo/SocialCommentData.h

@@ -0,0 +1,23 @@
+//
+//  SocialCommentData.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/26.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface SocialCommentData : NSObject
+
+@property (nonatomic, strong) NSString              *commentId;
+@property (nonatomic, strong) NSString              *socialId;
+@property (nonatomic, strong) NSString              *userId;
+@property (nonatomic, strong) NSString              *replyId;
+@property (nonatomic, strong) NSString              *comment;
+@property (nonatomic, strong) NSString              *time;
+@property (nonatomic, assign) CGFloat               cellHeight;
+
+- (void)setData:(NSDictionary *)data;
+
+@end

+ 22 - 0
NIMDemo/NIMDemo/SocialCommentData.m

@@ -0,0 +1,22 @@
+//
+//  SocialCommentData.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/26.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialCommentData.h"
+
+@implementation SocialCommentData
+
+- (void)setData:(NSDictionary *)data{
+    _commentId = [data objectForKey:@"id"];
+    _userId  = [data objectForKey:@"user_id"];
+    _socialId = [data objectForKey:@"social_id"];
+    _replyId = [data objectForKey:@"reply_id"];
+    _comment = [data objectForKey:@"comment"];
+    _time = [data objectForKey:@"inputtime"];
+}
+
+@end

+ 17 - 0
NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.h

@@ -0,0 +1,17 @@
+//
+//  SocialCommentDetailTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SocialCommentData.h"
+
+@interface SocialCommentDetailTableViewCell : UITableViewCell
+
+- (void)initWidth:(CGFloat)cellWidth;
+- (void)setSocialCommentData:(SocialCommentData *)socialCommentData;
+
+@end

+ 170 - 0
NIMDemo/NIMDemo/SocialCommentDetailTableViewCell.m

@@ -0,0 +1,170 @@
+//
+//  SocialCommentDetailTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialCommentDetailTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "SocialDetailViewController.h"
+#import "User.h"
+
+@interface SocialCommentDetailTableViewCell()<UITextViewDelegate>
+
+@property (nonatomic, strong) NIMAvatarImageView            *avatarView;
+@property (nonatomic, strong) UITextView                    *nickTextView;
+@property (nonatomic, strong) UILabel                       *timeLabel;
+@property (nonatomic, strong) UITextView                    *msgTextView;
+@property (nonatomic, strong) UIButton                      *likeBtn;
+
+@property (nonatomic, strong) SocialCommentData             *data;
+
+@end
+
+@implementation SocialCommentDetailTableViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    
+    float padding = 10;
+    
+    //avatar
+    _avatarView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(padding, padding, 40, 40)];
+    [_avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    [self addSubview:_avatarView];
+    
+    //nick name
+    _nickTextView = [[UITextView alloc] initWithFrame:CGRectMake(_avatarView.right + 5, padding, 200, 25)];
+    _nickTextView.backgroundColor = UIColor.clearColor;
+    _nickTextView.scrollEnabled = NO;
+    _nickTextView.editable = NO;
+    _nickTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    _nickTextView.delegate = self;
+    _nickTextView.textAlignment = NSTextAlignmentLeft;
+    [self addSubview:_nickTextView];
+    
+    //time
+    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nickTextView.left + 5, _nickTextView.bottom, 200, 15)];
+    _timeLabel.font = [UIFont systemFontOfSize:14];
+    _timeLabel.textColor = UIColor.lightGrayColor;
+    [self addSubview:_timeLabel];
+    
+    //message
+    _msgTextView = [[UITextView alloc] initWithFrame:CGRectMake(_nickTextView.left, _avatarView.bottom+5, cellWidth - padding - _nickTextView.left, 0)];
+    _msgTextView.font = [UIFont systemFontOfSize:15];
+    _msgTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    [_msgTextView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchMsg:)]];
+    [self addSubview:_msgTextView];
+    
+    
+    //_likeBtn = [[UIButton alloc] initWithFrame:CGRectMake(cellWidth - padding - 25, 5, 25, 25)];
+    //[_likeBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+}
+
+
+- (void)setSocialCommentData:(SocialCommentData *)socialCommentData{
+    
+    _data = socialCommentData;
+    
+    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.tag = [socialCommentData.userId intValue];
+    
+    _timeLabel.text = socialCommentData.time;
+    
+    
+    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init];
+    if(socialCommentData.replyId && ![socialCommentData.replyId isEqualToString:@"0"] && ![socialCommentData.replyId isEqualToString:@""])
+    {
+        //append sender name
+        NSString *userId = socialCommentData.userId;
+        user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        [attrString appendAttributedString:appendString];
+        
+        //append reply label
+        attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                 [UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+        appendString = [[NSMutableAttributedString alloc] initWithString:@" 回复 " attributes:attrs];
+        [attrString appendAttributedString:appendString];
+        
+        //append reply name
+        userId = socialCommentData.replyId;
+        user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+        nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+        attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                 [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                 UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        appendString = [[NSMutableAttributedString alloc] initWithString:user.userId attributes:attrs];
+        range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        [attrString appendAttributedString:appendString];
+        
+        _nickTextView.attributedText = attrString;
+    }
+    else
+    {
+        //append sender name
+        NSString *userId = socialCommentData.userId;
+        user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        [attrString appendAttributedString:appendString];
+        
+        _nickTextView.attributedText = attrString;
+    }
+    
+    
+    _msgTextView.text = socialCommentData.comment;
+    _msgTextView.height = _msgTextView.contentSize.height;
+    
+    socialCommentData.cellHeight = _msgTextView.bottom + 20;
+}
+
+
+- (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    [User showUserInfo:[NSString stringWithFormat:@"%ld", (long)viewClicked.tag]];
+    
+}
+
+- (void)onTouchMsg:(UITapGestureRecognizer *)gestureRecognizer{
+    SocialDetailViewController *vc = (SocialDetailViewController *)self.viewController;
+    if(vc)
+    {
+        [vc beginComment:nil];
+    }
+}
+     
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
+{
+    [User showUserInfo:url.absoluteString];
+    return NO;
+}
+
+@end

+ 19 - 0
NIMDemo/NIMDemo/SocialDetailTableViewCell.h

@@ -0,0 +1,19 @@
+//
+//  SocialDetailTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SocialItemData.h"
+
+@interface SocialDetailTableViewCell : UITableViewCell
+
+@property (nonatomic, assign) CGFloat cellHeight;
+
+- (void)initWidth:(CGFloat)cellWidth;
+- (void)setSocialData:(SocialItemData *)socialData;
+
+@end

+ 348 - 0
NIMDemo/NIMDemo/SocialDetailTableViewCell.m

@@ -0,0 +1,348 @@
+//
+//  SocialDetailTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialDetailTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+#import "User.h"
+#import "ImagePagerViewController.h"
+#import "HttpRequest.h"
+#import "SocialDetailViewController.h"
+
+@interface SocialDetailTableViewCell() <UITextViewDelegate>
+
+@property (nonatomic, strong) NIMAvatarImageView            *avatarView;
+@property (nonatomic, strong) UITextView                    *nickTextView;
+@property (nonatomic, strong) UILabel                       *timeLabel;
+@property (nonatomic, strong) UITextView                    *msgTextView;
+@property (nonatomic, strong) UIView                        *imgContainer;
+@property (nonatomic, strong) UIView                        *actionContainer;
+@property (nonatomic, strong) UIButton                      *locationBtn;
+@property (nonatomic, strong) UIButton                      *viewsBtn;
+@property (nonatomic, strong) UIButton                      *likeBtn;
+@property (nonatomic, strong) UIButton                      *commentBtn;
+@property (nonatomic, strong) UIView                        *likeTitleContainer;
+@property (nonatomic, strong) UILabel                       *likeTitle;
+@property (nonatomic, strong) UIView                        *likeContainer;
+@property (nonatomic, strong) UIView                        *commentTitleContainer;
+@property (nonatomic, strong) UILabel                       *commentTitle;
+
+@property (nonatomic, strong) SocialItemData                *data;
+@property (nonatomic, strong) NSMutableArray                *likeArr;
+
+@end
+
+@implementation SocialDetailTableViewCell
+
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    
+    float padding = 10;
+    
+    //avatar
+    _avatarView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(padding, padding, 40, 40)];
+    [_avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    [self addSubview:_avatarView];
+    
+    //nick name
+    _nickTextView = [[UITextView alloc] initWithFrame:CGRectMake(_avatarView.right + 5, padding, 200, 25)];
+    _nickTextView.backgroundColor = UIColor.clearColor;
+    _nickTextView.scrollEnabled = NO;
+    _nickTextView.editable = NO;
+    _nickTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    _nickTextView.delegate = self;
+    _nickTextView.textAlignment = NSTextAlignmentLeft;
+    [self addSubview:_nickTextView];
+    
+    //time
+    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nickTextView.left + 5, _nickTextView.bottom, 200, 15)];
+    _timeLabel.font = [UIFont systemFontOfSize:14];
+    _timeLabel.textColor = UIColor.lightGrayColor;
+    [self addSubview:_timeLabel];
+    
+    //message
+    _msgTextView = [[UITextView alloc] initWithFrame:CGRectMake(padding, _avatarView.bottom+5, cellWidth - padding * 2, 0)];
+    _msgTextView.font = [UIFont systemFontOfSize:15];
+    _msgTextView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    [self addSubview:_msgTextView];
+    
+    //image container
+    _imgContainer = [[UIView alloc] initWithFrame:CGRectMake(padding, _msgTextView.bottom, cellWidth - padding * 2, 0)];
+    [self addSubview:_imgContainer];
+    
+    //action buttons
+    _actionContainer = [[UIView alloc] initWithFrame:CGRectMake(0, _imgContainer.bottom, cellWidth, 0)];
+    [self addSubview:_actionContainer];
+    
+    _locationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _locationBtn.frame = CGRectMake(padding, 8, 80, 24);
+    [_locationBtn setImage:[UIImage imageNamed:@"朋友圈发布_03"] forState:UIControlStateNormal];
+    _locationBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    _locationBtn.layer.cornerRadius = 12;
+    _locationBtn.layer.borderWidth = 1;
+    _locationBtn.layer.borderColor = UIColor.lightGrayColor.CGColor;
+    [_locationBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_actionContainer addSubview:_locationBtn];
+    
+    CGFloat aBtnWidth = 55;
+    CGFloat aBtnHeight = 40;
+    
+    _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_commentBtn setFrame:CGRectMake(_actionContainer.width-aBtnWidth-padding, 0, aBtnWidth, aBtnHeight)];
+    _commentBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [_commentBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_commentBtn setImage:[UIImage imageNamed:@"朋友圈_09"] forState:UIControlStateNormal];
+    [_commentBtn setTitle:@"评论" forState:UIControlStateNormal];
+    [_commentBtn addTarget:self action:@selector(onTouchComment:) forControlEvents:UIControlEventTouchUpInside];
+    [_actionContainer addSubview:_commentBtn];
+    
+    
+    _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_likeBtn setFrame:CGRectMake(_commentBtn.left-3-aBtnWidth, 0, aBtnWidth, aBtnHeight)];
+    _likeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [_likeBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_likeBtn setImage:[UIImage imageNamed:@"朋友圈_06"] forState:UIControlStateNormal];
+    [_likeBtn addTarget:self action:@selector(onTouchLike:) forControlEvents:UIControlEventTouchUpInside];
+    [_actionContainer addSubview:_likeBtn];
+    
+    _viewsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_viewsBtn setFrame:CGRectMake(_likeBtn.left-3-aBtnWidth, 0, aBtnWidth, aBtnHeight)];
+    _viewsBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [_viewsBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_viewsBtn setImage:[UIImage imageNamed:@"朋友圈_03"] forState:UIControlStateNormal];
+    [_actionContainer addSubview:_viewsBtn];
+    
+    
+    //like title
+    _likeTitleContainer = [[UIView alloc] initWithFrame:CGRectMake(0, aBtnHeight, cellWidth, 40)];
+    _likeTitleContainer.backgroundColor = UIColorFromRGB(0xeeeeee);
+    [_actionContainer addSubview:_likeTitleContainer];
+    
+    UIView *likeTitleFlag = [[UIView alloc] initWithFrame:CGRectMake(padding, 5, 3, 16)];
+    likeTitleFlag.backgroundColor = User.orangeColor;
+    likeTitleFlag.centerY = _likeTitleContainer.height / 2;
+    [_likeTitleContainer addSubview:likeTitleFlag];
+    
+    _likeTitle = [[UILabel alloc] initWithFrame:CGRectMake(likeTitleFlag.right + 5, 5, 200, 20)];
+    [_likeTitle setTextColor:UIColor.lightGrayColor];
+    [_likeTitle setFont:[UIFont systemFontOfSize:15]];
+    _likeTitle.centerY = _likeTitleContainer.height / 2;
+    [_likeTitleContainer addSubview:_likeTitle];
+    
+    
+    //like container
+    _likeContainer = [[UIView alloc] initWithFrame:CGRectMake(padding, _likeTitleContainer.bottom+5, cellWidth - padding * 2, 40)];
+    [_actionContainer addSubview:_likeContainer];
+    
+    //comment title
+    _commentTitleContainer = [[UIView alloc] initWithFrame:CGRectMake(0, _likeContainer.bottom, cellWidth, 40)];
+    _commentTitleContainer.backgroundColor = UIColorFromRGB(0xeeeeee);
+    [_actionContainer addSubview:_commentTitleContainer];
+    
+    UIView *commentTitleFlag = [[UIView alloc] initWithFrame:CGRectMake(padding, 5, 3, 20)];
+    commentTitleFlag.backgroundColor = User.orangeColor;
+    commentTitleFlag.centerY = _commentTitleContainer.height / 2;
+    [_commentTitleContainer addSubview:commentTitleFlag];
+    
+    _commentTitle = [[UILabel alloc] initWithFrame:CGRectMake(commentTitleFlag.right + 5, 5, 200, 20)];
+    [_commentTitle setTextColor:UIColor.lightGrayColor];
+    [_commentTitle setFont:[UIFont systemFontOfSize:15]];
+    _commentTitle.centerY = _commentTitleContainer.height / 2;
+    [_commentTitleContainer addSubview:_commentTitle];
+
+}
+
+
+- (void)setSocialData:(SocialItemData *)data{
+    
+    self.data = data;
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:data.userId];
+    if(user)
+    {
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [_avatarView nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+        _avatarView.tag = [data.userId intValue];
+        
+        
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : data.userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        _nickTextView.attributedText = appendString;
+    }
+    
+    _timeLabel.text = data.time;
+    _msgTextView.text = data.msg;
+    
+    _msgTextView.height = _msgTextView.contentSize.height;
+    
+    _imgContainer.top = _msgTextView.bottom + 5;
+    float imgPadding = 2;
+    float imgSize = (_imgContainer.width - imgPadding * 2) / 3;
+    float imgContainerHeight = 0;
+    for(int i=0; i<data.thumbArr.count; i++)
+    {
+        float startX = (i % 3) * (imgSize + imgPadding);
+        float startY = (i / 3) * (imgSize + imgPadding);
+        imgContainerHeight = startY + imgSize;
+        UIImageView *img = nil;
+
+        img = [[UIImageView alloc] init];
+        [_imgContainer addSubview:img];
+        
+        img.frame = CGRectMake(startX, startY, imgSize, imgSize);
+        img.userInteractionEnabled = true;
+        
+        NSString *path = [data.thumbArr objectAtIndex:i];
+        NSURL *url = [NSURL URLWithString:path];
+        [img sd_setImageWithURL:url];
+        img.tag = i;
+        
+        [img addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchImage:)]];
+    }
+    _imgContainer.height = imgContainerHeight;
+    
+    User *myUser = [User sharedInfo];
+    
+    _actionContainer.top = _imgContainer.bottom;
+    [_locationBtn setTitle:[User distance:data.lat originLng:data.lng targetLat:myUser.latitude targetLng:myUser.longitude] forState:UIControlStateNormal];
+    [_locationBtn sizeToFit];
+    _locationBtn.width = _locationBtn.width + 12;
+    _locationBtn.height = 24;
+    
+    [_viewsBtn setTitle:[NSString stringWithFormat:@"%d", data.views] forState:UIControlStateNormal];
+    [_likeBtn setTitle:[NSString stringWithFormat:@"%d", data.likes] forState:UIControlStateNormal];
+    
+    
+    
+    if(data.likes > 0)
+    {
+        [_likeContainer setHidden:NO];
+        [_likeTitleContainer setHidden:NO];
+        [_likeTitle setText:[NSString stringWithFormat:@"%d人已赞", data.likes]];
+        
+        float likeSize = _likeContainer.width / 8;
+        _likeContainer.height = ceilf(data.likes / 8.0) * likeSize;
+        [self fetchLikes];
+        
+        _commentTitleContainer.top = _likeContainer.bottom + 5;
+    }
+    else
+    {
+        [_likeTitleContainer setHidden:YES];
+        [_likeContainer setHidden:YES];
+        
+        _commentTitleContainer.top = _likeTitleContainer.top;
+    }
+    
+    
+    [_commentTitle setText:[NSString stringWithFormat:@"全部评论 (%d)", data.comments]];
+    
+    _actionContainer.height = _commentTitleContainer.bottom;
+    _cellHeight = _actionContainer.bottom;
+}
+
+
+- (void)fetchLikes{
+    
+    if(_likeArr)
+        return;
+    
+    [[HttpRequest shared] socialLikeList:_data.socialId success:^(NSMutableArray * _Nullable dataList) {
+        
+        _likeArr = dataList;
+        
+        float likeSize = _likeContainer.width / 8;
+        float likePadding = 2;
+        
+        for(int i=0; i<dataList.count; i++)
+        {
+            NSString *userId = [dataList objectAtIndex:i];
+            NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+            
+            float startX = (i % 8) * likeSize;
+            float startY = floorf(i / 8) * likeSize;
+            
+            NIMAvatarImageView *avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(startX+likePadding, startY+likePadding, likeSize-likePadding*2, likeSize-likePadding*2)];
+            
+            avatar.tag = [userId intValue];
+            [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"]];
+            [_likeContainer addSubview:avatar];
+        }
+        
+    } failure:^{
+        
+    }];
+    
+}
+
+- (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    [User showUserInfo:[NSString stringWithFormat:@"%ld", (long)viewClicked.tag]];
+    
+}
+
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
+{
+    [User showUserInfo:url.absoluteString];
+    return NO;
+}
+
+- (void)onTouchImage:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    
+    NSLog(@"show image %ld", (long)viewClicked.tag);
+    
+    ImagePagerViewController *imagePageVC = [[ImagePagerViewController alloc] init];
+    [imagePageVC setImages:_data.picArr thumbs:_data.thumbArr startIndex:(int)viewClicked.tag];
+    
+    [self.viewController.navigationController pushViewController:imagePageVC animated:YES];
+}
+
+
+- (void)onTouchComment:(int)sender{
+    
+    SocialDetailViewController *vc = (SocialDetailViewController *)self.viewController;
+    if(vc)
+    {
+        [vc beginComment:nil];
+    }
+    
+}
+
+- (void)onTouchLike:(int)sender{
+    
+    [[HttpRequest shared] socialLike:_data.socialId success:^(NSString * _Nullable socialId, int currentLikes) {
+        
+        _data.likes = currentLikes;
+        
+    } failure:^{
+        
+    }];
+    
+}
+@end

+ 17 - 0
NIMDemo/NIMDemo/SocialDetailViewController.h

@@ -0,0 +1,17 @@
+//
+//  SocialDetailViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SocialItemData.h"
+
+@interface SocialDetailViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
+
+- (void)setSocialData:(SocialItemData *)socialData;
+- (void)beginComment:(NSString *)replyId;
+
+@end

+ 317 - 0
NIMDemo/NIMDemo/SocialDetailViewController.m

@@ -0,0 +1,317 @@
+//
+//  SocialDetailViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/28.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialDetailViewController.h"
+#import "SocialItemData.h"
+#import "SocialCommentData.h"
+#import "HttpRequest.h"
+#import "SocialDetailTableViewCell.h"
+#import "SocialCommentDetailTableViewCell.h"
+#import "UIView+NTES.h"
+
+@interface SocialDetailViewController ()<UIScrollViewDelegate, UITextFieldDelegate>
+
+@property (nonatomic, strong) NSMutableArray            *likeArr;
+@property (nonatomic, strong) NSMutableArray            *commentArr;
+@property (nonatomic, strong) SocialItemData            *data;
+
+@property (nonatomic, strong) NSMutableArray            *dataArr;
+@property (nonatomic, assign) float                     infoHeight;
+@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) UITableView               *tableView;
+@property (nonatomic, strong) NSString                  *replyId;
+
+@end
+
+@implementation SocialDetailViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+//    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
+//        self.edgesForExtendedLayout = UIRectEdgeNone;
+    
+    [self.view addSubview:[self tableView]];
+    
+    _flagRefresh = NO;
+    
+    _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 {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"详情"];
+}
+
+- (UITableView *)tableView
+{
+    if (!self.isViewLoaded) {
+        return nil;
+    }
+    if (!_tableView) {
+        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height) style:UITableViewStylePlain];
+        _tableView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
+        _tableView.backgroundColor  = [UIColor clearColor];
+        _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+        _tableView.dataSource = self;
+        _tableView.delegate   = self;
+    }
+    return _tableView;
+}
+
+
+- (void)setSocialData:(SocialItemData *)socialData{
+    
+    _data = socialData;
+    
+    _dataArr = [[NSMutableArray alloc] init];
+    [_dataArr addObject:_data];
+    
+    [self fetchCommentList];
+}
+
+
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(_dataArr)
+        return _dataArr.count;
+    return 0;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSObject *dataObj = [_dataArr objectAtIndex:indexPath.row];
+    
+    UITableViewCell *baseCell = nil;
+    
+    if([dataObj isKindOfClass:[SocialItemData class]])
+    {
+        NSString *cellId = @"social";
+        SocialDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        
+        if(!cell)
+        {
+            cell = [[SocialDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initWidth:self.view.frame.size.width];
+        }
+        
+        [cell setSocialData:(SocialItemData *)dataObj];
+        _infoHeight = cell.cellHeight;
+        
+        baseCell = cell;
+    }
+    else if([dataObj isKindOfClass:[SocialCommentData class]])
+    {
+        NSString *cellId = @"comment";
+        SocialCommentDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+        
+        if(!cell)
+        {
+            cell = [[SocialCommentDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+            [cell initWidth:self.view.frame.size.width];
+        }
+        
+        [cell setSocialCommentData:(SocialCommentData *)dataObj];
+        baseCell = cell;
+    }
+
+    return baseCell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    NSObject *dataObj = [_dataArr objectAtIndex:indexPath.row];
+    
+    if([dataObj isKindOfClass:[SocialCommentData class]])
+    {
+        SocialCommentData *commentData = (SocialCommentData *)dataObj;
+        return commentData.cellHeight;
+    }
+    
+    return _infoHeight;
+}
+
+
+
+
+- (void)fetchCommentList{
+    
+    if(_isFetching)
+        return;
+    
+    _isFetching = YES;
+    
+    NSString *lastId = nil;
+    if(self.commentArr && self.commentArr.count){
+        SocialCommentData *lastData = [self.commentArr lastObject];
+        lastId = lastData.commentId;
+    }
+    
+    
+    [[HttpRequest shared] socialCommentList:_data.socialId lastId:lastId success:^(NSMutableArray * _Nullable dataList) {
+        if(!self.commentArr)
+            self.commentArr = dataList;
+        else
+            [self.commentArr addObjectsFromArray:dataList];
+        
+        [self.dataArr addObjectsFromArray:dataList];
+        
+        [self.tableView reloadData];
+        
+        _isFetching = NO;
+    } failure:^{
+        _isFetching = NO;
+    }];
+}
+
+
+
+
+
+
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
+    //康海涛测试Ok的
+    CGPoint offset1 = scrollView.contentOffset;
+    CGRect bounds1 = scrollView.bounds;
+    CGSize size1 = scrollView.contentSize;
+    UIEdgeInsets inset1 = scrollView.contentInset;
+    float y1 = offset1.y + bounds1.size.height - inset1.bottom;
+    float h1 = size1.height;
+    
+    //NSLog(@"%f %f %i %f", y1, h1, _flagRefresh, bounds1.size.height);
+    
+    if(h1 < bounds1.size.height)
+        return;
+    
+    if (y1 > h1 + 50) {
+        _flagRefresh = YES;
+    }
+    else if (y1 == h1) {
+        if(_flagRefresh)
+        {
+            _flagRefresh = NO;
+            NSLog(@"下拉刷新");
+            [self fetchCommentList];
+        }
+    }
+}
+
+- (void)onTouchComment:(int)sender{
+    
+    if([_commentTextField.text isEqualToString:@""])
+    {
+        if(_commentContainer.bottom == self.view.bottom)
+        {
+            [self beginComment:nil];
+        }
+        else
+        {
+            [_commentTextField resignFirstResponder];
+        }
+    }
+    else
+    {
+        [self sendComment:_commentTextField.text replyId:_replyId];
+    }
+    
+}
+
+- (void)beginComment:(NSString *)replyId{
+    
+    _replyId = replyId;
+    _commentTextField.text = @"";
+    [_commentTextField becomeFirstResponder];
+    
+}
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
+{
+    if ([string isEqualToString:@"\n"]) {
+        [self sendComment:textField.text replyId:_replyId];
+        return NO;
+    }
+    return YES;
+}
+
+- (void)sendComment:(NSString *)comment replyId:(NSString *)replyId{
+    
+    NSLog(@"sender %@", comment);
+    
+    if(comment && ![comment isEqualToString:@""])
+    {
+        [[HttpRequest shared] socialComment:_data.socialId replyId:replyId comment:comment success:^(SocialCommentData * _Nullable commentData, int commentCount) {
+            
+            _data.comments = commentCount;
+            [self fetchCommentList];
+            
+        } 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;
+}
+
+@end

+ 32 - 0
NIMDemo/NIMDemo/SocialItemData.h

@@ -0,0 +1,32 @@
+//
+//  SocialItemData.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/21.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface SocialItemData : NSObject
+
+@property (nonatomic, strong) NSString          *socialId;
+@property (nonatomic, strong) NSString          *userId;
+@property (nonatomic, strong) NSString          *local;
+@property (nonatomic, assign) double            lat;
+@property (nonatomic, assign) double            lng;
+@property (nonatomic, strong) NSString          *msg;
+@property (nonatomic, strong) NSArray           *thumbArr;
+@property (nonatomic, strong) NSArray           *picArr;
+@property (nonatomic, strong) NSString          *time;
+@property (nonatomic, assign) int               likes;
+@property (nonatomic, assign) int               views;
+@property (nonatomic, assign) int               comments;
+@property (nonatomic, strong) NSMutableArray    *likeArr;
+@property (nonatomic, strong) NSMutableArray    *commentArr;
+
+@property (nonatomic, assign) CGFloat           cellHeight;
+
+- (void)setData:(NSDictionary *)data;
+
+@end

+ 55 - 0
NIMDemo/NIMDemo/SocialItemData.m

@@ -0,0 +1,55 @@
+//
+//  SocialItemData.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/21.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialItemData.h"
+#import "SocialCommentData.h"
+
+@implementation SocialItemData
+
+- (void)setData:(NSDictionary *)data{
+    _socialId = [data objectForKey:@"id"];
+    _userId  = [data objectForKey:@"user_id"];
+    
+    _local = [data objectForKey:@"local"];
+    _lat = [[data objectForKey:@"latitude"] doubleValue];
+    _lng = [[data objectForKey:@"longitude"] doubleValue];
+    
+    _msg = [data objectForKey:@"msg"];
+    
+    _picArr = [data objectForKey:@"pics"];
+    _thumbArr = [data objectForKey:@"thumbs"];
+   
+    _time = [data objectForKey:@"inputtime"];
+    _likes = [[data objectForKey:@"likes"] intValue];
+    _views = [[data objectForKey:@"views"] intValue];
+    _comments = [[data objectForKey:@"comments"] intValue];
+    
+    NSMutableArray *likeUserArr = [data objectForKey:@"like_users"];
+    _likeArr = [[NSMutableArray alloc] init];
+    [_likeArr addObjectsFromArray:likeUserArr];
+//    for(int i=0; i<likeUserArr.count; i++)
+//    {
+//        NSDictionary *likeUser = [likeUserArr objectAtIndex:i];
+//        NSString *likeUserId = [likeUser objectForKey:@"user_id"];
+//        [_likeArr addObject:likeUserId];
+//    }
+    
+    
+    NSMutableArray *commentDataArr = [data objectForKey:@"comments_list"];
+    _commentArr = [[NSMutableArray alloc] init];
+    for(int i=0; i<commentDataArr.count; i++)
+    {
+        NSDictionary *commentData = [commentDataArr objectAtIndex:i];
+        SocialCommentData *comment = [[SocialCommentData alloc] init];
+        [comment setData:commentData];
+        [_commentArr addObject:comment];
+    }
+    
+}
+
+@end

+ 13 - 0
NIMDemo/NIMDemo/SocialPublishViewController.h

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

+ 387 - 0
NIMDemo/NIMDemo/SocialPublishViewController.m

@@ -0,0 +1,387 @@
+//
+//  SocialPublishViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/20.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialPublishViewController.h"
+#import "UIView+NTES.h"
+#import "UIView+Toast.h"
+#import "User.h"
+#import "NIMKitMediaFetcher.h"
+#import "SVProgressHUD.h"
+#import "UIImage+NIM.h"
+#import "AFNetworking/AFNetworking.h"
+
+@interface SocialPublishViewController ()<UITextViewDelegate>
+
+@property (nonatomic, strong) UITextView            *msgTxtView;
+@property (nonatomic, strong) UILabel               *msgReplaceHolder;
+@property (nonatomic, strong) UILabel               *locationLabel;
+@property (nonatomic, strong) UILabel               *picLabel;
+@property (nonatomic, strong) NSMutableArray        *picArr;
+@property (nonatomic, strong) NSMutableArray        *picDataArr;
+@property (nonatomic, assign) int                   picUploadIndex;
+@property (nonatomic, strong) UIView                *picContainer;
+@property (nonatomic, strong) UIButton              *picAddBtn;
+@property (nonatomic, strong) NIMKitMediaFetcher    *mediaFetcher;
+
+@end
+
+int maxCountPictures = 9;
+CGFloat picPadding = 5;
+int picColumns = 5;
+
+@implementation SocialPublishViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.view.backgroundColor = UIColor.whiteColor;
+    
+    _picArr = [[NSMutableArray alloc] init];
+    _picDataArr = [[NSMutableArray alloc] init];
+    
+    
+    
+    
+    UINavigationItem *navItem = self.navigationController.navigationItem;
+    navItem.title = @"发布";
+    
+    CGFloat navBottom = self.navigationController.navigationBar.bottom;
+    
+    _msgTxtView = [[UITextView alloc] initWithFrame:CGRectMake(15, navBottom + 10, self.view.width-30, 100)];
+    [_msgTxtView setText:@""];
+    _msgTxtView.delegate = self;
+    _msgTxtView.font = [UIFont systemFontOfSize:15];
+    _msgTxtView.backgroundColor = UIColor.clearColor;
+    _msgReplaceHolder = [[UILabel alloc] initWithFrame:CGRectMake(15, navBottom + 10, self.view.width-30, 30)];
+    _msgReplaceHolder.textColor = UIColor.lightGrayColor;
+    _msgReplaceHolder.text = @"你想说点什么";
+    _msgReplaceHolder.font = [UIFont systemFontOfSize:15];
+    
+    [self.view addSubview:_msgReplaceHolder];
+    [self.view addSubview:_msgTxtView];
+    
+    
+    
+    
+    
+    
+    UIView *locationView = [[UIView alloc] initWithFrame:CGRectMake(15, _msgTxtView.bottom + 10, 100, 30)];
+    locationView.layer.cornerRadius = 15;
+    locationView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
+    
+    UIImageView *locationIcon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 4, 18, 22)];
+    [locationIcon setImage:[UIImage imageNamed:@"朋友圈发布_03"]];
+    [locationView addSubview:locationIcon];
+    
+    _locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(locationIcon.right+5, 0, 0, 30)];
+    [_locationLabel setText:[User sharedInfo].district ? [NSString stringWithFormat:@"%@%@", [User sharedInfo].city, [User sharedInfo].district] : @""];
+    _locationLabel.textColor = UIColor.grayColor;
+    _locationLabel.font = [UIFont systemFontOfSize:15];
+    [_locationLabel sizeToFit];
+    _locationLabel.top = (30 - _locationLabel.height)/2;
+    [locationView addSubview:_locationLabel];
+    
+    locationView.width = _locationLabel.right + 10;
+    [self.view addSubview:locationView];
+    
+    
+    
+    
+    
+    
+    
+    _picLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, locationView.bottom + 10, 150, 30)];
+    _picLabel.textColor = UIColor.lightGrayColor;
+    [self.view addSubview:_picLabel];
+    [self updatePictureTip];
+    
+    
+    float picSize = (self.view.width - 20 - picPadding * (picColumns - 1)) / picColumns;
+    _picContainer = [[UIView alloc] initWithFrame:CGRectMake(10, _picLabel.bottom+10, self.view.width - 20, picSize * 2 + picPadding)];
+    [self.view addSubview:_picContainer];
+    
+    _picAddBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,  0, picSize, picSize)];
+    [_picAddBtn setImage:[UIImage imageNamed:@"朋友圈发布_07"] forState:UIControlStateNormal];
+    [_picAddBtn addTarget:self action:@selector(onTouchAddPic:) forControlEvents:UIControlEventTouchUpInside];
+    [_picContainer addSubview:_picAddBtn];
+    
+    
+    
+    UIButton *publishBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, _picContainer.bottom+20, self.view.width - 30, 50)];
+    [publishBtn setTitle:@"发布" forState:UIControlStateNormal];
+    [publishBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
+    publishBtn.backgroundColor = User.orangeColor;
+    publishBtn.layer.cornerRadius = 5;
+    [publishBtn addTarget:self action:@selector(onTouchPublish:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:publishBtn];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+- (void)viewWillAppear:(BOOL)animated
+{
+    [super viewWillAppear:animated];
+}
+
+
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
+{
+    if (![text isEqualToString:@""])
+    {
+        _msgReplaceHolder.hidden = YES;
+    }
+    if ([text isEqualToString:@""] && range.location == 0 && range.length == 1)
+    {
+        _msgReplaceHolder.hidden = NO;
+    }
+    return YES;
+}
+
+
+- (void)updatePictureTip
+{
+    _picLabel.text = [NSString stringWithFormat:@"照片不超过%d张", (int)(maxCountPictures - _picArr.count)];
+    
+}
+
+- (void)layoutPictures
+{
+    float picSize = (self.view.width - 20 - picPadding * (picColumns - 1)) / picColumns;
+    
+    CGFloat startX = 0;
+    CGFloat startY = 0;
+    
+    int count = (int)_picArr.count;
+    int i = 0;
+    for(i=0; i<count; i++){
+        startX = (i % picColumns) * (picSize + picPadding);
+        startY = floorf(i / picColumns);
+        
+        UIImageView *imgView = nil;
+        if(_picContainer.subviews.count - 1 <= i){
+            imgView = [[UIImageView alloc] initWithFrame:CGRectMake(startX, startY, picSize, picSize)];
+            [_picContainer addSubview:imgView];
+        }
+        else{
+            imgView = [_picContainer.subviews objectAtIndex:i];
+            imgView.left = startX;
+            imgView.top = startY;
+        }
+        
+        UIImage *img = [_picArr objectAtIndex:i];
+        [imgView setImage:img];
+    }
+    
+    if(count < maxCountPictures)
+    {
+        startX = (count % picColumns) * (picSize + picPadding);
+        startY = floorf(count / picColumns);
+        _picAddBtn.left = startX;
+        _picAddBtn.top = startY;
+        _picAddBtn.hidden = NO;
+    }
+    else
+    {
+        _picAddBtn.hidden = YES;
+    }
+}
+
+- (void)onTouchAddPic:(int)sender
+{
+    [self showImagePicker:UIImagePickerControllerSourceTypePhotoLibrary];
+}
+
+- (NIMKitMediaFetcher *)mediaFetcher
+{
+    if (!_mediaFetcher) {
+        _mediaFetcher = [[NIMKitMediaFetcher alloc] init];
+    }
+    return _mediaFetcher;
+}
+
+- (void)showImagePicker:(UIImagePickerControllerSourceType)type{
+    
+    __weak typeof(self) weakSelf = self;
+    [self.mediaFetcher fetchPhotoFromLibrary:^(NSArray *images, NSString *path, PHAssetMediaType type) {
+        
+        int a = 1;
+        NSLog(@"%d", a);
+        
+        switch (type) {
+            case PHAssetMediaTypeImage:
+            {
+                for (UIImage *image in images) {
+                    [weakSelf.picArr addObject:image];
+                }
+                [weakSelf layoutPictures];
+            }
+                break;
+            case PHAssetMediaTypeVideo:
+            {
+            }
+                break;
+            default:
+                return;
+        }
+        
+    }];
+}
+
+
+
+- (void)onTouchPublish:(int)sender{
+
+    [SVProgressHUD show];
+    [self uploadPicture];
+
+}
+
+     
+- (void)uploadPicture{
+    
+    if(_msgTxtView.text.length == 0 && _picArr.count == 0)
+    {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"你还什么都没说呢" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+        [alert show];
+        return;
+    }
+    
+    if(_picUploadIndex >= _picArr.count)
+    {
+        [self publish];
+        return;
+    }
+    
+    UIImage *image = [_picArr objectAtIndex:_picUploadIndex];
+    NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
+    NSDictionary *dict = @{@"user_id":userId};
+    
+    NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=social&a=upload";
+    
+    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
+    manager.responseSerializer = [AFJSONResponseSerializer serializer];
+    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/html", nil];
+    
+    [manager POST:urlString parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
+
+            NSData *data = UIImageJPEGRepresentation(image, 1);
+            [formData appendPartWithFileData:data name:@"upload" fileName:[NSString stringWithFormat:@"image_%d.jpg", _picUploadIndex] mimeType:@"image/jpg"];
+        
+    } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
+        
+        //NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+        //NSLog(@"请求成功,服务器返回的信息%@", string);
+        
+        NSLog(@"请求成功,服务器返回的信息%@", responseObject);
+        
+        int code = [[responseObject objectForKey:@"c"] intValue];
+        if(code == 0)
+        {
+            NSDictionary *data = [responseObject objectForKey:@"d"];
+            NSString *aid = [data objectForKey:@"aid"];
+            
+            if(_picUploadIndex >= _picDataArr.count)
+            {
+                [_picDataArr addObject:aid];
+            }
+            else
+            {
+                [_picDataArr setObject:aid atIndexedSubscript:_picUploadIndex];
+            }
+            
+            _picUploadIndex++;
+            [self uploadPicture];
+        }
+        else{
+            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[responseObject objectForKey:@"d"] delegate:self cancelButtonTitle:@"放弃" otherButtonTitles:@"重试", nil];
+            [alert show];
+        }
+
+    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
+        NSLog(@"请求失败,服务器返回的错误信息%@",error);
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"上传图片失败" delegate:self cancelButtonTitle:@"放弃" otherButtonTitles:@"重试", nil];
+        [alert show];
+    }];
+}
+     
+- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
+    switch (buttonIndex) {
+        case 0:
+            [self.navigationController popViewControllerAnimated:YES];
+            break;
+        case 1:
+            [self uploadPicture];
+            break;
+        default:
+            break;
+    }
+}
+
+- (void)publish
+{
+    User *user = [User sharedInfo];
+    
+    NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
+    
+//    NSMutableDictionary *parameters = @{@"id":userId,
+//                                 @"local":_locationLabel.text,
+//                                 @"msg":_msgTxtView.text,
+//                                 @"pic":_picDataArr,
+//                                 };
+    NSString *local = _locationLabel.text ? _locationLabel.text : @"";
+    NSString *msg = _msgTxtView.text ? _msgTxtView.text : @"";
+    
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setObject:userId forKey:@"id"];
+    [parameters setObject:local forKey:@"local"];
+    [parameters setObject:msg forKey:@"msg"];
+    [parameters setObject:_picDataArr forKey:@"pic"];
+    [parameters setObject:[NSString stringWithFormat:@"%F", user.longitude] forKey:@"longitude"];
+    [parameters setObject:[NSString stringWithFormat:@"%F", user.latitude] forKey:@"latitude"];
+    
+    NSString *urlString = @"http://whosay.dashgame.com/index.php?m=who&c=social&a=publish";
+    //请求的managers
+    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
+    manager.responseSerializer = [AFJSONResponseSerializer new];
+    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
+    
+    //请求的方式:POST
+    
+    NSLog(@"%@", parameters);
+    
+    [manager POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
+        
+        [SVProgressHUD dismiss];
+        
+        NSLog(@"请求成功,服务器返回的信息%@", responseObject);
+        NSDictionary * dic = responseObject;
+        int code = [[dic valueForKey:@"c"] intValue];
+        if(code == 0){
+            NSDictionary *data = (NSDictionary *)[dic objectForKey:@"d"];
+            
+            NSLog(@"Json解析结果 = %d   %@", code, data);
+            [self.view makeToast:@"发布成功" duration:2.0 position:CSToastPositionCenter];
+            [self.navigationController popViewControllerAnimated:YES];
+        }
+        else{
+            [self.view makeToast:@"发布失败" duration:2.0 position:CSToastPositionCenter];
+        }
+    } failure:^(NSURLSessionDataTask *task, NSError * error) {
+        [SVProgressHUD dismiss];
+        NSLog(@"请求失败,服务器返回的错误信息%@",error);
+        [self.view makeToast:@"发布失败" duration:2.0 position:CSToastPositionCenter];
+    }];
+}
+     
+@end

+ 17 - 0
NIMDemo/NIMDemo/SocialTableViewCell.h

@@ -0,0 +1,17 @@
+//
+//  SocialTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/20.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SocialItemData.h"
+
+@interface SocialTableViewCell : UITableViewCell
+
+- (void)initWidth:(CGFloat)cellWidth;
+- (void)setData:(SocialItemData *)data;
+
+@end

+ 582 - 0
NIMDemo/NIMDemo/SocialTableViewCell.m

@@ -0,0 +1,582 @@
+//
+//  SocialTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/20.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialTableViewCell.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "UIImageView+WebCache.h"
+#import "HttpRequest.h"
+#import "ImagePagerViewController.h"
+#import "SocialDetailViewController.h"
+#import "User.h"
+#import "SocialTableViewController.h"
+
+@interface SocialTableViewCell() <UITextFieldDelegate, UITextViewDelegate>
+
+@property (nonatomic, strong) SocialItemData            *data;
+
+@property (nonatomic, strong) NIMAvatarImageView        *avatarImg;
+@property (nonatomic, strong) UITextView                *nickTextView;
+@property (nonatomic, strong) UITextView                *msgTxtView;
+@property (nonatomic, strong) UIView                    *picContainer;
+@property (nonatomic, strong) NSMutableArray            *picArr;
+@property (nonatomic, strong) UIView                    *actionContainer;
+@property (nonatomic, strong) UILabel                   *timeLabel;
+@property (nonatomic, strong) UIButton                  *viewsBtn;
+@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;
+
+@property (nonatomic, strong) UIView                    *commentContainer;
+@property (nonatomic, strong) UIButton                  *commentMoreBtn;
+
+@property (nonatomic, strong) UIView                    *footerView; //use to set cell height;
+
+@end
+
+@implementation SocialTableViewCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
+    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
+    if(self)
+    {
+        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
+    }
+    return self;
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    //[super setSelected:selected animated:animated];
+    // Configure the view for the selected state
+}
+
+- (void)initWidth:(CGFloat)cellWidth{
+    _avatarImg = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
+    [_avatarImg addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    [self addSubview:_avatarImg];
+    
+    CGFloat contentX = _avatarImg.right + 10;
+    
+    _nickTextView = [[UITextView alloc] initWithFrame:CGRectMake(contentX-5, 10, 200, 35)];
+    _nickTextView.backgroundColor = UIColor.clearColor;
+    _nickTextView.scrollEnabled = NO;
+    _nickTextView.editable = NO;
+    _nickTextView.textContainerInset = UIEdgeInsetsMake(7, 0, 0, 0);
+    _nickTextView.delegate = self;
+    _nickTextView.textAlignment = NSTextAlignmentLeft;
+    [self addSubview:_nickTextView];
+    
+    _msgTxtView = [[UITextView alloc] initWithFrame:CGRectMake(contentX-5, 35, cellWidth - 10 - contentX, 100)];
+    _msgTxtView.font = [UIFont systemFontOfSize:15];
+    _msgTxtView.userInteractionEnabled = NO;
+    [self addSubview:_msgTxtView];
+    
+    _picContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, _msgTxtView.bottom, cellWidth - 40 - contentX, 0)];
+    [self addSubview:_picContainer];
+    
+    _actionContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, _picContainer.bottom+5, cellWidth-contentX, 30)];
+    [self addSubview:_actionContainer];
+    
+    
+    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, _actionContainer.height)];
+    [_timeLabel setTextColor:UIColor.lightGrayColor];
+    [_timeLabel setFont:[UIFont systemFontOfSize:14]];
+    [_actionContainer addSubview:_timeLabel];
+    
+    CGFloat aBtnWidth = 55;
+    
+    _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_commentBtn setFrame:CGRectMake(_actionContainer.width-10-aBtnWidth, 0, aBtnWidth, _actionContainer.height)];
+    _commentBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [_commentBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_commentBtn setImage:[UIImage imageNamed:@"朋友圈_09"] forState:UIControlStateNormal];
+    [_commentBtn setTitle:@"评论" forState:UIControlStateNormal];
+    [_commentBtn addTarget:self action:@selector(onTouchComment:) forControlEvents:UIControlEventTouchUpInside];
+    [_actionContainer addSubview:_commentBtn];
+    
+    
+    _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_likeBtn setFrame:CGRectMake(_commentBtn.left-3-aBtnWidth, 0, aBtnWidth, _actionContainer.height)];
+    _likeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    [_likeBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [_likeBtn setImage:[UIImage imageNamed:@"朋友圈_06"] forState:UIControlStateNormal];
+    [_likeBtn addTarget:self action:@selector(onTouchLike:) forControlEvents:UIControlEventTouchUpInside];
+    [_actionContainer addSubview:_likeBtn];
+    
+    _viewsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_viewsBtn setFrame:CGRectMake(_likeBtn.left-3-aBtnWidth, 0, aBtnWidth, _actionContainer.height)];
+    _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];
+    
+    
+    _likesContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, 0, cellWidth - contentX - 10, 30)];
+    [_likesContainer setBackgroundColor:UIColorFromRGB(0xeeeeee)];
+    [self addSubview:_likesContainer];
+    
+    UIImageView *likeIcon = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 15, 15)];
+    [likeIcon setImage:[UIImage imageNamed:@"朋友圈_15"]];
+    [_likesContainer addSubview:likeIcon];
+    
+    _likeUserNames = [[UITextView alloc] initWithFrame:CGRectMake(30, 0, _likesContainer.width - 30 - 20, _likesContainer.height)];
+    [_likeUserNames setFont:[UIFont systemFontOfSize:14]];
+    [_likeUserNames setTextColor:UIColorFromRGB(0x4c82b0)];
+    _likeUserNames.backgroundColor = UIColor.clearColor;
+    _likeUserNames.scrollEnabled = NO;
+    _likeUserNames.editable = NO;
+    //_likeUserNames.selectable = NO;
+    //_likeUserNames.textContainer.lineFragmentPadding = 0;
+    _likeUserNames.textContainerInset = UIEdgeInsetsMake(7, 0, 0, 0);
+    _likeUserNames.delegate = self;
+    [_likesContainer addSubview:_likeUserNames];
+
+    _commentContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, 0, cellWidth - contentX - 10, 0)];
+    [_commentContainer setBackgroundColor:UIColorFromRGB(0xeeeeee)];
+    [self addSubview:_commentContainer];
+    
+    
+    
+    _commentMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [_commentMoreBtn setFrame:CGRectMake(contentX, 0, _commentContainer.width, 30)];
+    _commentMoreBtn.titleLabel.font = [UIFont systemFontOfSize:15];
+    _commentMoreBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
+    [_commentMoreBtn setTitleColor:UIColorFromRGB(0x4c82b0) forState:UIControlStateNormal];
+    _commentMoreBtn.contentEdgeInsets = UIEdgeInsetsMake(8, 10, 0, 0);
+    [_commentMoreBtn addTarget:self action:@selector(showAllComments:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:_commentMoreBtn];
+
+    
+    _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cellWidth, 0)];
+    [self addSubview:_footerView];
+}
+
+- (void)setData:(SocialItemData *)data{
+    
+    _data = data;
+    
+    [_avatarImg nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_team"]];
+    _avatarImg.tag = [data.userId intValue];
+
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:data.userId];
+    if(user)
+    {
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user"]];
+
+        
+        NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : data.userId;
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                               [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                               UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+        NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+        NSRange range = NSMakeRange(0, appendString.length);
+        [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+        _nickTextView.attributedText = appendString;
+    }
+    
+    
+    _msgTxtView.text = data.msg;
+    _msgTxtView.height = _msgTxtView.contentSize.height;
+    
+    _picContainer.top = _msgTxtView.bottom + 5;
+    
+    CGFloat picPadding = 5;
+    int columns = 3;
+    CGFloat picSize = (_picContainer.width - (columns - 1) * picPadding) / columns;
+    int i=0;
+    for(i=0; i<data.thumbArr.count; i++)
+    {
+        CGFloat startX = floorf(i%columns) * (picSize + picPadding);
+        CGFloat startY = floorf(i/columns) * (picSize + picPadding);
+        
+        UIImageView *imgView = nil;
+        if(i >= _picContainer.subviews.count)
+        {
+            imgView = [[UIImageView alloc] init];
+            imgView.userInteractionEnabled = YES;
+            [imgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchImage:)]];
+            [_picContainer addSubview:imgView];
+        }
+        else{
+            imgView = [_picContainer.subviews objectAtIndex:i];
+        }
+        
+        [imgView setHidden:NO];
+        [imgView setFrame:CGRectMake(startX, startY, picSize, picSize)];
+        NSURL *url = [NSURL URLWithString:[data.thumbArr objectAtIndex:i]];
+        [imgView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"聊天-_17"]];
+        [imgView setTag:i];
+    }
+    
+    for(int j=i; j<_picContainer.subviews.count; j++)
+    {
+        [[_picContainer.subviews objectAtIndex:j] setHidden:YES];
+    }
+    
+    _picContainer.top = _msgTxtView.bottom + 5;
+    
+    if(_data.thumbArr.count > 0)
+    {
+        int rows = ceilf((float)_data.thumbArr.count / (float)columns);
+        _picContainer.height = picSize * rows + picPadding * (rows - 1);
+        _actionContainer.top = _picContainer.bottom + 5;
+    }
+    else
+    {
+        _picContainer.height = 0;
+        _actionContainer.top = _msgTxtView.bottom + 5;
+    }
+    
+    [_timeLabel setText:_data.time];
+    [_viewsBtn setTitle:[NSString stringWithFormat:@"%d", _data.views] forState:UIControlStateNormal];
+    [_likeBtn setTitle:[NSString stringWithFormat:@"%d", _data.likes] forState:UIControlStateNormal];
+    
+    
+    [self setUpLikes];
+    [self setUpComments];
+    
+    self.height = _footerView.bottom + 10;
+    _data.cellHeight = self.height;
+}
+
+
+- (void)setUpLikes{
+
+    if(_data.likeArr.count > 0)
+    {
+        NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init];
+        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+
+        for(int i=0; i<_data.likeArr.count; i++)
+        {
+            NSString *userId = [_data.likeArr objectAtIndex:i];
+            NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+            if(!user)
+                continue;
+            
+            NSString *nick = user.userInfo.nickName ? user.userInfo.nickName : user.userId;
+            if(i>0)
+                nick = [NSString stringWithFormat:@",%@", nick];
+            
+            
+            NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+            
+            NSRange range = NSMakeRange(0, appendString.length);
+            [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+
+            [attrString appendAttributedString:appendString];
+        }
+        
+        _likeUserNames.attributedText = attrString;
+        [_likesContainer setHidden:NO];
+        _likesContainer.top = _actionContainer.bottom;
+        _footerView.top = _likesContainer.bottom;
+    }
+    else
+    {
+        [_likesContainer setHidden:YES];
+        _footerView.top = _actionContainer.bottom;
+    }
+    
+}
+
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
+{
+    if([textView isEqual:_likeUserNames] || [textView isEqual:_nickTextView])
+    {
+        [self showUserView:url.absoluteString];
+    }
+    else
+    {
+        [self replyTo:url.absoluteString];
+    }
+    return YES;
+}
+
+
+
+- (void)setUpComments{
+    
+    UIView *prevView = nil;
+    
+    float commentHeight = 0;
+    
+    int i=0;
+    for(i=0; i<_data.commentArr.count; i++)
+    {
+        UIView *commentView = nil;
+        if(_commentContainer.subviews && _commentContainer.subviews.count > i)
+        {
+            commentView = [_commentContainer.subviews objectAtIndex:i];
+            [commentView setHidden:NO];
+        }
+        
+        if(!commentView)
+        {
+            float startY = prevView ? prevView.bottom : 0;
+            commentView = [[UIView alloc] initWithFrame:CGRectMake(0, startY, _commentContainer.width, 0)];
+            [_commentContainer addSubview:commentView];
+            
+            NIMAvatarImageView *commentAvatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(5, 5, 20, 20)];
+            [commentView addSubview:commentAvatar];
+            
+            UITextView *commentTxt = [[UITextView alloc] initWithFrame:CGRectMake(commentAvatar.right, 0, commentView.width - commentAvatar.width, 0)];
+            commentTxt.delegate = self;
+            commentTxt.backgroundColor = UIColor.clearColor;
+//            commentTxt.scrollEnabled = NO;
+            commentTxt.editable = NO;
+            commentTxt.textContainerInset = UIEdgeInsetsMake(7, 5, 0, 5);
+            [commentView addSubview:commentTxt];
+        }
+        
+        SocialCommentData *commentData = [_data.commentArr objectAtIndex:i];
+        
+        //set comment avatar
+        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 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+        avatar.tag = [commentData.userId intValue];
+        
+        //set comment text content
+        UITextView *txt = [commentView.subviews objectAtIndex:1];
+        NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init];
+        if(commentData.replyId && ![commentData.replyId isEqualToString:@"0"] && ![commentData.replyId isEqualToString:@""])
+        {
+            //append sender name
+            NSString *userId = commentData.userId;
+            NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+            NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+            NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                                   [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                                   UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+            NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+            NSRange range = NSMakeRange(0, appendString.length);
+            [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+            [attrString appendAttributedString:appendString];
+            
+            //append reply label
+            attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                                   [UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+            appendString = [[NSMutableAttributedString alloc] initWithString:@" 回复 " attributes:attrs];
+            [attrString appendAttributedString:appendString];
+            
+            //append reply name
+            userId = commentData.replyId;
+            user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+            nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+            attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                     [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                     UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+            appendString = [[NSMutableAttributedString alloc] initWithString:user.userId attributes:attrs];
+            range = NSMakeRange(0, appendString.length);
+            [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+            [attrString appendAttributedString:appendString];
+            
+            //append comment
+            attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                     [UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+            appendString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", commentData.comment] attributes:attrs];
+            [attrString appendAttributedString:appendString];
+            
+            txt.attributedText = attrString;
+        }
+        else
+        {
+            //append sender name
+            NSString *userId = commentData.userId;
+            NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:userId];
+            NSString *nick = user && user.userInfo.nickName ? user.userInfo.nickName : userId;
+            NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                                   [UIFont systemFontOfSize:15.0], NSFontAttributeName,
+                                   UIColorFromRGB(0x4c82b0), NSForegroundColorAttributeName, nil];
+            NSMutableAttributedString *appendString = [[NSMutableAttributedString alloc] initWithString:nick attributes:attrs];
+            NSRange range = NSMakeRange(0, appendString.length);
+            [appendString addAttribute:NSLinkAttributeName value:user.userId range:range];
+            [attrString appendAttributedString:appendString];
+            
+            //append comment
+            attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+                     [UIFont systemFontOfSize:15.0], NSFontAttributeName, nil];
+            appendString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", commentData.comment] attributes:attrs];
+            [attrString appendAttributedString:appendString];
+            
+            txt.attributedText = attrString;
+        }
+        
+        
+        txt.height = txt.contentSize.height;
+        commentView.height = txt.contentSize.height;
+        
+        commentHeight += commentView.height;
+        
+        prevView = commentView;
+    }
+    
+    
+    for(int j=i; j<_commentContainer.subviews.count; j++)
+    {
+        [[_commentContainer.subviews objectAtIndex:j] setHidden:YES];
+    }
+    
+    
+    // set position
+    _commentContainer.top = _footerView.bottom;
+    if(commentHeight > 0)
+    {
+        [_commentContainer setHidden:NO];
+        
+        if(_data.comments > _data.commentArr.count)
+        {
+            [_commentMoreBtn setHidden:NO];
+            [_commentMoreBtn setTitle:[NSString stringWithFormat:@"所有%d条评论", _data.comments] forState:UIControlStateNormal];
+            _commentMoreBtn.top = _commentContainer.top + commentHeight;
+            commentHeight += _commentMoreBtn.height;
+        }
+        else
+        {
+            [_commentMoreBtn setHidden:YES];
+        }
+        
+        _commentContainer.height = commentHeight + 8;
+        _footerView.top = _commentContainer.bottom;
+    }
+    else
+    {
+        [_commentContainer setHidden:YES];
+        [_commentMoreBtn setHidden:YES];
+    }
+}
+
+
+
+
+
+- (void)showUserInfo:(int)sender{
+    
+    [User showUserInfo:_data.userId];
+    
+}
+
+- (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
+    
+    UIView *viewClicked = [gestureRecognizer view];
+    
+    [User showUserInfo:[NSString stringWithFormat:@"%ld", (long)viewClicked.tag]];
+}
+
+- (void)showUserView:(NSString *)userId{
+    
+    [User showUserInfo:_data.userId];
+    
+}
+
+
+- (void)onTouchLike:(int)sender{
+    
+    [[HttpRequest shared] socialLike:_data.socialId success:^(NSString * _Nullable socialId, int currentLikes) {
+        
+        if([_data.socialId isEqualToString:socialId])
+        {
+            _data.likes = currentLikes;
+            [self setData:_data];
+        }
+        
+    } failure:^{
+        
+    }];
+}
+
+- (void)onTouchComment:(int)sender{
+    _replyId = @"";
+    _textFiled.text = @"";
+    [_textFiled becomeFirstResponder];
+}
+
+- (void)replyTo:(NSString *)userId{
+    NSLog(@"replyTo  %@", userId);
+    _replyId = userId;
+    _textFiled.text = @"";
+    [_textFiled becomeFirstResponder];
+}
+
+- (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{
+    
+    NSLog(@"show all comments");
+    
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    SocialDetailViewController *next = (SocialDetailViewController *)[board instantiateViewControllerWithIdentifier:@"SocialDetail"];
+    [next setSocialData:_data];
+    [self.viewController.navigationController pushViewController:next animated:YES];
+}
+
+
+- (void)onTouchImage:(UITapGestureRecognizer *)gestureRecognizer{
+
+    UIView *viewClicked = [gestureRecognizer view];
+    
+    NSLog(@"show image %ld", (long)viewClicked.tag);
+    
+    
+    ImagePagerViewController *imagePageVC = [[ImagePagerViewController alloc] init];
+    [imagePageVC setImages:_data.picArr thumbs:_data.thumbArr startIndex:(int)viewClicked.tag];
+
+    [self.viewController.navigationController pushViewController:imagePageVC animated:YES];
+}
+
+@end

+ 13 - 0
NIMDemo/NIMDemo/SocialTableViewController.h

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

+ 217 - 0
NIMDemo/NIMDemo/SocialTableViewController.m

@@ -0,0 +1,217 @@
+//
+//  SocialTableViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/6/20.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "SocialTableViewController.h"
+#import "SocialPublishViewController.h"
+#import "SocialTableViewCell.h"
+#import "HttpRequest.h"
+#import "UIView+NTES.h"
+
+@interface SocialTableViewController () <UIScrollViewDelegate>
+
+@property (nonatomic, strong) NSMutableArray    *dataList;
+@property (nonatomic, assign) BOOL              isFetching;
+@property (nonatomic, assign) BOOL              flagRefresh;
+
+@end
+
+@implementation SocialTableViewController
+
+- (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;
+    _flagRefresh = NO;
+    [self fetchDataList];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    
+    UINavigationItem *navItem = self.parentViewController.navigationItem;
+    
+    navItem.title = @"朋友圈";
+    
+    UIButton *emptyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [emptyBtn setTitle:@"" forState:UIControlStateNormal];
+    [emptyBtn sizeToFit];
+    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:emptyBtn];
+    
+    [navItem setLeftBarButtonItems:@[leftItem]];
+    
+    UIButton *publishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [publishBtn setTitle:@"发布" forState:UIControlStateNormal];
+    [publishBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [publishBtn addTarget:self action:@selector(onTouchPublish:) forControlEvents:UIControlEventTouchUpInside];
+    [publishBtn sizeToFit];
+    
+    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:publishBtn];
+    [navItem setRightBarButtonItems:@[rightItem]];
+}
+
+
+- (void)fetchDataList{
+    
+    if(_isFetching)
+        return;
+    
+    _isFetching = YES;
+    
+    NSString *lastId = nil;
+    if(self.dataList && self.dataList.count){
+        SocialItemData *lastData = [self.dataList lastObject];
+        lastId = lastData.socialId;
+    }
+        
+    
+    [[HttpRequest shared] getSocialDataList:lastId success:^(NSMutableArray *dataList) {
+        if(!self.dataList)
+            self.dataList = dataList;
+        else
+            [self.dataList addObjectsFromArray:dataList];
+        
+        [self.tableView reloadData];
+        
+        _isFetching = NO;
+    } failure:^{
+        _isFetching = NO;
+    }];
+}
+
+
+#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;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    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];
+    
+    return cell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    SocialItemData *data = [self.dataList objectAtIndex:indexPath.row];
+    return data.cellHeight;
+}
+
+/*
+// Override to support conditional editing of the table view.
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+    // Return NO if you do not want the specified item to be editable.
+    return YES;
+}
+*/
+
+/*
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+    if (editingStyle == UITableViewCellEditingStyleDelete) {
+        // Delete the row from the data source
+        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
+        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
+    }   
+}
+*/
+
+/*
+// Override to support rearranging the table view.
+- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
+}
+*/
+
+/*
+// Override to support conditional rearranging of the table view.
+- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
+    // Return NO if you do not want the item to be re-orderable.
+    return YES;
+}
+*/
+
+/*
+#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.
+}
+*/
+
+
+
+- (void)onTouchPublish:(int)sender
+{
+    UIViewController *vc = [[SocialPublishViewController alloc] init];
+    [self.navigationController pushViewController:vc animated:YES];
+}
+
+
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
+    //康海涛测试Ok的
+    CGPoint offset1 = scrollView.contentOffset;
+    CGRect bounds1 = scrollView.bounds;
+    CGSize size1 = scrollView.contentSize;
+    UIEdgeInsets inset1 = scrollView.contentInset;
+    float y1 = offset1.y + bounds1.size.height - inset1.bottom;
+    float h1 = size1.height;
+    
+    //NSLog(@"%f %f %i %f", y1, h1, _flagRefresh, bounds1.size.height);
+    
+    if(h1 < bounds1.size.height)
+        return;
+    
+    if (y1 > h1 + 50) {
+        _flagRefresh = YES;
+    }
+    else if (y1 == h1) {
+        if(_flagRefresh)
+        {
+            _flagRefresh = NO;
+            NSLog(@"下拉刷新");
+            [self fetchDataList];
+        }
+    }
+    
+}
+
+@end

+ 1 - 1
NIMDemo/NIMDemo/Supporting Files/nim_debug.xcconfig

@@ -6,6 +6,6 @@
 //  Copyright © 2015 Netease. All rights reserved.
 //
 
-XCCONFIG_BUNDLE_ID                  = com.dashgame.whosay.dev
+XCCONFIG_BUNDLE_ID                  = com.sheishuo.apptest
 XCCONFIG_BUNDLE_NAME                = 谁说开发版
 

+ 1 - 1
NIMDemo/NIMDemo/Supporting Files/nim_release.xcconfig

@@ -6,5 +6,5 @@
 //  Copyright © 2015 Netease. All rights reserved.
 //
 
-XCCONFIG_BUNDLE_ID                  = com.dashgame.whosay
+XCCONFIG_BUNDLE_ID                  = com.sheishuo.app
 XCCONFIG_BUNDLE_NAME                = 谁说

+ 17 - 2
NIMDemo/NIMDemo/User.h

@@ -38,8 +38,15 @@
 
 
 
+@property (nonatomic, strong) NSMutableArray *picArr;
+@property (nonatomic, strong) NSMutableArray *thumbArr;
+
+
+@property (nonatomic, nullable, strong) NSString *currentChatRoomId;
+
 
 + (UIColor *_Nonnull)greenColor;
++ (UIColor *_Nonnull)orangeColor;
 
 
 - (void)login:(NSString *_Nonnull)mobile
@@ -55,7 +62,7 @@
          teamId:(NSString *_Nullable)teamId
        targetId:(NSString *_Nullable)targetId
             msg:(NSString *_Nullable)msg
-        success:(void (^_Nullable)(NSString * _Nullable info))sucCallBack
+        success:(void (^_Nullable)(NSString * _Nullable giftId, NSString * _Nullable info))sucCallBack
         failure:(void (^_Nullable)(NSError * _Nullable error))failCallBack;
 
 - (void)requestGif:(NSString *_Nullable)senderId
@@ -64,9 +71,17 @@
            success:(void (^_Nullable)(NSMutableArray * _Nonnull giftArr))sucCallBack
            failure:(void (^_Nullable)(NSError * _Nullable error))failCallBack;
 
-- (BOOL)isNewGiftGot:(NSString *)key dataId:(NSString *)dataId;
+
+- (BOOL)isNewGiftGot:(NSString *_Nonnull)key dataId:(NSString *_Nullable)dataId;
+- (void)initGiftGot:(NSString *_Nullable)key dataId:(NSString *_Nullable)dataId;
 
 - (GiftData *_Nullable)getGiftData:(NSString *_Nonnull)giftId;
 
 
+
+
++ (NSString *_Nonnull)distance:(double)originLat originLng:(double)originLng targetLat:(double)targetLat targetLng:(double)targetLng;
+
++ (void)showUserInfo:(NSString *_Nullable)userId;
+
 @end

+ 52 - 19
NIMDemo/NIMDemo/User.m

@@ -21,7 +21,7 @@
 
 int newCreateTeamId;
 
-+ (UIColor *)greenColor;
++ (UIColor *)greenColor
 {
     static UIColor *greenColor = nil;
     static dispatch_once_t onceToken;
@@ -31,6 +31,15 @@ int newCreateTeamId;
     return greenColor;
 }
 
++ (UIColor *)orangeColor{
+    static UIColor *orangeColor = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        orangeColor = [UIColor colorWithRed:(255.0 / 255.0) green:(171.0 / 255.0) blue:(8.0 / 255.0) alpha:1.0];
+    });
+    return orangeColor;
+}
+
 + (instancetype)sharedInfo
 {
     static User *sharedInfo = nil;
@@ -42,6 +51,29 @@ int newCreateTeamId;
     return sharedInfo;
 }
 
+
+
++ (NSString *_Nonnull)distance:(double)originLat originLng:(double)originLng targetLat:(double)targetLat targetLng:(double)targetLng{
+    
+    double pow1 = pow(sin((targetLat*M_PI/180 - originLat*M_PI/180)/2), 2);
+    double pow2 = pow(sin((targetLng*M_PI/180 - originLng*M_PI/180)/2), 2);
+    double cos2 = cos(targetLat*M_PI/180) * cos(originLat*M_PI/180);
+    double dis = round(6378.138 * 2 * asin(sqrt(pow1 + cos2 * pow2))*1000);
+    
+    if(dis > 1000)
+        return [NSString stringWithFormat:@"%.1FKM", dis/1000];
+    
+    return [NSString stringWithFormat:@"%.0fM", dis];
+}
+
++ (void)showUserInfo:(NSString *)userId{
+    
+    NSLog(@"showUserInfo %@", userId);
+    
+}
+
+
+
 - (void)login:(NSString *)mobile
           pwd:(NSString *)pwd
   sucCallBack:(void (^_Nullable)())sucCallBack
@@ -163,26 +195,26 @@ int newCreateTeamId;
 - (BOOL)isNewGiftGot:(NSString *)key dataId:(NSString *)dataId
 {
     NSString *existDataId = [self.giftGotDict objectForKey:key];
-    if(existDataId)
+    int existId = existDataId ? [existDataId intValue] : 0;
+    int currentId = [dataId intValue];
+    if(currentId > existId)
     {
-        if(![existDataId isEqualToString:dataId])
-        {
-            [self.giftGotDict setValue:dataId forKey:key];
-            return YES;
-        }
+        [self.giftGotDict setValue:[NSString stringWithFormat:@"%d", currentId] forKey:key];
+        return YES;
     }
-    else
+    
+    return NO;
+}
+
+- (void)initGiftGot:(NSString *)key dataId:(NSString *)dataId
+{
+    NSString *existDataId = [self.giftGotDict objectForKey:key];
+    int existId = existDataId ? [existDataId intValue] : 0;
+    int currentId = [dataId intValue];
+    if(currentId > existId)
     {
-        if(dataId)
-        {
-            [self.giftGotDict setValue:dataId forKey:key];
-        }
-        else
-        {
-            [self.giftGotDict setValue:@"" forKey:key];
-        }
+        [self.giftGotDict setValue:[NSString stringWithFormat:@"%d", currentId] forKey:key];
     }
-    return NO;
 }
 
 
@@ -210,7 +242,7 @@ int newCreateTeamId;
          teamId:(NSString *_Nullable)teamId
        targetId:(NSString *_Nullable)targetId
             msg:(NSString *_Nullable)msg
-        success:(void (^_Nullable)(NSString * _Nullable info))sucCallBack
+        success:(void (^_Nullable)(NSString * _Nullable giftId, NSString * _Nullable info))sucCallBack
         failure:(void (^_Nullable)(NSError * _Nullable error))failCallBack
 {
     
@@ -249,8 +281,9 @@ int newCreateTeamId;
         wself.coin -= price;
         
         NSString *info = [data objectForKey:@"info"];
+        NSString *giftId = [data objectForKey:@"id"];
         
-        sucCallBack(info);
+        sucCallBack(giftId, info);
         
     } failure:^(NSURLSessionDataTask *task, NSError * error) {
         NSLog(@"请求失败,服务器返回的错误信息%@",error);

+ 0 - 3
NIMDemo/NIMDemo/ViewController.m

@@ -36,9 +36,6 @@
     [super viewWillAppear:animated];
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     [appDelegate noNavBar:self];
-    
-    
-    
 }
 
 -(void) viewDidAppear:(BOOL)animated{

+ 4 - 1
NIMDemo/Pods/Toast/Toast/Toast/UIView+Toast.m

@@ -132,7 +132,7 @@ static const NSString * CSToastQueueKey             = @"CSToastQueueKey";
 
 - (void)cs_showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)position {
     toast.center = [self cs_centerPointForPosition:position withToast:toast];
-    toast.alpha = 0.0;
+    toast.alpha = 1.0;
     
     if ([CSToastManager isTapToDismissEnabled]) {
         UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cs_handleToastTapped:)];
@@ -155,6 +155,9 @@ static const NSString * CSToastQueueKey             = @"CSToastQueueKey";
                          [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
                          objc_setAssociatedObject(toast, &CSToastTimerKey, timer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
                      }];
+    
+    NSLog(@"%f %f %f %f", toast.bounds.origin.x, toast.bounds.origin.y, toast.bounds.size.width, toast.bounds.size.height);
+    NSLog(@"%f %f", toast.center.x, toast.center.y);
 }
 
 - (void)cs_hideToast:(UIView *)toast {

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

@@ -108,6 +108,7 @@
 		B2AE4FAD95BEBA7C7F466FF6 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A20B4DDFBE95B5A45FD742F5 /* libcrypto.a */; };
 		BDEF44778342E8508CD2214A /* NIMSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 343C48179E89F3CDB6D1EBD0 /* NIMSDK.framework */; };
 		C01F4353A19B845A75054965 /* libopus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9B4ACE8E4B6986E4BC851B /* libopus.a */; };
+		C482C2F81F09DB6D00EF2B71 /* TradeInputContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C482C2F71F09DB6D00EF2B71 /* TradeInputContainer.m */; };
 		C4B7C4931EEE90A8001CEA87 /* GiftInputContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C4B7C4921EEE90A8001CEA87 /* GiftInputContainer.m */; };
 		C4B7C4971EEEA9B6001CEA87 /* GiftInputButton.m in Sources */ = {isa = PBXBuildFile; fileRef = C4B7C4961EEEA9B6001CEA87 /* GiftInputButton.m */; };
 		C5354972B4A7419E04058CF6 /* NIMAVChat.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AAB4EA99569F4B8975DDD9A /* NIMAVChat.framework */; };
@@ -349,6 +350,8 @@
 		A20B4DDFBE95B5A45FD742F5 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = ./NIMKit/Vendors/NIMSDK/Libs/libcrypto.a; sourceTree = SOURCE_ROOT; };
 		B51C478E952C10698C9437C1 /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = ./NIMKit/Vendors/NIMSDK/Libs/libssl.a; sourceTree = SOURCE_ROOT; };
 		BC8242AE825D231FFC920107 /* libevent.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libevent.a; path = ./NIMKit/Vendors/NIMSDK/Libs/libevent.a; sourceTree = SOURCE_ROOT; };
+		C482C2F61F09DB6D00EF2B71 /* TradeInputContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TradeInputContainer.h; sourceTree = "<group>"; };
+		C482C2F71F09DB6D00EF2B71 /* TradeInputContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TradeInputContainer.m; sourceTree = "<group>"; };
 		C4B7C4911EEE90A8001CEA87 /* GiftInputContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftInputContainer.h; sourceTree = "<group>"; };
 		C4B7C4921EEE90A8001CEA87 /* GiftInputContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftInputContainer.m; sourceTree = "<group>"; };
 		C4B7C4951EEEA9B6001CEA87 /* GiftInputButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftInputButton.h; sourceTree = "<group>"; };
@@ -828,6 +831,8 @@
 				C4B7C4921EEE90A8001CEA87 /* GiftInputContainer.m */,
 				C4B7C4951EEEA9B6001CEA87 /* GiftInputButton.h */,
 				C4B7C4961EEEA9B6001CEA87 /* GiftInputButton.m */,
+				C482C2F61F09DB6D00EF2B71 /* TradeInputContainer.h */,
+				C482C2F71F09DB6D00EF2B71 /* TradeInputContainer.m */,
 			);
 			path = Input;
 			sourceTree = "<group>";
@@ -1087,6 +1092,7 @@
 				61D99FDA1BAFF6190059D369 /* NIMTeamCardOperationItem.m in Sources */,
 				61D99FC91BAFF48A0059D369 /* NIMTeamAnnouncementListCell.m in Sources */,
 				61E44E251DD2D1040086C7B2 /* NIMKitEvent.m in Sources */,
+				C482C2F81F09DB6D00EF2B71 /* TradeInputContainer.m in Sources */,
 				61D99FCB1BAFF48A0059D369 /* NIMTeamSwitchTableViewCell.m in Sources */,
 				61E44E271DD2D1040086C7B2 /* NIMMessageModel.m in Sources */,
 				61D99FB11BAFF4770059D369 /* NIMCreateTeamAnnouncement.m in Sources */,

+ 1 - 0
NIMKit/NIMKit/Classes/Sections/Common/NIMPageView.m

@@ -65,6 +65,7 @@
     
     CGSize size = self.bounds.size;
     [self.scrollView setContentSize:CGSizeMake(size.width * [self.pages count], size.height)];
+    
     for (NSInteger i = 0; i < [self.pages count]; i++)
     {
         id obj = [self.pages objectAtIndex:i];

+ 4 - 0
NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.h

@@ -9,6 +9,7 @@
 #import <UIKit/UIKit.h>
 #import "NIMPageView.h"
 #import "GiftInputButton.h"
+#import "TradeInputContainer.h"
 
 @interface GiftData : NSObject
 @property (nonatomic,strong)    NSString    *giftId;
@@ -34,10 +35,13 @@
 @property (nonatomic, strong)  UILabel          *balanceLabel;
 @property (nonatomic, weak) id<GiftDataSourceDelegate> delegate;
 
+@property (nonatomic, strong) TradeInputContainer           *tradeContainer;
+
 @property (nonatomic, assign)  BOOL             layoutHold;
 
 - (void)setBalance:(int)balance;
 - (void)initGiftList:(NSMutableArray *)dataList;
 - (void)setTeamId:(NSString *)teamId;
+- (void)tradePublished;
 
 @end

+ 116 - 1
NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m

@@ -15,9 +15,13 @@
 #import "NIMContactSelectConfig.h"
 #import "NIMContactSelectViewController.h"
 
+
 NSInteger GiftPageControlHeight = 20;
 NSInteger GiftPageViewHeight    = 162;
 
+NSInteger TradeTypeSupply = 1;
+NSInteger TradeTypeDemand = 2;
+
 @implementation GiftData
 @end
 
@@ -41,6 +45,10 @@ NSInteger GiftPageViewHeight    = 162;
 @property (nonatomic, strong) NSString                      *currentTeamId;
 @property (nonatomic, assign) int                           currentBalance;
 
+
+@property (nonatomic, strong) UIButton                      *supplyBtn;
+@property (nonatomic, strong) UIButton                      *demandBtn;
+
 @end
 
 @implementation GiftInputContainer
@@ -136,10 +144,28 @@ NSInteger GiftPageViewHeight    = 162;
     [self addSubview:sep1];
     
     
+    _demandBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _demandBtn.frame = CGRectMake(self.nim_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];
+    [self addSubview:_demandBtn];
     
     
+    _supplyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _supplyBtn.frame = CGRectMake(self.nim_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];
+    [self addSubview:_supplyBtn];
     
-    UIView *sep2 = [[UIView alloc] initWithFrame:CGRectMake(0, 90, self.nim_width, .5)];
+    
+    
+    UIView *sep2 = [[UIView alloc] initWithFrame:CGRectMake(0, 89, self.nim_width, .5)];
     sep2.backgroundColor = UIColor.lightGrayColor;
     [self addSubview:sep2];
     
@@ -251,6 +277,20 @@ NSInteger GiftPageViewHeight    = 162;
     sendOutBtn.backgroundColor = [UIColor colorWithRed:(255.0 / 255.0) green:(171.0 / 255.0) blue:(8.0 / 255.0) alpha:1.0];
     [sendOutBtn addTarget:self action:@selector(sendGift:) forControlEvents:UIControlEventTouchUpInside];
     [_sendGiftView addSubview:sendOutBtn];
+    
+    
+    
+    
+    
+    
+    
+    
+    //trade part
+    _tradeContainer = [[TradeInputContainer alloc] initWithFrame:CGRectMake(0, 90, self.nim_width, GiftPageViewHeight+GiftPageControlHeight)];
+    [_tradeContainer setHidden:YES];
+    [self addSubview:_tradeContainer];
+    
+    
 }
 
 
@@ -420,6 +460,12 @@ NSInteger GiftPageViewHeight    = 162;
     _countLabel.text = [NSString stringWithFormat:@"x%.0f", roundf(_slider.value)];
 }
 
+
+- (BOOL)layoutHold{
+    return _layoutHold || _tradeContainer.layoutHold;
+}
+
+
 - (void)onTouchAvatar:(int)sender{
     _layoutHold = YES;
     __weak typeof(self) wself = self;
@@ -489,4 +535,73 @@ NSInteger GiftPageViewHeight    = 162;
     [self hideGiftInfo:0];
     [self setHidden:YES];
 }
+
+
+
+- (void)toggleDemand:(int)sender{
+    
+    if(_tradeContainer.isHidden)
+    {
+        [_tradeContainer setHidden:NO];
+        _tradeContainer.tradeType = (int)TradeTypeDemand;
+        [_tradeContainer reset];
+        [_demandBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+        [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        [self hideGiftInfo:0];
+    }
+    else
+    {
+        if(_tradeContainer.tradeType != (int)TradeTypeDemand)
+        {
+            _tradeContainer.tradeType = (int)TradeTypeDemand;
+            [_demandBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+            [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        }
+        else
+        {
+            _tradeContainer.tradeType = 0;
+            [_tradeContainer setHidden:YES];
+            [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+            [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        }
+    }
+}
+
+- (void)toggleSupply:(int)sender{
+    if(_tradeContainer.isHidden)
+    {
+        [_tradeContainer setHidden:NO];
+        _tradeContainer.tradeType = (int)TradeTypeSupply;
+        [_tradeContainer reset];
+        [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+        [self hideGiftInfo:0];
+    }
+    else
+    {
+        if(_tradeContainer.tradeType != (int)TradeTypeSupply)
+        {
+            _tradeContainer.tradeType = (int)TradeTypeSupply;
+            [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+            [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
+        }
+        else
+        {
+            _tradeContainer.tradeType = 0;
+            [_tradeContainer setHidden:YES];
+            [_demandBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+            [_supplyBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        }
+    }
+}
+
+
+
+- (void)tradePublished{
+    
+    [_tradeContainer setHidden:YES];
+    [self hideGiftInfo:0];
+    [self setHidden:YES];
+    
+}
 @end

+ 27 - 0
NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.h

@@ -0,0 +1,27 @@
+//
+//  TradeInputContainer.h
+//  NIMKit
+//
+//  Created by Fenix Wang on 2017/7/2.
+//  Copyright © 2017年 NetEase. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@protocol TradeInputDelegate <NSObject>
+
+- (void)sendTrade:(NSString *)msg picArr:(NSMutableArray *)picArr priority:(int)priority type:(int)type;
+
+@end
+
+
+@interface TradeInputContainer : UIView
+
+@property (nonatomic, weak) id<TradeInputDelegate>  delegate;
+@property (nonatomic, assign) int                   tradeType;
+@property (nonatomic, assign) BOOL                  layoutHold;
+
+- (void)reset;
+
+@end

+ 263 - 0
NIMKit/NIMKit/Classes/Sections/Input/TradeInputContainer.m

@@ -0,0 +1,263 @@
+//
+//  TradeInputContainer.m
+//  NIMKit
+//
+//  Created by Fenix Wang on 2017/7/2.
+//  Copyright © 2017年 NetEase. All rights reserved.
+//
+
+#import "TradeInputContainer.h"
+#import "NIMGrowingTextView.h"
+#import "UIView+NIM.h"
+#import <NIMSDK/NIMSDK.h>
+#import "NIMKitMediaFetcher.h"
+#import "SVProgressHUD.h"
+
+
+@interface TradeInputContainer()<NIMGrowingTextViewDelegate, UIScrollViewDelegate>
+
+@property (nonatomic, strong) UILabel               *countLabel;
+@property (nonatomic, strong) UIButton              *countBtn;
+@property (nonatomic, strong) UISlider              *slider;
+@property (nonatomic, strong) UIView                *textViewContainer;
+@property (nonatomic, strong) UIView                *textViewBg;
+@property (nonatomic, strong) NIMGrowingTextView    *growTextView;
+@property (nonatomic, strong) UIButton              *sendBtn;
+@property (nonatomic, strong) UIScrollView          *picContainer;
+@property (nonatomic, strong) UIButton              *picAddBtn;
+
+
+@property (nonatomic, strong) NSMutableArray        *picArr;
+@property (nonatomic, strong) NSMutableArray        *imgViewArr;
+@property (nonatomic, strong) NSMutableArray        *picDataArr;
+@property (nonatomic, assign) int                   picUploadIndex;
+@property (nonatomic, strong) NIMKitMediaFetcher    *mediaFetcher;
+
+@end
+
+@implementation TradeInputContainer
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    if (self = [super initWithFrame:frame]) {
+        [self loadUIComponents];
+    }
+    return self;
+}
+
+- (void)loadUIComponents{
+    
+    _layoutHold = NO;
+    _imgViewArr = [[NSMutableArray alloc] init];
+    
+    UIButton *btn                  = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.nim_width, self.nim_height)];
+    btn.backgroundColor = UIColor.whiteColor;
+    [btn setTitle:@"" forState:UIControlStateNormal];
+    [self addSubview:btn];
+    
+    _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nim_width - 150, 5, 100, 40)];
+    _countLabel.textAlignment = NSTextAlignmentRight;
+    [self addSubview:_countLabel];
+    
+    UIButton *countBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    countBtn.frame = CGRectMake(self.nim_width - 50, 5, 30, 30);
+    [countBtn setImage:[UIImage imageNamed:@"箭头_下"] forState:UIControlStateNormal];
+    [countBtn addTarget:self action:@selector(toggleSlider:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:countBtn];
+    
+    _slider = [[UISlider alloc] initWithFrame:CGRectMake(10, 40, self.nim_width-20, 40)];
+    _slider.minimumValue = 1;
+    _slider.maximumValue = 100;
+    _slider.value = 1;
+    [_slider addTarget:self
+                action:@selector(sliderValueChanged)
+      forControlEvents:UIControlEventValueChanged
+     ];
+    [self addSubview:_slider];
+    
+    
+    _textViewContainer = [[UIView alloc] initWithFrame:CGRectMake(10, 80, self.nim_width-20, 40)];
+    [self addSubview:_textViewContainer];
+    
+    _textViewBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _textViewContainer.nim_width-80, 40)];
+    _textViewBg.layer.cornerRadius = 20;
+    _textViewBg.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
+    [_textViewContainer addSubview:_textViewBg];
+    
+    _growTextView = [[NIMGrowingTextView alloc] initWithFrame:CGRectMake(10, 0, _textViewContainer.nim_width-100, 40)];
+    _growTextView.textViewDelegate = self;
+    _growTextView.font = [UIFont systemFontOfSize:14.0f];
+    _growTextView.maxNumberOfLines = 1;
+    _growTextView.minNumberOfLines = 1;
+    _growTextView.textColor = [UIColor blackColor];
+    _growTextView.backgroundColor = [UIColor clearColor];
+    _growTextView.returnKeyType = UIReturnKeyDone;
+    [_textViewContainer addSubview:_growTextView];
+    
+    _sendBtn = [[UIButton alloc] initWithFrame:CGRectMake(_textViewContainer.nim_width-75, 0, 75, 40)];
+    _sendBtn.layer.cornerRadius = 20;
+    _sendBtn.backgroundColor = [UIColor colorWithRed:(255.0 / 255.0) green:(171.0 / 255.0) blue:(8.0 / 255.0) alpha:1.0];
+    [_sendBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
+    [_sendBtn setTitle:@"发送" forState:UIControlStateNormal];
+    [_sendBtn addTarget:self action:@selector(onTouchPublish:) forControlEvents:UIControlEventTouchUpInside];
+    [_textViewContainer addSubview:_sendBtn];
+    
+    _picContainer = [[UIScrollView alloc] initWithFrame:CGRectMake(10, self.nim_height-55, self.nim_width-20, 50)];
+    [self addSubview:_picContainer];
+    
+    _picAddBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _picAddBtn.frame = CGRectMake(_picContainer.nim_right+5, _picContainer.nim_top, 10, 10);
+    [_picAddBtn setImage:[UIImage imageNamed:@"帮助与反馈_03"] forState:UIControlStateNormal];
+    [_picAddBtn addTarget:self action:@selector(onTouchPicAdd:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:_picAddBtn];
+}
+
+
+- (void)reset{
+    _picArr = [[NSMutableArray alloc] init];
+    _picDataArr = [[NSMutableArray alloc] init];
+    _growTextView.text = @"";
+    _slider.value = 1;
+    [self sliderValueChanged];
+    
+    [self layoutPictures];
+}
+
+
+- (void)toggleSlider:(int)sender{
+    _slider.hidden = !_slider.isHidden;
+}
+
+- (void)sliderValueChanged{
+    _countLabel.text = [NSString stringWithFormat:@"x%.0f", roundf(_slider.value)];
+}
+
+- (void)didChangeHeight:(CGFloat)height
+{
+    NSLog(@"height changed %f", height);
+    _textViewBg.nim_height = height + 4;
+}
+
+- (BOOL)shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
+{
+    if ([text isEqualToString:@"\n"]) {
+        [_growTextView resignFirstResponder];
+        return NO;
+    }
+    return YES;
+}
+
+
+
+
+- (void)layoutPictures
+{
+    int maxCountPictures = 9;
+    CGFloat picPadding = 2;
+    float picSize = (self.nim_width - 20 - picPadding * (maxCountPictures - 1)) / maxCountPictures;
+    
+    CGFloat startX = 0;
+    
+    int count = (int)_picArr.count;
+    int i = 0;
+    for(i=0; i<count; i++){
+        startX = i * (picSize + picPadding);
+        
+        UIImageView *imgView = nil;
+        if(i >= _imgViewArr.count){
+            imgView = [[UIImageView alloc] initWithFrame:CGRectMake(startX, 0, picSize, picSize)];
+            [_picContainer addSubview:imgView];
+            [_imgViewArr addObject:imgView];
+        }
+        else{
+            imgView = [_imgViewArr objectAtIndex:i];
+            imgView.nim_left = startX;
+        }
+        
+        UIImage *img = [_picArr objectAtIndex:i];
+        [imgView setImage:img];
+        [imgView setHidden:NO];
+    }
+    
+    if(i < _imgViewArr.count)
+    {
+        for(int j=i; j<_imgViewArr.count; j++)
+        {
+            [[_imgViewArr objectAtIndex:j] setHidden:YES];
+        }
+    }
+    
+    _picContainer.nim_width = _picArr.count * (picSize + picPadding);
+    _picAddBtn.nim_left = _picContainer.nim_right + 5;
+    _picAddBtn.nim_width = picSize;
+    _picAddBtn.nim_height = picSize;
+    
+    if(count < maxCountPictures)
+    {
+        _picAddBtn.hidden = NO;
+    }
+    else
+    {
+        _picAddBtn.hidden = YES;
+    }
+}
+
+
+- (void)onTouchPicAdd:(int)sender{
+    [self showImagePicker:UIImagePickerControllerSourceTypePhotoLibrary];
+}
+
+
+- (NIMKitMediaFetcher *)mediaFetcher
+{
+    if (!_mediaFetcher) {
+        _mediaFetcher = [[NIMKitMediaFetcher alloc] init];
+    }
+    return _mediaFetcher;
+}
+
+- (void)showImagePicker:(UIImagePickerControllerSourceType)type{
+    
+    __weak typeof(self) weakSelf = self;
+    _layoutHold = YES;
+    [self.mediaFetcher fetchPhotoFromLibrary:^(NSArray *images, NSString *path, PHAssetMediaType type) {
+        
+        _layoutHold = NO;
+        
+        switch (type) {
+            case PHAssetMediaTypeImage:
+            {
+                for (UIImage *image in images) {
+                    [weakSelf.picArr addObject:image];
+                }
+                [weakSelf layoutPictures];
+            }
+                break;
+            case PHAssetMediaTypeVideo:
+            {
+            }
+                break;
+            default:
+                return;
+        }
+        
+    }];
+}
+
+- (void)onTouchPublish:(int)sender{
+    
+    if (self.delegate && [self.delegate respondsToSelector:@selector(sendTrade:picArr:priority:type:)]) {
+        
+        int count = (int)roundf(_slider.value);
+        [self.delegate sendTrade:_growTextView.text picArr:_picArr priority:count type:self.tradeType];
+        
+    }
+
+}
+
+
+
+
+
+
+@end