- 充值页面
- 充值页面返回挽留弹窗 - 圈子一级页面接口数据接入 - openIM sdk 接入 - IM 会话列表
|
After Width: | Height: | Size: 220 KiB |
3
Podfile
|
|
@ -43,7 +43,8 @@ target 'QuickLocation' do
|
|||
|
||||
#第三方SDk
|
||||
pod 'GYSDK' #个推一键登录
|
||||
|
||||
pod 'OpenIMSDK' #OpenIM
|
||||
|
||||
#高德地图
|
||||
pod 'AMap3DMap' #3D地图SDK
|
||||
pod 'AMapSearch' #地图SDK搜索功能
|
||||
|
|
|
|||
41
Podfile.lock
|
|
@ -82,12 +82,44 @@ PODS:
|
|||
- MarqueeLabel (4.5.3)
|
||||
- Masonry (1.1.0)
|
||||
- MBProgressHUD (1.2.0)
|
||||
- MJExtension (3.4.2)
|
||||
- MJRefresh (3.7.9)
|
||||
- Moya (15.0.0):
|
||||
- Moya/Core (= 15.0.0)
|
||||
- Moya/Core (15.0.0):
|
||||
- Alamofire (~> 5.0)
|
||||
- ObjectMapper (4.4.2)
|
||||
- "OpenIMSDK (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- "OpenIMSDK/Callbacker (= 3.8.3+hotfix.3.1)"
|
||||
- "OpenIMSDK/CallbackProxy (= 3.8.3+hotfix.3.1)"
|
||||
- "OpenIMSDK/Interface (= 3.8.3+hotfix.3.1)"
|
||||
- "OpenIMSDK/Model (= 3.8.3+hotfix.3.1)"
|
||||
- "OpenIMSDK/Utils (= 3.8.3+hotfix.3.1)"
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDK/Callbacker (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- OpenIMSDK/Model
|
||||
- OpenIMSDK/Utils
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDK/CallbackProxy (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- OpenIMSDK/Utils
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDK/Interface (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- OpenIMSDK/Callbacker
|
||||
- OpenIMSDK/CallbackProxy
|
||||
- OpenIMSDK/Model
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDK/Model (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- OpenIMSDK/Utils
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDK/Utils (3.8.3+hotfix.3.1)":
|
||||
- MJExtension
|
||||
- "OpenIMSDKCore (= 3.8.3+3)"
|
||||
- "OpenIMSDKCore (3.8.3+3)"
|
||||
- Popover (1.3.0)
|
||||
- RxCocoa (6.8.0):
|
||||
- RxRelay (= 6.8.0)
|
||||
|
|
@ -138,6 +170,7 @@ DEPENDENCIES:
|
|||
- MJRefresh
|
||||
- Moya
|
||||
- ObjectMapper
|
||||
- OpenIMSDK
|
||||
- Popover
|
||||
- RxCocoa
|
||||
- RxDataSources
|
||||
|
|
@ -179,9 +212,12 @@ SPEC REPOS:
|
|||
- lottie-ios
|
||||
- MarqueeLabel
|
||||
- Masonry
|
||||
- MJExtension
|
||||
- MJRefresh
|
||||
- Moya
|
||||
- ObjectMapper
|
||||
- OpenIMSDK
|
||||
- OpenIMSDKCore
|
||||
- Popover
|
||||
- RxCocoa
|
||||
- RxDataSources
|
||||
|
|
@ -235,9 +271,12 @@ SPEC CHECKSUMS:
|
|||
MarqueeLabel: 0c57d4c6634e04a6d015af79f7c9a175b2309525
|
||||
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
|
||||
MBProgressHUD: 1b0fb447e80a0fda94808180750e8b78a07b3cd2
|
||||
MJExtension: e97d164cb411aa9795cf576093a1fa208b4a8dd8
|
||||
MJRefresh: ff9e531227924c84ce459338414550a05d2aea78
|
||||
Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee
|
||||
ObjectMapper: e6e4d91ff7f2861df7aecc536c92d8363f4c9677
|
||||
OpenIMSDK: c1880296ead605bcac2a289ad0aef9170fe6e6df
|
||||
OpenIMSDKCore: 75caba22be8ee484011f367711178312bd64a17d
|
||||
Popover: 10e1d9528f81d9504df984b7b3f491292bc1822d
|
||||
RxCocoa: 2d33c1e1e5d66492052ad46b11024ae287572880
|
||||
RxDataSources: aa47cc1ed6c500fa0dfecac5c979b723542d79cf
|
||||
|
|
@ -256,6 +295,6 @@ SPEC CHECKSUMS:
|
|||
URLNavigator: e9c0426ba6e6ac57f34d018bbf3df840797f984d
|
||||
ZXSDK: 786338c0a18e98e03eda00699c3bfd2700b97117
|
||||
|
||||
PODFILE CHECKSUM: 7d3667576e8d6c3f1a98be0e406f215041cf2eb7
|
||||
PODFILE CHECKSUM: d9389fd0d3da8895e9ddac8adbec655edaf9bb3d
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
|
|
|||
|
|
@ -190,6 +190,9 @@
|
|||
3062E8C42FCFC90F00CEF511 /* CreateGroupVipPopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8C32FCFC90F00CEF511 /* CreateGroupVipPopView.swift */; };
|
||||
3062E8C72FCFD02F00CEF511 /* VipRechargeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8C62FCFD02F00CEF511 /* VipRechargeView.swift */; };
|
||||
3062E8C92FCFD03B00CEF511 /* VipRechargeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3062E8C82FCFD03B00CEF511 /* VipRechargeVC.swift */; };
|
||||
307073E12FD15F50004C37CC /* GroupIMService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307073E02FD15F50004C37CC /* GroupIMService.swift */; };
|
||||
307073E52FD18A20004C37CC /* GroupChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307073E32FD18A20004C37CC /* GroupChatView.swift */; };
|
||||
307073E62FD18A20004C37CC /* GroupChatVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307073E22FD18A20004C37CC /* GroupChatVC.swift */; };
|
||||
30A7A9112FCAEE3D00105780 /* GroupListPopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A7A9102FCAEE3D00105780 /* GroupListPopView.swift */; };
|
||||
30BAB84D2FCD2FDE00C33B5C /* InviteJoinView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB84C2FCD2FDE00C33B5C /* InviteJoinView.swift */; };
|
||||
30BAB84F2FCD2FED00C33B5C /* InviteJoinVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB84E2FCD2FED00C33B5C /* InviteJoinVC.swift */; };
|
||||
|
|
@ -197,10 +200,13 @@
|
|||
30BAB8532FCD337C00C33B5C /* GroupService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8522FCD337C00C33B5C /* GroupService.swift */; };
|
||||
30BAB8632FCD716C00C33B5C /* JoinGroupVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8622FCD716C00C33B5C /* JoinGroupVC.swift */; };
|
||||
30BAB8652FCD718A00C33B5C /* JoinGroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30BAB8642FCD718A00C33B5C /* JoinGroupView.swift */; };
|
||||
30BAB8682FCD750E00C33B5C /* Mask_group@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */; };
|
||||
30BAB8692FCD750E00C33B5C /* Mask_group@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */; };
|
||||
30DC18522FD009CD0041DCD1 /* VipExpenseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18512FD009CD0041DCD1 /* VipExpenseModel.swift */; };
|
||||
30DC18542FD00C4A0041DCD1 /* VipRechargeVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18532FD00C4A0041DCD1 /* VipRechargeVM.swift */; };
|
||||
30DC185A2FD11E7A0041DCD1 /* WebOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18562FD11E7A0041DCD1 /* WebOperations.swift */; };
|
||||
30DC185B2FD11E7A0041DCD1 /* NavigationTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18552FD11E7A0041DCD1 /* NavigationTitleView.swift */; };
|
||||
30DC185C2FD11E7A0041DCD1 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18572FD11E7A0041DCD1 /* WebViewController.swift */; };
|
||||
30DC185E2FD1211D0041DCD1 /* VipRightsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC185D2FD1211D0041DCD1 /* VipRightsVC.swift */; };
|
||||
30DC18602FD12A020041DCD1 /* VipWaivePopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC185F2FD12A020041DCD1 /* VipWaivePopView.swift */; };
|
||||
C49B37352A45A02C28FF41BA /* Pods_QuickLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1C77B42994F352054070537 /* Pods_QuickLocation.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -396,6 +402,9 @@
|
|||
3062E8C32FCFC90F00CEF511 /* CreateGroupVipPopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateGroupVipPopView.swift; sourceTree = "<group>"; };
|
||||
3062E8C62FCFD02F00CEF511 /* VipRechargeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipRechargeView.swift; sourceTree = "<group>"; };
|
||||
3062E8C82FCFD03B00CEF511 /* VipRechargeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipRechargeVC.swift; sourceTree = "<group>"; };
|
||||
307073E02FD15F50004C37CC /* GroupIMService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupIMService.swift; sourceTree = "<group>"; };
|
||||
307073E22FD18A20004C37CC /* GroupChatVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupChatVC.swift; sourceTree = "<group>"; };
|
||||
307073E32FD18A20004C37CC /* GroupChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupChatView.swift; sourceTree = "<group>"; };
|
||||
30A7A9102FCAEE3D00105780 /* GroupListPopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupListPopView.swift; sourceTree = "<group>"; };
|
||||
30BAB84C2FCD2FDE00C33B5C /* InviteJoinView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteJoinView.swift; sourceTree = "<group>"; };
|
||||
30BAB84E2FCD2FED00C33B5C /* InviteJoinVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteJoinVC.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -403,10 +412,13 @@
|
|||
30BAB8522FCD337C00C33B5C /* GroupService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupService.swift; sourceTree = "<group>"; };
|
||||
30BAB8622FCD716C00C33B5C /* JoinGroupVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinGroupVC.swift; sourceTree = "<group>"; };
|
||||
30BAB8642FCD718A00C33B5C /* JoinGroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinGroupView.swift; sourceTree = "<group>"; };
|
||||
30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Mask_group@2x.png"; sourceTree = "<group>"; };
|
||||
30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Mask_group@3x.png"; sourceTree = "<group>"; };
|
||||
30DC18512FD009CD0041DCD1 /* VipExpenseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipExpenseModel.swift; sourceTree = "<group>"; };
|
||||
30DC18532FD00C4A0041DCD1 /* VipRechargeVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipRechargeVM.swift; sourceTree = "<group>"; };
|
||||
30DC18552FD11E7A0041DCD1 /* NavigationTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationTitleView.swift; sourceTree = "<group>"; };
|
||||
30DC18562FD11E7A0041DCD1 /* WebOperations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebOperations.swift; sourceTree = "<group>"; };
|
||||
30DC18572FD11E7A0041DCD1 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
|
||||
30DC185D2FD1211D0041DCD1 /* VipRightsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipRightsVC.swift; sourceTree = "<group>"; };
|
||||
30DC185F2FD12A020041DCD1 /* VipWaivePopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipWaivePopView.swift; sourceTree = "<group>"; };
|
||||
3E4359082FC48D26003470A5 /* QuickLocation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuickLocation.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
93647DF3683AA5E71EC2FB1A /* Pods-QuickLocation.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.release.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D1C77B42994F352054070537 /* Pods_QuickLocation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_QuickLocation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
|
@ -790,14 +802,14 @@
|
|||
305A76262FCA8C7000227D26 /* Group */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
307073E02FD15F50004C37CC /* GroupIMService.swift */,
|
||||
305A76242FCA8C7000227D26 /* GroupViewController.swift */,
|
||||
305A76252FCA8C7000227D26 /* GroupViewModel.swift */,
|
||||
305A76232FCA8C7000227D26 /* GroupView.swift */,
|
||||
307073E42FD18A20004C37CC /* GroupChat */,
|
||||
3062E8B82FCEAC5600CEF511 /* CreateGroup */,
|
||||
30BAB8612FCD714700C33B5C /* Join */,
|
||||
30BAB84B2FCD2FA400C33B5C /* InviteJoin */,
|
||||
30BAB8662FCD750E00C33B5C /* Mask_group@2x.png */,
|
||||
30BAB8672FCD750E00C33B5C /* Mask_group@3x.png */,
|
||||
);
|
||||
path = Group;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -865,6 +877,7 @@
|
|||
305A798E2FCAC5F600227D26 /* InviteMember */,
|
||||
3062E8C52FCFD01000CEF511 /* VipRecharge */,
|
||||
3062E8B32FCE6BA400CEF511 /* Scan */,
|
||||
30DC18592FD11E7A0041DCD1 /* Web */,
|
||||
);
|
||||
path = Section;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1060,10 +1073,21 @@
|
|||
3062E8C62FCFD02F00CEF511 /* VipRechargeView.swift */,
|
||||
30DC18532FD00C4A0041DCD1 /* VipRechargeVM.swift */,
|
||||
30DC18512FD009CD0041DCD1 /* VipExpenseModel.swift */,
|
||||
30DC185D2FD1211D0041DCD1 /* VipRightsVC.swift */,
|
||||
30DC185F2FD12A020041DCD1 /* VipWaivePopView.swift */,
|
||||
);
|
||||
path = VipRecharge;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
307073E42FD18A20004C37CC /* GroupChat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
307073E22FD18A20004C37CC /* GroupChatVC.swift */,
|
||||
307073E32FD18A20004C37CC /* GroupChatView.swift */,
|
||||
);
|
||||
path = GroupChat;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
30BAB84B2FCD2FA400C33B5C /* InviteJoin */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -1082,6 +1106,24 @@
|
|||
path = Join;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
30DC18582FD11E7A0041DCD1 /* Controller */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
30DC18552FD11E7A0041DCD1 /* NavigationTitleView.swift */,
|
||||
30DC18562FD11E7A0041DCD1 /* WebOperations.swift */,
|
||||
30DC18572FD11E7A0041DCD1 /* WebViewController.swift */,
|
||||
);
|
||||
path = Controller;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
30DC18592FD11E7A0041DCD1 /* Web */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
30DC18582FD11E7A0041DCD1 /* Controller */,
|
||||
);
|
||||
path = Web;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3E4358FF2FC48D26003470A5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -1195,8 +1237,6 @@
|
|||
305A77F52FCA8C7000227D26 /* phone_search_no_vip.json in Resources */,
|
||||
305A77F62FCA8C7000227D26 /* phone_search_success.json in Resources */,
|
||||
305A77F72FCA8C7000227D26 /* sign_in_continuous_data.json in Resources */,
|
||||
30BAB8682FCD750E00C33B5C /* Mask_group@3x.png in Resources */,
|
||||
30BAB8692FCD750E00C33B5C /* Mask_group@2x.png in Resources */,
|
||||
305A77F82FCA8C7000227D26 /* sign_in_un_continuous_data.json in Resources */,
|
||||
305A77F92FCA8C7000227D26 /* Assets.xcassets in Resources */,
|
||||
305A77FB2FCA8C7000227D26 /* LaunchScreen.storyboard in Resources */,
|
||||
|
|
@ -1291,6 +1331,7 @@
|
|||
305A76912FCA8C7000227D26 /* Constant.swift in Sources */,
|
||||
305A76922FCA8C7000227D26 /* LogUtils.swift in Sources */,
|
||||
305A76932FCA8C7000227D26 /* AddImageCell.swift in Sources */,
|
||||
30DC185E2FD1211D0041DCD1 /* VipRightsVC.swift in Sources */,
|
||||
305A76942FCA8C7000227D26 /* UploadImageCell.swift in Sources */,
|
||||
305A76952FCA8C7000227D26 /* CornerRadiusCell.swift in Sources */,
|
||||
305A76962FCA8C7000227D26 /* CornerRadiusFooterView.swift in Sources */,
|
||||
|
|
@ -1344,6 +1385,9 @@
|
|||
305A76C12FCA8C7000227D26 /* BaseViewController.swift in Sources */,
|
||||
3062E8C02FCED7BB00CEF511 /* GroupIconListView.swift in Sources */,
|
||||
305A76C22FCA8C7000227D26 /* BaseViewModel.swift in Sources */,
|
||||
30DC185A2FD11E7A0041DCD1 /* WebOperations.swift in Sources */,
|
||||
30DC185B2FD11E7A0041DCD1 /* NavigationTitleView.swift in Sources */,
|
||||
30DC185C2FD11E7A0041DCD1 /* WebViewController.swift in Sources */,
|
||||
305A76C32FCA8C7000227D26 /* MainTabBarController.swift in Sources */,
|
||||
305A76C42FCA8C7000227D26 /* QuickLocationTabBar.swift in Sources */,
|
||||
305A76C52FCA8C7000227D26 /* Account.swift in Sources */,
|
||||
|
|
@ -1376,6 +1420,7 @@
|
|||
305A79902FCAC61A00227D26 /* InviteMemberVC.swift in Sources */,
|
||||
305A76DE2FCA8C7000227D26 /* ObservableType+ObjectMapper.swift in Sources */,
|
||||
305A76DF2FCA8C7000227D26 /* Single+ObjectMapper.swift in Sources */,
|
||||
30DC18602FD12A020041DCD1 /* VipWaivePopView.swift in Sources */,
|
||||
305A76E02FCA8C7000227D26 /* GroupView.swift in Sources */,
|
||||
30BAB8512FCD331C00C33B5C /* GroupAPI.swift in Sources */,
|
||||
305A76E12FCA8C7000227D26 /* GroupViewController.swift in Sources */,
|
||||
|
|
@ -1402,12 +1447,15 @@
|
|||
305A76F02FCA8C7000227D26 /* MineViewModel.swift in Sources */,
|
||||
305A76F12FCA8C7000227D26 /* SystemService.swift in Sources */,
|
||||
30DC18522FD009CD0041DCD1 /* VipExpenseModel.swift in Sources */,
|
||||
307073E12FD15F50004C37CC /* GroupIMService.swift in Sources */,
|
||||
305A76F22FCA8C7000227D26 /* UserService.swift in Sources */,
|
||||
305A76F32FCA8C7000227D26 /* AutoLayout+NSLayoutConstraint.swift in Sources */,
|
||||
305A76F42FCA8C7000227D26 /* AutoLayout+UIView.swift in Sources */,
|
||||
305A76F52FCA8C7000227D26 /* AutoLayoutSwift.swift in Sources */,
|
||||
305A76F62FCA8C7000227D26 /* AppRouter.swift in Sources */,
|
||||
305A76F72FCA8C7000227D26 /* RouterTarget.swift in Sources */,
|
||||
307073E52FD18A20004C37CC /* GroupChatView.swift in Sources */,
|
||||
307073E62FD18A20004C37CC /* GroupChatVC.swift in Sources */,
|
||||
305A76F82FCA8C7000227D26 /* DLAlert.swift in Sources */,
|
||||
305A76F92FCA8C7000227D26 /* DLToast.swift in Sources */,
|
||||
305A76FA2FCA8C7000227D26 /* DLEmptyDataSet.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ enum UserAPI {
|
|||
/// 用户信息
|
||||
case userInfo
|
||||
|
||||
/// 用户IM Token
|
||||
case imToken
|
||||
|
||||
/// 退出登录
|
||||
case logout
|
||||
}
|
||||
|
|
@ -34,6 +37,8 @@ extension UserAPI: MultiTargetProtocol {
|
|||
return "api/user/login"
|
||||
case .userInfo:
|
||||
return "api/user"
|
||||
case .imToken:
|
||||
return "mapi/openim/user/token/get"
|
||||
case .logout:
|
||||
return "api/user/logout"
|
||||
}
|
||||
|
|
@ -60,6 +65,12 @@ extension UserAPI: MultiTargetProtocol {
|
|||
case .userInfo:
|
||||
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
|
||||
|
||||
case .imToken:
|
||||
var params = Parameters()
|
||||
params["platform_id"] = 1
|
||||
params["force"] = true
|
||||
return .requestParameters(parameters: params, encoding: JSONEncoding())
|
||||
|
||||
case .logout:
|
||||
return .requestParameters(parameters: Parameters(), encoding: JSONEncoding())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
}
|
||||
#endif
|
||||
|
||||
// OpenIM
|
||||
GroupIMService.shared.initSDK()
|
||||
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window?.backgroundColor = .white
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"provides-namespace" : true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Plus@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Plus@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1613@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1613@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1898@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1898@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1614@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1614@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Icons_Photo@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Icons_Photo@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1862@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1862@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1863@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1863@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRecharge/battery.imageset/Group 1863@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
QuickLocation/Assets.xcassets/VipRecharge/battery.imageset/Group 1863@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1861@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1861@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRecharge/bubble.imageset/Group 1861@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
QuickLocation/Assets.xcassets/VipRecharge/bubble.imageset/Group 1861@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1864@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1864@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1858@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1858@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRecharge/location.imageset/Group 1858@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
QuickLocation/Assets.xcassets/VipRecharge/location.imageset/Group 1858@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1859@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1859@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1865@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1865@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRecharge/service.imageset/Group 1865@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
QuickLocation/Assets.xcassets/VipRecharge/service.imageset/Group 1865@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1860@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 1860@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "waive_bg@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "waive_bg@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRecharge/waive_bg.imageset/waive_bg@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
QuickLocation/Assets.xcassets/VipRecharge/waive_bg.imageset/waive_bg@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 173 KiB |
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"provides-namespace" : true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "bg@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "bg@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "desc@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "desc@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 290 KiB |
|
After Width: | Height: | Size: 551 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "header_bg@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "header_bg@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QuickLocation/Assets.xcassets/VipRights/header_bg.imageset/header_bg@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
QuickLocation/Assets.xcassets/VipRights/header_bg.imageset/header_bg@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 289 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "logo@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "logo@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 148 KiB |
|
After Width: | Height: | Size: 217 KiB |
|
|
@ -13,6 +13,9 @@ class AppContextManager: NSObject {
|
|||
|
||||
private var loginAccount: UserConfigModel?
|
||||
|
||||
var systemConfig: SystemConfigModel?
|
||||
var imToken: String?
|
||||
|
||||
var account: UserConfigModel? {
|
||||
if let loginAccount = loginAccount {
|
||||
return loginAccount
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ struct UserConfigModel: Mappable {
|
|||
/// 会员 1:非会员 2:普通会员 3:终身会员
|
||||
var vip: Int = 1
|
||||
|
||||
/// Config
|
||||
var config: SystemConfigModel?
|
||||
|
||||
init?(map: Map) {
|
||||
|
||||
}
|
||||
|
|
@ -40,6 +43,20 @@ struct UserConfigModel: Mappable {
|
|||
uid <- map["user_id"]
|
||||
avater <- map["avater"]
|
||||
head_pic <- (map["head_pic"], kIntTransformStr)
|
||||
config <- map["config"]
|
||||
vip <- map["vip"]
|
||||
}
|
||||
}
|
||||
|
||||
struct SystemConfigModel: Mappable {
|
||||
/// 圈子里的banner
|
||||
var groupBannerList: [String] = []
|
||||
|
||||
init?(map: Map) {
|
||||
|
||||
}
|
||||
|
||||
mutating func mapping(map: Map) {
|
||||
groupBannerList <- map["client.team.ad", nested: false]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ enum Route: String {
|
|||
case groupIconList = "groupIconList"
|
||||
/// 会员充值
|
||||
case vipRecharge = "vipRecharge"
|
||||
/// 权益对比
|
||||
case vipRights = "vipRights"
|
||||
/// 群聊
|
||||
case groupChat = "groupChat"
|
||||
}
|
||||
|
||||
extension Route: RouterTarget {
|
||||
|
|
@ -85,22 +89,22 @@ extension AppRouter: AppRouterProtocol {
|
|||
|
||||
public func setupRegisterRouter() {
|
||||
// MARK: - web
|
||||
// AppRouter.register(Route.web) { url, parameters in
|
||||
// guard let urlStr = parameters["url"] as? String,
|
||||
// let url = URL(string: urlStr)?.absoluteString else { return nil }
|
||||
// let params = parameters.compactMap {
|
||||
// guard $0.key != "url" else {
|
||||
// return nil
|
||||
// }
|
||||
// return "\($0.key)=\(String(describing: $0.value))"
|
||||
// }.joined(separator: "&")
|
||||
// let separator = url.contains("?") ? "&" : "?"
|
||||
// let tempUrl = url + separator + params
|
||||
// let style = parameters["style"].safeString
|
||||
// let isShare = parameters["isShare"].safeString == "1" ? true : false
|
||||
// let fullscreen = parameters["fullscreen"].safeString == "1" ? true : false
|
||||
// return WebViewController(url: tempUrl, isShare: isShare, fullscreen: fullscreen, style: style.isEmpty ? "default" : style)
|
||||
// }
|
||||
AppRouter.register(Route.web) { url, parameters in
|
||||
guard let urlStr = parameters["url"] as? String,
|
||||
let url = URL(string: urlStr)?.absoluteString else { return nil }
|
||||
let params = parameters.compactMap {
|
||||
guard $0.key != "url" else {
|
||||
return nil
|
||||
}
|
||||
return "\($0.key)=\(String(describing: $0.value))"
|
||||
}.joined(separator: "&")
|
||||
let separator = url.contains("?") ? "&" : "?"
|
||||
let tempUrl = url + separator + params
|
||||
let style = parameters["style"].safeString
|
||||
let isShare = parameters["isShare"].safeString == "1" ? true : false
|
||||
let fullscreen = parameters["fullscreen"].safeString == "1" ? true : false
|
||||
return WebViewController(url: tempUrl, isShare: isShare, fullscreen: fullscreen, style: style.isEmpty ? "default" : style)
|
||||
}
|
||||
|
||||
// MARK: - 登录
|
||||
AppRouter.register(Route.login) { url, parameters in
|
||||
|
|
@ -139,6 +143,16 @@ extension AppRouter: AppRouterProtocol {
|
|||
AppRouter.register(Route.vipRecharge) { url, parameters in
|
||||
VipRechargeVC()
|
||||
}
|
||||
|
||||
// MARK: - 权益对比
|
||||
AppRouter.register(Route.vipRights) { url, parameters in
|
||||
VipRightsVC()
|
||||
}
|
||||
|
||||
AppRouter.register(Route.groupChat) { url, parameters in
|
||||
let groupId = parameters["groupId"].safeString
|
||||
return GroupChatVC(groupId: groupId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,13 @@ extension DefaultsKeys {
|
|||
var openIM_WS = ""
|
||||
|
||||
/// 用户协议
|
||||
var userAgreementUrl: String { "https://sd.zuom8.cn/Agreement.html" }
|
||||
var userAgreementUrl: String { "https://smartdrive.zuom8.cn/jisu/Agreement.html" }
|
||||
/// 隐私政策
|
||||
var privacyPolicyUrl: String { "https://sd.zuom8.cn/Privacy.html" }
|
||||
var privacyPolicyUrl: String { "https://smartdrive.zuom8.cn/jisu/Privacy.html" }
|
||||
/// 儿童
|
||||
var kidsPrivacyUrl: String { "https://smartdrive.zuom8.cn/jisu/KidsPrivacy.html" }
|
||||
/// 注销须知
|
||||
var cancellationNoticeUrl: String { "https://h5.yiwen618.com.cn/yiwen_h5_logoff.html" }
|
||||
var cancellationNoticeUrl: String { "https://smartdrive.zuom8.cn/jisu/Cancellation.html" }
|
||||
|
||||
private override init() {
|
||||
super.init()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,23 @@ struct UserGroupResponse: BaseModelProtocol {
|
|||
}
|
||||
}
|
||||
|
||||
struct RecommandGroupResponse: BaseModelProtocol {
|
||||
// 状态码
|
||||
var code: String?
|
||||
// 消息
|
||||
var message: String?
|
||||
//
|
||||
var list: [GroupInfoModel] = []
|
||||
|
||||
init?(map: Map) {}
|
||||
|
||||
mutating func mapping(map: Map) {
|
||||
code <- map["code"]
|
||||
message <- map["msg"]
|
||||
list <- map["data"]
|
||||
}
|
||||
}
|
||||
|
||||
struct GroupModel: Mappable {
|
||||
/// 当前选中的圈子
|
||||
var default_group_key: String = ""
|
||||
|
|
@ -65,6 +82,8 @@ struct GroupInfoModel: Mappable, Equatable {
|
|||
var groupIcon: UIImage {
|
||||
UIImage(named: "GroupIcon/\(icon_index)") ?? UIImage()
|
||||
}
|
||||
/// 人数
|
||||
var people_no: Int = 0
|
||||
///
|
||||
var description: String = ""
|
||||
/// 会员等级
|
||||
|
|
@ -80,6 +99,7 @@ struct GroupInfoModel: Mappable, Equatable {
|
|||
name <- map["name"]
|
||||
icon_index <- map["icon_index"]
|
||||
level <- map["level"]
|
||||
people_no <- (map["people_no"], kStrTransformInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class CreateGroupViewModel {
|
|||
"description": desc,
|
||||
"labels": selectedTagList]).subscribe(onNext: { response in
|
||||
DLToast.showSuccess(text: "创建成功") {
|
||||
NotificationCenter.default.post(name: .RefreshGroupInfoNotification, object: nil)
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}
|
||||
}, onError: { (error) in
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class CreateGroupVipPopView: UIView {
|
|||
lazy var vipImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "Group/vip_pop")
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,177 @@
|
|||
//
|
||||
// GroupChatVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
import OpenIMSDK
|
||||
|
||||
final class GroupChatVC: BaseViewController {
|
||||
|
||||
override var isNavigationBarHidden: Bool { true }
|
||||
|
||||
fileprivate var rootView: GroupChatView!
|
||||
private let groupId: String
|
||||
|
||||
private var msgListener: MessageListenerProxy?
|
||||
|
||||
// MARK: - Init
|
||||
init(groupId: String) {
|
||||
self.groupId = groupId
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
rootView = GroupChatView(frame: UIScreen.main.bounds)
|
||||
view = rootView
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
reactiveAction()
|
||||
loadGroupInfo()
|
||||
loadMessages()
|
||||
setupMessageListener()
|
||||
}
|
||||
|
||||
// MARK: - Message Listener
|
||||
private func setupMessageListener() {
|
||||
msgListener = MessageListenerProxy { [weak self] msg in
|
||||
guard let self = self, msg.groupID == self.groupId else { return }
|
||||
let chatMsg = self.convertMessage(msg)
|
||||
DispatchQueue.main.async {
|
||||
self.rootView.messages.append(chatMsg)
|
||||
self.rootView.tableView.reloadData()
|
||||
self.rootView.tableView.scrollToRow(
|
||||
at: IndexPath(row: self.rootView.messages.count - 1, section: 0),
|
||||
at: .bottom, animated: true
|
||||
)
|
||||
}
|
||||
}
|
||||
OIMManager.callbacker.addAdvancedMsgListener(listener: msgListener!)
|
||||
}
|
||||
|
||||
// MARK: - Load Messages
|
||||
private func loadMessages() {
|
||||
let param = OIMGetAdvancedHistoryMessageListParam()
|
||||
param.conversationID = "sg_\(groupId)"
|
||||
param.count = 30
|
||||
|
||||
OIMManager.manager.getAdvancedHistoryMessageList(
|
||||
param,
|
||||
onSuccess: { [weak self] result in
|
||||
guard let self = self,
|
||||
let list = result?.messageList else { return }
|
||||
let msgs = list.compactMap { self.convertMessage($0) }.reversed()
|
||||
DispatchQueue.main.async {
|
||||
self.rootView.messages = Array(msgs)
|
||||
}
|
||||
},
|
||||
onFailure: { code, msg in
|
||||
print("loadMessages failed: \(code) \(msg ?? "")")
|
||||
})
|
||||
}
|
||||
|
||||
private func convertMessage(_ msg: OIMMessageInfo) -> ChatMessage {
|
||||
let isSelf = msg.isSelf()
|
||||
let content = msg.textElem?.content ?? "[非文本消息]"
|
||||
let ts = TimeInterval(msg.sendTime) / 1000.0
|
||||
|
||||
let lastTs = rootView.messages.last?.timestamp
|
||||
let showTime = lastTs == nil || (ts - lastTs!) > 300
|
||||
|
||||
return ChatMessage(
|
||||
id: msg.clientMsgID ?? UUID().uuidString,
|
||||
isSelf: isSelf,
|
||||
senderName: msg.senderNickname ?? "",
|
||||
content: content,
|
||||
timestamp: ts,
|
||||
showTime: showTime
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Group Info
|
||||
private func loadGroupInfo() {
|
||||
OIMManager.manager.getSpecifiedGroupsInfo([groupId]) { [weak self] groups in
|
||||
guard let self = self,
|
||||
let group = groups?.first else { return }
|
||||
self.rootView.groupNameLabel.text = group.groupName ?? ""
|
||||
if let faceURL = group.faceURL, !faceURL.isEmpty {
|
||||
self.rootView.groupAvatarView.dl.setImage(with: faceURL)
|
||||
}
|
||||
} onFailure: { code, msg in
|
||||
print("getGroupInfo failed: \(code) \(msg ?? "")")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
private func reactiveAction() {
|
||||
rootView.backBtn.rx.tap
|
||||
.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
rootView.sendBtn.rx.tap
|
||||
.subscribe(onNext: { [weak self] _ in
|
||||
self?.sendMessage()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
rootView.textField.rx.controlEvent(.editingDidEndOnExit)
|
||||
.subscribe(onNext: { [weak self] _ in
|
||||
self?.sendMessage()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func sendMessage() {
|
||||
guard let text = rootView.textField.text?.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
!text.isEmpty else { return }
|
||||
rootView.textField.text = ""
|
||||
|
||||
let msg = OIMMessageInfo.createTextMessage(text)
|
||||
|
||||
OIMManager.manager.sendMessage(msg,
|
||||
recvID: "",
|
||||
groupID: groupId,
|
||||
offlinePushInfo: nil,
|
||||
onSuccess: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
let chatMsg = self.convertMessage(msg)
|
||||
DispatchQueue.main.async {
|
||||
self.rootView.messages.append(chatMsg)
|
||||
self.rootView.tableView.reloadData()
|
||||
self.rootView.tableView.scrollToRow(
|
||||
at: IndexPath(row: self.rootView.messages.count - 1, section: 0),
|
||||
at: .bottom, animated: true
|
||||
)
|
||||
}
|
||||
},
|
||||
onProgress: nil as OIMNumberCallback?,
|
||||
onFailure: { code, errMsg in
|
||||
print("send failed: \(code) \(errMsg ?? "")")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MessageListenerProxy
|
||||
private class MessageListenerProxy: NSObject, OIMAdvancedMsgListener {
|
||||
private let handler: (OIMMessageInfo) -> Void
|
||||
|
||||
init(handler: @escaping (OIMMessageInfo) -> Void) {
|
||||
self.handler = handler
|
||||
}
|
||||
|
||||
func onRecvNewMessage(_ msg: OIMMessageInfo) {
|
||||
handler(msg)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,403 @@
|
|||
//
|
||||
// GroupChatView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
// MARK: - Message Model
|
||||
struct ChatMessage {
|
||||
let id: String
|
||||
let isSelf: Bool
|
||||
let senderName: String
|
||||
let content: String
|
||||
let timestamp: TimeInterval
|
||||
var showTime: Bool = false
|
||||
}
|
||||
|
||||
class GroupChatView: UIView {
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
// MARK: - Data
|
||||
var messages: [ChatMessage] = [] {
|
||||
didSet { tableView.reloadData() }
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
private func setupUI() {
|
||||
backgroundColor = UIColor(hexStr: "#F5FBFB")
|
||||
addSubview(navBgView)
|
||||
addSubview(navBarView)
|
||||
navBarView.addSubview(backBtn)
|
||||
navBarView.addSubview(groupAvatarView)
|
||||
navBarView.addSubview(groupNameLabel)
|
||||
navBarView.addSubview(onlineStatusLabel)
|
||||
navBarView.addSubview(rightIconsView)
|
||||
|
||||
rightIconsView.addSubview(reviewBtn)
|
||||
rightIconsView.addSubview(memberBtn)
|
||||
rightIconsView.addSubview(settingBtn)
|
||||
|
||||
addSubview(tableView)
|
||||
addSubview(bottomBar)
|
||||
bottomBar.addSubview(voiceBtn)
|
||||
bottomBar.addSubview(textField)
|
||||
bottomBar.addSubview(emojiBtn)
|
||||
bottomBar.addSubview(addBtn)
|
||||
bottomBar.addSubview(sendBtn)
|
||||
|
||||
navBgView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
backBtn.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.left(7)
|
||||
.width(24).height(24)
|
||||
|
||||
groupAvatarView.layoutChain
|
||||
.centerY(backBtn)
|
||||
.leftToRightOfView(backBtn, offset: 5)
|
||||
.width(32).height(32)
|
||||
|
||||
groupNameLabel.layoutChain
|
||||
.topToView(groupAvatarView)
|
||||
.leftToRightOfView(groupAvatarView, offset: 8)
|
||||
|
||||
onlineStatusLabel.layoutChain
|
||||
.topToBottomOfView(groupNameLabel, offset: 2)
|
||||
.leftToView(groupNameLabel)
|
||||
|
||||
rightIconsView.layoutChain
|
||||
.centerY(backBtn)
|
||||
.right(15)
|
||||
.height(24)
|
||||
|
||||
reviewBtn.layoutChain
|
||||
.left().centerY()
|
||||
.width(24).height(24)
|
||||
|
||||
memberBtn.layoutChain
|
||||
.leftToRightOfView(reviewBtn, offset: 20)
|
||||
.centerY()
|
||||
.width(24).height(24)
|
||||
|
||||
settingBtn.layoutChain
|
||||
.leftToRightOfView(memberBtn, offset: 20)
|
||||
.centerY()
|
||||
.width(24).height(24)
|
||||
.right()
|
||||
|
||||
tableView.layoutChain
|
||||
.topToBottomOfView(navBarView)
|
||||
.edgesHorzontal()
|
||||
.bottomToTopOfView(bottomBar)
|
||||
|
||||
bottomBar.layoutChain
|
||||
.edgesHorzontal()
|
||||
.height(56)
|
||||
.bottom(kSafeBottomMargin)
|
||||
|
||||
voiceBtn.layoutChain
|
||||
.left(12).centerY()
|
||||
.width(28).height(28)
|
||||
|
||||
sendBtn.layoutChain
|
||||
.right(12).centerY()
|
||||
.width(52).height(32)
|
||||
|
||||
addBtn.layoutChain
|
||||
.rightToLeftOfView(sendBtn, offset: -10)
|
||||
.centerY()
|
||||
.width(28).height(28)
|
||||
|
||||
emojiBtn.layoutChain
|
||||
.rightToLeftOfView(addBtn, offset: -10)
|
||||
.centerY()
|
||||
.width(28).height(28)
|
||||
|
||||
textField.layoutChain
|
||||
.leftToRightOfView(voiceBtn, offset: 10)
|
||||
.rightToLeftOfView(emojiBtn, offset: -10)
|
||||
.centerY()
|
||||
.height(36)
|
||||
}
|
||||
|
||||
// MARK: - Nav
|
||||
lazy var navBgView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.image = UIImage(named: "Common/navBar_bg_2")
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 40)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var groupAvatarView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 16
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#E0E0E0")
|
||||
return iv
|
||||
}()
|
||||
|
||||
lazy var groupNameLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#333333")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var onlineStatusLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "今日活跃"
|
||||
label.font = .systemFont(ofSize: 12, weight: .regular)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var rightIconsView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var reviewBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/review"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var memberBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/member"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var settingBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/setting"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
// MARK: - Message List
|
||||
lazy var tableView: UITableView = {
|
||||
let tv = UITableView(frame: .zero, style: .plain)
|
||||
tv.backgroundColor = .clear
|
||||
tv.separatorStyle = .none
|
||||
tv.showsVerticalScrollIndicator = false
|
||||
tv.register(TextMsgCell.self)
|
||||
tv.estimatedRowHeight = 60
|
||||
tv.rowHeight = UITableView.automaticDimension
|
||||
tv.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
|
||||
tv.delegate = self
|
||||
tv.dataSource = self
|
||||
return tv
|
||||
}()
|
||||
|
||||
// MARK: - Bottom Bar
|
||||
lazy var bottomBar: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#F7F8F9")
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var voiceBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/voice"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var textField: UITextField = {
|
||||
let tf = UITextField()
|
||||
tf.font = .systemFont(ofSize: 14)
|
||||
tf.backgroundColor = .white
|
||||
tf.cornerRadius = 18
|
||||
tf.placeholder = "输入消息..."
|
||||
tf.returnKeyType = .send
|
||||
tf.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 12, height: 36))
|
||||
tf.leftViewMode = .always
|
||||
return tf
|
||||
}()
|
||||
|
||||
lazy var emojiBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/emoji"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var addBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/add"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var sendBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("发送", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
|
||||
btn.backgroundColor = UIColor(hexStr: "#16B3FF")
|
||||
btn.cornerRadius = 16
|
||||
return btn
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: .zero)
|
||||
setupUI()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate, UITableViewDataSource
|
||||
extension GroupChatView: UITableViewDelegate, UITableViewDataSource {
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return messages.count
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell: TextMsgCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(messages[indexPath.row])
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TextMsgCell
|
||||
final class TextMsgCell: UITableViewCell {
|
||||
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 11)
|
||||
label.textColor = UIColor(hexStr: "#B0B0B0")
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
private let avatarView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 18
|
||||
iv.clipsToBounds = true
|
||||
return iv
|
||||
}()
|
||||
|
||||
private let bubbleView: UIView = {
|
||||
let v = UIView()
|
||||
v.cornerRadius = 8
|
||||
return v
|
||||
}()
|
||||
|
||||
private let contentLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 14)
|
||||
label.numberOfLines = 0
|
||||
return label
|
||||
}()
|
||||
|
||||
override init(style: CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
selectionStyle = .none
|
||||
backgroundColor = .clear
|
||||
contentView.addSubview(timeLabel)
|
||||
contentView.addSubview(avatarView)
|
||||
contentView.addSubview(bubbleView)
|
||||
bubbleView.addSubview(contentLabel)
|
||||
|
||||
timeLabel.frame = CGRect(x: 0, y: 12, width: kScreenWidth, height: 16)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(_ msg: ChatMessage) {
|
||||
timeLabel.isHidden = !msg.showTime
|
||||
if msg.showTime {
|
||||
timeLabel.text = formatTime(msg.timestamp)
|
||||
}
|
||||
contentLabel.text = msg.content
|
||||
|
||||
let showTime = msg.showTime
|
||||
let topY: CGFloat = showTime ? 34 : 10
|
||||
let screenW = kScreenWidth
|
||||
let maxBubbleW = screenW - 100
|
||||
let contentW = min(msg.content.boundingSize(font: contentLabel.font, maxWidth: maxBubbleW - 24).width + 24, maxBubbleW)
|
||||
|
||||
if msg.isSelf {
|
||||
avatarView.isHidden = true
|
||||
bubbleView.backgroundColor = UIColor(hexStr: "#16B3FF")
|
||||
contentLabel.textColor = .white
|
||||
|
||||
let bubbleH = msg.content.boundingSize(font: contentLabel.font, maxWidth: maxBubbleW - 24).height + 20
|
||||
bubbleView.frame = CGRect(x: screenW - 12 - contentW, y: topY, width: contentW, height: bubbleH)
|
||||
contentLabel.frame = CGRect(x: 12, y: 10, width: contentW - 24, height: bubbleH - 20)
|
||||
} else {
|
||||
avatarView.isHidden = false
|
||||
avatarView.image = UIImage(named: "GroupIcon1")
|
||||
bubbleView.backgroundColor = .white
|
||||
contentLabel.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
|
||||
avatarView.frame = CGRect(x: 12, y: topY, width: 36, height: 36)
|
||||
let bubbleH = msg.content.boundingSize(font: contentLabel.font, maxWidth: maxBubbleW - 24).height + 20
|
||||
bubbleView.frame = CGRect(x: 56, y: topY, width: contentW, height: bubbleH)
|
||||
contentLabel.frame = CGRect(x: 12, y: 10, width: contentW - 24, height: bubbleH - 20)
|
||||
}
|
||||
}
|
||||
|
||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||
// This is handled by rowHeight = automaticDimension + proper intrinsic sizing
|
||||
guard let text = contentLabel.text, !text.isEmpty else {
|
||||
return CGSize(width: size.width, height: 60)
|
||||
}
|
||||
let showTime = !timeLabel.isHidden
|
||||
let topY: CGFloat = showTime ? 34 : 10
|
||||
let maxBubbleW = size.width - 100
|
||||
let textH = text.boundingSize(font: contentLabel.font, maxWidth: maxBubbleW - 24).height
|
||||
return CGSize(width: size.width, height: topY + textH + 20 + 10)
|
||||
}
|
||||
|
||||
private func formatTime(_ t: TimeInterval) -> String {
|
||||
let date = Date(timeIntervalSince1970: t)
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "M-d HH:mm"
|
||||
return f.string(from: date)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - String bounding helper
|
||||
private extension String {
|
||||
func boundingSize(font: UIFont, maxWidth: CGFloat) -> CGSize {
|
||||
let rect = (self as NSString).boundingRect(
|
||||
with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude),
|
||||
options: [.usesLineFragmentOrigin, .usesFontLeading],
|
||||
attributes: [.font: font],
|
||||
context: nil
|
||||
)
|
||||
return CGSize(width: ceil(rect.width), height: ceil(rect.height))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
//
|
||||
// GroupIMService.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/4.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMSDK
|
||||
|
||||
final class GroupIMService {
|
||||
|
||||
static let shared = GroupIMService()
|
||||
|
||||
private var isLogined = false
|
||||
|
||||
private init() {}
|
||||
|
||||
// MARK: - Init SDK
|
||||
func initSDK() {
|
||||
let config = OIMInitConfig()
|
||||
config.apiAddr = URLManager.shared.openIM_API
|
||||
config.wsAddr = URLManager.shared.openIM_WS
|
||||
config.platform = .iPhone
|
||||
OIMManager.manager.initSDK(with: config,
|
||||
onConnecting: {},
|
||||
onConnectFailure: { _, _ in },
|
||||
onConnectSuccess: {},
|
||||
onKickedOffline: {},
|
||||
onUserTokenExpired: {},
|
||||
onUserTokenInvalid: { _ in })
|
||||
}
|
||||
|
||||
// MARK: - Login
|
||||
func login(completion: @escaping (Bool) -> Void) {
|
||||
guard !isLogined, let token = AppContextManager.shared.imToken else {
|
||||
completion(true)
|
||||
return
|
||||
}
|
||||
let userId = AppContextManager.shared.userId
|
||||
guard !userId.isEmpty, !token.isEmpty else {
|
||||
completion(false)
|
||||
return
|
||||
}
|
||||
OIMManager.manager.login(userId, token: token) { [weak self] _ in
|
||||
self?.isLogined = true
|
||||
completion(true)
|
||||
} onFailure: { code, msg in
|
||||
print("OpenIM login failed: \(code) \(msg ?? "")")
|
||||
completion(false)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Get Joined Groups
|
||||
func getJoinedGroups(completion: @escaping ([OIMGroupInfo]) -> Void) {
|
||||
OIMManager.manager.getJoinedGroupListWith(onSuccess: { groups in
|
||||
completion(groups ?? [])
|
||||
}, onFailure: { code, msg in
|
||||
print("getJoinedGroupList failed: \(code) \(msg ?? "")")
|
||||
completion([])
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: - Conversation List (for unread count & last msg time)
|
||||
func getConversationList(completion: @escaping ([OIMConversationInfo]) -> Void) {
|
||||
OIMManager.manager.getAllConversationListWith(onSuccess: { list in
|
||||
completion(list ?? [])
|
||||
}, onFailure: { code, msg in
|
||||
completion([])
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: - Conversation Listener
|
||||
private var conversationListener: ConversationListenerProxy?
|
||||
|
||||
func setConversationListener(_ handler: @escaping ([OIMConversationInfo]) -> Void) {
|
||||
conversationListener = ConversationListenerProxy(handler: handler)
|
||||
OIMManager.callbacker.addConversationListener(listener: conversationListener!)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ConversationListenerProxy
|
||||
private class ConversationListenerProxy: NSObject, OIMConversationListener {
|
||||
private let handler: ([OIMConversationInfo]) -> Void
|
||||
|
||||
init(handler: @escaping ([OIMConversationInfo]) -> Void) {
|
||||
self.handler = handler
|
||||
}
|
||||
|
||||
func onConversationChanged(_ conversations: [OIMConversationInfo]) {
|
||||
handler(conversations)
|
||||
}
|
||||
|
||||
func onNewConversation(_ conversations: [OIMConversationInfo]) {
|
||||
handler(conversations)
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import UIKit
|
|||
import RxSwift
|
||||
import RxCocoa
|
||||
import SDCycleScrollView
|
||||
import OpenIMSDK
|
||||
|
||||
// MARK: - PanScrollView(参考 PanScrollView,允许嵌套手势同时识别)
|
||||
class PanScrollView: UIScrollView {
|
||||
|
|
@ -217,7 +218,6 @@ class GroupView: UIView {
|
|||
view.currentPageDotColor = UIColor(hexStr: "#16B3FF")
|
||||
view.pageDotColor = UIColor(hexStr: "#7AD6FF").withAlphaComponent(0.4)
|
||||
view.pageControlDotSize = CGSize(width: 8, height: 8)
|
||||
view.localizationImageNamesGroup = ["Mask_group", "Mask_group", "Mask_group"]
|
||||
view.clipsToBounds = false
|
||||
view.pageControlBottomOffset = -34
|
||||
return view
|
||||
|
|
@ -338,7 +338,7 @@ class GroupView: UIView {
|
|||
tv.separatorStyle = .none
|
||||
tv.showsVerticalScrollIndicator = false
|
||||
tv.register(CircleGroupCell.self)
|
||||
tv.rowHeight = 72
|
||||
tv.estimatedRowHeight = 70
|
||||
tv.bounces = true
|
||||
tv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 97 + kSafeBottomMargin, right: 0)
|
||||
return tv
|
||||
|
|
@ -350,7 +350,7 @@ class GroupView: UIView {
|
|||
tv.separatorStyle = .none
|
||||
tv.showsVerticalScrollIndicator = false
|
||||
tv.register(CircleGroupCell.self)
|
||||
tv.rowHeight = 72
|
||||
tv.estimatedRowHeight = 70
|
||||
tv.bounces = true
|
||||
tv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 97 + kSafeBottomMargin, right: 0)
|
||||
return tv
|
||||
|
|
@ -491,10 +491,10 @@ final class HotGroupCell: UICollectionViewCell {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(_ item: HotGroupItem) {
|
||||
iconView.image = UIImage(named: item.icon)
|
||||
nameLabel.text = item.name
|
||||
countLabel.text = "\(item.memberCount)人·\(item.onlineCount)在线"
|
||||
func configure(_ model: GroupInfoModel) {
|
||||
iconView.image = model.groupIcon
|
||||
nameLabel.text = model.name
|
||||
countLabel.text = "共\(model.people_no)个成员"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,7 +504,7 @@ final class CircleGroupCell: UITableViewCell {
|
|||
private let iconView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.layer.cornerRadius = 24
|
||||
iv.cornerRadius = 20
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#F0F0F0")
|
||||
return iv
|
||||
|
|
@ -513,21 +513,37 @@ final class CircleGroupCell: UITableViewCell {
|
|||
private let nameLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
return label
|
||||
}()
|
||||
|
||||
private let countLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12, weight: .regular)
|
||||
label.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
return label
|
||||
}()
|
||||
|
||||
private let addressLabel: UILabel = {
|
||||
lazy var unreadBadgeView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#FF383C")
|
||||
view.cornerRadius = 7
|
||||
view.isHidden = true
|
||||
return view
|
||||
}()
|
||||
|
||||
private let unreadBadge: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12, weight: .regular)
|
||||
label.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
label.textColor = .white
|
||||
return label
|
||||
}()
|
||||
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 10, weight: .regular)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
label.textAlignment = .right
|
||||
return label
|
||||
}()
|
||||
|
||||
|
|
@ -545,35 +561,94 @@ final class CircleGroupCell: UITableViewCell {
|
|||
contentView.addSubview(iconView)
|
||||
contentView.addSubview(nameLabel)
|
||||
contentView.addSubview(countLabel)
|
||||
contentView.addSubview(addressLabel)
|
||||
contentView.addSubview(unreadBadgeView)
|
||||
unreadBadgeView.addSubview(unreadBadge)
|
||||
contentView.addSubview(timeLabel)
|
||||
contentView.addSubview(dividerLine)
|
||||
|
||||
iconView.layoutChain
|
||||
.left(16).centerY()
|
||||
.width(48).height(48)
|
||||
.left(15).edgesVertical(15)
|
||||
.width(40).height(40)
|
||||
|
||||
nameLabel.layoutChain
|
||||
.top(12).leftToRightOfView(iconView, offset: 12)
|
||||
.topToView(iconView, offset: 4)
|
||||
.leftToRightOfView(iconView, offset: 12)
|
||||
.right(90)
|
||||
|
||||
countLabel.layoutChain
|
||||
.topToBottomOfView(nameLabel, offset: 4)
|
||||
.leftToView(nameLabel)
|
||||
|
||||
addressLabel.layoutChain
|
||||
.centerY().right(16)
|
||||
unreadBadgeView.layoutChain
|
||||
.centerY(nameLabel)
|
||||
.right(15)
|
||||
|
||||
unreadBadge.layoutChain
|
||||
.edgesHorzontal(8)
|
||||
.edgesVertical(1)
|
||||
|
||||
timeLabel.layoutChain
|
||||
.right(15)
|
||||
.centerY(countLabel)
|
||||
|
||||
dividerLine.layoutChain
|
||||
.left(76).right().bottom().height(0.5)
|
||||
.edgesHorzontal(15)
|
||||
.bottom()
|
||||
.height(0.5)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(_ item: CircleGroupItem) {
|
||||
iconView.image = UIImage(named: item.icon)
|
||||
nameLabel.text = item.name
|
||||
countLabel.text = "\(item.memberCount)人·\(item.onlineCount)在线"
|
||||
addressLabel.text = item.address
|
||||
func configure(_ model: GroupCellData) {
|
||||
let g = model.groupInfo
|
||||
// if let faceURL = g.faceURL, !faceURL.isEmpty {
|
||||
// iconView.dl.setImage(with: faceURL)
|
||||
// } else {
|
||||
// iconView.image = UIImage(named: "GroupIcon1")
|
||||
// }
|
||||
iconView.image = model.localIcon
|
||||
nameLabel.text = g.groupName ?? ""
|
||||
countLabel.text = "共\(g.memberCount)个成员"
|
||||
|
||||
// 未读消息数
|
||||
if model.unreadCount > 0 {
|
||||
unreadBadgeView.isHidden = false
|
||||
unreadBadge.text = model.unreadCount > 99 ? "99+" : "\(model.unreadCount)"
|
||||
} else {
|
||||
unreadBadgeView.isHidden = true
|
||||
}
|
||||
|
||||
// 最后消息时间
|
||||
if model.lastMsgTime > 0 {
|
||||
let date = Date(timeIntervalSince1970: TimeInterval(model.lastMsgTime) / 1000)
|
||||
timeLabel.text = date.formatForIM()
|
||||
} else {
|
||||
timeLabel.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Date IM format
|
||||
private extension Date {
|
||||
func formatForIM() -> String {
|
||||
let now = Date()
|
||||
let calendar = Calendar.current
|
||||
if calendar.isDateInToday(self) {
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "HH:mm"
|
||||
return f.string(from: self)
|
||||
} else if calendar.isDateInYesterday(self) {
|
||||
return "昨天"
|
||||
} else if calendar.isDate(self, equalTo: now, toGranularity: .year) {
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "MM/dd"
|
||||
return f.string(from: self)
|
||||
} else {
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "yyyy/MM/dd"
|
||||
return f.string(from: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import UIKit
|
|||
import RxSwift
|
||||
import RxCocoa
|
||||
import RxDataSources
|
||||
import SDCycleScrollView
|
||||
import OpenIMSDK
|
||||
|
||||
final class GroupViewController: BaseViewController {
|
||||
|
||||
|
|
@ -25,43 +27,78 @@ final class GroupViewController: BaseViewController {
|
|||
bindViewModel()
|
||||
reactiveAction()
|
||||
observeTableViews()
|
||||
requestRecommandGroup()
|
||||
requestGroupInfo()
|
||||
|
||||
viewModel.loadMockData()
|
||||
setupOpenIM()
|
||||
|
||||
guard let config = AppContextManager.shared.systemConfig else { return }
|
||||
rootView.cycleScrollView.imageURLStringsGroup = config.groupBannerList
|
||||
}
|
||||
|
||||
// MARK: - OpenIM
|
||||
private func setupOpenIM() {
|
||||
GroupIMService.shared.login { [weak self] success in
|
||||
guard success else { return }
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
self?.refreshIMData()
|
||||
}
|
||||
}
|
||||
GroupIMService.shared.setConversationListener { [weak self] _ in
|
||||
// 收到新消息后重新拉取完整会话列表
|
||||
GroupIMService.shared.getConversationList { conversations in
|
||||
self?.viewModel.updateConversations(conversations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshIMData() {
|
||||
let group = DispatchGroup()
|
||||
var groups: [OIMGroupInfo] = []
|
||||
var conversations: [OIMConversationInfo] = []
|
||||
|
||||
group.enter()
|
||||
GroupIMService.shared.getJoinedGroups { g in
|
||||
groups = g
|
||||
group.leave()
|
||||
}
|
||||
group.enter()
|
||||
GroupIMService.shared.getConversationList { c in
|
||||
conversations = c
|
||||
group.leave()
|
||||
}
|
||||
group.notify(queue: .main) { [weak self] in
|
||||
self?.viewModel.loadIMGroups(groups, conversations: conversations)
|
||||
}
|
||||
}
|
||||
|
||||
private func requestIMGroups(retryCount: Int = 3) {
|
||||
GroupIMService.shared.getJoinedGroups { [weak self] groups in
|
||||
guard let self = self else { return }
|
||||
if groups.isEmpty && retryCount > 0 {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
self.requestIMGroups(retryCount: retryCount - 1)
|
||||
}
|
||||
} else {
|
||||
self.refreshIMData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Bindings
|
||||
private func bindViewModel() {
|
||||
// 热门酷圈
|
||||
viewModel.output.hotGroups
|
||||
.drive(rootView.hotGroupsCollectionView.rx.items(
|
||||
cellIdentifier: HotGroupCell.reuseId,
|
||||
cellType: HotGroupCell.self
|
||||
)) { _, item, cell in
|
||||
cell.configure(item)
|
||||
}
|
||||
.observe(on: MainScheduler.asyncInstance)
|
||||
.bind(to: rootView.hotGroupsCollectionView.rx.items(dataSource: hotGroupDataSource))
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
// 我创建的圈子
|
||||
let createdDataSource = RxTableViewSectionedReloadDataSource<CircleListSectionModel>(
|
||||
configureCell: { (_, tableView, indexPath, model) in
|
||||
let cell: CircleGroupCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
})
|
||||
|
||||
viewModel.output.createdSections
|
||||
.observe(on: MainScheduler.asyncInstance)
|
||||
.bind(to: rootView.createdTableView.rx.items(dataSource: createdDataSource))
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
// 我加入的圈子
|
||||
let joinedDataSource = RxTableViewSectionedReloadDataSource<CircleListSectionModel>(
|
||||
configureCell: { (_, tableView, indexPath, model) in
|
||||
let cell: CircleGroupCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
})
|
||||
|
||||
viewModel.output.joinedSections
|
||||
.observe(on: MainScheduler.asyncInstance)
|
||||
.bind(to: rootView.joinedTableView.rx.items(dataSource: joinedDataSource))
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
|
@ -69,13 +106,13 @@ final class GroupViewController: BaseViewController {
|
|||
private func reactiveAction() {
|
||||
rootView.createGroupBtn.rx.tapGesture
|
||||
.subscribe(onNext: { _ in
|
||||
// TODO: 创建圈子
|
||||
AppRouter.push(Route.createGroup)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
rootView.joinGroupBtn.rx.tapGesture
|
||||
.subscribe(onNext: { _ in
|
||||
// TODO: 加入圈子
|
||||
AppRouter.push(Route.joinGroup)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
|
|
@ -86,6 +123,22 @@ final class GroupViewController: BaseViewController {
|
|||
rootView.joinedTabLabel.rx.tapGesture
|
||||
.subscribe(onNext: { [weak self] _ in self?.switchToSegment(1) })
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
NotificationCenter.default.rx.notification(.RefreshGroupInfoNotification)
|
||||
.subscribe(onNext: { [weak self] _ in
|
||||
self?.requestIMGroups()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
Observable.merge(
|
||||
rootView.createdTableView.rx.modelSelected(GroupCellData.self).asObservable(),
|
||||
rootView.joinedTableView.rx.modelSelected(GroupCellData.self).asObservable()
|
||||
)
|
||||
.subscribe(onNext: { data in
|
||||
guard let groupId = data.groupInfo.groupID else { return }
|
||||
AppRouter.push(Route.groupChat, userInfo: ["groupId": groupId])
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func switchToSegment(_ index: Int) {
|
||||
|
|
@ -94,9 +147,10 @@ final class GroupViewController: BaseViewController {
|
|||
rootView.segmentScrollView.setContentOffset(offset, animated: false)
|
||||
}
|
||||
|
||||
// MARK: - 内层 tableView 滚动 → 转发给 GroupView 处理吸顶脱离
|
||||
// MARK: - 内层 tableView 滚动
|
||||
private func observeTableViews() {
|
||||
rootView.createdTableView.rx.didScroll
|
||||
.observe(on: MainScheduler.asyncInstance)
|
||||
.subscribe(onNext: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.rootView.handleTableViewScroll(self.rootView.createdTableView)
|
||||
|
|
@ -104,10 +158,50 @@ final class GroupViewController: BaseViewController {
|
|||
.disposed(by: disposeBag)
|
||||
|
||||
rootView.joinedTableView.rx.didScroll
|
||||
.observe(on: MainScheduler.asyncInstance)
|
||||
.subscribe(onNext: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.rootView.handleTableViewScroll(self.rootView.joinedTableView)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - dataSource
|
||||
private lazy var hotGroupDataSource: RxCollectionViewSectionedReloadDataSource<HotGroupListSectionModel> = {
|
||||
RxCollectionViewSectionedReloadDataSource<HotGroupListSectionModel> { datasource, collectionView, indexPath, model in
|
||||
let cell: HotGroupCell = collectionView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
}
|
||||
}()
|
||||
|
||||
private lazy var createdDataSource: RxTableViewSectionedReloadDataSource<CircleListSectionModel> = {
|
||||
RxTableViewSectionedReloadDataSource<CircleListSectionModel> { _, tableView, indexPath, model in
|
||||
let cell: CircleGroupCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
}
|
||||
}()
|
||||
|
||||
private lazy var joinedDataSource: RxTableViewSectionedReloadDataSource<CircleListSectionModel> = {
|
||||
RxTableViewSectionedReloadDataSource<CircleListSectionModel> { _, tableView, indexPath, model in
|
||||
let cell: CircleGroupCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
}
|
||||
}()
|
||||
|
||||
// MARK: - API
|
||||
private func requestRecommandGroup() {
|
||||
GroupService.recommand(count: 5).subscribe(onNext: { response in
|
||||
self.viewModel.loadHotGroupData(response.list)
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func requestGroupInfo() {
|
||||
GroupService.groupInfo().subscribe { response in
|
||||
guard let model = response.model else { return }
|
||||
self.viewModel.groupList = model.groups
|
||||
}.disposed(by: disposeBag)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,36 +7,23 @@ import Foundation
|
|||
import RxSwift
|
||||
import RxCocoa
|
||||
import RxDataSources
|
||||
import OpenIMSDK
|
||||
|
||||
typealias CircleListSectionModel = SectionModel<String, CircleGroupItem>
|
||||
typealias HotGroupListSectionModel = SectionModel<String, GroupInfoModel>
|
||||
typealias CircleListSectionModel = SectionModel<String, GroupCellData>
|
||||
|
||||
// MARK: - Models
|
||||
|
||||
/// 热门酷圈
|
||||
struct HotGroupItem {
|
||||
let id: String
|
||||
let name: String
|
||||
let icon: String
|
||||
let memberCount: Int
|
||||
let onlineCount: Int
|
||||
/// 群聊 cell 数据(融合群信息 + 会话信息)
|
||||
struct GroupCellData {
|
||||
let groupInfo: OIMGroupInfo
|
||||
let unreadCount: Int
|
||||
let lastMsgTime: Int // ms timestamp
|
||||
let localIcon: UIImage
|
||||
}
|
||||
|
||||
/// 圈子
|
||||
struct CircleGroupItem {
|
||||
let id: String
|
||||
let name: String
|
||||
let icon: String
|
||||
let memberCount: Int
|
||||
let onlineCount: Int
|
||||
let address: String
|
||||
}
|
||||
|
||||
// MARK: - ViewModel
|
||||
|
||||
final class GroupViewModel {
|
||||
|
||||
struct Output {
|
||||
let hotGroups: Driver<[HotGroupItem]>
|
||||
let hotGroups: Observable<[HotGroupListSectionModel]>
|
||||
let createdSections: Observable<[CircleListSectionModel]>
|
||||
let joinedSections: Observable<[CircleListSectionModel]>
|
||||
let segmentTitles: Driver<[String]>
|
||||
|
|
@ -44,54 +31,82 @@ final class GroupViewModel {
|
|||
|
||||
let output: Output
|
||||
|
||||
private let hotGroupsSubject = BehaviorRelay<[HotGroupItem]>(value: [])
|
||||
private let hotGroupSectionedItems = PublishSubject<[HotGroupListSectionModel]>()
|
||||
private let createdSectionsSubject = PublishSubject<[CircleListSectionModel]>()
|
||||
private let joinedSectionsSubject = PublishSubject<[CircleListSectionModel]>()
|
||||
|
||||
let segmentTitles = BehaviorRelay<[String]>(value: ["我创建的圈子", "我加入的圈子"])
|
||||
|
||||
var groupList: [GroupInfoModel] = []
|
||||
|
||||
private var cachedGroups: [OIMGroupInfo] = []
|
||||
private var cachedConversations: [OIMConversationInfo] = []
|
||||
|
||||
/// 当前群的本地图标
|
||||
func getLocalIcon(groupId: String) -> UIImage {
|
||||
groupList.first { groupId == $0.group_key }?.groupIcon ?? UIImage(named: "GroupIcon/1")!
|
||||
}
|
||||
|
||||
/// 热门酷圈
|
||||
func loadHotGroupData(_ list: [GroupInfoModel]) {
|
||||
hotGroupSectionedItems.onNext(list.mapSection())
|
||||
}
|
||||
|
||||
/// 加载群列表(全量刷新)
|
||||
func loadIMGroups(_ groups: [OIMGroupInfo], conversations: [OIMConversationInfo] = []) {
|
||||
if !groups.isEmpty { cachedGroups = groups }
|
||||
if !conversations.isEmpty { cachedConversations = conversations }
|
||||
reloadData()
|
||||
}
|
||||
|
||||
/// 仅更新会话元数据(未读、时间)- 消息监听回调(只返回变更的会话,需合并)
|
||||
func updateConversations(_ conversations: [OIMConversationInfo]) {
|
||||
var merged: [String: OIMConversationInfo] = [:]
|
||||
for c in cachedConversations { if let gid = c.groupID { merged[gid] = c } }
|
||||
for c in conversations { if let gid = c.groupID { merged[gid] = c } }
|
||||
cachedConversations = Array(merged.values)
|
||||
reloadData()
|
||||
}
|
||||
|
||||
private func reloadData() {
|
||||
let currentUserId = AppContextManager.shared.userId
|
||||
let convMap: [String: OIMConversationInfo] = {
|
||||
var m: [String: OIMConversationInfo] = [:]
|
||||
for c in cachedConversations where c.groupID != nil && !(c.groupID?.isEmpty ?? true) {
|
||||
m[c.groupID!] = c
|
||||
}
|
||||
return m
|
||||
}()
|
||||
|
||||
var created: [GroupCellData] = []
|
||||
var joined: [GroupCellData] = []
|
||||
|
||||
for g in cachedGroups {
|
||||
let conv = convMap[g.groupID ?? ""]
|
||||
let data = GroupCellData(
|
||||
groupInfo: g,
|
||||
unreadCount: Int(conv?.unreadCount ?? 0),
|
||||
lastMsgTime: Int(conv?.latestMsgSendTime ?? 0),
|
||||
localIcon: getLocalIcon(groupId: g.groupID ?? "")
|
||||
)
|
||||
if g.ownerUserID == currentUserId || g.creatorUserID == currentUserId {
|
||||
created.append(data)
|
||||
} else {
|
||||
joined.append(data)
|
||||
}
|
||||
}
|
||||
|
||||
createdSectionsSubject.onNext(created.mapSection())
|
||||
joinedSectionsSubject.onNext(joined.mapSection())
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
init() {
|
||||
output = Output(
|
||||
hotGroups: hotGroupsSubject.asDriver(),
|
||||
hotGroups: hotGroupSectionedItems.asObservable(),
|
||||
createdSections: createdSectionsSubject.asObservable(),
|
||||
joinedSections: joinedSectionsSubject.asObservable(),
|
||||
segmentTitles: segmentTitles.asDriver()
|
||||
)
|
||||
}
|
||||
|
||||
func loadMockData() {
|
||||
hotGroupsSubject.accept([
|
||||
HotGroupItem(id: "h1", name: "户外探险队", icon: "map_avatar_1", memberCount: 128, onlineCount: 32),
|
||||
HotGroupItem(id: "h2", name: "城市慢跑团", icon: "map_avatar_2", memberCount: 256, onlineCount: 45),
|
||||
HotGroupItem(id: "h3", name: "骑行爱好者", icon: "map_avatar_3", memberCount: 89, onlineCount: 12),
|
||||
HotGroupItem(id: "h4", name: "登山俱乐部", icon: "map_avatar_4", memberCount: 342, onlineCount: 67),
|
||||
HotGroupItem(id: "h5", name: "摄影交流圈", icon: "map_avatar_5", memberCount: 156, onlineCount: 28)
|
||||
])
|
||||
|
||||
let createdItems = [
|
||||
CircleGroupItem(id: "c1", name: "户外探险队", icon: "map_avatar_1", memberCount: 128, onlineCount: 32, address: "重庆市渝北区"),
|
||||
CircleGroupItem(id: "c2", name: "周末徒步小组", icon: "map_avatar_2", memberCount: 45, onlineCount: 8, address: "重庆市江北区"),
|
||||
CircleGroupItem(id: "c3", name: "夜跑小分队", icon: "map_avatar_3", memberCount: 67, onlineCount: 15, address: "重庆市南岸区"),
|
||||
CircleGroupItem(id: "c4", name: "钓鱼爱好者", icon: "map_avatar_4", memberCount: 32, onlineCount: 6, address: "重庆市北碚区"),
|
||||
CircleGroupItem(id: "c5", name: "美食探店团", icon: "map_avatar_5", memberCount: 89, onlineCount: 23, address: "重庆市渝中区"),
|
||||
CircleGroupItem(id: "c6", name: "桌游俱乐部", icon: "map_avatar_1", memberCount: 56, onlineCount: 18, address: "重庆市沙坪坝区"),
|
||||
CircleGroupItem(id: "c7", name: "电影交流群", icon: "map_avatar_2", memberCount: 112, onlineCount: 34, address: "重庆市九龙坡区")
|
||||
]
|
||||
createdSectionsSubject.onNext([SectionModel(model: "created", items: createdItems)])
|
||||
|
||||
let joinedItems = [
|
||||
CircleGroupItem(id: "j1", name: "城市慢跑团", icon: "map_avatar_2", memberCount: 256, onlineCount: 45, address: "重庆市两江新区"),
|
||||
CircleGroupItem(id: "j2", name: "骑行爱好者", icon: "map_avatar_3", memberCount: 89, onlineCount: 12, address: "重庆市沙坪坝区"),
|
||||
CircleGroupItem(id: "j3", name: "登山俱乐部", icon: "map_avatar_4", memberCount: 342, onlineCount: 67, address: "重庆市九龙坡区"),
|
||||
CircleGroupItem(id: "j4", name: "摄影交流圈", icon: "map_avatar_5", memberCount: 156, onlineCount: 28, address: "重庆市大渡口区"),
|
||||
CircleGroupItem(id: "j5", name: "羽毛球爱好者", icon: "map_avatar_1", memberCount: 98, onlineCount: 22, address: "重庆市巴南区"),
|
||||
CircleGroupItem(id: "j6", name: "宠物家长群", icon: "map_avatar_2", memberCount: 67, onlineCount: 15, address: "重庆市渝北区"),
|
||||
CircleGroupItem(id: "j7", name: "读书分享会", icon: "map_avatar_3", memberCount: 45, onlineCount: 11, address: "重庆市江北区"),
|
||||
CircleGroupItem(id: "j8", name: "电竞战队", icon: "map_avatar_4", memberCount: 134, onlineCount: 42, address: "重庆市南岸区"),
|
||||
CircleGroupItem(id: "j9", name: "手工DIY圈", icon: "map_avatar_5", memberCount: 78, onlineCount: 19, address: "重庆市渝中区"),
|
||||
CircleGroupItem(id: "j10", name: "瑜伽冥想群", icon: "map_avatar_1", memberCount: 56, onlineCount: 24, address: "重庆市巴南区")
|
||||
]
|
||||
joinedSectionsSubject.onNext([SectionModel(model: "joined", items: joinedItems)])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 424 KiB |
|
|
@ -17,6 +17,9 @@ class GroupListPopView: UIView {
|
|||
groupNameLab.text = model.groups.first(where: { $0.group_key == model.default_group_key })?.name ?? ""
|
||||
defaultGroupKey = model.default_group_key
|
||||
groupList = model.groups
|
||||
|
||||
let viewHeight = CGFloat(model.groups.count * 68)
|
||||
tableView.layoutChain.height(viewHeight, relation: .greaterThanOrEqual)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,8 +228,7 @@ extension GroupListPopView {
|
|||
GroupListPopView.shared.bgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
|
||||
superView.addSubview(GroupListPopView.shared)
|
||||
superView.bringSubviewToFront(GroupListPopView.shared)
|
||||
let viewHeight = CGFloat(GroupListPopView.shared.groupList.count * 68) + 10 + 81
|
||||
GroupListPopView.shared.tableView.dl.height = viewHeight
|
||||
|
||||
GroupListPopView.shared.infoView.alpha = 0
|
||||
GroupListPopView.shared.completion = { (text) in
|
||||
completion(text)
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class HomeViewModel {
|
|||
func loadGroupMemberList(_ list: [GroupMemberModel]) {
|
||||
// 调整圈子成为位置 圈主 -> 本人 -> 成员
|
||||
var tempList = list
|
||||
tempList.moveToFirst { $0.user_id == AppContextManager.shared.userId }
|
||||
tempList.moveToFirst { isGroupOwn(id: $0.user_id) }
|
||||
sectionedItems.onNext(tempList.mapSection())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ class LaunchViewController: BaseViewController {
|
|||
/// 获取用户配置
|
||||
func getUserConfig() {
|
||||
SystemService.userConfig().subscribe(onNext: { response in
|
||||
self.getUserIMToken()
|
||||
guard let model = response.model else { return }
|
||||
AppContextManager.shared.systemConfig = model.config
|
||||
// 保存用户数据
|
||||
AppContextManager.shared.saveAccount(model)
|
||||
}, onError: { [weak self] (error) in
|
||||
|
|
@ -77,6 +79,14 @@ class LaunchViewController: BaseViewController {
|
|||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
/// 获取用户IM Token
|
||||
func getUserIMToken() {
|
||||
UserService.imToken().subscribe(onNext: { response in
|
||||
guard let data = response.data, let token = data["token"] as? String else { return }
|
||||
AppContextManager.shared.imToken = token
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
|
|
|||
|
|
@ -58,14 +58,17 @@ class ScanVC: BaseViewController {
|
|||
captureSession.stopRunning()
|
||||
rootView.scanLineView.alpha = 0
|
||||
rootView.scanLineView.layer.removeAllAnimations()
|
||||
requestOperateGroup(code: text)
|
||||
requestJoinGroup(code: text)
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestOperateGroup(code: String) {
|
||||
private func requestJoinGroup(code: String) {
|
||||
DLToast.showLoading()
|
||||
GroupService.operate(opType: "join", requestData: ["share_code" : code]).subscribe(onNext: { response in
|
||||
|
||||
DLToast.show(text: "加入成功") {
|
||||
NotificationCenter.default.post(name: .RefreshGroupInfoNotification, object: nil)
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}
|
||||
}, onError: { [weak self] (error) in
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
||||
self?.isScanning = false
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class VipRechargeVC: BaseViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
fd_interactivePopDisabled = true
|
||||
bindViewModel()
|
||||
reactiveAction()
|
||||
requestRechargeInfo()
|
||||
|
|
@ -32,6 +33,22 @@ class VipRechargeVC: BaseViewController {
|
|||
viewModel.output.sectionedItems
|
||||
.bind(to: rootView.expenseCollectionView.rx.items(dataSource: dataSource))
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
viewModel.output.vipRightItems
|
||||
.bind(to: rootView.vipRightsCollectionView.rx.items(dataSource: vipRightsDataSource))
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
viewModel.createCount.asObservable()
|
||||
.bind(to: rootView.createCountLab.rx.text)
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
viewModel.groupCount.asObservable()
|
||||
.bind(to: rootView.groupCountLab.rx.text)
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
viewModel.joinCount.asObservable()
|
||||
.bind(to: rootView.joinCountLab.rx.text)
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func reactiveAction() {
|
||||
|
|
@ -43,7 +60,6 @@ class VipRechargeVC: BaseViewController {
|
|||
self.rootView.setupPayTypes(model.pay_type)
|
||||
self.rootView.animatePrice(to: model.price)
|
||||
self.rootView.discountLab.text = self.viewModel.discountPriceString
|
||||
self.viewModel.refreshData()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
|
@ -56,6 +72,14 @@ class VipRechargeVC: BaseViewController {
|
|||
return cell
|
||||
}
|
||||
}()
|
||||
|
||||
private lazy var vipRightsDataSource: RxCollectionViewSectionedReloadDataSource<VipRightsListSectionModel> = {
|
||||
RxCollectionViewSectionedReloadDataSource<VipRightsListSectionModel> { datasource, collectionView, indexPath, model in
|
||||
let cell: VipRightsCell = collectionView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(model)
|
||||
return cell
|
||||
}
|
||||
}()
|
||||
|
||||
// MARK: - API
|
||||
private func requestRechargeInfo() {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import RxDataSources
|
|||
import SwiftyUserDefaults
|
||||
|
||||
typealias ExpenseListSectionModel = SectionModel<String, VipExpenseModel>
|
||||
typealias VipRightsListSectionModel = SectionModel<String, VipRightsModel>
|
||||
|
||||
class VipRechargeVM {
|
||||
struct Input {
|
||||
|
|
@ -18,15 +19,37 @@ class VipRechargeVM {
|
|||
}
|
||||
struct Output {
|
||||
var sectionedItems: Observable<[ExpenseListSectionModel]>
|
||||
var vipRightItems: Observable<[VipRightsListSectionModel]>
|
||||
}
|
||||
|
||||
let input: Input
|
||||
let output: Output
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
private let sectionedItems = PublishSubject<[ExpenseListSectionModel]>()
|
||||
var createCount = BehaviorRelay<String>(value: "0")
|
||||
var groupCount = BehaviorRelay<String>(value: "0")
|
||||
var joinCount = BehaviorRelay<String>(value: "0")
|
||||
|
||||
var selectedIndex: Int = -1
|
||||
private let sectionedItems = PublishSubject<[ExpenseListSectionModel]>()
|
||||
private let vipRightsItems = PublishSubject<[VipRightsListSectionModel]>()
|
||||
|
||||
private let vipRightsList: [VipRightsModel] = [
|
||||
VipRightsModel(icon: "VipRecharge/location", title: "定位查询"),
|
||||
VipRightsModel(icon: "VipRecharge/map", title: "地图样式"),
|
||||
VipRightsModel(icon: "VipRecharge/sos", title: "SOS求救"),
|
||||
VipRightsModel(icon: "VipRecharge/bubble", title: "创建气泡"),
|
||||
VipRightsModel(icon: "VipRecharge/ad", title: "无广告"),
|
||||
VipRightsModel(icon: "VipRecharge/battery", title: "电池电量"),
|
||||
VipRightsModel(icon: "VipRecharge/emoji", title: "趣味表情"),
|
||||
VipRightsModel(icon: "VipRecharge/service", title: "专属客服")
|
||||
]
|
||||
|
||||
var selectedIndex: Int = -1 {
|
||||
didSet {
|
||||
refreshData()
|
||||
loadVipRightsData()
|
||||
}
|
||||
}
|
||||
var list: [VipExpenseModel] = []
|
||||
var payType: String {
|
||||
guard list.count > 0 else { return "" }
|
||||
|
|
@ -62,11 +85,45 @@ class VipRechargeVM {
|
|||
sectionedItems.onNext(list.mapSection())
|
||||
}
|
||||
|
||||
func loadVipRightsData() {
|
||||
// 20040(没有专属客服): 5 10 5 20041: 10 20 10 20042: 15 30 15
|
||||
let model = list[selectedIndex]
|
||||
var tmpList = vipRightsList
|
||||
|
||||
switch model.goods_id {
|
||||
case "20040":
|
||||
createCount.accept("5")
|
||||
groupCount.accept("10")
|
||||
joinCount.accept("5")
|
||||
let _ = tmpList.popLast()
|
||||
case "20041":
|
||||
createCount.accept("10")
|
||||
groupCount.accept("20")
|
||||
joinCount.accept("10")
|
||||
case "20042":
|
||||
createCount.accept("15")
|
||||
groupCount.accept("30")
|
||||
joinCount.accept("15")
|
||||
default:
|
||||
createCount.accept("5")
|
||||
groupCount.accept("10")
|
||||
joinCount.accept("5")
|
||||
}
|
||||
|
||||
vipRightsItems.onNext(tmpList.mapSection())
|
||||
}
|
||||
|
||||
// MARK: - init
|
||||
init() {
|
||||
input = Input()
|
||||
output = Output(
|
||||
sectionedItems: sectionedItems.asObservable()
|
||||
sectionedItems: sectionedItems.asObservable(),
|
||||
vipRightItems: vipRightsItems.asObservable()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct VipRightsModel {
|
||||
var icon: String
|
||||
var title: String
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,15 @@ class VipRechargeView: UIView {
|
|||
|
||||
private func setupRx() {
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
VipWaivePopView.show()
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
agreementLab.rx.tapGesture.subscribe { _ in
|
||||
// TODO: 打开会员服务协议
|
||||
AppRouter.push(Route.web, userInfo: ["url": URLManager.shared.userAgreementUrl])
|
||||
}.disposed(by: disposeBag)
|
||||
|
||||
vipRightsDetailView.rx.tapGesture.subscribe { _ in
|
||||
AppRouter.push(Route.vipRights)
|
||||
}.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +31,7 @@ class VipRechargeView: UIView {
|
|||
addSubview(scrollView)
|
||||
scrollView.addSubview(scrollContentView)
|
||||
scrollContentView.addSubview(headerBgImgView)
|
||||
scrollContentView.addSubview(vipRightsDetailView)
|
||||
scrollContentView.addSubview(cornerView)
|
||||
scrollContentView.addSubview(expenseCollectionView)
|
||||
scrollContentView.addSubview(vipRightsView)
|
||||
|
|
@ -34,6 +39,8 @@ class VipRechargeView: UIView {
|
|||
scrollContentView.addSubview(tipsLab)
|
||||
|
||||
vipRightsView.addSubview(vipRightsTitleView)
|
||||
vipRightsView.addSubview(groupCountView)
|
||||
vipRightsView.addSubview(vipRightsCollectionView)
|
||||
|
||||
addSubview(bottomView)
|
||||
bottomView.addSubview(payTypeStackView)
|
||||
|
|
@ -93,6 +100,11 @@ class VipRechargeView: UIView {
|
|||
// .edges(excludingEdge: .bottom)
|
||||
.heightToWidth(267/375)
|
||||
|
||||
vipRightsDetailView.layoutChain
|
||||
.top(36)
|
||||
.right()
|
||||
.height(24)
|
||||
|
||||
cornerView.layoutChain
|
||||
.topToBottomOfView(headerBgImgView, offset: -20)
|
||||
.edges(excludingEdge: .top)
|
||||
|
|
@ -106,12 +118,21 @@ class VipRechargeView: UIView {
|
|||
vipRightsView.layoutChain
|
||||
.topToBottomOfView(expenseCollectionView, offset: 18)
|
||||
.edgesHorzontal(16)
|
||||
.height(302)
|
||||
|
||||
vipRightsTitleView.layoutChain
|
||||
.top(14)
|
||||
.centerX()
|
||||
|
||||
groupCountView.layoutChain
|
||||
.topToBottomOfView(vipRightsTitleView, offset: 9)
|
||||
.edgesHorzontal()
|
||||
|
||||
vipRightsCollectionView.layoutChain
|
||||
.topToBottomOfView(groupCountView, offset: 14)
|
||||
.edgesHorzontal()
|
||||
.bottom(14)
|
||||
.height(150)
|
||||
|
||||
agreementLab.layoutChain
|
||||
.topToBottomOfView(vipRightsView, offset: 6)
|
||||
.leftToView(vipRightsView)
|
||||
|
|
@ -143,7 +164,7 @@ class VipRechargeView: UIView {
|
|||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 15, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
|
|
@ -168,6 +189,23 @@ class VipRechargeView: UIView {
|
|||
return view
|
||||
}()
|
||||
|
||||
lazy var vipRightsDetailView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#FFFFFF", alpha: 0.7)
|
||||
|
||||
let label = UILabel()
|
||||
label.text = "权益对比"
|
||||
label.font = .systemFont(ofSize: 11, weight: .bold)
|
||||
label.textColor = UIColor(hexStr: "#224E92")
|
||||
|
||||
view.addSubview(label)
|
||||
label.layoutChain
|
||||
.edgesVertical(4)
|
||||
.edgesHorzontal(8)
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var cornerView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#F5FBFB")
|
||||
|
|
@ -292,27 +330,198 @@ class VipRechargeView: UIView {
|
|||
|
||||
createBgImg.layoutChain
|
||||
.top(8)
|
||||
.edges(excludingEdge: .top)
|
||||
|
||||
createCountLab.layoutChain
|
||||
.topToBottomOfView(createIcon)
|
||||
.topToBottomOfView(createIcon, offset: 2)
|
||||
.centerX()
|
||||
|
||||
createUnitLab.layoutChain
|
||||
.leftToRightOfView(createCountLab)
|
||||
.bottomToView(createCountLab, offset: 0)
|
||||
|
||||
createTitleLab.layoutChain
|
||||
.centerX()
|
||||
.bottom(4)
|
||||
|
||||
// 分隔线
|
||||
let separator1 = UIImageView(image: UIImage(named: "VipRecharge/separator"))
|
||||
|
||||
// 圈子人数
|
||||
let groupCountView = UIView()
|
||||
groupCountView.backgroundColor = .clear
|
||||
|
||||
let groupCountIcon = UIImageView(image: UIImage(named: "VipRecharge/member_count"))
|
||||
|
||||
let groupCountBgImg = UIImageView(image: UIImage(named: "VipRecharge/count_bg"))
|
||||
|
||||
let groupCountUnitLab = UILabel()
|
||||
groupCountUnitLab.text = "个"
|
||||
groupCountUnitLab.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
groupCountUnitLab.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
|
||||
let groupCountTitleLab = UILabel()
|
||||
groupCountTitleLab.text = "圈子人数"
|
||||
groupCountTitleLab.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
groupCountTitleLab.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
|
||||
groupCountView.addSubview(groupCountIcon)
|
||||
groupCountView.addSubview(groupCountBgImg)
|
||||
groupCountView.addSubview(groupCountUnitLab)
|
||||
groupCountView.addSubview(groupCountTitleLab)
|
||||
groupCountView.addSubview(groupCountLab)
|
||||
|
||||
groupCountIcon.layoutChain
|
||||
.top()
|
||||
.centerX()
|
||||
.width(34).height(34)
|
||||
|
||||
groupCountBgImg.layoutChain
|
||||
.top(8)
|
||||
.edges(excludingEdge: .top)
|
||||
|
||||
groupCountLab.layoutChain
|
||||
.topToBottomOfView(groupCountIcon, offset: 2)
|
||||
.centerX()
|
||||
|
||||
groupCountUnitLab.layoutChain
|
||||
.leftToRightOfView(groupCountLab)
|
||||
.bottomToView(groupCountLab, offset: 0)
|
||||
|
||||
groupCountTitleLab.layoutChain
|
||||
.centerX()
|
||||
.bottom(4)
|
||||
|
||||
// 分隔线
|
||||
let separator2 = UIImageView(image: UIImage(named: "VipRecharge/separator"))
|
||||
|
||||
// 加入圈子
|
||||
let joinCountView = UIView()
|
||||
joinCountView.backgroundColor = .clear
|
||||
|
||||
let joinCountIcon = UIImageView(image: UIImage(named: "VipRecharge/join_count"))
|
||||
|
||||
let joinCountBgImg = UIImageView(image: UIImage(named: "VipRecharge/count_bg"))
|
||||
|
||||
let joinCountUnitLab = UILabel()
|
||||
joinCountUnitLab.text = "个"
|
||||
joinCountUnitLab.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
joinCountUnitLab.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
|
||||
let joinCountTitleLab = UILabel()
|
||||
joinCountTitleLab.text = "加入圈子"
|
||||
joinCountTitleLab.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
joinCountTitleLab.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
|
||||
joinCountView.addSubview(joinCountIcon)
|
||||
joinCountView.addSubview(joinCountBgImg)
|
||||
joinCountView.addSubview(joinCountUnitLab)
|
||||
joinCountView.addSubview(joinCountTitleLab)
|
||||
joinCountView.addSubview(joinCountLab)
|
||||
|
||||
joinCountIcon.layoutChain
|
||||
.top()
|
||||
.centerX()
|
||||
.width(34).height(34)
|
||||
|
||||
joinCountBgImg.layoutChain
|
||||
.top(8)
|
||||
.edges(excludingEdge: .top)
|
||||
|
||||
joinCountLab.layoutChain
|
||||
.topToBottomOfView(joinCountIcon, offset: 2)
|
||||
.centerX()
|
||||
|
||||
joinCountUnitLab.layoutChain
|
||||
.leftToRightOfView(joinCountLab)
|
||||
.bottomToView(joinCountLab, offset: 0)
|
||||
|
||||
joinCountTitleLab.layoutChain
|
||||
.centerX()
|
||||
.bottom(4)
|
||||
|
||||
view.addSubview(createCountView)
|
||||
view.addSubview(separator1)
|
||||
view.addSubview(groupCountView)
|
||||
view.addSubview(separator2)
|
||||
view.addSubview(joinCountView)
|
||||
|
||||
groupCountView.layoutChain
|
||||
.top()
|
||||
.centerX()
|
||||
.width(69)
|
||||
.height(90)
|
||||
.bottom()
|
||||
|
||||
separator1.layoutChain
|
||||
.rightToLeftOfView(groupCountView, offset: -26)
|
||||
.centerY()
|
||||
.height(85)
|
||||
.width(1)
|
||||
|
||||
createCountView.layoutChain
|
||||
.topToView(groupCountView)
|
||||
.rightToLeftOfView(separator1, offset: -26)
|
||||
.width(69)
|
||||
.height(90)
|
||||
|
||||
separator2.layoutChain
|
||||
.leftToRightOfView(groupCountView, offset: 26)
|
||||
.centerY()
|
||||
.height(85)
|
||||
.width(1)
|
||||
|
||||
joinCountView.layoutChain
|
||||
.topToView(groupCountView)
|
||||
.leftToRightOfView(separator2, offset: 26)
|
||||
.width(69)
|
||||
.height(90)
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var createCountLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "0"
|
||||
label.font = .systemFont(ofSize: 24, weight: .bold)
|
||||
label.textColor = UIColor(hexStr: "#FF4F44")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var groupCountLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "0"
|
||||
label.font = .systemFont(ofSize: 24, weight: .bold)
|
||||
label.textColor = UIColor(hexStr: "#FF4F44")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var joinCountLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "0"
|
||||
label.font = .systemFont(ofSize: 24, weight: .bold)
|
||||
label.textColor = UIColor(hexStr: "#FF4F44")
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var vipRightsCollectionView: UICollectionView = {
|
||||
let layout = UICollectionViewFlowLayout()
|
||||
let spacing: CGFloat = 35
|
||||
let cvWidth = kScreenWidth - 64
|
||||
let itemW = (cvWidth - spacing * 3) / 4
|
||||
layout.itemSize = CGSize(width: itemW, height: 65)
|
||||
layout.sectionInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
|
||||
layout.minimumLineSpacing = 20
|
||||
layout.minimumInteritemSpacing = spacing
|
||||
layout.scrollDirection = .vertical
|
||||
|
||||
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
cv.backgroundColor = .clear
|
||||
cv.showsHorizontalScrollIndicator = false
|
||||
cv.register(VipRightsCell.self)
|
||||
return cv
|
||||
}()
|
||||
|
||||
lazy var agreementLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 10, weight: .medium)
|
||||
|
|
@ -519,6 +728,10 @@ class VipRechargeView: UIView {
|
|||
cornerView.setNeedsLayout()
|
||||
cornerView.layoutIfNeeded()
|
||||
cornerView.setCornerRadius(corners: [.topLeft, .topRight], withCornerRadii: CGSize(width: 10, height: 10))
|
||||
|
||||
vipRightsDetailView.setNeedsLayout()
|
||||
vipRightsDetailView.layoutIfNeeded()
|
||||
vipRightsDetailView.setCornerRadius(corners: [.topLeft, .bottomLeft], withCornerRadii: CGSize(width: 6, height: 6))
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
|
|
@ -531,7 +744,15 @@ class VipRechargeView: UIView {
|
|||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIScrollViewDelegate
|
||||
extension VipRechargeView: UIScrollViewDelegate {
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
let maxY = scrollView.contentOffset.y
|
||||
let alpha = maxY / kNaviHeight
|
||||
navBarView.alpha = alpha < 0.0 ? 0.0 : alpha
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ExpenseCell
|
||||
|
|
@ -675,10 +896,46 @@ final class ExpenseCell: UICollectionViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
extension VipRechargeView: UIScrollViewDelegate {
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
let maxY = scrollView.contentOffset.y
|
||||
let alpha = maxY / kNaviHeight
|
||||
navBarView.alpha = alpha < 0.0 ? 0.0 : alpha
|
||||
// MARK: - ExpenseCell
|
||||
final class VipRightsCell: UICollectionViewCell {
|
||||
|
||||
func configure(_ model: VipRightsModel) {
|
||||
iconView.image = UIImage(named: model.icon)
|
||||
titleLabel.text = model.title
|
||||
}
|
||||
|
||||
private let titleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
private let iconView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
return iv
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
contentView.addSubview(titleLabel)
|
||||
contentView.addSubview(iconView)
|
||||
|
||||
iconView.layoutChain
|
||||
.top().centerX()
|
||||
.width(40)
|
||||
.height(40)
|
||||
|
||||
titleLabel.layoutChain
|
||||
.edgesHorzontal()
|
||||
.bottom()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
//
|
||||
// VipRightsVC.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class VipRightsVC: BaseViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
setupUI()
|
||||
setupRx()
|
||||
}
|
||||
|
||||
private func setupRx() {
|
||||
backBtn.rx.tap.subscribe(onNext: { _ in
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
view.addSubview(bgImgView)
|
||||
view.addSubview(scrollView)
|
||||
view.addSubview(headerBgImg)
|
||||
view.addSubview(scrollView)
|
||||
scrollView.addSubview(scrollContentView)
|
||||
scrollContentView.addSubview(logoImg)
|
||||
scrollContentView.addSubview(detailImg)
|
||||
|
||||
view.addSubview(navBarView)
|
||||
navBarView.addSubview(navTitleLabel)
|
||||
navBarView.addSubview(backBtn)
|
||||
|
||||
navBarView.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(kNaviHeight)
|
||||
|
||||
navTitleLabel.layoutChain
|
||||
.top(kStatusBarHeight + 12)
|
||||
.centerY(backBtn)
|
||||
.centerX()
|
||||
|
||||
backBtn.layoutChain
|
||||
.centerY(navTitleLabel)
|
||||
.left(15)
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
bgImgView.layoutChain.edges()
|
||||
|
||||
headerBgImg.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.heightToWidth(233/375)
|
||||
|
||||
scrollView.layoutChain
|
||||
.topToBottomOfView(navBarView)
|
||||
.edges(excludingEdge: .top)
|
||||
|
||||
scrollContentView.layoutChain
|
||||
.edges()
|
||||
.widthToView(scrollView)
|
||||
|
||||
logoImg.layoutChain
|
||||
.top()
|
||||
.left(9)
|
||||
.width(337).height(126)
|
||||
|
||||
detailImg.layoutChain
|
||||
.topToBottomOfView(logoImg, offset: 40)
|
||||
.edgesHorzontal(15)
|
||||
.bottom(kSafeBottomMargin + 34)
|
||||
.heightToWidth(1081/345)
|
||||
}
|
||||
|
||||
lazy var navBarView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "会员权益"
|
||||
label.font = .systemFont(ofSize: 18, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var backBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 15, right: 100)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var bgImgView: UIImageView = {
|
||||
let view = UIImageView(image: UIImage(named: "VipRights/bg"))
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var scrollView: UIScrollView = {
|
||||
let view = UIScrollView()
|
||||
view.backgroundColor = .clear
|
||||
view.showsVerticalScrollIndicator = false
|
||||
view.bounces = false
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var scrollContentView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var headerBgImg: UIImageView = {
|
||||
let view = UIImageView(image: UIImage(named: "VipRights/header_bg"))
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var logoImg: UIImageView = {
|
||||
let view = UIImageView(image: UIImage(named: "VipRights/logo"))
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var detailImg: UIImageView = {
|
||||
let view = UIImageView(image: UIImage(named: "VipRights/detail"))
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
//
|
||||
// VipWaivePopView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/4.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class VipWaivePopView: UIView {
|
||||
|
||||
private static let shared = VipWaivePopView(frame: CGRect(origin: .zero, size: kScreenSize))
|
||||
|
||||
var disposeBag = DisposeBag()
|
||||
|
||||
static func show() {
|
||||
guard let superView = kKeyWindow else {
|
||||
return
|
||||
}
|
||||
|
||||
if VipWaivePopView.shared.superview != nil {
|
||||
VipWaivePopView.shared.removeFromSuperview()
|
||||
VipWaivePopView.shared.bgView.frame = .zero
|
||||
}
|
||||
VipWaivePopView.shared.bgView.alpha = 1
|
||||
VipWaivePopView.shared.bgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
|
||||
superView.addSubview(VipWaivePopView.shared)
|
||||
superView.bringSubviewToFront(VipWaivePopView.shared)
|
||||
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
VipWaivePopView.shared.bgView.alpha = 1
|
||||
}
|
||||
}
|
||||
|
||||
/// 关闭
|
||||
static func dismiss() {
|
||||
guard VipWaivePopView.shared.superview != nil else { return }
|
||||
|
||||
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseIn]) {
|
||||
VipWaivePopView.shared.bgView.alpha = 0
|
||||
} completion: { _ in
|
||||
VipWaivePopView.shared.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
private func setupRx() {
|
||||
confirmBtn.rx.tap.subscribe(onNext: { _ in
|
||||
VipWaivePopView.dismiss()
|
||||
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
closeBtn.rx.tap.subscribe(onNext: { _ in
|
||||
VipWaivePopView.dismiss()
|
||||
AppRouter.shared.popOrDismiss()
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private lazy var bgView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .black.withAlphaComponent(0.5)
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var popView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var bgImgView: UIImageView = {
|
||||
let view = UIImageView()
|
||||
view.image = UIImage(named: "VipRecharge/waive_bg")
|
||||
view.contentMode = .scaleAspectFill
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var confirmBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("确认开通", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
// btn.backgroundColor = UIColor(hexStr: "#00ADFE")
|
||||
// btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
||||
btn.cornerRadius = 25
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var closeBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setTitle("残忍放弃", for: .normal)
|
||||
btn.setTitleColor(UIColor(hexStr: "#00ADFE"), for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
btn.backgroundColor = .white
|
||||
btn.borderWidth = 1
|
||||
btn.borderColor = UIColor(hexStr: "#00ADFE")
|
||||
btn.cornerRadius = 25
|
||||
return btn
|
||||
}()
|
||||
|
||||
// MARK: - Init
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = .clear
|
||||
addSubview(bgView)
|
||||
bgView.addSubview(popView)
|
||||
popView.addSubview(bgImgView)
|
||||
popView.addSubview(confirmBtn)
|
||||
popView.addSubview(closeBtn)
|
||||
|
||||
popView.layoutChain
|
||||
.centerY()
|
||||
.edgesHorzontal(30)
|
||||
.heightToWidth(389/315)
|
||||
|
||||
bgImgView.layoutChain.edges()
|
||||
|
||||
closeBtn.layoutChain
|
||||
.left(18)
|
||||
.bottom(18)
|
||||
.width(100)
|
||||
.height(50)
|
||||
|
||||
confirmBtn.layoutChain
|
||||
.topToView(closeBtn)
|
||||
.leftToRightOfView(closeBtn, offset: 19)
|
||||
.right(18)
|
||||
.height(50)
|
||||
|
||||
setupRx()
|
||||
self.layoutIfNeeded()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
popView.layoutIfNeeded()
|
||||
confirmBtn.setGradientLayer(frame: confirmBtn.bounds,
|
||||
startPoint: CGPoint(x: 0.5, y: 0.5),
|
||||
endPoint: CGPoint(x: 1, y: 0),
|
||||
colors: [UIColor(hexStr: "#00ADFE"), UIColor(hexStr: "#46C8FF")],
|
||||
locations: [0.1, 1])
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// NavigationTitleView.swift
|
||||
// PaiLiBo
|
||||
//
|
||||
// Created by SeanXu on 2019/7/9.
|
||||
// Copyright © 2019 DemoOrg. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SnapKit
|
||||
|
||||
class NavigationTitleView: UIView {
|
||||
let titleLabel = UILabel(frame: .zero)
|
||||
let imageView = UIImageView(frame: .zero)
|
||||
let spacingView = UIView(frame: .zero)
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
return UIView.layoutFittingExpandedSize
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: [titleLabel, imageView])
|
||||
stackView.alignment = .center
|
||||
stackView.spacing = 4.0
|
||||
|
||||
titleLabel.font = UIFont.systemFont(ofSize: 18, weight: .bold)
|
||||
titleLabel.textColor = UIColor.black
|
||||
titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
titleLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||
imageView.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
||||
imageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
|
||||
let contentView = UIView(frame: .zero)
|
||||
addSubview(spacingView)
|
||||
addSubview(contentView)
|
||||
contentView.addSubview(stackView)
|
||||
|
||||
spacingView.snp.makeConstraints { make in
|
||||
make.left.top.bottom.equalToSuperview()
|
||||
make.width.equalTo(0)
|
||||
}
|
||||
contentView.snp.makeConstraints { make in
|
||||
make.left.equalTo(spacingView.snp.right)
|
||||
make.top.bottom.right.equalToSuperview()
|
||||
}
|
||||
stackView.snp.makeConstraints { make in
|
||||
make.left.greaterThanOrEqualToSuperview()
|
||||
make.right.lessThanOrEqualToSuperview()
|
||||
make.top.bottom.equalToSuperview()
|
||||
make.center.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func configure(spacing: CGFloat) {
|
||||
spacingView.snp.updateConstraints { make in
|
||||
make.width.equalTo(spacing)
|
||||
}
|
||||
layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// CRMWebOperations.swift
|
||||
// GXM-CRM
|
||||
//
|
||||
// Created by jsonmess on 2017/12/8.
|
||||
// Copyright © 2017年 DemoOrg. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import WebKit
|
||||
|
||||
class WebOperations {
|
||||
// 拦截规则
|
||||
lazy var allowUrlRules: [String] = {
|
||||
["http", "https"]
|
||||
}()
|
||||
// MARK: 处理和维护Web中拦截的规则
|
||||
/// 检测过滤内部跳转并返回拦截需求
|
||||
func checkAndBlockInternalUrlScheme(request: URLRequest?) -> WKNavigationActionPolicy {
|
||||
if let url = request?.url {
|
||||
if let scheme = url.scheme, !allowUrlRules.contains(scheme) {
|
||||
return .cancel
|
||||
}
|
||||
}
|
||||
return .allow
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,724 @@
|
|||
//
|
||||
// TerminalStatisticsH5ViewController.swift
|
||||
// GXM-CRM
|
||||
//
|
||||
// Created by jsonmess on 2017/11/22.
|
||||
// Copyright © 2017年 DemoOrg. All rights reserved.
|
||||
//
|
||||
|
||||
import SnapKit
|
||||
import UIKit
|
||||
@preconcurrency import WebKit
|
||||
import MJRefresh
|
||||
import SwiftyJSON
|
||||
import Kingfisher
|
||||
import KingfisherWebP
|
||||
internal import Alamofire
|
||||
import SwiftyUserDefaults
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
// 页面加载状态
|
||||
enum LoadingStatus: Int {
|
||||
// 初始状态
|
||||
case initial = 0
|
||||
// 加载中..
|
||||
case inLoading = 1
|
||||
// 加载完成
|
||||
case success = 2
|
||||
// 加载失败
|
||||
case faild = 3
|
||||
}
|
||||
|
||||
enum ScriptMessageName: String, CaseIterable {
|
||||
case updateStatusBarStyle
|
||||
case openPageRouter
|
||||
case openPage
|
||||
case openWebView
|
||||
case buyInquiryItem
|
||||
case openIM
|
||||
case toast
|
||||
case dialog
|
||||
case showBigImage
|
||||
case showCamera
|
||||
case showAlbum
|
||||
case showDatePicker
|
||||
case backConfirm
|
||||
case closeWebView
|
||||
}
|
||||
|
||||
enum WebViewError: Error {
|
||||
case downloadImage
|
||||
}
|
||||
|
||||
extension WebViewError: LocalizedError {
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .downloadImage:
|
||||
return "图片下载失败"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FullscreenWebView: WKWebView {
|
||||
@available(iOS 11.0, *)
|
||||
override var safeAreaInsets: UIEdgeInsets {
|
||||
return .zero
|
||||
}
|
||||
}
|
||||
|
||||
// sourcery: router="web", name="Web页面"
|
||||
@objcMembers class WebViewController: BaseViewController {//}, InitRoutable {
|
||||
|
||||
private static let uniqueProcessPool = WKProcessPool()
|
||||
|
||||
override var isNavigationBarHidden: Bool {
|
||||
// guard let fullscreen = fullscreen, fullscreen else {
|
||||
// return false
|
||||
// }
|
||||
return fullscreen
|
||||
}
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||
guard let style = style, style == "default" else {
|
||||
return .lightContent
|
||||
}
|
||||
return .default
|
||||
}
|
||||
override var isChangeNavigationBarStyle: Bool {
|
||||
guard let style = style, style == "lightContent" else {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// sourcery: parameter
|
||||
private var url: String
|
||||
// sourcery: parameter
|
||||
private var isShare: Bool?
|
||||
// sourcery: parameter
|
||||
private var fullscreen: Bool = false
|
||||
// sourcery: parameter
|
||||
private var style: String?
|
||||
//
|
||||
private var flag: String = ""
|
||||
//
|
||||
private var popConfirmTitle: String = ""
|
||||
private var popConfirmContent: String = ""
|
||||
//
|
||||
private var popType: Int = 0 // 0: 不需要二次确认 1: 返回原生 2: 返回h5上一页
|
||||
|
||||
private var operation = WebOperations()
|
||||
private let commonMessageHandler = CommonMessageHandler()
|
||||
private let commonMessageNames: [ScriptMessageName] = ScriptMessageName.allCases
|
||||
private var webViewImageCache = ImageCache(name: "WebView")
|
||||
|
||||
var webView: WKWebView!
|
||||
private var progressView: UIProgressView!
|
||||
private let downloadImageMaxSize = 1024
|
||||
|
||||
var canGoBack = true
|
||||
var isHome = false
|
||||
var isMounted = false
|
||||
var hasPullRefresh = true
|
||||
var isH5Pay = false
|
||||
|
||||
typealias MessageHandler = (name: String, handler: WKScriptMessageHandler)
|
||||
|
||||
var messageHandlers: [MessageHandler] = []
|
||||
|
||||
init(url: String, isShare: Bool?, fullscreen: Bool?, style: String?) {
|
||||
self.url = url
|
||||
self.isShare = isShare
|
||||
self.fullscreen = fullscreen ?? false
|
||||
self.style = style
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
init(url: String) {
|
||||
self.url = url
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
init(url: String, style: String) {
|
||||
self.url = url
|
||||
self.style = style
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@MainActor deinit {
|
||||
guard webView != nil else { return }
|
||||
let userContentController = webView.configuration.userContentController
|
||||
let messageNames = commonMessageNames.map { $0.rawValue }
|
||||
messageNames.forEach { userContentController.removeScriptMessageHandler(forName: $0) }
|
||||
messageHandlers.forEach { userContentController.removeScriptMessageHandler(forName: $0.name) }
|
||||
webView = nil
|
||||
|
||||
// let dateFrom: NSDate = NSDate.init(timeIntervalSince1970: 0)
|
||||
// let websiteDataTypes = WKWebsiteDataStore.allWebsiteDataTypes()
|
||||
// WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes , modifiedSince: dateFrom as Date) {
|
||||
// print("清空缓存完成")
|
||||
// }
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
fd_interactivePopDisabled = true
|
||||
if style == "default" {
|
||||
// setupLeftBarButtonItem(iconColor: "gray")
|
||||
}
|
||||
// setupErrorView()
|
||||
setupView()
|
||||
addObservers()
|
||||
reload()
|
||||
bindAction()
|
||||
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
// setupNavigationBar(titleColor: style=="default" ? Color.rgb0E0E0E : .white,
|
||||
// barTinColor: style=="default" ? .white : Color.mainColor)
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
// setupNavigationBar(titleColor: .white, barTinColor: Color.mainColor)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
// MTAHybrid.restart(webView)
|
||||
onPageShow()
|
||||
}
|
||||
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
super.viewDidDisappear(animated)
|
||||
// MTAHybrid.stop(webView)
|
||||
}
|
||||
|
||||
@objc func videoDidRotate() {
|
||||
self.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
|
||||
override var prefersStatusBarHidden: Bool {
|
||||
return UIApplication.shared.statusBarOrientation.isLandscape
|
||||
}
|
||||
|
||||
private func setupView() {
|
||||
let configuration = WKWebViewConfiguration()
|
||||
let userContentController = WKUserContentController()
|
||||
|
||||
commonMessageHandler.webViewController = self
|
||||
let messageNames = commonMessageNames.map { $0.rawValue }
|
||||
messageNames.forEach { userContentController.add(commonMessageHandler, name: $0) }
|
||||
messageHandlers.forEach { userContentController.add($0.handler, name: $0.name) }
|
||||
|
||||
configuration.processPool = WebViewController.uniqueProcessPool
|
||||
configuration.userContentController = userContentController
|
||||
configuration.applicationNameForUserAgent = configuration.applicationNameForUserAgent?.appending("/wlwm")
|
||||
// 访问文件路径
|
||||
configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
|
||||
// 配置相册访问权限
|
||||
configuration.allowsInlineMediaPlayback = true
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = .all
|
||||
configuration.allowsPictureInPictureMediaPlayback = true
|
||||
|
||||
let mWebView = FullscreenWebView(frame: CGRect.zero, configuration: configuration)
|
||||
webView = mWebView
|
||||
mWebView.uiDelegate = self
|
||||
mWebView.navigationDelegate = self
|
||||
mWebView.allowsBackForwardNavigationGestures = true
|
||||
// mWebView.customUserAgent = userAgent?.appending("/osell")
|
||||
if #available(iOS 16.4, *) {
|
||||
mWebView.isInspectable = true
|
||||
}
|
||||
view.addSubview(mWebView)
|
||||
// mWebView.snp.makeConstraints { make in
|
||||
// make.edges.equalToSuperview()
|
||||
// }
|
||||
mWebView.layoutChain
|
||||
.top(fullscreen ? 0 : kNaviHeight)
|
||||
.edgesHorzontal()
|
||||
.bottom()
|
||||
// .bottom(kSafeBottomMargin)
|
||||
|
||||
if #available(iOS 11.0, *) {
|
||||
mWebView.scrollView.contentInsetAdjustmentBehavior = .automatic
|
||||
}
|
||||
|
||||
// ProgressView
|
||||
let mProgressView = UIProgressView(frame: CGRect.zero)
|
||||
progressView = mProgressView
|
||||
mProgressView.progress = 0.0
|
||||
mProgressView.progressTintColor = ThemeManager.shared.color.mainColor
|
||||
mProgressView.backgroundColor = UIColor.clear
|
||||
mProgressView.trackTintColor = UIColor.clear
|
||||
view.addSubview(mProgressView)
|
||||
mProgressView.snp.makeConstraints { maker in
|
||||
maker.trailing.leading.equalToSuperview()
|
||||
maker.top.equalToSuperview()
|
||||
maker.height.equalTo(2.0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 创建空白页
|
||||
private func setupErrorView() {
|
||||
let errorImage = UIImage(named: "EmptyDataSet/network_error")
|
||||
let errorStatusImageView = UIImageView(image: errorImage)
|
||||
errorStatusImageView.contentMode = .scaleAspectFit
|
||||
view.addSubview(errorStatusImageView)
|
||||
|
||||
let errorStatusLabel = UILabel()
|
||||
errorStatusLabel.text = "oapp_NetworkFailed".localizedString
|
||||
errorStatusLabel.font = UIFont.systemFont(ofSize: 13, weight: .medium)
|
||||
// errorStatusLabel.textColor = UIColor.themeTC4
|
||||
view.addSubview(errorStatusLabel)
|
||||
|
||||
let refreshBtn = UIButton(type: .custom)
|
||||
refreshBtn.setImage(UIImage(named: "EmptyDataSet/empty_reload"), for: .normal)
|
||||
refreshBtn.addTarget(self, action: #selector(reload), for: .touchUpInside)
|
||||
view.addSubview(refreshBtn)
|
||||
|
||||
// contraints
|
||||
errorStatusImageView.snp.makeConstraints { (maker) in
|
||||
maker.centerX.equalToSuperview()
|
||||
maker.centerY.equalToSuperview().offset(-70.0)
|
||||
}
|
||||
|
||||
errorStatusLabel.snp.makeConstraints { (maker) in
|
||||
maker.top.equalTo(errorStatusImageView.snp.bottom).offset(15.0)
|
||||
maker.centerX.equalToSuperview()
|
||||
}
|
||||
|
||||
refreshBtn.snp.makeConstraints { (maker) in
|
||||
maker.top.equalTo(errorStatusLabel.snp.bottom).offset(39.0)
|
||||
maker.centerX.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - LeftBarButtonItems
|
||||
private func setupLeftBarButtonItem(iconColor: String) {
|
||||
guard !isNavigationBarHidden else { return }
|
||||
|
||||
// let backItem = UIBarButtonItem(image: UIImage(named: "Common/back_\(iconColor)"),
|
||||
// style: .plain,
|
||||
// target: self, action: #selector(leftBackClicked(_:)))
|
||||
// backItem.tintColor = iconColor=="white" ? .white : .black
|
||||
// backItem.tag = 1
|
||||
|
||||
let backBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 19, height: 19))
|
||||
backBtn.setImage(UIImage(named: "Common/back_\(iconColor)"), for: .normal)
|
||||
backBtn.addTarget(self, action: #selector(leftBackClicked(_:)), for: .touchUpInside)
|
||||
backBtn.tintColor = iconColor=="white" ? .white : .black
|
||||
backBtn.tag = 1
|
||||
let backItem = UIBarButtonItem(customView: backBtn)
|
||||
|
||||
let popBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 19, height: 19))
|
||||
popBtn.setImage(UIImage(named: "Common/close_black"), for: .normal)
|
||||
popBtn.addTarget(self, action: #selector(leftBackClicked(_:)), for: .touchUpInside)
|
||||
popBtn.tintColor = iconColor=="white" ? .white : .black
|
||||
popBtn.tag = 2
|
||||
|
||||
let popItem = UIBarButtonItem(customView: popBtn)
|
||||
|
||||
// let popItem = UIBarButtonItem(image: UIImage(named: "Common/close_black"),
|
||||
// style: .plain,
|
||||
// target: self,
|
||||
// action: #selector(leftBackClicked(_:)))
|
||||
// popItem.tintColor = iconColor=="white" ? .white : .black
|
||||
// popItem.tag = 2
|
||||
|
||||
navigationItem.leftBarButtonItems = [backItem, popItem]
|
||||
}
|
||||
|
||||
override func leftBackClicked(_ item: UIBarButtonItem) {
|
||||
if canGoBack {
|
||||
// 1.如果有缓存页,则加载上一页
|
||||
if webView.canGoBack {
|
||||
webView.goBack()
|
||||
} else {
|
||||
// 2.否则关闭
|
||||
if isPresented {
|
||||
dismiss(animated: true, completion: nil)
|
||||
} else {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if isH5Pay {
|
||||
NotificationCenter.default.post(name: Notification.Name("RequestPayStatus"), object: nil)
|
||||
}
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: bindAction
|
||||
private func bindAction() {
|
||||
|
||||
}
|
||||
|
||||
// MARK: Observer
|
||||
private func addObservers() {
|
||||
self.webView.rx.observeWeakly(String.self, "title").subscribe(onNext: { [weak self] (title) in
|
||||
guard let self = self else { return }
|
||||
if self.isHome {
|
||||
self.navTitle = self.webView.title ?? ""
|
||||
} else {
|
||||
self.navTitle = self.webView.title ?? ""//self.webView.title == "物联物美" ? "便民商圈" : self.webView.title ?? ""
|
||||
}
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
self.webView.rx.observeWeakly(Double.self, "estimatedProgress").subscribe(onNext: { [weak self] _ in
|
||||
UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseInOut, animations: {
|
||||
if let progres = self?.webView.estimatedProgress {
|
||||
self?.progressView?.progress = Float(progres)
|
||||
}
|
||||
}, completion: nil)
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// 加载 request
|
||||
func loadRequest(_ loadUrl: URL) {
|
||||
updateShow(status: .initial)
|
||||
var request = URLRequest(url: loadUrl, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 15)
|
||||
webView?.load(request)
|
||||
}
|
||||
|
||||
// 重新加载
|
||||
@objc func reload() {
|
||||
updateShow(status: .initial)
|
||||
// WKWebsiteDataStore.default().removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(),
|
||||
// modifiedSince: Date(timeIntervalSince1970: 0), completionHandler:{
|
||||
// debugPrint("清除web缓存")
|
||||
// })
|
||||
if webView.url != nil {
|
||||
webView.reload()
|
||||
} else if let loadUrl = URL(string: url) {
|
||||
// 重新加载初始页
|
||||
loadRequest(loadUrl)
|
||||
}
|
||||
}
|
||||
|
||||
//UI显示加载 状态机
|
||||
private func updateShow(status: LoadingStatus) {
|
||||
switch status {
|
||||
case .initial:
|
||||
self.webView.isHidden = false
|
||||
self.progressView?.isHidden = false
|
||||
self.progressView?.progress = 0.0
|
||||
case .inLoading:
|
||||
self.webView.isHidden = false
|
||||
self.progressView?.isHidden = false
|
||||
case .success:
|
||||
self.webView.isHidden = false
|
||||
self.progressView?.isHidden = true
|
||||
case .faild:
|
||||
self.webView.isHidden = true
|
||||
self.progressView?.isHidden = true
|
||||
}
|
||||
|
||||
switch status {
|
||||
case .initial:
|
||||
break
|
||||
case .inLoading:
|
||||
break
|
||||
case .success, .faild:
|
||||
if hasPullRefresh {
|
||||
self.webView.scrollView.mj_header?.endRefreshing()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示Toast
|
||||
private func showLoading(body: Any) {
|
||||
guard let config = body as? String,
|
||||
let show = BoolType(rawValue: config) else { return }
|
||||
show.boolValue ? dl.showLoading() : dl.dismiss()
|
||||
}
|
||||
|
||||
// 隐藏键盘
|
||||
private func hideKeyboard() {
|
||||
webView.endEditing(true)
|
||||
}
|
||||
|
||||
// 下拉刷新header
|
||||
// private func enablePullRefresh(body: Any) {
|
||||
// guard let config = body as? String,
|
||||
// let enable = BoolType(rawValue: config) else { return }
|
||||
// if enable.boolValue {
|
||||
// let header = createRefreshHeader()
|
||||
// webView.scrollView.mj_header = header
|
||||
// } else {
|
||||
// webView.scrollView.mj_header = nil
|
||||
// }
|
||||
// }
|
||||
|
||||
// 保存图片
|
||||
// private func saveImage(body: Any) {
|
||||
// ProgressHUD.show(inController: self)
|
||||
// let config = JSON(body)
|
||||
// guard let url = config["image"].url else { return }
|
||||
// let completion: CompletionHandler = { [weak self] (image, _, _, _) in
|
||||
// guard let self = self else { return }
|
||||
// guard let image = image else {
|
||||
// if let callback = config["callback"].string {
|
||||
// self.jsCallback(method: callback, result: false)
|
||||
// }
|
||||
// ProgressHUD.dismiss(forController: self)
|
||||
// return
|
||||
// }
|
||||
// let selector = #selector(self.image(_:didFinishSavingWithError:context:))
|
||||
// if let callback = config["callback"].string {
|
||||
// let pointer = Unmanaged<NSString>.passRetained(callback as NSString).toOpaque()
|
||||
// let context = UnsafeMutableRawPointer(pointer)
|
||||
// UIImageWriteToSavedPhotosAlbum(image, self, selector, context)
|
||||
// } else {
|
||||
// UIImageWriteToSavedPhotosAlbum(image, self, selector, nil)
|
||||
// }
|
||||
// }
|
||||
// KingfisherManager.shared.retrieveImage(with: url,
|
||||
// options: KingfisherManager.shared.defaultOptions,
|
||||
// progressBlock: nil,
|
||||
// completionHandler: completion)
|
||||
// }
|
||||
|
||||
@objc private func image(_ image: UIImage, didFinishSavingWithError error: NSError?, context: UnsafeRawPointer) {
|
||||
if let error = error {
|
||||
error.isShowErrorTips ? DLToast.showError(text: error.localizedDescription) : ()
|
||||
} else {
|
||||
DLToast.showSuccess(text: "oapp_Success".localizedString)
|
||||
}
|
||||
let method = unsafeBitCast(context, to: NSString.self) as String
|
||||
if !method.isEmpty {
|
||||
let result = error == nil
|
||||
jsCallback(method: method, result: result)
|
||||
}
|
||||
Unmanaged<NSString>.fromOpaque(context).release()
|
||||
}
|
||||
|
||||
private func jsCallback(method: String, result: Bool) {
|
||||
let callbackName = method + "(\(result))"
|
||||
self.webView.evaluateJavaScript(callbackName, completionHandler: nil)
|
||||
}
|
||||
|
||||
// MARK: - JS to Native
|
||||
private func jsCallback(method: String, params: String, secondParams: String="") {
|
||||
let callbackName = method + (secondParams.isEmpty ? "(\(params))" : "('\(params)', '\(secondParams)')")
|
||||
webView.evaluateJavaScript(callbackName, completionHandler: nil)
|
||||
}
|
||||
|
||||
// MARK: Native to JS
|
||||
|
||||
// 页面路由
|
||||
func openPageRouter(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let url = body["url"] as? String else { return }
|
||||
AppRouter.push(url)
|
||||
}
|
||||
|
||||
// 页面显示
|
||||
func onPageShow() {
|
||||
webView.evaluateJavaScript("try { window.onPageShow(); } catch (e) {}", completionHandler: nil)
|
||||
}
|
||||
|
||||
// MAKR: - 状态栏样式
|
||||
func updateStatusBarStyle(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let style = body["style"] as? String else { return }
|
||||
self.style = style
|
||||
setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
|
||||
// MARK: - 打开原生页面(无参数)
|
||||
func openPage(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let pageName = body["pageName"] as? String else { return }
|
||||
if let class_VC = NSClassFromString("dinoGo.\(pageName)") as? BaseViewController.Type {
|
||||
let vc = class_VC.init()
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 打开WebView
|
||||
func openWebView(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let url = body["url"] as? String else { return }
|
||||
let vc = WebViewController(url: url, style: "default")
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
|
||||
// MARK: - 弹框提示
|
||||
func dialog(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let title = body["title"] as? String,
|
||||
let message = body["message"] as? String else { return }
|
||||
showAlert(title: title,
|
||||
message: message,
|
||||
cancelText: "")
|
||||
}
|
||||
|
||||
// MARK: - 显示toast
|
||||
func toast(body: Any) {
|
||||
guard let body = body as? [String: Any],
|
||||
let message = body["message"] as? String,
|
||||
let type = body["type"] as? Int else { return }
|
||||
switch type { // 0 纯文字 1 成功 2 失败
|
||||
case 0:
|
||||
DLToast.show(text: message)
|
||||
case 1:
|
||||
DLToast.showSuccess(text: message)
|
||||
case 2:
|
||||
DLToast.showError(text: message)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 返回上一级页面 二次确认
|
||||
func backConfirm(body: Any) {
|
||||
guard let body = body as? [String: Any] else { return }
|
||||
|
||||
if let title = body["title"] as? String {
|
||||
popConfirmTitle = title
|
||||
}
|
||||
|
||||
if let content = body["content"] as? String {
|
||||
popConfirmContent = content
|
||||
}
|
||||
|
||||
if let type = body["type"] as? Int {
|
||||
popType = type
|
||||
} else if let type = body["type"] as? String {
|
||||
popType = type.integer
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 退出webview
|
||||
func closeWebView(body: Any) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
/// MARK: WKNavigationDelegate
|
||||
extension WebViewController: WKNavigationDelegate {
|
||||
|
||||
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
||||
updateShow(status: .inLoading)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
updateShow(status: .success)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
|
||||
updateShow(status: .faild)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
||||
updateShow(status: .faild)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
|
||||
let actionPolicy = self.operation.checkAndBlockInternalUrlScheme(request: navigationAction.request)
|
||||
if let url = navigationAction.request.url {//, actionPolicy == .cancel {
|
||||
// navigator.open(url)
|
||||
print(url.absoluteString)
|
||||
}
|
||||
decisionHandler(actionPolicy)
|
||||
|
||||
// 延迟0.1秒检查返回
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
|
||||
// 设置返回按钮
|
||||
if self.isHome {
|
||||
if webView.canGoBack {
|
||||
// self.setupLeftBarButtonItem(iconColor: "white")
|
||||
} else {
|
||||
// self.navigationItem.leftBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: WKUIDelegate
|
||||
extension WebViewController: WKUIDelegate {
|
||||
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .cancel, handler: { _ in
|
||||
completionHandler()
|
||||
}))
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .default, handler: { _ in
|
||||
completionHandler(true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "取消", style: .cancel, handler: { _ in
|
||||
completionHandler(false)
|
||||
}))
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {
|
||||
let alert = UIAlertController(title: title, message: prompt, preferredStyle: .alert)
|
||||
alert.addTextField { textField in
|
||||
textField.text = defaultText
|
||||
}
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .default, handler: { _ in
|
||||
let inputText = alert.textFields?.first?.text
|
||||
completionHandler(inputText)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "取消", style: .cancel, handler: { _ in
|
||||
completionHandler(nil)
|
||||
}))
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
private class CommonMessageHandler: NSObject, WKScriptMessageHandler {
|
||||
weak var webViewController: WebViewController?
|
||||
|
||||
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||
switch message.name {
|
||||
case "updateStatusBarStyle":
|
||||
webViewController?.updateStatusBarStyle(body: message.body)
|
||||
case "openPageRouter":
|
||||
webViewController?.openPageRouter(body: message.body)
|
||||
case "openPage":
|
||||
webViewController?.openPage(body: message.body)
|
||||
case "dialog":
|
||||
webViewController?.dialog(body: message.body)
|
||||
case "toast":
|
||||
webViewController?.toast(body: message.body)
|
||||
case "backConfirm":
|
||||
webViewController?.backConfirm(body: message.body)
|
||||
case "closeWebView":
|
||||
webViewController?.closeWebView(body: message.body)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: UIDocumentInteractionControllerDelegate
|
||||
extension WebViewController: UIDocumentInteractionControllerDelegate {
|
||||
|
||||
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
|
||||
return self
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -29,4 +29,12 @@ struct GroupService {
|
|||
.map(ResponseModel.self)
|
||||
.asObservable()
|
||||
}
|
||||
|
||||
/// 推荐
|
||||
static func recommand(count: Int) -> Observable<RecommandGroupResponse> {
|
||||
let api = GroupAPI.operate(opType: "recommand", requestData: ["recommand_count": count]).multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(RecommandGroupResponse.self)
|
||||
.asObservable()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ struct UserService {
|
|||
.asObservable()
|
||||
}
|
||||
|
||||
static func imToken() -> Observable<ResponseModel> {
|
||||
let api = UserAPI.imToken.multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(ResponseModel.self)
|
||||
.asObservable()
|
||||
}
|
||||
|
||||
/// 退出登录
|
||||
static func logout() -> Observable<ResponseModel> {
|
||||
let api = UserAPI.logout.multiTarget
|
||||
|
|
|
|||