Fenix Wang пре 8 година
родитељ
комит
33ac8d75e0
65 измењених фајлова са 4036 додато и 262 уклоњено
  1. BIN
      NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/UserInterfaceState.xcuserstate
  2. 48 0
      NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 90 2
      NIMDemo/NIMDemo.xcodeproj/project.pbxproj
  4. 16 0
      NIMDemo/NIMDemo/AddFriendViewController.h
  5. 70 0
      NIMDemo/NIMDemo/AddFriendViewController.m
  6. 1024 55
      NIMDemo/NIMDemo/Base.lproj/Main.storyboard
  7. 15 0
      NIMDemo/NIMDemo/ChatConfigViewController.h
  8. 182 0
      NIMDemo/NIMDemo/ChatConfigViewController.m
  9. 1 1
      NIMDemo/NIMDemo/Classes/Sections/Contact/View/NTESContactDataCell.m
  10. 2 0
      NIMDemo/NIMDemo/Classes/Sections/Contact/View/NTESContactUtilItem.h
  11. 22 5
      NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m
  12. 15 0
      NIMDemo/NIMDemo/ComplainDetailViewController.h
  13. 88 0
      NIMDemo/NIMDemo/ComplainDetailViewController.m
  14. 15 0
      NIMDemo/NIMDemo/ComplainViewController.h
  15. 106 0
      NIMDemo/NIMDemo/ComplainViewController.m
  16. 16 0
      NIMDemo/NIMDemo/ContactTableViewCell.h
  17. 137 0
      NIMDemo/NIMDemo/ContactTableViewCell.m
  18. 21 0
      NIMDemo/NIMDemo/ContactViewController.h
  19. 181 0
      NIMDemo/NIMDemo/ContactViewController.m
  20. 15 0
      NIMDemo/NIMDemo/FriendListTableViewCell.h
  21. 69 0
      NIMDemo/NIMDemo/FriendListTableViewCell.m
  22. 19 0
      NIMDemo/NIMDemo/FriendListViewController.h
  23. 255 0
      NIMDemo/NIMDemo/FriendListViewController.m
  24. 25 0
      NIMDemo/NIMDemo/FriendRequestTableViewCell.h
  25. 88 0
      NIMDemo/NIMDemo/FriendRequestTableViewCell.m
  26. 21 0
      NIMDemo/NIMDemo/FriendRequestViewController.h
  27. 126 0
      NIMDemo/NIMDemo/FriendRequestViewController.m
  28. 33 2
      NIMDemo/NIMDemo/FriendViewController.m
  29. 2 127
      NIMDemo/NIMDemo/GroupTableController.m
  30. 52 0
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.h
  31. 267 12
      NIMDemo/NIMDemo/HttpRequest/HttpRequest.m
  32. 94 19
      NIMDemo/NIMDemo/ImagePagerViewController.m
  33. 21 0
      NIMDemo/NIMDemo/Images.xcassets/Whosay/送礼物_03.imageset/Contents.json
  34. BIN
      NIMDemo/NIMDemo/Images.xcassets/Whosay/送礼物_03.imageset/送礼物_03.png
  35. 22 2
      NIMDemo/NIMDemo/MyUserInfoViewController.m
  36. 16 1
      NIMDemo/NIMDemo/RegisterViewController.m
  37. 31 1
      NIMDemo/NIMDemo/SectionGroup/GroupToogleTableViewCell.m
  38. 13 0
      NIMDemo/NIMDemo/SectionSetting/AboutViewController.h
  39. 51 0
      NIMDemo/NIMDemo/SectionSetting/AboutViewController.m
  40. 13 0
      NIMDemo/NIMDemo/SectionSetting/AgreementViewController.h
  41. 50 0
      NIMDemo/NIMDemo/SectionSetting/AgreementViewController.m
  42. 22 0
      NIMDemo/NIMDemo/SectionSetting/LawViewController.h
  43. 120 0
      NIMDemo/NIMDemo/SectionSetting/LawViewController.m
  44. 1 1
      NIMDemo/NIMDemo/SectionTrade/MyTradeTableViewCell.m
  45. 1 1
      NIMDemo/NIMDemo/SectionTrade/TradeModifyImageView.m
  46. 2 2
      NIMDemo/NIMDemo/SectionTrade/TradeModifyViewController.m
  47. 7 1
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.h
  48. 52 5
      NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m
  49. 8 5
      NIMDemo/NIMDemo/SectionTrade/TradeViewController.m
  50. 3 1
      NIMDemo/NIMDemo/SettingAccountViewController.m
  51. 14 4
      NIMDemo/NIMDemo/SettingTopTableViewCell.m
  52. 5 0
      NIMDemo/NIMDemo/SocialTopTableViewCell.m
  53. 10 8
      NIMDemo/NIMDemo/Supporting Files/Info.plist
  54. 2 2
      NIMDemo/NIMDemo/Supporting Files/NIMKitSettings.bundle/NIMKitBubbleSetting.plist
  55. 48 1
      NIMDemo/NIMDemo/TabBarController.m
  56. 25 0
      NIMDemo/NIMDemo/User.h
  57. 143 1
      NIMDemo/NIMDemo/User.m
  58. 15 0
      NIMDemo/NIMDemo/UserConfigViewController.h
  59. 155 0
      NIMDemo/NIMDemo/UserConfigViewController.m
  60. 36 0
      NIMDemo/NIMDemo/UserInfoViewController.m
  61. 3 0
      NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.h
  62. 17 0
      NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m
  63. 6 3
      NIMKit/NIMKit/Classes/Sections/Session/ViewController/NIMSessionViewController.m
  64. 1 0
      NIMKit/NIMKit/Classes/Sections/SessionList/NIMSessionListViewController.m
  65. 8 0
      NIMKit/NIMKit/Classes/Sections/Util/NIMKitUtil.m

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


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

@@ -17,5 +17,53 @@
             endingLineNumber = "6">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "../../../../Fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/TabBarController.m"
+            timestampString = "523178770.396612"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "106"
+            endingLineNumber = "106"
+            landmarkName = "-allMessagesDeleted"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "../NIMKit/NIMKit/Classes/Sections/Session/Object/NIMSessionInteractorImpl.m"
+            timestampString = "523182366.178267"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "190"
+            endingLineNumber = "190"
+            landmarkName = "-markAllMessagesRead"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <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/ViewController/NTESSessionPeekViewController.m"
+            timestampString = "523182372.389647"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "53"
+            endingLineNumber = "53"
+            landmarkName = "-previewActionItems"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 90 - 2
NIMDemo/NIMDemo.xcodeproj/project.pbxproj

@@ -288,6 +288,21 @@
 		C4DB33BB1F25F7720080D72F /* FeedBackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33BA1F25F7720080D72F /* FeedBackViewController.m */; };
 		C4DB33BE1F2709240080D72F /* HobbyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33BD1F2709240080D72F /* HobbyViewController.m */; };
 		C4DB33C11F273EFB0080D72F /* AddPhotoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33C01F273EFB0080D72F /* AddPhotoViewController.m */; };
+		C4DB33C41F29863B0080D72F /* ChatConfigViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33C31F29863B0080D72F /* ChatConfigViewController.m */; };
+		C4DB33C71F298A710080D72F /* UserConfigViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33C61F298A710080D72F /* UserConfigViewController.m */; };
+		C4DB33CA1F298D6A0080D72F /* ComplainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33C91F298D6A0080D72F /* ComplainViewController.m */; };
+		C4DB33CD1F299A0C0080D72F /* ComplainDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33CC1F299A0C0080D72F /* ComplainDetailViewController.m */; };
+		C4DB33D01F2C3D120080D72F /* ContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33CF1F2C3D120080D72F /* ContactViewController.m */; };
+		C4DB33D31F2C3EF00080D72F /* ContactTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33D21F2C3EF00080D72F /* ContactTableViewCell.m */; };
+		C4DB33D51F2C41FE0080D72F /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4DB33D41F2C41FE0080D72F /* AddressBook.framework */; };
+		C4DB33D81F2C7ECC0080D72F /* FriendRequestTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33D71F2C7ECC0080D72F /* FriendRequestTableViewCell.m */; };
+		C4DB33DB1F2C7F190080D72F /* FriendRequestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33DA1F2C7F190080D72F /* FriendRequestViewController.m */; };
+		C4DB33DE1F2C9CAC0080D72F /* AddFriendViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33DD1F2C9CAC0080D72F /* AddFriendViewController.m */; };
+		C4DB33E11F2CA5B90080D72F /* FriendListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33E01F2CA5B90080D72F /* FriendListViewController.m */; };
+		C4DB33E41F2CA6750080D72F /* FriendListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33E31F2CA6750080D72F /* FriendListTableViewCell.m */; };
+		C4DB33E71F2D7BA60080D72F /* AboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33E61F2D7BA60080D72F /* AboutViewController.m */; };
+		C4DB33EA1F2D8C840080D72F /* LawViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33E91F2D8C840080D72F /* LawViewController.m */; };
+		C4DB33ED1F2D91A60080D72F /* AgreementViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4DB33EC1F2D91A60080D72F /* AgreementViewController.m */; };
 		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 */; };
@@ -892,6 +907,35 @@
 		C4DB33BD1F2709240080D72F /* HobbyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HobbyViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/HobbyViewController.m; sourceTree = "<group>"; };
 		C4DB33BF1F273EFB0080D72F /* AddPhotoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddPhotoViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AddPhotoViewController.h; sourceTree = "<group>"; };
 		C4DB33C01F273EFB0080D72F /* AddPhotoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AddPhotoViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AddPhotoViewController.m; sourceTree = "<group>"; };
+		C4DB33C21F29863B0080D72F /* ChatConfigViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChatConfigViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/ChatConfigViewController.h; sourceTree = "<group>"; };
+		C4DB33C31F29863B0080D72F /* ChatConfigViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ChatConfigViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/ChatConfigViewController.m; sourceTree = "<group>"; };
+		C4DB33C51F298A710080D72F /* UserConfigViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserConfigViewController.h; sourceTree = "<group>"; };
+		C4DB33C61F298A710080D72F /* UserConfigViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserConfigViewController.m; sourceTree = "<group>"; };
+		C4DB33C81F298D6A0080D72F /* ComplainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplainViewController.h; sourceTree = "<group>"; };
+		C4DB33C91F298D6A0080D72F /* ComplainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComplainViewController.m; sourceTree = "<group>"; };
+		C4DB33CB1F299A0C0080D72F /* ComplainDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplainDetailViewController.h; sourceTree = "<group>"; };
+		C4DB33CC1F299A0C0080D72F /* ComplainDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComplainDetailViewController.m; sourceTree = "<group>"; };
+		C4DB33CE1F2C3D120080D72F /* ContactViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactViewController.h; sourceTree = "<group>"; };
+		C4DB33CF1F2C3D120080D72F /* ContactViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactViewController.m; sourceTree = "<group>"; };
+		C4DB33D11F2C3EF00080D72F /* ContactTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactTableViewCell.h; sourceTree = "<group>"; };
+		C4DB33D21F2C3EF00080D72F /* ContactTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactTableViewCell.m; sourceTree = "<group>"; };
+		C4DB33D41F2C41FE0080D72F /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
+		C4DB33D61F2C7ECC0080D72F /* FriendRequestTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FriendRequestTableViewCell.h; sourceTree = "<group>"; };
+		C4DB33D71F2C7ECC0080D72F /* FriendRequestTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FriendRequestTableViewCell.m; sourceTree = "<group>"; };
+		C4DB33D91F2C7F190080D72F /* FriendRequestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FriendRequestViewController.h; sourceTree = "<group>"; };
+		C4DB33DA1F2C7F190080D72F /* FriendRequestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FriendRequestViewController.m; sourceTree = "<group>"; };
+		C4DB33DC1F2C9CAC0080D72F /* AddFriendViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddFriendViewController.h; sourceTree = "<group>"; };
+		C4DB33DD1F2C9CAC0080D72F /* AddFriendViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddFriendViewController.m; sourceTree = "<group>"; };
+		C4DB33DF1F2CA5B90080D72F /* FriendListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FriendListViewController.h; sourceTree = "<group>"; };
+		C4DB33E01F2CA5B90080D72F /* FriendListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FriendListViewController.m; sourceTree = "<group>"; };
+		C4DB33E21F2CA6750080D72F /* FriendListTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FriendListTableViewCell.h; sourceTree = "<group>"; };
+		C4DB33E31F2CA6750080D72F /* FriendListTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FriendListTableViewCell.m; sourceTree = "<group>"; };
+		C4DB33E51F2D7BA60080D72F /* AboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AboutViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AboutViewController.h; sourceTree = "<group>"; };
+		C4DB33E61F2D7BA60080D72F /* AboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AboutViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AboutViewController.m; sourceTree = "<group>"; };
+		C4DB33E81F2D8C840080D72F /* LawViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LawViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/LawViewController.h; sourceTree = "<group>"; };
+		C4DB33E91F2D8C840080D72F /* LawViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LawViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/LawViewController.m; sourceTree = "<group>"; };
+		C4DB33EB1F2D91A60080D72F /* AgreementViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AgreementViewController.h; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AgreementViewController.h; sourceTree = "<group>"; };
+		C4DB33EC1F2D91A60080D72F /* AgreementViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AgreementViewController.m; path = ../../../../../fenix/XCode_Project/NIM_iOS_Demo_v3/NIMDemo/NIMDemo/SectionSetting/AgreementViewController.m; 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>"; };
@@ -942,6 +986,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				C4DB33D51F2C41FE0080D72F /* AddressBook.framework in Frameworks */,
 				C445A2BA1F1E0353005E88B6 /* CoreMotion.framework in Frameworks */,
 				C445A2B61F1E0335005E88B6 /* UIKit.framework in Frameworks */,
 				C445A2B81F1E033F005E88B6 /* Foundation.framework in Frameworks */,
@@ -983,6 +1028,7 @@
 		5176189D0086B38FE643A26A /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				C4DB33D41F2C41FE0080D72F /* AddressBook.framework */,
 				C4DB33A01F1F10790080D72F /* libcrypto.a */,
 				C4DB33A11F1F10790080D72F /* libssl.a */,
 				C4DB33341F1E25690080D72F /* AlipaySDK.framework */,
@@ -2010,6 +2056,12 @@
 				C4DB33BA1F25F7720080D72F /* FeedBackViewController.m */,
 				C4DB33BF1F273EFB0080D72F /* AddPhotoViewController.h */,
 				C4DB33C01F273EFB0080D72F /* AddPhotoViewController.m */,
+				C4DB33E51F2D7BA60080D72F /* AboutViewController.h */,
+				C4DB33E61F2D7BA60080D72F /* AboutViewController.m */,
+				C4DB33E81F2D8C840080D72F /* LawViewController.h */,
+				C4DB33E91F2D8C840080D72F /* LawViewController.m */,
+				C4DB33EB1F2D91A60080D72F /* AgreementViewController.h */,
+				C4DB33EC1F2D91A60080D72F /* AgreementViewController.m */,
 			);
 			name = SectionSetting;
 			sourceTree = "<group>";
@@ -2043,10 +2095,32 @@
 				C4DB33A51F20A83E0080D72F /* UserGiftViewController.m */,
 				C4DB33A71F2445AF0080D72F /* UserInfo.h */,
 				C4DB33A81F2445AF0080D72F /* UserInfo.m */,
-				C4DB33AA1F245A910080D72F /* MyUserInfoViewController.h */,
-				C4DB33AB1F245A910080D72F /* MyUserInfoViewController.m */,
 				C4DB33BC1F2709240080D72F /* HobbyViewController.h */,
 				C4DB33BD1F2709240080D72F /* HobbyViewController.m */,
+				C4DB33C21F29863B0080D72F /* ChatConfigViewController.h */,
+				C4DB33C31F29863B0080D72F /* ChatConfigViewController.m */,
+				C4DB33C51F298A710080D72F /* UserConfigViewController.h */,
+				C4DB33C61F298A710080D72F /* UserConfigViewController.m */,
+				C4DB33C81F298D6A0080D72F /* ComplainViewController.h */,
+				C4DB33C91F298D6A0080D72F /* ComplainViewController.m */,
+				C4DB33CB1F299A0C0080D72F /* ComplainDetailViewController.h */,
+				C4DB33AA1F245A910080D72F /* MyUserInfoViewController.h */,
+				C4DB33AB1F245A910080D72F /* MyUserInfoViewController.m */,
+				C4DB33CC1F299A0C0080D72F /* ComplainDetailViewController.m */,
+				C4DB33CE1F2C3D120080D72F /* ContactViewController.h */,
+				C4DB33CF1F2C3D120080D72F /* ContactViewController.m */,
+				C4DB33D11F2C3EF00080D72F /* ContactTableViewCell.h */,
+				C4DB33D21F2C3EF00080D72F /* ContactTableViewCell.m */,
+				C4DB33D61F2C7ECC0080D72F /* FriendRequestTableViewCell.h */,
+				C4DB33D71F2C7ECC0080D72F /* FriendRequestTableViewCell.m */,
+				C4DB33D91F2C7F190080D72F /* FriendRequestViewController.h */,
+				C4DB33DA1F2C7F190080D72F /* FriendRequestViewController.m */,
+				C4DB33DC1F2C9CAC0080D72F /* AddFriendViewController.h */,
+				C4DB33DD1F2C9CAC0080D72F /* AddFriendViewController.m */,
+				C4DB33DF1F2CA5B90080D72F /* FriendListViewController.h */,
+				C4DB33E01F2CA5B90080D72F /* FriendListViewController.m */,
+				C4DB33E21F2CA6750080D72F /* FriendListTableViewCell.h */,
+				C4DB33E31F2CA6750080D72F /* FriendListTableViewCell.m */,
 			);
 			name = User;
 			sourceTree = "<group>";
@@ -2465,7 +2539,9 @@
 				6118F5A71C5A0FC1009AF01E /* UINavigationController+Swizzling.m in Sources */,
 				C4D4C9321ED7C37F00ADD7B7 /* AppDelegate.m in Sources */,
 				C4F1D0FE1F010E1D00A04B28 /* SocialCommentData.m in Sources */,
+				C4DB33E71F2D7BA60080D72F /* AboutViewController.m in Sources */,
 				C482C3191F10A00900EF2B71 /* GroupInfoViewController.m in Sources */,
+				C4DB33CD1F299A0C0080D72F /* ComplainDetailViewController.m in Sources */,
 				61E4719C1B7D9C8300F4A1BF /* NTESSessionViewController.m in Sources */,
 				61E4712F1B7D963E00F4A1BF /* NTESChartletAttachment.m in Sources */,
 				8351CB721E977D9000DF4866 /* NTESContactDataCell.m in Sources */,
@@ -2490,12 +2566,16 @@
 				03A4C9FF1AC2B79700E45E03 /* UIAlertView+NTESBlock.m in Sources */,
 				6173AECE1BAAC70200854D49 /* NTESBirthSettingViewController.m in Sources */,
 				61E4715A1B7D963E00F4A1BF /* NTESMutiClientsHeaderView.m in Sources */,
+				C4DB33D31F2C3EF00080D72F /* ContactTableViewCell.m in Sources */,
 				6159DF5A1C45FAF500E32EB4 /* NTESChatroomTextContentView.m in Sources */,
 				61775E931C571FE500C1DA03 /* NTESLiveActionView.m in Sources */,
 				61E4713B1B7D963E00F4A1BF /* NTESSessionChartletContentView.m in Sources */,
 				619586811C19717B00858434 /* NTESChatroomListViewController.m in Sources */,
+				C4DB33D01F2C3D120080D72F /* ContactViewController.m in Sources */,
 				61E471941B7D96AA00F4A1BF /* NTESService.m in Sources */,
+				C4DB33C71F298A710080D72F /* UserConfigViewController.m in Sources */,
 				61E470F61B7D963E00F4A1BF /* NTESColorButtonCell.m in Sources */,
+				C4DB33C41F29863B0080D72F /* ChatConfigViewController.m in Sources */,
 				61518A561CA233BB0061C4A9 /* NTESDemoService.m in Sources */,
 				C482C32C1F13686A00EF2B71 /* GroupMenberIcon.m in Sources */,
 				C4D4C9361ED7C37F00ADD7B7 /* TabBarController.m in Sources */,
@@ -2566,12 +2646,14 @@
 				C4D8F1301ED48658002F9F3A /* AFURLResponseSerialization.m in Sources */,
 				61E4711D1B7D963E00F4A1BF /* NTESContactViewController.m in Sources */,
 				61E471491B7D963E00F4A1BF /* NTESSessionLocalHistoryViewController.m in Sources */,
+				C4DB33DB1F2C7F190080D72F /* FriendRequestViewController.m in Sources */,
 				613A2FED1C21049E00508990 /* NTESLiveViewController.m in Sources */,
 				61E4713F1B7D963E00F4A1BF /* NTESAudio2TextViewController.m in Sources */,
 				61E471341B7D963E00F4A1BF /* NTESSessionMsgConverter.m in Sources */,
 				C4DB33951F1E25A30080D72F /* RSADataSigner.m in Sources */,
 				61EAD9121B82F275005DC715 /* NTESContactAddFriendViewController.m in Sources */,
 				61C2CE521C489F0D00D76104 /* NTESChatroomManager.m in Sources */,
+				C4DB33EA1F2D8C840080D72F /* LawViewController.m in Sources */,
 				C482C3231F13577200EF2B71 /* GroupIntroViewController.m in Sources */,
 				61E4713C1B7D963E00F4A1BF /* NTESSessionJankenponContentView.m in Sources */,
 				61E471971B7D96AA00F4A1BF /* NTESPinyinConverter.m in Sources */,
@@ -2580,6 +2662,7 @@
 				613A2FEA1C21016600508990 /* NTESChatroomSegmentedControl.m in Sources */,
 				E4562D8B1CE0855A00D66909 /* NTESSDKConfigDelegate.m in Sources */,
 				C4B639571ED581E2004288FC /* User.m in Sources */,
+				C4DB33E11F2CA5B90080D72F /* FriendListViewController.m in Sources */,
 				C4F1D0F81EFA197300A04B28 /* SocialItemData.m in Sources */,
 				6117562E1BEB6978006A1589 /* NTESAliasSettingViewController.m in Sources */,
 				C482C3071F0B389400EF2B71 /* MyTradeTableViewCell.m in Sources */,
@@ -2601,8 +2684,10 @@
 				E45E17801CA8CBA500C4ED69 /* NTESLogManager.m in Sources */,
 				C4D4C9331ED7C37F00ADD7B7 /* LoginViewController.m in Sources */,
 				61518A4B1CA233390061C4A9 /* NTESNavigationHandler.m in Sources */,
+				C4DB33CA1F298D6A0080D72F /* ComplainViewController.m in Sources */,
 				61E471621B7D963E00F4A1BF /* NTESAboutViewController.m in Sources */,
 				61E471411B7D963E00F4A1BF /* NTESFilePreViewController.m in Sources */,
+				C4DB33DE1F2C9CAC0080D72F /* AddFriendViewController.m in Sources */,
 				611ABF011B3CF4FC00B8706C /* NTESBadgeView.m in Sources */,
 				C4B146391EF2351900819893 /* SettingTableViewController.m in Sources */,
 				C482C30A1F0B857800EF2B71 /* NTESGiftAttachment.m in Sources */,
@@ -2635,6 +2720,7 @@
 				61E471671B7D963E00F4A1BF /* NTESSettingSwitcherCell.m in Sources */,
 				C482C3011F0A792300EF2B71 /* SettingOptionTableViewCell.m in Sources */,
 				61E4710C1B7D963E00F4A1BF /* NTESTeamListViewController.m in Sources */,
+				C4DB33D81F2C7ECC0080D72F /* FriendRequestTableViewCell.m in Sources */,
 				61E4718A1B7D96AA00F4A1BF /* NTESBundleSetting.m in Sources */,
 				AE2AA6851A7CD35C00CFF013 /* UIView+NTES.m in Sources */,
 				C4DB33B21F25A69F0080D72F /* NearUserTableViewCell.m in Sources */,
@@ -2669,6 +2755,7 @@
 				6118F5A91C5A0FC1009AF01E /* UIView+Swizzling.m in Sources */,
 				C4DB33AF1F25A61A0080D72F /* NearUserViewController.m in Sources */,
 				6110D8A91C23E76D00805BA4 /* NTESChatroomMemberCell.m in Sources */,
+				C4DB33ED1F2D91A60080D72F /* AgreementViewController.m in Sources */,
 				E48988EB1DE42391001CF6C5 /* NTESSessionCustomContentConfig.m in Sources */,
 				61E471211B7D963E00F4A1BF /* NTESCustomSysNotificationViewController.m in Sources */,
 				61E471311B7D963E00F4A1BF /* NTESJanKenPonAttachment.m in Sources */,
@@ -2679,6 +2766,7 @@
 				BD52DB3E1B8F300E00434D0E /* NTESCADisplayLinkHolder.m in Sources */,
 				61EAD91B1B834E72005DC715 /* NTESUserListCell.m in Sources */,
 				61E471511B7D963E00F4A1BF /* NetCallChatInfo.m in Sources */,
+				C4DB33E41F2CA6750080D72F /* FriendListTableViewCell.m in Sources */,
 				E49D53C11B451C7400A869AC /* NSData+NTES.m in Sources */,
 				61EEE7761C22964500022315 /* NTESLiveMasterInfoView.m in Sources */,
 				C4F1D15D1F03DDCA00A04B28 /* SocialDetailTableViewCell.m in Sources */,

+ 16 - 0
NIMDemo/NIMDemo/AddFriendViewController.h

@@ -0,0 +1,16 @@
+//
+//  AddFriendViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "FriendRequestViewController.h"
+
+@interface AddFriendViewController : UIViewController
+
+- (void)setUserId:(NSString *)userId;
+
+@end

+ 70 - 0
NIMDemo/NIMDemo/AddFriendViewController.m

@@ -0,0 +1,70 @@
+//
+//  AddFriendViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "AddFriendViewController.h"
+#import "HttpRequest.h"
+#import "UIView+Toast.h"
+#import "UIAlertView+NTESBlock.h"
+
+@interface AddFriendViewController ()<UITextFieldDelegate>
+
+@property (weak, nonatomic) IBOutlet UITextField *textField;
+@property (nonatomic, strong) NSString             *userId;
+
+@end
+
+@implementation AddFriendViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    _textField.layer.borderWidth = 0;
+    _textField.layer.borderColor = UIColor.clearColor.CGColor;
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"朋友验证"];
+    
+    UIButton *doneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [doneBtn setTitle:@"发送" forState:UIControlStateNormal];
+    [doneBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
+    [doneBtn addTarget:self action:@selector(onTouchDone:) forControlEvents:UIControlEventTouchUpInside];
+    [doneBtn sizeToFit];
+    
+    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:doneBtn];
+    [self.navigationItem setRightBarButtonItems:@[rightItem]];
+}
+
+- (void)setUserId:(NSString *)userId{
+    _userId = userId;
+}
+
+- (void)onTouchDone:(id)sender{
+    
+    __weak typeof(self)wself = self;
+    [[HttpRequest shared] requestFriend:_userId msg:_textField.text success:^{
+        
+        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"发送成功" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
+        [alertView showAlertWithCompletionHandler:^(NSInteger index) {
+            [wself.navigationController popViewControllerAnimated:YES];
+        }];
+        
+    } failure:^{
+        [self.view makeToast:@"发送失败" duration:2.0 position:CSToastPositionCenter];
+    }];
+}
+
+@end

Разлика између датотеке није приказан због своје велике величине
+ 1024 - 55
NIMDemo/NIMDemo/Base.lproj/Main.storyboard


+ 15 - 0
NIMDemo/NIMDemo/ChatConfigViewController.h

@@ -0,0 +1,15 @@
+//
+//  ChatConfigViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ChatConfigViewController : UITableViewController
+
+- (void)setUserId:(NSString *)userId;
+
+@end

+ 182 - 0
NIMDemo/NIMDemo/ChatConfigViewController.m

@@ -0,0 +1,182 @@
+//
+//  ChatConfigViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ChatConfigViewController.h"
+#import "UserInfoViewController.h"
+#import "User.h"
+#import "NIMAvatarImageView.h"
+#import "UIView+NTES.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+#import "UIActionSheet+NTESBlock.h"
+#import "NTESBundleSetting.h"
+#import "NTESSessionLocalHistoryViewController.h"
+#import "HttpRequest.h"
+
+
+@interface ChatConfigViewController ()
+@property (weak, nonatomic) IBOutlet UIView *avatarContainer;
+@property (weak, nonatomic) IBOutlet UISwitch *stickSwitch;
+@property (weak, nonatomic) IBOutlet UISwitch *disturbSwitch;
+@property (weak, nonatomic) IBOutlet UISwitch *blackListSwitch;
+
+@property (nonatomic, strong) NIMAvatarImageView    *avatar;
+@property (nonatomic, strong) NSString              *userId;
+
+@end
+
+@implementation ChatConfigViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    [self refresh];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"聊天设置"];
+}
+
+- (void)setUserId:(NSString *)userId{
+    
+    _userId = userId;
+    
+    [self refresh];
+}
+
+- (void)refresh{
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:self.userId];
+    NSURL *url = user.userInfo && user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+    
+    if(_avatarContainer && !_avatar)
+    {
+        _avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, _avatarContainer.width, _avatarContainer.height)];
+        [_avatarContainer addSubview:_avatar];
+    }
+    [_avatar nim_setImageWithURL:url placeholderImage:User.defaultUserAvatar];
+    
+    
+    BOOL isInBlackList = [[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
+    [_blackListSwitch setOn:isInBlackList];
+    
+    BOOL needNotify    = [[NIMSDK sharedSDK].userManager notifyForNewMsg:self.userId];
+    [_disturbSwitch setOn:!needNotify];
+    
+    
+    __weak typeof(self) wself = self;
+    [[User sharedInfo] requestChatStickList:^{
+        BOOL isChatStick = [[User sharedInfo] isChatStick:wself.userId];
+        [wself.stickSwitch setOn:isChatStick];
+    }];
+}
+
+#pragma mark - Table view data source
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+    
+    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    switch(cell.tag)
+    {
+        case 1:{
+            UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+            UserInfoViewController *vc = [board instantiateViewControllerWithIdentifier:@"UserInfo"];
+            [vc setUserId:_userId];
+            [self.navigationController pushViewController:vc animated:YES];
+            break;
+        }
+        case 2:{
+            NIMSession *session = [NIMSession session:_userId type:NIMSessionTypeP2P];
+            NTESSessionLocalHistoryViewController *vc = [[NTESSessionLocalHistoryViewController alloc] initWithSession:session];
+            [self.navigationController pushViewController:vc animated:YES];
+            break;
+        }
+        case 3:{
+            UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确定清空聊天记录?" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil, nil];
+            __weak UIActionSheet *wSheet;
+            [sheet showInView:self.view completionHandler:^(NSInteger index) {
+                if (index == wSheet.destructiveButtonIndex) {
+                    BOOL removeRecentSession = [NTESBundleSetting sharedConfig].removeSessionWheDeleteMessages;
+                    NIMSession *session = [NIMSession session:_userId type:NIMSessionTypeP2P];
+                    [[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:session removeRecentSession:removeRecentSession];
+                }
+            }];
+            break;
+        }
+    }
+    
+    
+}
+
+
+- (IBAction)onStickChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    [[HttpRequest shared] chatStick:self.userId stick:switcher.isOn success:^(int inputTime) {
+        [SVProgressHUD dismiss];
+        if(switcher.isOn)
+        {
+            [[User sharedInfo] addChatStick:self.userId inputTime:inputTime];
+        }
+        else
+        {
+            [[User sharedInfo] removeChatStick:self.userId];
+        }
+    } failure:^{
+        [SVProgressHUD dismiss];
+        [wself.view makeToast:@"操作失败"duration:2.0f position:CSToastPositionCenter];
+        [wself refresh];
+    }];
+}
+
+- (IBAction)onDisturbChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    [[NIMSDK sharedSDK].userManager updateNotifyState:!switcher.on forUser:self.userId completion:^(NSError *error) {
+        [SVProgressHUD dismiss];
+        if (error) {
+            [wself.view makeToast:@"操作失败"duration:2.0f position:CSToastPositionCenter];
+        }
+    }];
+}
+
+- (IBAction)onBlackListChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    if (switcher.on) {
+        [[NIMSDK sharedSDK].userManager addToBlackList:self.userId completion:^(NSError *error) {
+            [SVProgressHUD dismiss];
+            if (!error) {
+                [wself.view makeToast:@"拉黑成功"duration:2.0f position:CSToastPositionCenter];
+            }else{
+                [wself.view makeToast:@"拉黑失败"duration:2.0f position:CSToastPositionCenter];
+            }
+        }];
+    }else{
+        [[NIMSDK sharedSDK].userManager removeFromBlackBlackList:self.userId completion:^(NSError *error) {
+            [SVProgressHUD dismiss];
+            if (!error) {
+                [wself.view makeToast:@"移除黑名单成功"duration:2.0f position:CSToastPositionCenter];
+            }else{
+                [wself.view makeToast:@"移除黑名单失败"duration:2.0f position:CSToastPositionCenter];
+            }
+        }];
+    }
+}
+
+@end

+ 1 - 1
NIMDemo/NIMDemo/Classes/Sections/Contact/View/NTESContactDataCell.m

@@ -14,7 +14,7 @@
 {
     [super refreshUser:member];
     NSString *state = [NTESSessionUtil onlineState:self.memberId detail:NO];
-    NSString *title = [NSString stringWithFormat:@"[%@] %@",state,member.showName];
+    NSString *title = [NSString stringWithFormat:@"%@",member.showName];
     self.textLabel.text = title;
 }
 

+ 2 - 0
NIMDemo/NIMDemo/Classes/Sections/Contact/View/NTESContactUtilItem.h

@@ -30,4 +30,6 @@
 
 @property (nonatomic,copy) NSString *selName;
 
+@property (nonatomic,copy) NSString *storyboardId;
+
 @end

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

@@ -61,6 +61,7 @@
 #import "GroupInfoViewController.h"
 #import "NIMInputView.h"
 #import "CityManager.h"
+#import "ChatConfigViewController.h"
 
 
 @interface NTESSessionViewController ()
@@ -190,6 +191,7 @@ NIMSessionDelegate>
 
 - (void)viewWillAppear:(BOOL)animated
 {
+    [super viewWillAppear:animated];
     User *user = [User sharedInfo];
     GiftInputContainer *giftInput = [self.sessionInputView giftContainer];
     [giftInput setBalance:user.coin];
@@ -921,6 +923,12 @@ NIMSessionDelegate>
     [deleteBtn setImage:[UIImage imageNamed:@"icon_session_info_normal"] forState:UIControlStateNormal];
     [deleteBtn sizeToFit];
     
+    UIButton *chatConfigBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [chatConfigBtn addTarget:self action:@selector(onTouchChatConfig:) forControlEvents:UIControlEventTouchUpInside];
+    [chatConfigBtn setImage:[UIImage imageNamed:@"设置图标"] forState:UIControlStateNormal];
+    [chatConfigBtn setSize:CGSizeMake(30, 30)];
+    UIBarButtonItem *chatConfigItem = [[UIBarButtonItem alloc] initWithCustomView:chatConfigBtn];
+    
     //UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:searchBtn];
     //UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithCustomView:deleteBtn];
     
@@ -942,7 +950,7 @@ NIMSessionDelegate>
     }
     else
     {
-        self.navigationItem.rightBarButtonItems = @[deleteItem, searchItem];
+        self.navigationItem.rightBarButtonItems = @[chatConfigItem];
     }
     
 }
@@ -1202,7 +1210,9 @@ NIMSessionDelegate>
 
 
 
-
+- (BOOL)checkLaw{
+    return [[TradePublishManager sharedManager] checkLaw:self];
+}
 
 - (void)sendTrade:(NSString *)msg picArr:(NSMutableArray *)picArr priority:(int)priority priorityType:(int)priorityType type:(int)type{
     
@@ -1213,14 +1223,21 @@ NIMSessionDelegate>
         return;
     }
     
-    TradePublishManager *tradePublishManager = [[TradePublishManager alloc] init];
+    TradePublishManager *tradePublishManager = [TradePublishManager sharedManager];
     tradePublishManager.inputView = self.sessionInputView;
-    [tradePublishManager tradePublish:msg picArr:picArr priority:priority priorityType:priorityType tradeType:type];
+    [tradePublishManager tradePublish:msg picArr:picArr priority:priority priorityType:priorityType tradeType:type roomId:self.session.sessionId];
     
 }
 
 
-
+- (void)onTouchChatConfig:(id)sender{
+    
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    ChatConfigViewController *vc = [board instantiateViewControllerWithIdentifier:@"ChatConfig"];
+    [vc setUserId:self.session.sessionId];
+    [self.navigationController pushViewController:vc animated:YES];
+    
+}
 
 
 @end

+ 15 - 0
NIMDemo/NIMDemo/ComplainDetailViewController.h

@@ -0,0 +1,15 @@
+//
+//  ComplainDetailViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ComplainDetailViewController : UIViewController
+
+- (void)setInfo:(NSString *)userId type:(int)type;
+
+@end

+ 88 - 0
NIMDemo/NIMDemo/ComplainDetailViewController.m

@@ -0,0 +1,88 @@
+//
+//  ComplainDetailViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ComplainDetailViewController.h"
+#import "HttpRequest.h"
+#import "UIView+Toast.h"
+
+@interface ComplainDetailViewController ()
+@property (unsafe_unretained, nonatomic) IBOutlet UILabel *placeHoldLabel;
+@property (unsafe_unretained, nonatomic) IBOutlet UITextView *textView;
+
+@property (nonatomic, strong) NSString              *userId;
+@property (nonatomic, assign) int                   type;
+@end
+
+@implementation ComplainDetailViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    [self reset];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"投诉"];
+}
+
+- (void)setInfo:(NSString *)userId type:(int)type{
+    _userId = userId;
+    _type = type;
+}
+
+- (void)reset{
+    
+    _textView.text = @"";
+}
+
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
+    
+    if([text isEqualToString:@"\n"])
+    {
+        [textView resignFirstResponder];
+        return NO;
+    }
+    
+    _placeHoldLabel.hidden = textView.text.length > 0;
+    return YES;
+}
+
+- (IBAction)onTouchSubmit:(id)sender {
+
+    NSString *msg = _textView.text;
+    
+    if(msg.length == 0)
+    {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您还什么都没写" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+        [alert show];
+        return;
+    }
+    
+    
+    __weak typeof(self) wself = self;
+    [[HttpRequest shared] complain:msg type:_type userId:_userId success:^{
+        
+        [wself.view makeToast:@"提交成功" duration:2.0 position:CSToastPositionCenter];
+        [wself reset];
+        
+    } failure:^{
+        
+        [wself.view makeToast:@"提交失败,请重试" duration:2.0 position:CSToastPositionCenter];
+        
+    }];
+}
+
+
+@end

+ 15 - 0
NIMDemo/NIMDemo/ComplainViewController.h

@@ -0,0 +1,15 @@
+//
+//  ComplainViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ComplainViewController : UITableViewController
+
+- (void)setUserId:(NSString *)userId;
+
+@end

+ 106 - 0
NIMDemo/NIMDemo/ComplainViewController.m

@@ -0,0 +1,106 @@
+//
+//  ComplainViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ComplainViewController.h"
+#import "ComplainDetailViewController.h"
+
+@interface ComplainViewController ()
+
+@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *selection1;
+@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *selection2;
+@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *selection3;
+@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *selection4;
+@property (unsafe_unretained, nonatomic) IBOutlet UIImageView *selection5;
+
+
+@property (nonatomic, strong) NSString                              *userId;
+@property (nonatomic, strong) NSMutableArray<UIImageView *>         *optionArr;
+@property (nonatomic, assign) int                                   currentOption;
+
+@end
+
+@implementation ComplainViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    _optionArr = [[NSMutableArray alloc] init];
+    [_optionArr addObject:_selection1];
+    [_optionArr addObject:_selection2];
+    [_optionArr addObject:_selection3];
+    [_optionArr addObject:_selection4];
+    [_optionArr addObject:_selection5];
+    
+    _currentOption = -1;
+    
+    [self refresh];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    
+    
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"投诉"];
+}
+
+- (void)setUserId:(NSString *)userId{
+    _userId = userId;
+}
+
+
+- (void)refresh{
+    
+    for(int i=0; i<_optionArr.count; i++)
+    {
+        UIImageView *imgView = [_optionArr objectAtIndex:i];
+        if(i == _currentOption)
+        {
+            [imgView setImage:[UIImage imageNamed:@"充值_06"]];
+        }
+        else
+        {
+            [imgView setImage:[UIImage imageNamed:@"聊天3_03"]];
+        }
+    }
+    
+}
+
+
+#pragma mark - Table view data source
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+    
+    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    _currentOption = (int)(cell.tag) - 1;
+    [self refresh];
+    
+}
+
+- (IBAction)onTouchNext:(id)sender {
+    
+    if(_currentOption < 0)
+    {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"请选择投诉类型" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
+        [alert show];
+        return;
+    }
+    
+    
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    ComplainDetailViewController *vc = [board instantiateViewControllerWithIdentifier:@"ComplainDetail"];
+    [vc setInfo:_userId type:_currentOption];
+    [self.navigationController pushViewController:vc animated:YES];
+    
+}
+
+@end

+ 16 - 0
NIMDemo/NIMDemo/ContactTableViewCell.h

@@ -0,0 +1,16 @@
+//
+//  ContactTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "ContactViewController.h"
+
+@interface ContactTableViewCell : UITableViewCell
+
+- (void)setData:(ContactData *)data;
+
+@end

+ 137 - 0
NIMDemo/NIMDemo/ContactTableViewCell.m

@@ -0,0 +1,137 @@
+//
+//  ContactTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ContactTableViewCell.h"
+#import "User.h"
+#import "UIView+NTES.h"
+#import "NIMAvatarImageView.h"
+#import "AddFriendViewController.h"
+#import "HttpRequest.h"
+#import "UIView+Toast.h"
+
+@interface ContactTableViewCell()
+
+@property (weak, nonatomic) IBOutlet UIView *avatarContainer;
+@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
+@property (weak, nonatomic) IBOutlet UILabel *descLabel;
+@property (weak, nonatomic) IBOutlet UIButton *actionBtn;
+
+@property (nonatomic, strong) NIMAvatarImageView    *avatar;
+@property (nonatomic, strong) ContactData           *data;
+
+@end
+
+@implementation ContactTableViewCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+    
+    _actionBtn.layer.cornerRadius = 3;
+    [self setData:_data];
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setData:(ContactData *)data{
+    _data = data;
+    
+    if(!data)
+        return;
+    
+    if(!_avatar)
+    {
+        _avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, _avatarContainer.width, _avatarContainer.height)];
+        [_avatarContainer addSubview:_avatar];
+    }
+    
+    NSURL *url = nil;
+    if(data.userId)
+    {
+        NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:data.userId];
+        
+        url = user.userInfo && user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        
+        _nameLabel.text = data.name;
+        BOOL isFollow = [[User sharedInfo] isFollowd:data.userId];
+        if(isFollow)
+        {
+            [_actionBtn setBackgroundColor:UIColor.clearColor];
+            [_actionBtn setTitle:@"已添加" forState:UIControlStateNormal];
+            [_actionBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+            [_actionBtn setUserInteractionEnabled:NO];
+        }
+        else
+        {
+            [_actionBtn setBackgroundColor:User.greenColor];
+            [_actionBtn setTitle:@"添加" forState:UIControlStateNormal];
+            [_actionBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
+            [_actionBtn setUserInteractionEnabled:YES];
+        }
+        
+        if(data.follow > 0)
+        {
+            _descLabel.text = [NSString stringWithFormat:@"%@已经关注了你", data.name];
+        }
+        else
+        {
+            _descLabel.text = [data.phones objectAtIndex:0];
+            
+        }
+    }
+    else
+    {
+        _nameLabel.text = data.name;
+        _descLabel.text = [data.phones objectAtIndex:0];
+        
+        if(_data.msgSend)
+        {
+            [_actionBtn setBackgroundColor:UIColor.clearColor];
+            [_actionBtn setTitle:@"已发送" forState:UIControlStateNormal];
+            [_actionBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+            [_actionBtn setUserInteractionEnabled:NO];
+
+        }
+        else
+        {
+            [_actionBtn setBackgroundColor:User.orangeColor];
+            [_actionBtn setTitle:@"邀请" forState:UIControlStateNormal];
+            [_actionBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
+            [_actionBtn setUserInteractionEnabled:YES];
+        }
+    }
+    
+    [_avatar nim_setImageWithURL:url placeholderImage:User.defaultUserAvatar];
+}
+
+- (IBAction)onTouchActionBtn:(id)sender {
+    
+    if(_data.userId)
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        AddFriendViewController *vc = [board instantiateViewControllerWithIdentifier:@"AddFriend"];
+        [vc setUserId:_data.userId];
+        [self.viewController.navigationController pushViewController:vc animated:YES];
+    }
+    else
+    {
+        [[HttpRequest shared] sendMsg:_data.phones[0] success:^{
+            [self makeToast:@"发送成功" duration:2.0 position:CSToastPositionCenter];
+            _data.msgSend = YES;
+            [self setData:_data];
+        } failure:^{
+            [self makeToast:@"发送失败,请重试" duration:2.0 position:CSToastPositionCenter];
+        }];
+    }
+}
+
+@end

+ 21 - 0
NIMDemo/NIMDemo/ContactViewController.h

@@ -0,0 +1,21 @@
+//
+//  ContactViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ContactData : NSObject
+@property (nonatomic, strong) NSString            *name;
+@property (nonatomic, strong) NSMutableArray      *phones;
+@property (nonatomic, strong) NSString            *userId;
+@property (nonatomic, assign) int                 follow;
+@property (nonatomic, assign) BOOL                msgSend;
+@end
+
+@interface ContactViewController : UITableViewController
+
+@end

+ 181 - 0
NIMDemo/NIMDemo/ContactViewController.m

@@ -0,0 +1,181 @@
+//
+//  ContactViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "ContactViewController.h"
+#import <AddressBook/AddressBook.h>
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+#import "HttpRequest.h"
+#import "ContactTableViewCell.h"
+#import "User.h"
+
+@implementation ContactData
+@end
+
+@interface ContactViewController ()
+
+@property (nonatomic, strong) NSMutableArray            *contactArr;
+@property (nonatomic, strong) NSMutableDictionary       *contactDict;
+
+@end
+
+@implementation ContactViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    [self.navigationItem setTitle:@"手机联系人"];
+}
+
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    [self requestAuthorizationAddressBook];
+}
+
+- (void)requestAuthorizationAddressBook {
+    // 判断是否授权
+    ABAuthorizationStatus authorizationStatus = ABAddressBookGetAuthorizationStatus();
+    if (authorizationStatus == kABAuthorizationStatusNotDetermined) {
+        // 请求授权
+        ABAddressBookRef addressBookRef =  ABAddressBookCreate();
+        __weak typeof(self) wself = self;
+        ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
+            if (granted) {  // 授权成功
+                [wself setUpContact];
+            } else {        // 授权失败
+                NSLog(@"授权失败!");
+            }
+        });
+        return;
+    }
+    
+    [self setUpContact];
+}
+
+- (void)setUpContact{
+    ABAuthorizationStatus authorizationStatus = ABAddressBookGetAuthorizationStatus();
+    if (authorizationStatus != kABAuthorizationStatusAuthorized) {
+        
+        NSLog(@"没有授权");
+        return;
+    }
+    
+    // 2. 获取所有联系人
+    _contactArr = [[NSMutableArray alloc] init];
+    _contactDict = [[NSMutableDictionary alloc] init];
+    NSMutableArray *mobiles = [[NSMutableArray alloc] init];
+    
+    ABAddressBookRef addressBookRef = ABAddressBookCreate();
+    CFArrayRef arrayRef = ABAddressBookCopyArrayOfAllPeople(addressBookRef);
+    long count = CFArrayGetCount(arrayRef);
+    for (int i = 0; i < count; i++) {
+        //获取联系人对象的引用
+        ABRecordRef people = CFArrayGetValueAtIndex(arrayRef, i);
+        
+        //获取当前联系人名字
+        NSString *firstName=(__bridge NSString *)(ABRecordCopyValue(people, kABPersonFirstNameProperty));
+        
+        //获取当前联系人姓氏
+        NSString *lastName=(__bridge NSString *)(ABRecordCopyValue(people, kABPersonLastNameProperty));
+        NSLog(@"--------------------------------------------------");
+        NSLog(@"firstName=%@, lastName=%@", firstName, lastName);
+        
+        ContactData *data = [[ContactData alloc] init];
+        data.name = [NSString stringWithFormat:@"%@%@", lastName, firstName];
+        
+        //获取当前联系人的电话 数组
+        NSMutableArray *phoneArray = [[NSMutableArray alloc] init];
+        ABMultiValueRef phones = ABRecordCopyValue(people, kABPersonPhoneProperty);
+        long phoneCount = ABMultiValueGetCount(phones);
+        for(int j=0; j<phoneCount; j++)
+        {
+            NSString * personPhone = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phones, j);
+            [phoneArray addObject:personPhone];
+            [mobiles addObject:personPhone];
+            [_contactDict setValue:data forKey:personPhone];
+        }
+        
+        data.phones = phoneArray;
+        [_contactArr addObject:data];
+    }
+    
+    if(mobiles.count > 0)
+    {
+        [self requestState:mobiles];
+    }
+}
+
+
+- (void)requestState:(NSMutableArray *)mobiles{
+    
+    [SVProgressHUD show];
+    
+    __weak typeof(self) wself = self;
+    [[HttpRequest shared] contactState:mobiles success:^(NSMutableArray * _Nullable stateArr) {
+        [SVProgressHUD dismiss];
+        
+        for(int i=0; i<stateArr.count; i++)
+        {
+            NSMutableDictionary *state = [stateArr objectAtIndex:i];
+            NSString *userId = [state objectForKey:@"id"];
+            NSString *mobile = [state objectForKey:@"mobile"];
+            int follow = [[state objectForKey:@"follow"] intValue];
+            ContactData *contactData = [wself.contactDict objectForKey:mobile];
+            if(contactData && !contactData.userId)
+            {
+                contactData.userId = userId;
+                contactData.follow = follow;
+            }
+        }
+        
+        [[User sharedInfo] requestFollowList:^{
+            [wself.tableView reloadData];
+        }];
+        
+    } failure:^{
+        [SVProgressHUD dismiss];
+        [self.view makeToast:@"获取联系人信息失败,请重试" duration:2.0 position:CSToastPositionCenter];
+    }];
+}
+
+
+
+
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(!_contactArr)
+        return 0;
+    return _contactArr.count;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Contact"];
+    ContactData *data = [_contactArr objectAtIndex:indexPath.row];
+    [cell setData:data];
+    
+    return cell;
+}
+
+
+@end

+ 15 - 0
NIMDemo/NIMDemo/FriendListTableViewCell.h

@@ -0,0 +1,15 @@
+//
+//  FriendListTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface FriendListTableViewCell : UITableViewCell
+
+- (void)setData:(NSObject *)data;
+
+@end

+ 69 - 0
NIMDemo/NIMDemo/FriendListTableViewCell.m

@@ -0,0 +1,69 @@
+//
+//  FriendListTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "FriendListTableViewCell.h"
+#import "User.h"
+#import "UIView+NTES.h"
+#import "NIMAvatarImageView.h"
+
+@interface FriendListTableViewCell()
+
+@property (weak, nonatomic) IBOutlet UIView *avatarContainer;
+@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
+
+@property (nonatomic, strong) NIMAvatarImageView *avatar;
+@property (nonatomic, strong) NSObject           *data;
+
+@end
+
+@implementation FriendListTableViewCell
+
+- (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
+}
+
+- (void)setData:(NSObject *)data{
+    
+    _data = data;
+    
+    if(!_avatarContainer)
+    {
+        return;
+    }
+    
+    if(!_avatar)
+    {
+        _avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, _avatarContainer.width, _avatarContainer.height)];
+        [_avatarContainer addSubview:_avatar];
+    }
+    
+    if([data isKindOfClass:[NIMUser class]])
+    {
+        NIMUser *user = (NIMUser *)data;
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [_avatar nim_setImageWithURL:url placeholderImage:User.defaultUserAvatar];
+        _nameLabel.text = [[User sharedInfo] getUserName:user];
+    }
+    else
+    {
+        NSDictionary *obj = (NSDictionary *)data;
+        NSString *img = [obj objectForKey:@"img"];
+        NSString *name = [obj objectForKey:@"name"];
+        [_avatar setImage:[UIImage imageNamed:img]];
+        _nameLabel.text = name;
+    }
+}
+
+@end

+ 19 - 0
NIMDemo/NIMDemo/FriendListViewController.h

@@ -0,0 +1,19 @@
+//
+//  FriendListViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "NTESGroupedDataCollection.h"
+
+@interface GroupedContacts : NTESGroupedDataCollection
+
+@end
+
+
+@interface FriendListViewController : UITableViewController
+
+@end

+ 255 - 0
NIMDemo/NIMDemo/FriendListViewController.m

@@ -0,0 +1,255 @@
+//
+//  FriendListViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "FriendListViewController.h"
+#import "User.h"
+#import "FriendListTableViewCell.h"
+#import "NTESContactUtilItem.h"
+#import "NTESContactDataMember.h"
+#import "NTESContactUtilCell.h"
+#import "NTESContactDataCell.h"
+#import "UIView+Toast.h"
+#import "ContactViewController.h"
+#import "HttpRequest.h"
+
+@implementation GroupedContacts
+
+- (instancetype)initWithMembers:(NSMutableArray *)members
+{
+    self = [super init];
+    if(self) {
+        self.groupTitleComparator = ^NSComparisonResult(NSString *title1, NSString *title2) {
+            if ([title1 isEqualToString:@"#"]) {
+                return NSOrderedDescending;
+            }
+            if ([title2 isEqualToString:@"#"]) {
+                return NSOrderedAscending;
+            }
+            return [title1 compare:title2];
+        };
+        self.groupMemberComparator = ^NSComparisonResult(NSString *key1, NSString *key2) {
+            return [key1 compare:key2];
+        };
+        [self setMembers:members];
+    }
+    return self;
+}
+
+@end
+
+
+
+
+@interface FriendListViewController ()<NTESContactUtilCellDelegate,
+NIMContactDataCellDelegate>
+
+@property (nonatomic, strong) GroupedContacts       *contacts;
+@property (nonatomic, strong) NSMutableArray        *requestArr;
+
+@end
+
+@implementation FriendListViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    __weak typeof(self) wself = self;
+    [[User sharedInfo] requestFollowList:^{
+        
+        [[HttpRequest shared] requestFriendList:^(NSMutableArray<FriendRequestData *> * _Nullable dataArr) {
+            
+            wself.requestArr = dataArr;
+            [wself fetchUserInfos];
+            
+        } failure:^{
+            [wself fetchUserInfos];
+        }];
+        
+    }];
+}
+
+
+- (void)fetchUserInfos{
+    __weak typeof(self) wself = self;
+    NSArray *followList = [[User sharedInfo] followList];
+    [[NIMSDK sharedSDK].userManager fetchUserInfos:followList completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+        [wself prepareData];
+    }];
+}
+
+
+- (void)prepareData{
+    
+    NSMutableArray *infoArr = [NSMutableArray array];
+    for (NSString *userId in [[User sharedInfo] followList]) {
+        NIMKitInfo *info           = [[NIMKit sharedKit] infoByUser:userId option:nil];
+        NTESContactDataMember *contact = [[NTESContactDataMember alloc] init];
+        contact.info               = info;
+        [infoArr addObject:contact];
+    }
+    
+    _contacts = [[GroupedContacts alloc] initWithMembers:infoArr];
+    
+    NSString *contactCellUtilIcon   = @"icon";
+    NSString *contactCellUtilVC     = @"vc";
+    NSString *contactCellUtilStory  = @"story";
+    NSString *contactCellUtilBadge  = @"badge";
+    NSString *contactCellUtilTitle  = @"title";
+    NSString *contactCellUtilUid    = @"uid";
+    NSString *contactCellUtilSelectorName = @"selName";
+    
+    NSMutableArray *utils =
+    [@[
+       @{
+           contactCellUtilIcon:@"通讯录_03",
+           contactCellUtilTitle:@"新的朋友",
+           contactCellUtilStory:@"FriendRequest",
+           contactCellUtilBadge:@(_requestArr.count)
+           },
+       @{
+           contactCellUtilIcon:@"通讯录_06",
+           contactCellUtilTitle:@"手机联系人",
+           contactCellUtilStory:@"Contact"
+           },
+       @{
+           contactCellUtilIcon:@"通讯录_08",
+           contactCellUtilTitle:@"群组",
+           contactCellUtilVC:@"NTESAdvancedTeamListViewController"
+           },
+       ] mutableCopy];
+    
+    
+    //构造显示的数据模型
+    NTESContactUtilItem *contactUtil = [[NTESContactUtilItem alloc] init];
+    NSMutableArray * members = [[NSMutableArray alloc] init];
+    for (NSDictionary *item in utils) {
+        NTESContactUtilMember *utilItem = [[NTESContactUtilMember alloc] init];
+        utilItem.nick              = item[contactCellUtilTitle];
+        utilItem.icon              = [UIImage imageNamed:item[contactCellUtilIcon]];
+        utilItem.vcName            = item[contactCellUtilVC];
+        utilItem.badge             = [item[contactCellUtilBadge] stringValue];
+        utilItem.userId            = item[contactCellUtilUid];
+        utilItem.selName           = item[contactCellUtilSelectorName];
+        utilItem.storyboardId      = item[contactCellUtilStory];
+        [members addObject:utilItem];
+    }
+    contactUtil.members = members;
+    
+    [_contacts addGroupAboveWithTitle:@"" members:contactUtil.members];
+    
+    [self.tableView reloadData];
+}
+
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    [self.navigationItem setTitle:@"通讯录"];
+}
+
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    [self prepareData];
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
+    return [_contacts memberCountOfGroup:section];
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
+    return [_contacts groupCount];
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    id contactItem = [_contacts memberOfIndex:indexPath];
+    NSString * cellId = [contactItem reuseId];
+    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
+    if (!cell) {
+        Class cellClazz = NSClassFromString([contactItem cellName]);
+        cell = [[cellClazz alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
+    }
+    if ([contactItem showAccessoryView]) {
+        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+    }else{
+        cell.accessoryType = UITableViewCellAccessoryNone;
+    }
+    if ([cell isKindOfClass:[NTESContactUtilCell class]]) {
+        [(NTESContactUtilCell *)cell refreshWithContactItem:contactItem];
+        [(NTESContactUtilCell *)cell setDelegate:self];
+    }else{
+        [(NTESContactDataCell *)cell refreshUser:contactItem];
+        [(NTESContactDataCell *)cell setDelegate:self];
+    }
+    return cell;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+    [tableView deselectRowAtIndexPath:indexPath animated:YES];
+    id<NTESContactItem> contactItem = (id<NTESContactItem>)[_contacts memberOfIndex:indexPath];
+    if ([contactItem respondsToSelector:@selector(selName)] && [contactItem selName].length) {
+        SEL sel = NSSelectorFromString([contactItem selName]);
+        SuppressPerformSelectorLeakWarning([self performSelector:sel withObject:nil]);
+    }
+    else if (contactItem.vcName.length) {
+        Class clazz = NSClassFromString(contactItem.vcName);
+        UIViewController * vc = [[clazz alloc] initWithNibName:nil bundle:nil];
+        [self.navigationController pushViewController:vc animated:YES];
+    }
+    else if ([contactItem isKindOfClass:[NTESContactUtilMember class]] && ((NTESContactUtilMember *)contactItem).storyboardId.length > 0){
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        UIViewController *vc = [board instantiateViewControllerWithIdentifier:((NTESContactUtilMember *)contactItem).storyboardId];
+        if([vc isKindOfClass:[FriendRequestViewController class]])
+        {
+            [((FriendRequestViewController *)vc) setDataArr:_requestArr];
+        }
+        [self.navigationController pushViewController:vc animated:YES];
+    }
+    else if([contactItem respondsToSelector:@selector(userId)]){
+        NSString * friendId   = contactItem.userId;
+        [self onPressAvatar:friendId];
+    }
+    
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
+    id<NTESContactItem> contactItem = (id<NTESContactItem>)[_contacts memberOfIndex:indexPath];
+    return contactItem.uiHeight;
+}
+
+- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
+    return [_contacts titleOfGroup:section];
+}
+
+- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
+    return _contacts.sortedGroupTitles;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
+    return index + 1;
+}
+
+
+
+#pragma mark - NIMContactDataCellDelegate
+- (void)onPressAvatar:(NSString *)memberId{
+    [User showUserInfo:memberId viewController:self];
+}
+
+#pragma mark - NTESContactUtilCellDelegate
+- (void)onPressUtilImage:(NSString *)content{
+    [self.view makeToast:[NSString stringWithFormat:@"点我干嘛 我是<%@>",content] duration:2.0 position:CSToastPositionCenter];
+}
+
+@end

+ 25 - 0
NIMDemo/NIMDemo/FriendRequestTableViewCell.h

@@ -0,0 +1,25 @@
+//
+//  FriendRequestTableViewCell.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "FriendRequestViewController.h"
+
+@protocol FriendRequestAction <NSObject>
+
+- (void)friendRequestAccept:(FriendRequestData *)data;
+- (void)friendRequestDelete:(NSString *)requestId;
+
+@end
+
+@interface FriendRequestTableViewCell : UITableViewCell
+
+@property (nonatomic, weak) id<FriendRequestAction>             delegate;
+
+- (void)setData:(FriendRequestData *)data;
+
+@end

+ 88 - 0
NIMDemo/NIMDemo/FriendRequestTableViewCell.m

@@ -0,0 +1,88 @@
+//
+//  FriendRequestTableViewCell.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "FriendRequestTableViewCell.h"
+#import "User.h"
+#import "UIView+NTES.h"
+#import "NIMAvatarImageView.h"
+
+@interface FriendRequestTableViewCell()
+
+@property (weak, nonatomic) IBOutlet UIView *avatarContainer;
+@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
+@property (weak, nonatomic) IBOutlet UILabel *descLabel;
+@property (weak, nonatomic) IBOutlet UIButton *btn;
+
+@property (nonatomic, strong) NIMAvatarImageView *avatar;
+@property (nonatomic, strong) FriendRequestData *data;
+@end
+
+@implementation FriendRequestTableViewCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+    
+    _btn.layer.cornerRadius = 3;
+    
+    [self setData:_data];
+    
+    
+    UILongPressGestureRecognizer *longPressGesture= [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longGesturePress:)];
+    [self addGestureRecognizer:longPressGesture];
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setData:(FriendRequestData *)data{
+    _data = data;
+    
+    if(!_avatarContainer || !data)
+    {
+        return;
+    }
+    
+    if(!_avatar)
+    {
+        _avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, _avatarContainer.width, _avatarContainer.height)];
+        [_avatarContainer addSubview:_avatar];
+    }
+    
+    __weak typeof(self) wself = self;
+    [[NIMSDK sharedSDK].userManager fetchUserInfos:@[data.userId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+        NIMUser *user = [users objectAtIndex:0];
+        NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;
+        [wself.avatar nim_setImageWithURL:url placeholderImage:User.defaultUserAvatar];
+        
+        wself.nameLabel.text = [[User sharedInfo] getUserName:user];
+    }];
+    
+    _descLabel.text = data.msg;
+}
+
+- (void)longGesturePress:(UIGestureRecognizer*)gestureRecognizer
+{
+    if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] &&
+        gestureRecognizer.state == UIGestureRecognizerStateBegan) {
+        if (self.delegate && [self.delegate respondsToSelector:@selector(friendRequestDelete:)]) {
+            [self.delegate friendRequestDelete:_data.requestId];
+        }
+    }
+}
+
+- (IBAction)onTouchAccept:(id)sender {
+    if (self.delegate && [self.delegate respondsToSelector:@selector(friendRequestAccept:)]) {
+        [self.delegate friendRequestAccept:_data];
+    }
+}
+
+@end

+ 21 - 0
NIMDemo/NIMDemo/FriendRequestViewController.h

@@ -0,0 +1,21 @@
+//
+//  FriendRequestViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface FriendRequestData : NSObject
+@property (nonatomic, strong) NSString            *requestId;
+@property (nonatomic, strong) NSString            *userId;
+@property (nonatomic, strong) NSString            *msg;
+@end
+
+@interface FriendRequestViewController : UITableViewController
+
+- (void)setDataArr:(NSMutableArray *)dataArr;
+
+@end

+ 126 - 0
NIMDemo/NIMDemo/FriendRequestViewController.m

@@ -0,0 +1,126 @@
+//
+//  FriendRequestViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/29.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "FriendRequestViewController.h"
+#import "UIActionSheet+NTESBlock.h"
+#import "SVProgressHUD.h"
+#import "FriendRequestTableViewCell.h"
+#import "HttpRequest.h"
+#import "UIView+Toast.h"
+
+@implementation FriendRequestData
+
+@end
+
+@interface FriendRequestViewController ()<FriendRequestAction>
+
+@property (nonatomic, strong) NSMutableArray            *dataArr;
+
+@end
+
+@implementation FriendRequestViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    [self.navigationItem setTitle:@"新的朋友"];
+}
+
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    [self.tableView reloadData];
+}
+
+- (void)setDataArr:(NSMutableArray *)dataArr{
+    _dataArr = dataArr;
+}
+
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(!_dataArr)
+        return 0;
+    return _dataArr.count;
+}
+
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    FriendRequestTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Request"];
+    
+    cell.delegate = self;
+    [cell setData:[_dataArr objectAtIndex:indexPath.row]];
+    
+    return cell;
+}
+
+
+
+
+
+- (void)friendRequestAccept:(FriendRequestData *)data{
+    __weak typeof(self) wself = self;
+    
+    [[HttpRequest shared] addFriend:data.requestId targetId:data.userId success:^{
+        [wself.view makeToast:@"添加成功" duration:2.0 position:CSToastPositionCenter];
+        [wself removeData:data.requestId];
+    } failure:^{
+        [wself.view makeToast:@"添加失败" duration:2.0 position:CSToastPositionCenter];
+    }];
+}
+
+
+- (void)friendRequestDelete:(NSString *)requestId{
+    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"删除", nil];
+    
+    __weak typeof(self) wself = self;
+    [sheet showInView:self.view completionHandler:^(NSInteger index) {
+        switch (index) {
+            case 0:
+            {
+                [[HttpRequest shared] deleteFriendRequest:requestId success:^{
+                    [wself removeData:requestId];
+                } failure:^{
+                    [wself.view makeToast:@"删除失败" duration:2.0 position:CSToastPositionCenter];
+                }];
+                break;
+            }
+            default:
+                break;
+        }
+    }];
+}
+
+- (void)removeData:(NSString *)requestId
+{
+    for(int i=0; i<_dataArr.count; i++)
+    {
+        FriendRequestData *data = [_dataArr objectAtIndex:i];
+        if([data.requestId isEqualToString:requestId])
+        {
+            [_dataArr removeObjectAtIndex:i];
+            break;
+        }
+    }
+    
+    [self.tableView reloadData];
+}
+
+@end

+ 33 - 2
NIMDemo/NIMDemo/FriendViewController.m

@@ -23,6 +23,7 @@
 #import "NTESContactViewController.h"
 #import "NTESContactAddFriendViewController.h"
 #import "User.h"
+#import "ContactViewController.h"
 
 #define SessionListTitle @"谁说"
 
@@ -77,6 +78,12 @@
     
     NSString *userID = [[[NIMSDK sharedSDK] loginManager] currentAccount];
     self.navigationItem.titleView  = [self titleView:userID];
+    
+    __weak typeof(self) wself = self;
+    [[User sharedInfo] requestChatStickList:^{
+        [wself sort];
+        [wself refresh:YES];
+    }];
 }
 
 - (void)viewWillAppear:(BOOL)animated{
@@ -106,7 +113,9 @@
     UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithCustomView:addBtn];
     
     [navItem setRightBarButtonItems:@[addItem, contactItem]];
-
+    
+    [self sort];
+    [self refresh:YES];
 }
 
 - (void)refresh:(BOOL)reload{
@@ -366,7 +375,8 @@
 
 - (void)showContact:(int)sender
 {
-    NTESContactViewController *vc = [[NTESContactViewController alloc] init];
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    ContactViewController *vc = [board instantiateViewControllerWithIdentifier:@"FriendList"];
     [self.navigationController pushViewController:vc animated:YES];
 }
 
@@ -375,4 +385,25 @@
     NTESContactAddFriendViewController *vc = [[NTESContactAddFriendViewController alloc] init];
     [self.navigationController pushViewController:vc animated:YES];
 }
+
+
+- (void)sort{
+    [self.recentSessions sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
+        NIMRecentSession *item1 = obj1;
+        NIMRecentSession *item2 = obj2;
+        
+        NSComparisonResult result = [[User sharedInfo] compareChatStick:item1.session.sessionId chatIdB:item2.session.sessionId];
+        
+        if(result != NSOrderedSame)
+            return result;
+        
+        if (item1.lastMessage.timestamp < item2.lastMessage.timestamp) {
+            return NSOrderedDescending;
+        }
+        if (item1.lastMessage.timestamp > item2.lastMessage.timestamp) {
+            return NSOrderedAscending;
+        }
+        return NSOrderedSame;
+    }];
+}
 @end

+ 2 - 127
NIMDemo/NIMDemo/GroupTableController.m

@@ -23,7 +23,6 @@
 @property (nonatomic, strong) UIButton *localBtn;
 
 @property (nonatomic, strong) NSMutableArray *groupArr;
-@property(strong, nonatomic) CLLocationManager *locationManager;
 
 @end
 
@@ -31,20 +30,6 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    
-    self.locationManager = [[CLLocationManager alloc] init];
-    self.locationManager.delegate = self;
-    self.locationManager.distanceFilter = 1.0;
-    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
-    
-    if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
-    {
-        [self.locationManager requestAlwaysAuthorization]; // 永久授权
-        [self.locationManager requestWhenInUseAuthorization]; //使用中授权
-    }
-    
-    [self.locationManager startUpdatingLocation];
-    
     NSLog(@"check user data is saved %@", [User sharedInfo].mobile);
 }
 
@@ -60,7 +45,7 @@
     
     UINavigationItem *navItem = self.parentViewController.navigationItem;
     
-    navItem.title = @"群组";
+    navItem.title = @"谁说";
     
     User *user = [User sharedInfo];
     NSString *title = @"请重试定位";
@@ -140,7 +125,7 @@
     
     NIMTeam *team = [[[NIMSDK sharedSDK] teamManager] teamById:user.countryRoomId];
     NSString *desc = [NSString stringWithFormat:@"%ld%@", (long)team.memberNumber, @"人热聊中"];
-    NSDictionary *county = @{@"cid":@"Group", @"name":@"国家", @"desc":desc, @"sid":user.countryRoomId, @"avatar":@""};
+    NSDictionary *county = @{@"cid":@"Group", @"name":@"国家聊天室", @"desc":desc, @"sid":user.countryRoomId, @"avatar":@""};
     [myTeams addObject:county];
     
     if(![user.provinceRoomId isEqualToString:@""] && user.provinceRoomId != nil)
@@ -359,114 +344,4 @@
 }
 
 
-- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
-{
-    User *user = [User sharedInfo];
-    
-    if(user.districtRoomId && user.districtRoomId.length > 0)
-        [self.locationManager stopUpdatingLocation];
-    
-    NSLog(@"经度:%f", newLocation.coordinate.longitude);
-    NSLog(@"纬度:%f", newLocation.coordinate.latitude);
-    NSLog(@"速度:%f 米/秒", newLocation.speed);
-    CLGeocoder * geocoder = [[CLGeocoder alloc] init];
-    [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
-        
-        NSDictionary *locationInfo = [[NSDictionary alloc]init];
-        for (CLPlacemark * placemark in placemarks) {
-            locationInfo = [placemark addressDictionary];
-        }
-        NSLog(@"%@",locationInfo);
-    }];
-    
-    
-    if(user.latitude != newLocation.coordinate.latitude || user.longitude != newLocation.coordinate.longitude)
-    {
-        user.longitude = newLocation.coordinate.longitude;
-        user.latitude = newLocation.coordinate.latitude;
-        
-        [self coordinate2Location];
-    }
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
-{
-    NSLog(@"localtion error %@", error);
-}
-
-
-- (void)coordinate2Location
-{
-    User *user = [User sharedInfo];
-    
-    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";
-    //请求的managers
-    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
-    manager.responseSerializer = [AFJSONResponseSerializer new];
-    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
-    
-    __weak typeof(self) wself = self;
-    
-    NSLog(@"%@", parameters);
-    
-    //请求的方式:POST
-    [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];
-        NSDictionary *data = (NSDictionary *)[dic objectForKey:@"d"];
-        
-        NSLog(@"Json解析结果 = %d   %@", code, data);
-        
-        if(code == 0 && ([user.provinceRoomId isEqualToString:@""] || user.provinceRoomId == nil))
-        {
-            if([data objectForKey:@"province"])
-                user.province = [data objectForKey:@"province"];
-            if([data objectForKey:@"city"])
-                user.city = [data objectForKey:@"city"];
-            if([data objectForKey:@"district"])
-                user.district = [data objectForKey:@"district"];
-            
-            if([data objectForKey:@"province_room_id"])
-                user.provinceRoomId = [data objectForKey:@"province_room_id"];
-            if([data objectForKey:@"city_room_id"])
-                user.cityRoomId = [data objectForKey:@"city_room_id"];
-            if([data objectForKey:@"district_room_id"])
-                user.districtRoomId = [data objectForKey:@"district_room_id"];
-            
-            [wself setDataList];
-            [wself.tableView reloadData];
-            
-            if(user.district && user.district.length > 0)
-            {
-                NSString *title = @"";
-                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)], @"..."];
-                }
-                [wself.localBtn setTitle:title forState:UIControlStateNormal];
-                
-                [self gotoTeamChat:user.districtRoomId];
-            }
-        }
-        
-    } failure:^(NSURLSessionDataTask *task, NSError * error) {
-        [SVProgressHUD dismiss];
-        NSLog(@"请求失败,服务器返回的错误信息%@",error);
-    }];
-}
-
 @end

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

@@ -11,9 +11,17 @@
 #import "SocialCommentData.h"
 #import "TradeData.h"
 #import "UserInfo.h"
+#import "FriendRequestViewController.h"
 
 @interface HttpRequest : NSObject
 
+
+@property (nonatomic, strong) NSString * _Nullable urlAbout;
+@property (nonatomic, strong) NSString * _Nullable urlLaw;
+@property (nonatomic, strong) NSString * _Nullable urlAgreement;
+
+
+
 + (instancetype _Nonnull )shared;
 
 
@@ -22,6 +30,10 @@
          success:(void (^_Nullable)())success
          failure:(void (^_Nullable)())failure;
 
+- (void)sendMsg:(NSString *_Nullable)mobile
+        success:(void (^_Nullable)())success
+        failure:(void (^_Nullable)())failure;
+
 //register
 - (void)registerAccount:(NSString *_Nullable)mobile
                    code:(NSString *_Nullable)code
@@ -77,6 +89,9 @@
        success:(void (^_Nullable)(int follow))success
        failure:(void (^_Nullable)())failure;
 
+- (void)followList:(void (^_Nullable)(NSMutableArray * _Nullable follows))success
+           failure:(void (^_Nullable)())failure;
+
 - (void)userInfo:(NSString *_Nullable)userId
        success:(void (^_Nullable)(UserInfo * _Nullable userInfo))success
        failure:(void (^_Nullable)())failure;
@@ -101,6 +116,24 @@
             success:(void (^_Nullable)(NSMutableDictionary * _Nullable photoData))success
             failure:(void (^_Nullable)())failure;
 
+- (void)requestFriend:(NSString *_Nullable)userId
+                  msg:(NSString *_Nullable)msg
+              success:(void (^_Nullable)())success
+              failure:(void (^_Nullable)())failure;
+
+- (void)requestFriendList:(void (^_Nullable)(NSMutableArray<FriendRequestData *> * _Nullable dataArr))success
+            failure:(void (^_Nullable)())failure;
+
+- (void)addFriend:(NSString *_Nullable)requestId
+         targetId:(NSString *_Nullable)targetId
+          success:(void (^_Nullable)())success
+          failure:(void (^_Nullable)())failure;
+
+- (void)deleteFriendRequest:(NSString *_Nullable)requestId
+                    success:(void (^_Nullable)())success
+                    failure:(void (^_Nullable)())failure;
+
+
 
 //trade
 - (void)tradePublish:(NSString *_Nullable)msg
@@ -108,6 +141,7 @@
                 type:(int)type
             priority:(int)priority
         priorityType:(int)priorityType
+              roomId:(NSString *_Nullable)roomId
              success:(void (^_Nullable)())success
              failure:(void (^_Nullable)())failure;
 
@@ -165,4 +199,22 @@
 - (void)hobbyList:(void (^_Nullable)(NSMutableDictionary * _Nullable dict))success
           failure:(void (^_Nullable)())failure;
 
+- (void)complain:(NSString *_Nullable)msg
+            type:(int)type
+          userId:(NSString *_Nullable)userId
+         success:(void (^_Nullable)())success
+         failure:(void (^_Nullable)())failure;
+
+- (void)contactState:(NSMutableArray *_Nullable)mobileArr
+             success:(void (^_Nullable)(NSMutableArray * _Nullable stateArr))success
+             failure:(void (^_Nullable)())failure;
+
+- (void)chatStickList:(void (^_Nullable)(NSMutableArray * _Nullable chatStickArr))success
+              failure:(void (^_Nullable)())failure;
+
+- (void)chatStick:(NSString *_Nullable)chatId
+            stick:(BOOL)stick
+          success:(void (^_Nullable)(int inputTime))success
+          failure:(void (^_Nullable)())failure;
+
 @end

+ 267 - 12
NIMDemo/NIMDemo/HttpRequest/HttpRequest.m

@@ -35,6 +35,7 @@
 @property (nonatomic, strong) NSString *urlSocialComment;
 @property (nonatomic, strong) NSString *urlSocialCommentList;
 @property (nonatomic, strong) NSString *urlFollow;
+@property (nonatomic, strong) NSString *urlFollowList;
 @property (nonatomic, strong) NSString *urlUserInfo;
 @property (nonatomic, strong) NSString *urlUpdateUserInfo;
 @property (nonatomic, strong) NSString *urlUpdateNick;
@@ -42,6 +43,11 @@
 @property (nonatomic, strong) NSString *urlNearUser;
 @property (nonatomic, strong) NSString *urlPhotoUpload;
 
+@property (nonatomic, strong) NSString *urlRequestFriend;
+@property (nonatomic, strong) NSString *urlFriendRequestList;
+@property (nonatomic, strong) NSString *urlAddFriend;
+@property (nonatomic, strong) NSString *urlDeleteFriendRequest;
+
 //trade
 @property (nonatomic, strong) NSString *urlTradePublish;
 @property (nonatomic, strong) NSString *urlTradeEdit;
@@ -53,12 +59,18 @@
 @property (nonatomic, strong) NSString *urlTradeDeleteFollow;
 
 //setting
-@property (nonatomic, strong) NSString *urlSendCode;
 @property (nonatomic, strong) NSString *urlChangeMobile;
 @property (nonatomic, strong) NSString *urlChangePassword;
 @property (nonatomic, strong) NSString *urlFeedBack;
 @property (nonatomic, strong) NSString *urlHobbyList;
+@property (nonatomic, strong) NSString *urlComplain;
+@property (nonatomic, strong) NSString *urlContact;
+@property (nonatomic, strong) NSString *urlChatStickList;
+@property (nonatomic, strong) NSString *urlChatStick;
 
+//sms
+@property (nonatomic, strong) NSString *urlSendCode;
+@property (nonatomic, strong) NSString *urlSendMsg;
 
 @end
 
@@ -96,12 +108,19 @@
         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.urlFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=follow"];
+        self.urlFollowList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=follows"];
         self.urlUserInfo = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=get_user"];
         self.urlUpdateNick = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=update_nick"];
         self.urlUpdateUserInfo = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=update_info"];
         self.urlUploadSocialBanner = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=banner_upload"];
         self.urlNearUser = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=near_user"];
         self.urlPhotoUpload = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=photo_upload"];
+        self.urlContact = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=contact"];
+        
+        self.urlRequestFriend = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=request_friend"];
+        self.urlFriendRequestList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=request_list"];
+        self.urlAddFriend = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=add_friend"];
+        self.urlDeleteFriendRequest = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=delete_request"];
         
         
         self.urlTradePublish = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=publish"];
@@ -114,11 +133,20 @@
         self.urlTradeDeleteFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete_follow"];
         
         
-        self.urlSendCode = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=send_code"];
         self.urlChangeMobile = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=change_mobile"];
         self.urlChangePassword = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=pwd_update"];
         self.urlFeedBack = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=feedback&a=report"];
         self.urlHobbyList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=hobby_list"];
+        self.urlComplain = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=complain"];
+        self.urlAbout = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=about"];
+        self.urlLaw = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=law"];
+        self.urlAgreement = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=agreement"];
+        self.urlChatStickList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=chatstick_list"];
+        self.urlChatStick = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=chatstick"];
+        
+        
+        self.urlSendCode = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=send_code"];
+        self.urlSendMsg = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=send_msg"];
     }
     return self;
 }
@@ -274,15 +302,11 @@
 
 
 
-
-
-
-
-//register
+//sms
 - (void)sendCode:(NSString *_Nullable)mobile
          success:(void (^_Nullable)())success
          failure:(void (^_Nullable)())failure{
-
+    
     NSDictionary *parameters = @{@"mobile":mobile};
     
     [self request:_urlSendCode parameters:parameters progress:nil success:^(id jsonData) {
@@ -295,6 +319,26 @@
     
 }
 
+- (void)sendMsg:(NSString *)mobile
+        success:(void (^)())success
+        failure:(void (^)())failure
+{
+    NSInteger index = [User sharedInfo].mobile.length - 4;
+    NSString *msg = [[User sharedInfo].mobile substringFromIndex:index];
+    NSDictionary *parameters = @{@"mobile":mobile, @"msg":msg};
+    
+    [self request:_urlSendMsg parameters:parameters progress:nil success:^(id jsonData) {
+        if(success)
+            success();
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+
+
+//register
 - (void)registerAccount:(NSString *_Nullable)mobile
                    code:(NSString *_Nullable)code
                password:(NSString *_Nullable)password
@@ -346,7 +390,7 @@
         user.districtRoomId = [data valueForKey:@"district_room_id"];
         user.firstTimeJoin = YES;
         
-        
+        user.tradePublishCount = [[data valueForKey:@"trade_count"] intValue];
         
         NSMutableArray *tradePriorityItemArr = [data valueForKey:@"trade_priority"];
         [user.tradePriorityItemArr removeAllObjects];
@@ -654,6 +698,11 @@
         
         int follow = [[jsonData objectForKey:@"follow"] intValue];
         
+        if(follow > 0)
+            [[User sharedInfo] follow:userId];
+        else
+            [[User sharedInfo] unfollow:userId];
+        
         if(success)
             success(follow);
         
@@ -665,7 +714,24 @@
     }];
 }
 
-
+- (void)followList:(void (^_Nullable)(NSMutableArray * _Nullable follows))success
+           failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId]};
+    
+    [self request:_urlFollowList parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success(jsonData);
+        
+    } failure:^{
+        
+        if(failure)
+            failure();
+        
+    }];
+}
 
 - (void)userInfo:(NSString *_Nullable)userId
          success:(void (^_Nullable)(UserInfo * _Nullable userInfo))success
@@ -814,12 +880,97 @@
 }
 
 
+
+
+- (void)requestFriend:(NSString *)userId msg:(NSString *)msg success:(void (^)())success failure:(void (^)())failure{
+    
+    NSDictionary *parameters = @{@"target_id":userId, @"user_id":[NSString stringWithFormat:@"%d", [User sharedInfo].userId]};
+    
+    [self request:_urlRequestFriend parameters:parameters progress:nil success:^(id jsonData) {
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+- (void)requestFriendList:(void (^)(NSMutableArray<FriendRequestData *> * _Nullable))success failure:(void (^)())failure{
+    
+    NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", [User sharedInfo].userId]};
+    
+    [self request:_urlFriendRequestList parameters:parameters progress:nil success:^(id jsonData) {
+        
+        NSMutableArray *dataList = (NSMutableArray *)jsonData;
+        NSMutableArray<FriendRequestData *> *requestList = [[NSMutableArray alloc] init];
+        NSMutableArray *userIds = [[NSMutableArray alloc] init];
+        for(int i=0; i<dataList.count; i++)
+        {
+            NSMutableDictionary *data = [dataList objectAtIndex:i];
+            FriendRequestData *requestData = [[FriendRequestData alloc] init];
+            requestData.requestId = [data objectForKey:@"id"];
+            requestData.userId = [data objectForKey:@"user_id"];
+            requestData.msg = [data objectForKey:@"msg"];
+            
+            [requestList addObject:requestData];
+            [userIds addObject:requestData.userId];
+        }
+        
+        [[NIMSDK sharedSDK].userManager fetchUserInfos:userIds completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
+            if(success)
+                success(requestList);
+        }];
+        
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+- (void)addFriend:(NSString *)requestId targetId:(NSString *)targetId success:(void (^)())success failure:(void (^)())failure{
+    
+    NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", [User sharedInfo].userId],
+                                 @"target_id":targetId,
+                                 @"id":requestId};
+    
+    [self request:_urlAddFriend parameters:parameters progress:nil success:^(id jsonData) {
+        
+        [[User sharedInfo] follow:targetId];
+        
+        if(success)
+            success();
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+    
+}
+
+- (void)deleteFriendRequest:(NSString *)requestId success:(void (^)())success failure:(void (^)())failure{
+    
+    NSDictionary *parameters = @{@"id":requestId};
+    
+    [self request:_urlDeleteFriendRequest parameters:parameters progress:nil success:^(id jsonData) {
+        if(success)
+            success();
+    } failure:^{
+        if(failure)
+            failure();
+    }];
+}
+
+
+
+
 //trade
 - (void)tradePublish:(NSString *)msg
               picArr:(NSMutableArray *)picArr
                 type:(int)type
             priority:(int)priority
         priorityType:(int)priorityType
+              roomId:(NSString *_Nullable)roomId
              success:(void (^_Nullable)())success
              failure:(void (^_Nullable)())failure{
     
@@ -828,12 +979,19 @@
     
     NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
     [parameters setValue:userId forKey:@"user_id"];
+    [parameters setValue:picArr forKey:@"pic"];
+    [parameters setValue:@(type) forKey:@"type"];
+    [parameters setValue:@(priority) forKey:@"priority"];
+    [parameters setValue:@(priorityType) forKey:@"priority_type"];
+    [parameters setValue:msg forKey:@"msg"];
+    if(roomId)
+       [parameters setValue:roomId forKey:@"room_id"];
     
     
-
-    
     [self request:_urlTradePublish parameters:parameters progress:nil success:^(id jsonData) {
         
+        [User sharedInfo].tradePublishCount++;
+        
         if(success)
             success();
         
@@ -1223,4 +1381,101 @@
     
 }
 
+
+- (void)complain:(NSString *_Nullable)msg
+            type:(int)type
+          userId:(NSString *_Nullable)userId
+         success:(void (^_Nullable)())success
+         failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    NSString *myUserId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:myUserId forKey:@"user_id"];
+    [parameters setValue:userId forKey:@"target_id"];
+    [parameters setValue:msg forKey:@"msg"];
+    [parameters setValue:[NSString stringWithFormat:@"%d", type] forKey:@"type"];
+    
+    [self request:_urlComplain parameters:parameters progress:nil
+          success:^(id jsonData) {
+              if(success)
+                  success();
+          } failure:^{
+              if(failure)
+                  failure();
+          }];
+}
+
+- (void)contactState:(NSMutableArray *_Nullable)mobileArr
+             success:(void (^_Nullable)(NSMutableArray * _Nullable stateArr))success
+             failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    NSString *myUserId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:myUserId forKey:@"user_id"];
+    [parameters setValue:mobileArr forKey:@"mobiles"];
+    
+    [self request:_urlContact parameters:parameters progress:nil
+          success:^(id jsonData) {
+              
+              NSMutableArray *contacts = (NSMutableArray *)jsonData;
+              if(success)
+                  success(contacts);
+          } failure:^{
+              if(failure)
+                  failure();
+          }];
+}
+
+
+- (void)chatStickList:(void (^_Nullable)(NSMutableArray * _Nullable chatStickArr))success
+              failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    NSString *myUserId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:myUserId forKey:@"user_id"];
+    
+    [self request:_urlChatStickList parameters:parameters progress:nil
+          success:^(id jsonData) {
+              
+              NSMutableArray *chatStickArr = (NSMutableArray *)jsonData;
+              if(success)
+                  success(chatStickArr);
+          } failure:^{
+              if(failure)
+                  failure();
+          }];
+    
+}
+
+- (void)chatStick:(NSString *_Nullable)chatId
+            stick:(BOOL)stick
+          success:(void (^_Nullable)(int inputTime))success
+          failure:(void (^_Nullable)())failure{
+    
+    User *user = [User sharedInfo];
+    NSString *myUserId = [NSString stringWithFormat:@"%d", user.userId];
+    
+    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
+    [parameters setValue:myUserId forKey:@"user_id"];
+    [parameters setValue:chatId forKey:@"chat_id"];
+    [parameters setValue:(stick ? @"1" : @"0") forKey:@"stick"];
+    
+    [self request:_urlChatStick parameters:parameters progress:nil
+          success:^(id jsonData) {
+              
+              int inputTime = [[jsonData objectForKey:@"inputtime"] intValue];
+              if(success)
+                  success(inputTime);
+          } failure:^{
+              if(failure)
+                  failure();
+          }];
+    
+}
 @end

+ 94 - 19
NIMDemo/NIMDemo/ImagePagerViewController.m

@@ -7,21 +7,21 @@
 //
 
 #import "ImagePagerViewController.h"
-#import "NIMPageView.h"
 #import "UIView+NTES.h"
 #import "UIImageView+WebCache.h"
 #import "SVProgressHUD.h"
 
 
-@interface ImagePagerViewController ()<NIMPageViewDataSource,NIMPageViewDelegate>
+@interface ImagePagerViewController ()<NIMPageViewDataSource,NIMPageViewDelegate, UIScrollViewDelegate>
 
 @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;
 
+@property (nonatomic, strong) UIScrollView              *scrollView;
+
 @end
 
 @implementation ImagePagerViewController
@@ -43,11 +43,15 @@
     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];
+    _scrollView = [[UIScrollView alloc] initWithFrame:container.bounds];
+    _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+    [container addSubview:_scrollView];
+    _scrollView.pagingEnabled = YES;
+    _scrollView.showsVerticalScrollIndicator = NO;
+    _scrollView.showsHorizontalScrollIndicator = NO;
+    _scrollView.delegate = self;
+    _scrollView.scrollsToTop = NO;
+    _scrollView.contentSize = CGSizeMake(_images.count * _scrollView.width, _scrollView.height);
     
     
     _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, container.bottom - 30, container.width, 30)];
@@ -56,8 +60,23 @@
     _pageControl.currentPageIndicatorTintColor = [UIColor lightGrayColor];
     _pageControl.hidesForSinglePage = YES;
     [_pageControl setUserInteractionEnabled:NO];
+    _pageControl.numberOfPages = _images.count;
     [self.view addSubview:_pageControl];
     
+
+    
+    
+    for(int i=0; i<_images.count; i++)
+    {
+        UIView *view = [self pageView:i];
+        view.frame = CGRectMake(i*container.width, 0, container.width, container.height);
+        [_scrollView addSubview:view];
+    }
+    
+    CGPoint offset = _scrollView.contentOffset;
+    offset.x = _currentIndex * _scrollView.width;
+    [_scrollView setContentOffset:offset];
+    _pageControl.currentPage = _currentIndex;
 }
 
 - (void)didReceiveMemoryWarning {
@@ -67,41 +86,49 @@
 
 - (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 *)pageView:(NSInteger)index
 {
-    UIView *subView = [[UIView alloc] init];
+    float width = _scrollView.width;
+    float height = _scrollView.height;
+    
+    UIScrollView *subView = [[UIScrollView 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)];
+    UIImageView *thumbView = [[UIImageView alloc] initWithFrame:CGRectMake(width/2 - 64, height/2 - 64, 128, 128)];
     [thumbView sd_setImageWithURL:thumbUrl];
     [subView addSubview:thumbView];
     
-    UIActivityIndicatorView* act = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(_pageView.width/2 - 15, _pageView.height/2 - 15, 30, 30)];
+    UIActivityIndicatorView* act = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(width/2 - 15, height/2 - 15, 30, 30)];
     act.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;
     act.color = UIColor.whiteColor;
     [act startAnimating];
     
+    [subView addSubview:act];
     
-    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _pageView.width, _pageView.height)];
+    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
     [imgView sd_setImageWithURL:imageUrl completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
         [act stopAnimating];
     }];
     imgView.contentMode =  UIViewContentModeScaleAspectFit;
+    imgView.tag = 1;
     [subView addSubview:imgView];
     
-    [subView addSubview:act];
+    
+    
+    subView.delegate = self;
+    subView.maximumZoomScale = 2.0;
+    subView.minimumZoomScale = 1.0;
+    
+    
     
     return subView;
 }
@@ -114,6 +141,37 @@
     self.pageControl.currentPage = index;
 }
 
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView
+{
+    if(![scrollView isEqual:_scrollView])
+    {
+        return;
+    }
+    
+    CGFloat width = scrollView.bounds.size.width;
+    CGFloat offsetX = scrollView.contentOffset.x;
+    NSInteger page = (NSInteger)(fabs(offsetX / width));
+    if (page >= 0 && page < [_images count])
+    {
+        if (_currentIndex == page) {
+            return;
+        }
+        _currentIndex = (int)page;
+        _pageControl.currentPage = page;
+    }
+    
+    for(int i=0; i<_images.count; i++)
+    {
+        UIScrollView *view = [_scrollView.subviews objectAtIndex:i];
+        if(i != _currentIndex)
+        {
+            [view setZoomScale:1.0 animated:NO];
+            view.top = 0;
+            view.left = i*_scrollView.width;
+        }
+    }
+}
+
 
 - (void)setImages:(NSArray *)images thumbs:(NSArray *)thumbs startIndex:(int)startIndex{
     
@@ -123,4 +181,21 @@
 
 }
 
+
+-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
+{
+    if([scrollView isEqual:_scrollView])
+    {
+        return nil;
+    }
+    
+    for(int i=0; i<scrollView.subviews.count; i++)
+    {
+        UIView *view = [scrollView.subviews objectAtIndex:i];
+        if(view.tag == 1)
+            return view;
+    }
+    return nil;
+}
+
 @end

+ 21 - 0
NIMDemo/NIMDemo/Images.xcassets/Whosay/送礼物_03.imageset/Contents.json

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

BIN
NIMDemo/NIMDemo/Images.xcassets/Whosay/送礼物_03.imageset/送礼物_03.png


+ 22 - 2
NIMDemo/NIMDemo/MyUserInfoViewController.m

@@ -40,6 +40,9 @@
 @property (nonatomic, strong) UIAlertView       *realNameAlert;
 @property (nonatomic, strong) UIAlertView       *idNumberAlert;
 
+@property (nonatomic, strong) NSString          *realNamePlaceHold;
+@property (nonatomic, strong) NSString          *idNumberPlaceHold;
+
 @end
 
 @implementation MyUserInfoViewController
@@ -47,11 +50,15 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
+    _realNamePlaceHold = @"请填写真实姓名";
+    _idNumberPlaceHold = @"请填写身份证号码";
+    
     __weak typeof(self) wself = self;
     [[User sharedInfo] fetchUserInfo:^(UserInfo * _Nonnull userInfo) {
         wself.userInfo = userInfo;
         [wself fillInfo];
     }];
+    
 }
 
 - (void)viewWillAppear:(BOOL)animated{
@@ -121,15 +128,16 @@
         _hobbyLabel.text = @"";
     }
     
+    
     if(_userInfo.realName && _userInfo.realName.length > 0)
         _realNameLabel.text = _userInfo.realName;
     else
-        _realNameLabel.text = @"请填写真实姓名";
+        _realNameLabel.text = _realNamePlaceHold;
     
     if(_userInfo.idNumber && _userInfo.idNumber.length > 0)
         _idNumberLabel.text = _userInfo.idNumber;
     else
-        _idNumberLabel.text = @"请填写身份证号码";
+        _idNumberLabel.text = _idNumberPlaceHold;
 }
 
 - (void)didReceiveMemoryWarning {
@@ -316,12 +324,24 @@
 }
 
 - (void)handleRealName{
+    
+    if(![_realNameLabel.text isEqualToString:_realNamePlaceHold])
+    {
+        return;
+    }
+    
     _realNameAlert = [[UIAlertView alloc] initWithTitle:@"" message:@"设置姓名" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
     _realNameAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
     [_realNameAlert show];
 }
 
 - (void)handleIdNumber{
+
+    if(![_idNumberLabel.text isEqualToString:_idNumberPlaceHold])
+    {
+        return;
+    }
+    
     _idNumberAlert = [[UIAlertView alloc] initWithTitle:@"" message:@"设置身份证" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
     _idNumberAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
     [_idNumberAlert show];

+ 16 - 1
NIMDemo/NIMDemo/RegisterViewController.m

@@ -153,13 +153,22 @@
     _agreementBtn.frame = CGRectMake(startX, registerBtn.bottom+padding, width, 20);
     _agreementBtn.titleLabel.font = [UIFont systemFontOfSize:12];
     [_agreementBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
-    [_agreementBtn setTitle:@" 我同意遵守《谁说社交APP服务协议》" forState:UIControlStateNormal];
+    [_agreementBtn setTitle:@" 我同意遵守" forState:UIControlStateNormal];
     [_agreementBtn setImage:[UIImage imageNamed:@"聊天3_05"] forState:UIControlStateNormal];
     [_agreementBtn addTarget:self action:@selector(toggleAgreement:) forControlEvents:UIControlEventTouchUpInside];
     [_agreementBtn sizeToFit];
     [self.view addSubview:_agreementBtn];
     
     
+    UIButton *agreeInfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    agreeInfoBtn.frame = CGRectMake(_agreementBtn.right, registerBtn.bottom+padding-3, width, 20);
+    agreeInfoBtn.titleLabel.font = [UIFont systemFontOfSize:12];
+    [agreeInfoBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [agreeInfoBtn setTitle:@"《谁说社交APP服务协议》" forState:UIControlStateNormal];
+    [agreeInfoBtn addTarget:self action:@selector(showAgreement:) forControlEvents:UIControlEventTouchUpInside];
+    [agreeInfoBtn sizeToFit];
+    [self.view addSubview:agreeInfoBtn];
+    
     
     UILabel *copyRight = [[UILabel alloc] initWithFrame:CGRectMake(startX, self.view.bottom-50, width, 20)];
     [copyRight setTextColor:UIColor.lightGrayColor];
@@ -228,6 +237,12 @@
     
 }
 
+- (void)showAgreement:(id)sender{
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"Agreement"];
+    [self.navigationController pushViewController:vc animated:YES];
+}
+
 
 - (void)onTouchRegister:(id)sender {
     

+ 31 - 1
NIMDemo/NIMDemo/SectionGroup/GroupToogleTableViewCell.m

@@ -9,6 +9,10 @@
 #import "GroupToogleTableViewCell.h"
 #import "UIView+NTES.h"
 #import "NIMKit.h"
+#import "User.h"
+#import "HttpRequest.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
 
 @interface GroupToogleTableViewCell()
 
@@ -63,6 +67,15 @@
         [_toggleSwitch setOn:!team.notifyForNewMsg];
     else if([key isEqualToString:@"stick"])
         NSLog(@"stick toggle");
+    
+    if([key isEqualToString:@"stick"])
+    {
+        __weak typeof(self) wself = self;
+        [[User sharedInfo] requestChatStickList:^{
+            BOOL isChatStick = [[User sharedInfo] isChatStick:wself.teamId];
+            [wself.toggleSwitch setOn:isChatStick];
+        }];
+    }
 }
 
 
@@ -85,7 +98,24 @@
     }
     else if([key isEqualToString:@"stick"])
     {
-    
+        UISwitch *switcher = sender;
+        [SVProgressHUD show];
+        __weak typeof(self) wself = self;
+        [[HttpRequest shared] chatStick:self.teamId stick:switcher.isOn success:^(int inputTime) {
+            [SVProgressHUD dismiss];
+            if(switcher.isOn)
+            {
+                [[User sharedInfo] addChatStick:self.teamId inputTime:inputTime];
+            }
+            else
+            {
+                [[User sharedInfo] removeChatStick:self.teamId];
+            }
+        } failure:^{
+            [SVProgressHUD dismiss];
+            [wself makeToast:@"操作失败"duration:2.0f position:CSToastPositionCenter];
+            [wself setData:_data];
+        }];
     }
 }
 

+ 13 - 0
NIMDemo/NIMDemo/SectionSetting/AboutViewController.h

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

+ 51 - 0
NIMDemo/NIMDemo/SectionSetting/AboutViewController.m

@@ -0,0 +1,51 @@
+//
+//  AboutViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/30.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "AboutViewController.h"
+#import "SVProgressHUD.h"
+#import "HttpRequest.h"
+
+@interface AboutViewController ()<UIWebViewDelegate>
+
+@property (unsafe_unretained, nonatomic) IBOutlet UIWebView *webView;
+@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
+
+@end
+
+@implementation AboutViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:[HttpRequest shared].urlAbout]];
+    [_webView loadRequest:request];
+    
+    NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
+    _versionLabel.text = [NSString stringWithFormat:@"版本号:V%@", version];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"关于谁说"];
+}
+
+- (void)webViewDidStartLoad:(UIWebView *)webView{
+    [SVProgressHUD show];
+}
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView{
+    [SVProgressHUD dismiss];
+}
+
+@end

+ 13 - 0
NIMDemo/NIMDemo/SectionSetting/AgreementViewController.h

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

+ 50 - 0
NIMDemo/NIMDemo/SectionSetting/AgreementViewController.m

@@ -0,0 +1,50 @@
+//
+//  AgreementViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/30.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "AgreementViewController.h"
+#import "SVProgressHUD.h"
+#import "HttpRequest.h"
+#import "AppDelegate.h"
+
+@interface AgreementViewController ()<UIWebViewDelegate>
+@property (unsafe_unretained, nonatomic) IBOutlet UIWebView *webview;
+
+@end
+
+@implementation AgreementViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:[HttpRequest shared].urlAgreement]];
+    [_webview loadRequest:request];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"谁说社交APP服务协议"];
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    [appDelegate orangeNavBar:self];
+}
+
+- (void)webViewDidStartLoad:(UIWebView *)webView{
+    [SVProgressHUD show];
+}
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView{
+    [SVProgressHUD dismiss];
+}
+
+
+@end

+ 22 - 0
NIMDemo/NIMDemo/SectionSetting/LawViewController.h

@@ -0,0 +1,22 @@
+//
+//  LawViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/30.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol LawDeletegate <NSObject>
+
+@optional
+- (void)lawAuthResult:(BOOL)result;
+
+@end
+
+@interface LawViewController : UIViewController
+
+@property (nonatomic, weak) id<LawDeletegate>       delegate;
+
+@end

+ 120 - 0
NIMDemo/NIMDemo/SectionSetting/LawViewController.m

@@ -0,0 +1,120 @@
+//
+//  LawViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/30.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "LawViewController.h"
+#import "User.h"
+#import "SVProgressHUD.h"
+#import "HttpRequest.h"
+
+@interface LawViewController ()<UIWebViewDelegate>
+@property (weak, nonatomic) IBOutlet UIWebView *webview;
+@property (weak, nonatomic) IBOutlet UIButton *agreeToggleBtn;
+@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
+@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
+
+@property (nonatomic, assign) BOOL      isAgree;
+
+@end
+
+@implementation LawViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:[HttpRequest shared].urlLaw]];
+    [_webview loadRequest:request];
+    
+    _confirmBtn.layer.cornerRadius = 3;
+    
+    _cancelBtn.layer.cornerRadius = 3;
+    _cancelBtn.layer.borderColor = UIColor.lightGrayColor.CGColor;
+    _cancelBtn.layer.borderWidth = 1;
+    
+    [self toggleAgreement:YES];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"互联网广告管理暂行办法"];
+    
+    UIButton *emptyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [emptyBtn setTitle:@"" forState:UIControlStateNormal];
+    [emptyBtn sizeToFit];
+    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:emptyBtn];
+    
+    [self.navigationItem setLeftBarButtonItems:@[leftItem]];
+    
+    UserInfo *userInfo = [User sharedInfo].userInfo;
+    if(userInfo.realName.length > 0 && userInfo.idNumber.length > 0)
+    {
+        [self.navigationController popViewControllerAnimated:YES];
+    }
+}
+
+- (void)webViewDidStartLoad:(UIWebView *)webView{
+    [SVProgressHUD show];
+}
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView{
+    [SVProgressHUD dismiss];
+}
+
+- (void)toggleAgreement:(BOOL)toggle{
+    
+    _isAgree = toggle;
+    if(toggle)
+    {
+        [_agreeToggleBtn setImage:[UIImage imageNamed:@"国家法-_03"] forState:UIControlStateNormal];
+        [_confirmBtn setBackgroundColor:User.greenColor];
+        [_confirmBtn setUserInteractionEnabled:YES];
+    }
+    else
+    {
+        [_agreeToggleBtn setImage:[UIImage imageNamed:@"聊天3_03"] forState:UIControlStateNormal];
+        [_confirmBtn setBackgroundColor:UIColor.lightGrayColor];
+        [_confirmBtn setUserInteractionEnabled:NO];
+    }
+    
+}
+
+- (IBAction)onTouchAgreement:(id)sender {
+    [self toggleAgreement:!_isAgree];
+}
+
+- (IBAction)onTouchCancel:(id)sender {
+    if(self.delegate && [self.delegate respondsToSelector:@selector(lawAuthResult:)])
+    {
+        [self.delegate lawAuthResult:NO];
+        self.delegate = nil;
+    }
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+- (IBAction)onTouchConfirm:(id)sender {
+    if(self.delegate && [self.delegate respondsToSelector:@selector(lawAuthResult:)])
+    {
+        [self.delegate lawAuthResult:YES];
+        [self.navigationController popViewControllerAnimated:YES];
+        self.delegate = nil;
+    }
+    else
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"MyUserInfo"];
+        [self.navigationController pushViewController:vc animated:YES];
+    }
+}
+
+@end

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

@@ -93,7 +93,7 @@
     _modifyBtn.titleLabel.textAlignment = NSTextAlignmentRight;
     [_modifyBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
     _modifyBtn.frame = CGRectMake(cellWidth-padding-80, padding, 80, 20);
-    [_modifyBtn setTitle:@"修改图片" forState:UIControlStateNormal];
+    [_modifyBtn setTitle:@"修改" forState:UIControlStateNormal];
     [_modifyBtn sizeToFit];
     [_modifyBtn addTarget:self action:@selector(onTouchModifyImage:) forControlEvents:UIControlEventTouchUpInside];
     [self.contentView addSubview:_modifyBtn];

+ 1 - 1
NIMDemo/NIMDemo/SectionTrade/TradeModifyImageView.m

@@ -17,7 +17,7 @@
         UIButton *deleteBtn = [[UIButton alloc] initWithFrame:CGRectMake((frame.size.width-20)/2, 5, 20, 20)];
         [deleteBtn setImage:[UIImage imageNamed:@"编辑照片--取消_03"] forState:UIControlStateNormal];
         [deleteBtn addTarget:self action:@selector(onTouchDelete:) forControlEvents:UIControlEventTouchUpInside];
-        [self addSubview:deleteBtn];
+        //[self addSubview:deleteBtn];
         
         [self setUserInteractionEnabled:YES];
     }

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

@@ -84,7 +84,7 @@
 {
     [super viewWillAppear:animated];
     
-    [self.navigationItem setTitle:@"修改图片"];
+    [self.navigationItem setTitle:@"修改"];
     
     UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
     [rightBtn setTitle:@"修改" forState:UIControlStateNormal];
@@ -124,7 +124,7 @@
     _addImgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _imgSize, _imgSize)];
     _addImgView.backgroundColor = User.tinyGrayColor;
     [_addImgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAddImg:)]];
-    [_scrollView addSubview:_addImgView];
+    //[_scrollView addSubview:_addImgView];
     
     UIImageView *addIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _imgSize/4, _imgSize/4)];
     addIcon.centerX = _imgSize / 2;

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

@@ -23,14 +23,20 @@
 @property (nonatomic, weak, nullable) id<TradePublishDelegate>  delegate;
 @property (nonatomic, weak) NIMInputView            * _Nullable inputView;
 
++ (instancetype _Nonnull )sharedManager;
+
 - (void)tradePublish:(NSString *_Nullable)msg
               picArr:(NSMutableArray *_Nullable)picArr
             priority:(int)priority
         priorityType:(int)priorityType
-           tradeType:(int)tradeType;
+           tradeType:(int)tradeType
+              roomId:(NSString *_Nullable)roomId;
 
 - (void)tradeEdit:(NSString *_Nullable)msg
               picArr:(NSMutableArray *_Nullable)picArr
             priority:(int)priority;
 
+
+- (BOOL)checkLaw:(UIViewController *_Nonnull)vc;
+
 @end

+ 52 - 5
NIMDemo/NIMDemo/SectionTrade/TradePublishManager.m

@@ -13,8 +13,9 @@
 #import "UIView+Toast.h"
 #import "HttpRequest.h"
 #import "TradeModifyImageView.h"
+#import "LawViewController.h"
 
-@interface TradePublishManager()
+@interface TradePublishManager()<LawDeletegate>
 
 @property (nonatomic, strong) NSString              *tradeId;
 @property (nonatomic, strong) NSString              *msg;
@@ -24,6 +25,7 @@
 @property (nonatomic, assign) int                   priority;
 @property (nonatomic, assign) int                   priorityType;
 @property (nonatomic, assign) int                   tradeType;
+@property (nonatomic, strong) NSString              *roomId;
 
 @property (nonatomic, assign) BOOL                  isEdit;
 
@@ -31,28 +33,39 @@
 
 @implementation TradePublishManager
 
++ (instancetype)sharedManager
+{
+    static TradePublishManager *shared = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        shared = [[TradePublishManager alloc] init];
+    });
+    return shared;
+}
+
 - (void)tradePublish:(NSString *)msg
               picArr:(NSMutableArray *)picArr
             priority:(int)priority
         priorityType:(int)priorityType
-           tradeType:(int)tradeType{
+           tradeType:(int)tradeType
+              roomId:(NSString *_Nullable)roomId{
     
     self.msg = msg;
     self.picArr = picArr;
     self.priority = priority;
     self.priorityType = priorityType;
     self.tradeType = tradeType;
+    self.roomId = roomId;
     
     self.picDataArr = [[NSMutableArray alloc] init];
     self.uploadIndex = 0;
     self.isEdit = NO;
     
-    [SVProgressHUD show];
     
+    [SVProgressHUD show];
     [self uploadPicture];
 }
 
-
 - (void)uploadPicture{
     
     if(_uploadIndex >= _picArr.count)
@@ -162,7 +175,7 @@
     NSString *sendMsg = _msg ? _msg : @"";
     
     
-    [[HttpRequest shared] tradePublish:sendMsg picArr:_picDataArr type:_tradeType priority:_priority priorityType:_priorityType success:^{
+    [[HttpRequest shared] tradePublish:sendMsg picArr:_picDataArr type:_tradeType priority:_priority priorityType:_priorityType roomId:_roomId success:^{
         
         [SVProgressHUD dismiss];
         if(_inputView)
@@ -175,6 +188,7 @@
         
         if ([_delegate respondsToSelector:@selector(tradePublishResult:)]){
             [_delegate tradePublishResult:YES];
+            _delegate = nil;
         }
     } failure:^{
         
@@ -186,6 +200,7 @@
         
         if ([_delegate respondsToSelector:@selector(tradePublishResult:)]){
             [_delegate tradePublishResult:NO];
+            _delegate = nil;
         }
     }];
 
@@ -234,6 +249,7 @@
             
             if ([_delegate respondsToSelector:@selector(tradeEditResult:tradeData:)]){
                 [_delegate tradeEditResult:YES tradeData:tradeData];
+                _delegate = nil;
             }
         }
         
@@ -242,9 +258,40 @@
 
         if ([_delegate respondsToSelector:@selector(tradeEditResult:tradeData:)]){
             [_delegate tradeEditResult:NO tradeData:nil];
+            _delegate = nil;
         }
     }];
     
 }
 
+
+
+
+
+
+- (BOOL)checkLaw:(UIViewController *_Nonnull)vc{
+    if([User sharedInfo].userInfo.realName.length == 0 || [User sharedInfo].userInfo.idNumber.length == 0)
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        LawViewController *lawVC = [board instantiateViewControllerWithIdentifier:@"Law"];
+        [vc.navigationController pushViewController:lawVC animated:YES];
+        return NO;
+    }
+    return YES;
+}
+
+//- (void)lawAuthResult:(BOOL)result{
+//    if(result)
+//    {
+//        [SVProgressHUD show];
+//        [self uploadPicture];
+//    }
+//    else
+//    {
+//        if ([_delegate respondsToSelector:@selector(tradePublishResult:)]){
+//            [_delegate tradePublishResult:NO];
+//            _delegate = nil;
+//        }
+//    }
+//}
 @end

+ 8 - 5
NIMDemo/NIMDemo/SectionTrade/TradeViewController.m

@@ -570,9 +570,12 @@ float postHeight = 30;
 
 
 - (void)showTradeInput:(id)sender{
-    [_tradePublishView setHidden:NO];
-    [_tradeInput reset];
-    [self toggleDemand:nil];
+    if([[TradePublishManager sharedManager] checkLaw:self])
+    {
+        [_tradePublishView setHidden:NO];
+        [_tradeInput reset];
+        [self toggleDemand:nil];
+    }
 }
 
 - (void)hideTradeInput:(id)sender{
@@ -607,9 +610,9 @@ float postHeight = 30;
         return;
     }
     
-    TradePublishManager *tradePublishManager = [[TradePublishManager alloc] init];
+    TradePublishManager *tradePublishManager = [TradePublishManager sharedManager];
     tradePublishManager.delegate = self;
-    [tradePublishManager tradePublish:msg picArr:picArr priority:priority priorityType:priorityType tradeType:type];
+    [tradePublishManager tradePublish:msg picArr:picArr priority:priority priorityType:priorityType tradeType:type roomId:nil];
     
     [self hideTradeInput:nil];
 }

+ 3 - 1
NIMDemo/NIMDemo/SettingAccountViewController.m

@@ -143,7 +143,9 @@
 }
 
 - (void)handleAbout{
-    NSLog(@"handleAbout");
+    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    UIViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"About"];
+    [self.navigationController pushViewController:vc animated:YES];
 }
 
 

+ 14 - 4
NIMDemo/NIMDemo/SettingTopTableViewCell.m

@@ -58,9 +58,9 @@
     _avatarImg = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
     _avatarImg.centerX = cellWidth / 2;
     _avatarImg.centerY = _topImgView.bottom;
+    [_avatarImg addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
+    
     
-    NSURL *url = nimUser.userInfo.avatarUrl ? [NSURL URLWithString:nimUser.userInfo.avatarUrl] : nil;
-    [_avatarImg nim_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
     [self addSubview:_avatarImg];
     
     _genderImg = [[UIImageView alloc] initWithFrame:CGRectMake(_avatarImg.right-20, _avatarImg.bottom-20, 20, 20)];
@@ -96,13 +96,13 @@
     UIView *step = [[UIView alloc] initWithFrame:CGRectMake(0, cellHeight-0.5, cellWidth, 0.5)];
     step.backgroundColor = UIColor.lightGrayColor;
     [self addSubview:step];
- 
-    [self updateBanner];
 }
 
 
 - (void)fillPhotos
 {
+    [self updateBanner];
+    
     if(!_photoContainer)
     {
         _photoContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 300, _cellWidth, 0)];
@@ -181,6 +181,12 @@
     NSString *imgURL = [User sharedInfo].userInfo.socialBanner;
     NSURL *url = imgURL && imgURL.length > 0 ? [NSURL URLWithString:imgURL] : nil;
     [self.topImgView sd_setImageWithURL:url placeholderImage:User.defaultSocialBanner];
+    
+    NSString *userId = [NIMSDK sharedSDK].loginManager.currentAccount;
+    NIMUser *nimUser = [[NIMSDK sharedSDK].userManager userInfo:userId];
+    
+    url = nimUser.userInfo.avatarUrl ? [NSURL URLWithString:nimUser.userInfo.avatarUrl] : nil;
+    [_avatarImg nim_setImageWithURL:url placeholderImage:User.defaultUserAvatar];
 }
 
 - (void)onTouchTopImage:(id)sender{
@@ -241,4 +247,8 @@
     
 }
 
+- (void)onTouchAvatar:(id)sender{
+    [User showUserInfo:[NIMSDK sharedSDK].loginManager.currentAccount viewController:self.viewController];
+}
+
 @end

+ 5 - 0
NIMDemo/NIMDemo/SocialTopTableViewCell.m

@@ -46,6 +46,7 @@
     
     _avatarImg = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(15, cellHeight - 70, 60, 60)];
     [_avatarImg nim_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"avatar_user2"]];
+    [_avatarImg addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTouchAvatar:)]];
     [self addSubview:_avatarImg];
     
     _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_avatarImg.right+10, _avatarImg.centerY-15, 200, 30)];
@@ -118,4 +119,8 @@
     [self.imgBg sd_setImageWithURL:url placeholderImage:User.defaultSocialBanner];
 }
 
+- (void)onTouchAvatar:(id)sender{
+    [User showUserInfo:[NIMSDK sharedSDK].loginManager.currentAccount viewController:self.viewController];
+}
+
 @end

+ 10 - 8
NIMDemo/NIMDemo/Supporting Files/Info.plist

@@ -2,14 +2,6 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>LSApplicationQueriesSchemes</key>
-	<array>
-		<string>alipayauath</string>
-		<string>safepay</string>
-		<string>alipay</string>
-	</array>
-	<key>LSApplicationCategoryType</key>
-	<string></string>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>zh_CN</string>
 	<key>CFBundleDisplayName</key>
@@ -45,6 +37,14 @@
 	</array>
 	<key>CFBundleVersion</key>
 	<string>1</string>
+	<key>LSApplicationCategoryType</key>
+	<string></string>
+	<key>LSApplicationQueriesSchemes</key>
+	<array>
+		<string>alipayauath</string>
+		<string>safepay</string>
+		<string>alipay</string>
+	</array>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>NSAppTransportSecurity</key>
@@ -54,6 +54,8 @@
 	</dict>
 	<key>NSCameraUsageDescription</key>
 	<string>谁说想使用您的摄像头</string>
+	<key>NSContactsUsageDescription</key>
+	<string>谁说想使用您的通讯录</string>
 	<key>NSLocationAlwaysUsageDescription</key>
 	<string>谁说想使用您的地理位置信息</string>
 	<key>NSLocationWhenInUseDescription</key>

+ 2 - 2
NIMDemo/NIMDemo/Supporting Files/NIMKitSettings.bundle/NIMKitBubbleSetting.plist

@@ -7,9 +7,9 @@
 		<key>Content_Insets</key>
 		<dict>
 			<key>Left</key>
-			<string>{11,15,9,9}</string>
+			<string>{5,15,0,9}</string>
 			<key>Right</key>
-			<string>{11,11,9,15}</string>
+			<string>{5,11,0,15}</string>
 		</dict>
 		<key>Content_Color</key>
 		<dict>

+ 48 - 1
NIMDemo/NIMDemo/TabBarController.m

@@ -12,7 +12,13 @@
 #import "NIMKit.h"
 #import "User.h"
 
-@interface TabBarController ()
+@interface TabBarController ()<NIMSystemNotificationManagerDelegate,NIMConversationManagerDelegate>
+
+@property (nonatomic,assign) NSInteger sessionUnreadCount;
+
+@property (nonatomic,assign) NSInteger systemUnreadCount;
+
+@property (nonatomic,assign) NSInteger customSystemUnreadCount;
 
 @end
 
@@ -22,6 +28,11 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     
+    [[NIMSDK sharedSDK].conversationManager addDelegate:self];
+    
+    self.sessionUnreadCount  = [NIMSDK sharedSDK].conversationManager.allUnreadCount;
+    self.systemUnreadCount   = [NIMSDK sharedSDK].systemNotificationManager.allUnreadCount;
+    
     [[User sharedInfo] fetchUserInfo:^(UserInfo * _Nonnull userInfo) {}];
 }
 
@@ -63,4 +74,40 @@
         NSLog(@"请求失败,服务器返回的错误信息%@",error);
     }];
 }
+
+
+#pragma mark - NIMConversationManagerDelegate
+- (void)didAddRecentSession:(NIMRecentSession *)recentSession
+           totalUnreadCount:(NSInteger)totalUnreadCount{
+    self.sessionUnreadCount = totalUnreadCount;
+    [self refreshSessionBadge];
+}
+
+
+- (void)didUpdateRecentSession:(NIMRecentSession *)recentSession
+              totalUnreadCount:(NSInteger)totalUnreadCount{
+    self.sessionUnreadCount = totalUnreadCount;
+    [self refreshSessionBadge];
+}
+
+
+- (void)didRemoveRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount{
+    self.sessionUnreadCount = totalUnreadCount;
+    [self refreshSessionBadge];
+}
+
+- (void)messagesDeletedInSession:(NIMSession *)session{
+    self.sessionUnreadCount = [NIMSDK sharedSDK].conversationManager.allUnreadCount;
+    [self refreshSessionBadge];
+}
+
+- (void)allMessagesDeleted{
+    self.sessionUnreadCount = 0;
+    [self refreshSessionBadge];
+}
+
+- (void)refreshSessionBadge{
+    UINavigationController *nav = self.viewControllers[1];
+    nav.tabBarItem.badgeValue = self.sessionUnreadCount ? @(self.sessionUnreadCount).stringValue : nil;
+}
 @end

+ 25 - 0
NIMDemo/NIMDemo/User.h

@@ -12,6 +12,14 @@
 #import "UserInfo.h"
 
 
+@interface ChatStick : NSObject
+
+@property (nonatomic, strong, nullable) NSString      *chatId;
+@property (nonatomic, assign) int                     inputtime;
+
+@end
+
+
 @interface User : NSObject
 
 + (instancetype _Nonnull ) sharedInfo;
@@ -28,6 +36,8 @@
 @property (nonatomic, nullable) NSString *city;
 @property (nonatomic, nullable) NSString *district;
 
+@property (nonatomic, assign) int       tradePublishCount;
+
 @property (nonatomic, strong) UserInfo *userInfo;
 
 //chat
@@ -50,6 +60,8 @@
 @property (nonatomic, strong, nonnull)  NSMutableArray *thumbArr;
 
 
+
+
 //trade
 @property (nonatomic, strong, nonnull) NSMutableArray *tradePriorityItemArr;
 
@@ -85,12 +97,25 @@
 
 - (GiftData *_Nullable)getGiftData:(NSString *_Nonnull)giftId;
 
+//social utils
+- (void)requestFollowList:(void (^_Nullable)())success;
+- (NSArray *_Nullable)followList;
+- (BOOL)isFollowd:(NSString *_Nullable)userId;
+- (void)follow:(NSString *_Nullable)userId;
+- (void)unfollow:(NSString *_Nullable)userId;
 
 //trade utils
 - (BOOL)isNewTradeGot:(NSString *_Nullable)key dataId:(NSString *_Nullable)dataId;
 
 
 
+//chat
+- (void)requestChatStickList:(void (^_Nullable)())success;
+- (NSComparisonResult)compareChatStick:(NSString *_Nullable)chatIdA chatIdB:(NSString *_Nullable)chatIdB;
+- (BOOL)isChatStick:(NSString *_Nullable)chatId;
+- (void)addChatStick:(NSString *_Nullable)chatId inputTime:(int)inputTime;
+- (void)removeChatStick:(NSString *_Nullable)chatId;
+
 
 //user info utils
 + (NSString *_Nonnull)distance:(double)originLat originLng:(double)originLng targetLat:(double)targetLat targetLng:(double)targetLng;

+ 143 - 1
NIMDemo/NIMDemo/User.m

@@ -15,11 +15,15 @@
 #import "GroupInfoViewController.h"
 
 
+@implementation ChatStick
+
+@end
 
 @interface User()
 
 @property (nonatomic, strong) NSMutableArray<GiftData *> *giftList;
-
+@property (nonatomic, strong) NSMutableDictionary *followDict;
+@property (nonatomic, strong) NSMutableDictionary *chatStickDict;
 
 @end
 
@@ -394,6 +398,144 @@ int newCreateTeamId;
 
 
 
+//social utils
+- (void)requestFollowList:(void (^_Nullable)())success{
+    
+    if(_followDict)
+    {
+        if(success)
+            success();
+        return;
+    }
+    
+    __weak typeof(self) wself = self;
+    [[HttpRequest shared] followList:^(NSMutableArray * _Nullable follows) {
+       
+        [wself setFollowList:follows];
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+    }];
+    
+}
+
+- (void)setFollowList:(NSMutableArray *)followList{
+    
+    if(!_followDict)
+        _followDict = [[NSMutableDictionary alloc] init];
+    
+    [_followDict removeAllObjects];
+    for(int i=0; i<followList.count; i++)
+    {
+        NSString *userId = [followList objectAtIndex:i];
+        [_followDict setValue:userId forKey:userId];
+    }
+}
+
+- (NSArray *_Nullable)followList{
+    return _followDict.allValues;
+}
+
+- (BOOL)isFollowd:(NSString *)userId{
+    NSString *follow = [_followDict objectForKey:userId];
+    if(follow)
+    {
+        return YES;
+    }
+    return NO;
+}
+
+- (void)follow:(NSString *)userId{
+    if(_followDict)
+    {
+        [_followDict setValue:userId forKey:userId];
+    }
+}
+
+- (void)unfollow:(NSString *)userId{
+    if(_followDict)
+    {
+        [_followDict removeObjectForKey:userId];
+    }
+}
+
+
+//chat
+- (void)requestChatStickList:(void (^_Nullable)())success{
+    if(_chatStickDict)
+    {
+        if(success)
+            success();
+        return;
+    }
+    
+    [[HttpRequest shared] chatStickList:^(NSMutableArray * _Nullable chatStickArr) {
+        
+        _chatStickDict = [[NSMutableDictionary alloc] init];
+        for(int i=0; i<chatStickArr.count; i++)
+        {
+            NSMutableDictionary *data = [chatStickArr objectAtIndex:i];
+            NSString *chatId = [data objectForKey:@"chat_id"];
+            int inputtime = [[data objectForKey:@"inputtime"] intValue];
+            [self addChatStick:chatId inputTime:inputtime];
+        }
+        
+        if(success)
+            success();
+        
+    } failure:^{
+        
+    }];
+}
+
+- (NSComparisonResult)compareChatStick:(NSString *)chatIdA chatIdB:(NSString *)chatIdB{
+    
+    ChatStick *stickA = [_chatStickDict objectForKey:chatIdA];
+    ChatStick *stickB = [_chatStickDict objectForKey:chatIdB];
+    
+    if(stickA && !stickB)
+        return NSOrderedAscending;
+    else if(!stickA && stickB)
+        return NSOrderedDescending;
+    else if(stickA && stickB)
+    {
+        if(stickA.inputtime > stickB.inputtime)
+            return NSOrderedAscending;
+        else if(stickA.inputtime < stickB.inputtime)
+            return NSOrderedDescending;
+    }
+    
+    return NSOrderedSame;
+}
+
+- (BOOL)isChatStick:(NSString *_Nullable)chatId{
+    ChatStick *chatStick = [_chatStickDict objectForKey:chatId];
+    if(!chatStick)
+    {
+        return NO;
+    }
+    return YES;
+}
+
+- (void)addChatStick:(NSString *_Nullable)chatId inputTime:(int)inputTime{
+    
+    ChatStick *chatStick = [_chatStickDict objectForKey:chatId];
+    if(!chatStick)
+    {
+        chatStick = [[ChatStick alloc] init];
+        chatStick.chatId = chatId;
+        [_chatStickDict setValue:chatStick forKey:chatId];
+    }
+    chatStick.inputtime = inputTime;
+}
+
+- (void)removeChatStick:(NSString *_Nullable)chatId{
+    [_chatStickDict removeObjectForKey:chatId];
+}
+
 
 //user info
 - (void)fetchUserInfo:(void (^_Nonnull)(UserInfo * _Nonnull userInfo))callBack{

+ 15 - 0
NIMDemo/NIMDemo/UserConfigViewController.h

@@ -0,0 +1,15 @@
+//
+//  UserConfigViewController.h
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UserConfigViewController : UITableViewController
+
+- (void)setUserId:(NSString *)userId;
+
+@end

+ 155 - 0
NIMDemo/NIMDemo/UserConfigViewController.m

@@ -0,0 +1,155 @@
+//
+//  UserConfigViewController.m
+//  NIMDemo
+//
+//  Created by Fenix Wang on 2017/7/27.
+//  Copyright © 2017年 Netease. All rights reserved.
+//
+
+#import "UserConfigViewController.h"
+#import "NTESAliasSettingViewController.h"
+#import "SVProgressHUD.h"
+#import "UIView+Toast.h"
+#import "ComplainViewController.h"
+#import "User.h"
+#import "HttpRequest.h"
+
+@interface UserConfigViewController ()
+@property (unsafe_unretained, nonatomic) IBOutlet UILabel *remarkLabel;
+@property (unsafe_unretained, nonatomic) IBOutlet UISwitch *stickSwitch;
+@property (unsafe_unretained, nonatomic) IBOutlet UISwitch *disturbSwitch;
+@property (unsafe_unretained, nonatomic) IBOutlet UISwitch *blackListSwitch;
+
+
+@property (nonatomic, strong) NSString              *userId;
+
+@end
+
+@implementation UserConfigViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    [self refresh];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    [self.navigationItem setTitle:@"设置"];
+}
+
+- (void)setUserId:(NSString *)userId{
+    _userId = userId;
+}
+
+- (void)refresh{
+    
+    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:_userId];
+    
+    _remarkLabel.text = user.alias.length ? user.alias : @"";
+    
+    BOOL isInBlackList = [[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
+    BOOL needNotify    = [[NIMSDK sharedSDK].userManager notifyForNewMsg:self.userId];
+    
+    [_blackListSwitch setOn:isInBlackList];
+    [_disturbSwitch setOn:!needNotify];
+    
+    __weak typeof(self) wself = self;
+    [[User sharedInfo] requestChatStickList:^{
+        BOOL isChatStick = [[User sharedInfo] isChatStick:wself.userId];
+        [wself.stickSwitch setOn:isChatStick];
+    }];
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+    
+    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    switch(cell.tag)
+    {
+        case 1:{
+            NTESAliasSettingViewController *vc = [[NTESAliasSettingViewController alloc] initWithUserId:self.userId];
+            [self.navigationController pushViewController:vc animated:YES];
+            break;
+        }
+        case 2:{
+            UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+            ComplainViewController *vc = [board instantiateViewControllerWithIdentifier:@"Complain"];
+            [vc setUserId:_userId];
+            [self.navigationController pushViewController:vc animated:YES];
+            break;
+        }
+    }
+    
+    
+}
+
+#pragma mark - Table view data source
+
+
+- (IBAction)onStickChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    [[HttpRequest shared] chatStick:self.userId stick:switcher.isOn success:^(int inputTime) {
+        [SVProgressHUD dismiss];
+        if(switcher.isOn)
+        {
+            [[User sharedInfo] addChatStick:self.userId inputTime:inputTime];
+        }
+        else
+        {
+            [[User sharedInfo] removeChatStick:self.userId];
+        }
+    } failure:^{
+        [SVProgressHUD dismiss];
+        [wself.view makeToast:@"操作失败"duration:2.0f position:CSToastPositionCenter];
+        [wself refresh];
+    }];
+}
+
+- (IBAction)onDisturbChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    [[NIMSDK sharedSDK].userManager updateNotifyState:!switcher.on forUser:self.userId completion:^(NSError *error) {            [SVProgressHUD dismiss];
+        if (error) {
+            [wself.view makeToast:@"操作失败"duration:2.0f position:CSToastPositionCenter];
+            [wself refresh];
+        }
+    }];
+}
+
+- (IBAction)onBlackListChanged:(id)sender {
+    UISwitch *switcher = sender;
+    [SVProgressHUD show];
+    __weak typeof(self) wself = self;
+    if (switcher.on) {
+        [[NIMSDK sharedSDK].userManager addToBlackList:self.userId completion:^(NSError *error) {
+            [SVProgressHUD dismiss];
+            if (!error) {
+                [wself.view makeToast:@"拉黑成功"duration:2.0f position:CSToastPositionCenter];
+            }else{
+                [wself.view makeToast:@"拉黑失败"duration:2.0f position:CSToastPositionCenter];
+                [wself refresh];
+            }
+        }];
+    }else{
+        [[NIMSDK sharedSDK].userManager removeFromBlackBlackList:self.userId completion:^(NSError *error) {
+            [SVProgressHUD dismiss];
+            if (!error) {
+                [wself.view makeToast:@"移除黑名单成功"duration:2.0f position:CSToastPositionCenter];
+            }else{
+                [wself.view makeToast:@"移除黑名单失败"duration:2.0f position:CSToastPositionCenter];
+                [wself refresh];
+            }
+        }];
+    }
+}
+
+@end

+ 36 - 0
NIMDemo/NIMDemo/UserInfoViewController.m

@@ -16,6 +16,7 @@
 #import "UserGiftViewController.h"
 #import "HttpRequest.h"
 #import "UIView+Toast.h"
+#import "UserConfigViewController.h"
 
 @interface UserInfoViewController ()
 @property (weak, nonatomic) IBOutlet UIImageView *bannerImage;
@@ -76,6 +77,14 @@
     
     [self.navigationItem setTitle:@""];
     
+    UIButton *configBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [configBtn setImage:[UIImage imageNamed:@"群成员信息_03"] forState:UIControlStateNormal];
+    [configBtn addTarget:self action:@selector(onTouchConfig:) forControlEvents:UIControlEventTouchUpInside];
+    [configBtn sizeToFit];
+    
+    UIBarButtonItem *configItem = [[UIBarButtonItem alloc] initWithCustomView:configBtn];
+    [self.navigationItem setRightBarButtonItems:@[configItem]];
+    
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     [appDelegate transparentNavBar:self];
 }
@@ -171,6 +180,25 @@
     NSString *imgURL = _userInfo.socialBanner;
     url = imgURL && imgURL.length > 0 ? [NSURL URLWithString:imgURL] : nil;
     [_bannerImage sd_setImageWithURL:url placeholderImage:User.defaultSocialBanner];
+    
+    
+    float space = 5;
+    float size = _picContainer.height;
+    for(int i=0; i<_userInfo.photeArr.count; i++)
+    {
+        float x = i*(size + space);
+        if(x+size > _picContainer.width)
+        {
+            break;
+        }
+        
+        NSMutableDictionary *photo = [_userInfo.photeArr objectAtIndex:i];
+        NSString *thumb = [photo objectForKey:@"thumb"];
+        NSURL *url = [NSURL URLWithString:thumb];
+        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(x, 0, size, size)];
+        [imgView sd_setImageWithURL:url placeholderImage:User.defaultPlaceHolderImage];
+        [_picContainer addSubview:imgView];
+    }
 }
 
 
@@ -224,4 +252,12 @@
     NSLog(@"onTouchMorePic");
 }
 
+
+- (void)onTouchConfig:(id)sender{
+    UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+    UserConfigViewController *vc = [board instantiateViewControllerWithIdentifier:@"UserConfig"];
+    [vc setUserId:_userId];
+    [self.navigationController pushViewController:vc animated:YES];
+}
+
 @end

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

@@ -24,6 +24,9 @@
 - (void)requestGiftDataList;
 - (void)sendGift:(GiftData *)giftData count:(int)count msg:(NSString *)msg userId:(NSString *)userId;
 
+@optional
+- (BOOL)checkLaw;
+
 @end
 
 @interface GiftInputContainer : UIView<NIMPageViewDataSource,NIMPageViewDelegate,GiftButtonTouchDelegate>

+ 17 - 0
NIMKit/NIMKit/Classes/Sections/Input/GiftInputContainer.m

@@ -545,6 +545,14 @@ NSInteger TradeTypeDemand = 2;
 
 - (void)toggleDemand:(int)sender{
     
+    if(_delegate && [_delegate respondsToSelector:@selector(checkLaw)])
+    {
+        if(![_delegate checkLaw])
+        {
+            return;
+        }
+    }
+    
     if(_tradeContainer.isHidden)
     {
         [_tradeContainer setHidden:NO];
@@ -573,6 +581,15 @@ NSInteger TradeTypeDemand = 2;
 }
 
 - (void)toggleSupply:(int)sender{
+    
+    if(_delegate && [_delegate respondsToSelector:@selector(checkLaw)])
+    {
+        if(![_delegate checkLaw])
+        {
+            return;
+        }
+    }
+    
     if(_tradeContainer.isHidden)
     {
         [_tradeContainer setHidden:NO];

+ 6 - 3
NIMKit/NIMKit/Classes/Sections/Session/ViewController/NIMSessionViewController.m

@@ -65,8 +65,6 @@
     [self setupInputView];
     //会话相关逻辑配置器安装
     [self setupConfigurator];
-    //添加监听
-    [self addListener];
     //进入会话时,标记所有消息已读,并发送已读回执
     [self markRead];
     //更新已读位置
@@ -129,6 +127,9 @@
 {
     [super viewWillAppear:animated];
     [self.interactor onViewWillAppear];
+    
+    //添加监听
+    [self addListener];
 }
 
 - (void)viewDidDisappear:(BOOL)animated{
@@ -136,6 +137,9 @@
     [self.interactor onViewDidDisappear];
     
     [self.sessionInputView endEditing:YES];
+    
+    //添加监听
+    [self removeListener];
 }
 
 
@@ -624,7 +628,6 @@
 
 - (void)addListener
 {
-    
     if (![self.sessionConfig respondsToSelector:@selector(disableReceiveNewMessages)]
         || ![self.sessionConfig disableReceiveNewMessages]) {
         [[NIMSDK sharedSDK].chatManager addDelegate:self];

+ 1 - 0
NIMKit/NIMKit/Classes/Sections/SessionList/NIMSessionListViewController.m

@@ -51,6 +51,7 @@
     self.tableView.tableFooterView  = [[UIView alloc] init];
     self.tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
     _recentSessions = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy];
+    [self sort];
     if (!self.recentSessions.count) {
         _recentSessions = [NSMutableArray array];
     }

+ 8 - 0
NIMKit/NIMKit/Classes/Sections/Util/NIMKitUtil.m

@@ -252,6 +252,12 @@
             case NIMTeamOperationTypeApplyPass:{
                 if ([source isEqualToString:targetText]) {
                     //说明是以不需要验证的方式进入
+                    NIMNotificationObject *object = message.messageObject;
+                    NIMTeamNotificationContent *content = (NIMTeamNotificationContent*)object.content;
+                    NSString *currentAccount = [[NIMSDK sharedSDK].loginManager currentAccount];
+                    if ([content.sourceID isEqualToString:currentAccount]) {
+                        source = @"欢迎你";
+                    }
                     formatedMessage = [NSString stringWithFormat:@"%@进入了%@",source,teamName];
                 }else{
                     formatedMessage = [NSString stringWithFormat:@"%@通过了%@的申请",source,targetText];
@@ -466,6 +472,8 @@
 + (NSString *)teamNotificationTeamShowName:(NIMMessage *)message{
     NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:message.session.sessionId];
     NSString *teamName = team.type == NIMTeamTypeNormal ? @"讨论组" : @"群";
+    if([team.owner isEqualToString:@"10000"])
+        teamName = @"聊天室";
     return teamName;
 }
 

Неке датотеке нису приказане због велике количине промена