diff --git a/yinmeng-ios.xcodeproj/project.pbxproj b/yinmeng-ios.xcodeproj/project.pbxproj index 4c1f017..444b986 100644 --- a/yinmeng-ios.xcodeproj/project.pbxproj +++ b/yinmeng-ios.xcodeproj/project.pbxproj @@ -44,6 +44,10 @@ E8D15AB82B8B003C00369467 /* UserInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AB72B8B003C00369467 /* UserInfoVC.swift */; }; E8D15ABC2B8B87BA00369467 /* UserViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15ABB2B8B87BA00369467 /* UserViewModel.swift */; }; E8D15ABF2B8B885700369467 /* UserObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15ABE2B8B885700369467 /* UserObject.swift */; }; + E8D15AC22B8C703C00369467 /* UserFunctionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AC12B8C703C00369467 /* UserFunctionView.swift */; }; + E8D15AC52B8C90D400369467 /* AboutUsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AC42B8C90D400369467 /* AboutUsVC.swift */; }; + E8D15AE82B8CD47100369467 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AE72B8CD47100369467 /* WebViewController.swift */; }; + E8D15AEA2B8CD77800369467 /* H5Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AE92B8CD77800369467 /* H5Utils.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -91,6 +95,10 @@ E8D15AB72B8B003C00369467 /* UserInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfoVC.swift; sourceTree = ""; }; E8D15ABB2B8B87BA00369467 /* UserViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserViewModel.swift; sourceTree = ""; }; E8D15ABE2B8B885700369467 /* UserObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserObject.swift; sourceTree = ""; }; + E8D15AC12B8C703C00369467 /* UserFunctionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserFunctionView.swift; sourceTree = ""; }; + E8D15AC42B8C90D400369467 /* AboutUsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutUsVC.swift; sourceTree = ""; }; + E8D15AE72B8CD47100369467 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = ""; }; + E8D15AE92B8CD77800369467 /* H5Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = H5Utils.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -133,6 +141,7 @@ E86A43A72B85DF7A0084C04D /* Base */ = { isa = PBXGroup; children = ( + E8D15AE62B8CD45D00369467 /* Web */, E8D15A9B2B899DD400369467 /* Request */, E81A7BB02B88628B009E736E /* Hud */, E8EE60802B8858A500D02F6E /* Security */, @@ -221,6 +230,7 @@ children = ( E86A43BE2B8620C40084C04D /* Utils.swift */, E86A43D22B8773C90084C04D /* APPUtils.swift */, + E8D15AE92B8CD77800369467 /* H5Utils.swift */, ); path = Utils; sourceTree = ""; @@ -336,8 +346,9 @@ E8D15AB92B8B004000369467 /* User */ = { isa = PBXGroup; children = ( + E8D15AC32B8C90B100369467 /* VC */, + E8D15AC02B8C700600369467 /* View */, E8D15ABA2B8B87A900369467 /* VM */, - E8D15AB72B8B003C00369467 /* UserInfoVC.swift */, ); path = User; sourceTree = ""; @@ -351,6 +362,31 @@ path = VM; sourceTree = ""; }; + E8D15AC02B8C700600369467 /* View */ = { + isa = PBXGroup; + children = ( + E8D15AC12B8C703C00369467 /* UserFunctionView.swift */, + ); + path = View; + sourceTree = ""; + }; + E8D15AC32B8C90B100369467 /* VC */ = { + isa = PBXGroup; + children = ( + E8D15AB72B8B003C00369467 /* UserInfoVC.swift */, + E8D15AC42B8C90D400369467 /* AboutUsVC.swift */, + ); + path = VC; + sourceTree = ""; + }; + E8D15AE62B8CD45D00369467 /* Web */ = { + isa = PBXGroup; + children = ( + E8D15AE72B8CD47100369467 /* WebViewController.swift */, + ); + path = Web; + sourceTree = ""; + }; E8EE60802B8858A500D02F6E /* Security */ = { isa = PBXGroup; children = ( @@ -484,6 +520,7 @@ E86A43B02B85E11B0084C04D /* BaseNavigationViewController.swift in Sources */, E86A43E82B884C5E0084C04D /* String+.swift in Sources */, E8D15AA32B89B03D00369467 /* Deserialized.swift in Sources */, + E8D15AC22B8C703C00369467 /* UserFunctionView.swift in Sources */, E86A43DA2B877A840084C04D /* AppConfigObject.swift in Sources */, E8D15AA62B89B0C600369467 /* List+.swift in Sources */, E81A7BAE2B885B20009E736E /* Base64.m in Sources */, @@ -492,16 +529,19 @@ E86A43C32B8628AF0084C04D /* BaseTabBarViewController.swift in Sources */, E86A43AA2B85DFA90084C04D /* BaseViewController.swift in Sources */, E884E85F2B6900C500ADE6EE /* AppDelegate.swift in Sources */, + E8D15AEA2B8CD77800369467 /* H5Utils.swift in Sources */, E8D15AAA2B8ACC6B00369467 /* YMNetworkFun.swift in Sources */, E8D15AB82B8B003C00369467 /* UserInfoVC.swift in Sources */, E86A43B82B85F0B80084C04D /* AuthLaunchVC.swift in Sources */, E86A43C82B8743EA0084C04D /* AuthFillDataVC.swift in Sources */, E86A43CD2B874C8E0084C04D /* BaseView.swift in Sources */, + E8D15AE82B8CD47100369467 /* WebViewController.swift in Sources */, E8D15AA12B89AF4F00369467 /* UserTokenObject.swift in Sources */, E8D15AB62B8B002700369467 /* ChatVC.swift in Sources */, E86A43C62B862CC70084C04D /* UIImage+.swift in Sources */, E86A43D32B8773C90084C04D /* APPUtils.swift in Sources */, E86A43CB2B874C6F0084C04D /* AuthPrivacyView.swift in Sources */, + E8D15AC52B8C90D400369467 /* AboutUsVC.swift in Sources */, E8D15ABF2B8B885700369467 /* UserObject.swift in Sources */, E86A43BF2B8620C40084C04D /* Utils.swift in Sources */, E86A43BA2B85F1360084C04D /* AuthLoginVC.swift in Sources */, diff --git a/yinmeng-ios.xcworkspace/xcuserdata/fengshuo.xcuserdatad/UserInterfaceState.xcuserstate b/yinmeng-ios.xcworkspace/xcuserdata/fengshuo.xcuserdatad/UserInterfaceState.xcuserstate index 27502f0..ef88c2e 100644 Binary files a/yinmeng-ios.xcworkspace/xcuserdata/fengshuo.xcuserdatad/UserInterfaceState.xcuserstate and b/yinmeng-ios.xcworkspace/xcuserdata/fengshuo.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/yinmeng-ios/Assets.xcassets/user/Contents.json b/yinmeng-ios/Assets.xcassets/user/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/yinmeng-ios/Assets.xcassets/user/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/Contents.json b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/Contents.json new file mode 100644 index 0000000..05afa69 --- /dev/null +++ b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "about_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "about_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@2x.png b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@2x.png new file mode 100644 index 0000000..2690fe0 Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@2x.png differ diff --git a/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@3x.png b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@3x.png new file mode 100644 index 0000000..95e8918 Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/about_icon.imageset/about_icon@3x.png differ diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/Contents.json b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/Contents.json new file mode 100644 index 0000000..81c756a --- /dev/null +++ b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "user_function_diamond@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "user_function_diamond@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@2x.png b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@2x.png new file mode 100644 index 0000000..bceeb3b Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@2x.png differ diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@3x.png b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@3x.png new file mode 100644 index 0000000..015db9e Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/user_function_diamond.imageset/user_function_diamond@3x.png differ diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/Contents.json b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/Contents.json new file mode 100644 index 0000000..619d126 --- /dev/null +++ b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "user_function_more@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "user_function_more@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@2x.png b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@2x.png new file mode 100644 index 0000000..8a33acd Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@2x.png differ diff --git a/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@3x.png b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@3x.png new file mode 100644 index 0000000..ef65e4e Binary files /dev/null and b/yinmeng-ios/Assets.xcassets/user/user_function_more.imageset/user_function_more@3x.png differ diff --git a/yinmeng-ios/Base/Utils/H5Utils.swift b/yinmeng-ios/Base/Utils/H5Utils.swift new file mode 100644 index 0000000..2796b3b --- /dev/null +++ b/yinmeng-ios/Base/Utils/H5Utils.swift @@ -0,0 +1,13 @@ +// +// H5Utils.swift +// yinmeng-ios +// +// Created by MaiMang on 2024/2/26. +// + +import Foundation + +enum H5Utils:String { + case privacy = "modules/rule/privacy-wap.html" + case logoff = "modules/logout/index.html" +} diff --git a/yinmeng-ios/Base/Utils/Utils.swift b/yinmeng-ios/Base/Utils/Utils.swift index 4f499cf..9856d44 100644 --- a/yinmeng-ios/Base/Utils/Utils.swift +++ b/yinmeng-ios/Base/Utils/Utils.swift @@ -30,3 +30,7 @@ let TabHeight = (49) let DesKey = "1ea53d260ecf11e7b56e00163e046a26" + +let API_URL = "http://beta.api.ymlive.fun" + +let H5_URL = "http://beta.h5.ymlive.fun" diff --git a/yinmeng-ios/Base/ViewController/BaseNavigationViewController.swift b/yinmeng-ios/Base/ViewController/BaseNavigationViewController.swift index b85e92e..887815b 100644 --- a/yinmeng-ios/Base/ViewController/BaseNavigationViewController.swift +++ b/yinmeng-ios/Base/ViewController/BaseNavigationViewController.swift @@ -32,11 +32,11 @@ class BaseNavigationViewController: UINavigationController, UIGestureRecognizerD super.viewDidLoad() navigationBar.isTranslucent = false let mai_font22 = UIFont.systemFont(ofSize: 18, weight: .medium) - let mai_colorone = UIColor.firstText + let mai_colorone = UIColor.white // 去掉导航栏蒙版效果 let mai_titleTextAttributesmang = [NSAttributedString.Key.font:mai_font22,NSAttributedString.Key.foregroundColor:mai_colorone] UINavigationBar.appearance().titleTextAttributes = mai_titleTextAttributesmang - UINavigationBar.appearance().tintColor = UIColor.red + UINavigationBar.appearance().tintColor = UIColor.white UINavigationBar.appearance().backgroundColor = UIColor.viewBackGround UIBarButtonItem.appearance().setTitleTextAttributes(mai_titleTextAttributesmang, for: .normal) @@ -53,7 +53,7 @@ class BaseNavigationViewController: UINavigationController, UIGestureRecognizerD mai_appearance33.backgroundColor = UIColor.viewBackGround mai_appearance33.titleTextAttributes = mai_titleTextAttributesmang navigationBar.standardAppearance = mai_appearance33 - navigationBar.tintColor = UIColor.red + navigationBar.tintColor = UIColor.white UINavigationBar.appearance().scrollEdgeAppearance = navigationBar.standardAppearance } } diff --git a/yinmeng-ios/Base/Web/WebViewController.swift b/yinmeng-ios/Base/Web/WebViewController.swift new file mode 100644 index 0000000..a568ebb --- /dev/null +++ b/yinmeng-ios/Base/Web/WebViewController.swift @@ -0,0 +1,198 @@ +// +// WebViewController.swift +// yinmeng-ios +// +// Created by MaiMang on 2024/2/26. +// + +import UIKit +import WebKit +class WebViewWeakScriptMessage: NSObject, WKScriptMessageHandler { + + private(set) weak var target: WKScriptMessageHandler? + + required init(target: WKScriptMessageHandler?) { + self.target = target + } + + + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { + target?.userContentController(userContentController, didReceive: message) + } + +} + +class WebViewController: BaseViewController { + + typealias OnReceiveMessage = (_ msg: WKScriptMessage) -> Void + + private(set) lazy var webview = makeWebView() + + private(set) var progressView = UIProgressView() + + private lazy var userContentController = WKUserContentController() + + private var callbacks: [String: [OnReceiveMessage]] = [:] + + private(set) weak var navigationDelegate: WKNavigationDelegate? + + private(set) var url: String? + + convenience init( + url: String?, + navigationDelegate: WKNavigationDelegate? = nil + ) { + self.init(nibName: nil, bundle: nil) + self.url = url + if var url = url { + if !url.hasPrefix("http") { + url = "\(H5_URL)/\(url)" + } + self.url = url + } + self.navigationDelegate = navigationDelegate + } + + override func viewDidLoad() { + super.viewDidLoad() + loadSubViews() + loadWebView() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + addObserve() + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + removeObserve() + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + view.bringSubviewToFront(progressView) + } + + private func loadSubViews() { + view.addSubview(webview) + view.addSubview(progressView) + progressView.snp.makeConstraints { make in + make.top.equalTo(view).offset(0) + make.left.right.equalTo(view).offset(0) + make.height.equalTo(1) + } + + webview.snp.makeConstraints { make in + make.top.equalTo(view).offset(1) + make.left.right.bottom.equalTo(view) + } + progressView.trackTintColor = .clear + progressView.transform = .init(scaleX: 1, y: 1.5) + progressView.alpha = 0 + } + + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + if let object = object as? WKWebView, object == webview { + if keyPath == "estimatedProgress" { + progressView.setProgress(Float(webview.estimatedProgress), animated: true) + return + } + } + + if keyPath == "title" { + title = webview.title + return + } + } + + func addObserve() { + //添加KVO,WKWebView有一个属性estimatedProgress,就是当前网页加载的进度,所以监听这个属性 + webview.addObserver(self, forKeyPath: "estimatedProgress", context: nil) + //添加KVO,监听title属性 + webview.addObserver(self, forKeyPath: "title", context: nil) + } + + func removeObserve() { + webview.removeObserver(self, forKeyPath: "estimatedProgress") + webview.removeObserver(self, forKeyPath: "title") + } + + func loadWebView() { + guard let url = url, + let theUrl = URL(string: url), + let _ = theUrl.scheme, + let _ = theUrl.host else { + return + } + + webview.load(URLRequest(url: theUrl)) + } + + func reloadWebViewWithUrl(_ url: String) { + self.url = url + loadWebView() + } + + func makeWebView() -> WKWebView { + let configuration = WKWebViewConfiguration() + configuration.mediaTypesRequiringUserActionForPlayback = .all + configuration.allowsInlineMediaPlayback = true + configuration.allowsPictureInPictureMediaPlayback = true + configuration.selectionGranularity = .character + configuration.userContentController = userContentController + + let preferences = WKPreferences() + if #available(iOS 14, *) { + let webpagePreferences = WKWebpagePreferences() + webpagePreferences.allowsContentJavaScript = true + configuration.defaultWebpagePreferences = webpagePreferences + } else { + preferences.javaScriptEnabled = true + } + preferences.javaScriptCanOpenWindowsAutomatically = true + preferences.minimumFontSize = 10 + configuration.preferences = preferences + let webview = WKWebView(frame: UIScreen.main.bounds, configuration: configuration) + webview.navigationDelegate = self + return webview + } + + func dicValueString(_ dic:[String:Any]) ->String? { + let data = try? JSONSerialization.data(withJSONObject: dic,options: []) + let str = String(data: data!,encoding:String.Encoding.utf8) + return str + } + +} + +extension WebViewController: WKScriptMessageHandler { + + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { + //TODO: 拦截一些h5的事件 + } +} + +extension WebViewController: WKNavigationDelegate { + + func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { + progressView.alpha = 1 + navigationDelegate?.webView?(webview, didStartProvisionalNavigation: navigation) + } + + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + UIView.animate(withDuration: 0.2) { + self.progressView.alpha = 0 + } + navigationDelegate?.webView?(webview, didFinish: navigation) + } + + func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { + UIView.animate(withDuration: 0.2) { + self.progressView.alpha = 0 + } + navigationDelegate?.webView?(webView, didFailProvisionalNavigation: navigation, withError: error) + } +} diff --git a/yinmeng-ios/Extension/Color/Color+.swift b/yinmeng-ios/Extension/Color/Color+.swift index 3558197..52659ec 100644 --- a/yinmeng-ios/Extension/Color/Color+.swift +++ b/yinmeng-ios/Extension/Color/Color+.swift @@ -10,7 +10,7 @@ import Foundation extension UIColor { ///主背景的颜色 - static let viewBackGround = UIColor.red + static let viewBackGround = ThemeColor(hexStr: "#14171B") ///cel的背景颜色 static let cellBackGround = UIColor.yellow ///主文字的颜色 diff --git a/yinmeng-ios/Modules/User/UserInfoVC.swift b/yinmeng-ios/Modules/User/UserInfoVC.swift deleted file mode 100644 index a2f47d5..0000000 --- a/yinmeng-ios/Modules/User/UserInfoVC.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// UserInfoVC.swift -// yinmeng-ios -// -// Created by MaiMang on 2024/2/25. -// - -import UIKit - -class UserInfoVC: BaseViewController { - - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = .lightGray - } - -} diff --git a/yinmeng-ios/Modules/User/VC/AboutUsVC.swift b/yinmeng-ios/Modules/User/VC/AboutUsVC.swift new file mode 100644 index 0000000..bd3e17c --- /dev/null +++ b/yinmeng-ios/Modules/User/VC/AboutUsVC.swift @@ -0,0 +1,129 @@ +// +// AboutUsVC.swift +// yinmeng-ios +// +// Created by MaiMang on 2024/2/26. +// + +import UIKit + +class AboutUsVC: BaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + title = "关于我们" + view.addSubview(sepView) + view.addSubview(logoImgView) + view.addSubview(nickLb) + view.addSubview(versionLb) + view.addSubview(privacyView) + privacyView.addSubview(titleLb) + privacyView.addSubview(detailImgView) + + sepView.snp.makeConstraints { make in + make.left.right.top.equalTo(view).inset(0) + make.height.equalTo(10) + } + + logoImgView.snp.makeConstraints { make in + make.size.equalTo(CGSize(width: 88, height: 88)) + make.centerX.equalTo(view) + make.top.equalTo(view).offset(50) + } + + nickLb.snp.makeConstraints { make in +make.centerX.equalTo(view) + make.top.equalTo(logoImgView.snp.bottom).offset(10) + make.height.equalTo(36) + } + + versionLb.snp.makeConstraints { make in +make.centerX.equalTo(view) + make.top.equalTo(nickLb.snp.bottom).offset(4) + make.height.equalTo(22) + } + + privacyView.snp.makeConstraints { make in +make.left.right.equalTo(view).inset(0) + make.height.equalTo(62) + make.top.equalTo(versionLb.snp.bottom).offset(20) + } + + titleLb.snp.makeConstraints { make in +make.left.equalTo(privacyView).offset(24) + make.centerY.equalTo(privacyView) + } + + detailImgView.snp.makeConstraints { make in +make.size.equalTo(CGSize(width: 14, height: 14)) + make.centerY.equalTo(privacyView) + make.right.equalTo(privacyView).offset(-20) + } + } + + @objc func privacyRecognizer() { + //TODO: 跳转隐私政策的 + let web = WebViewController(url: "yinmeng/\(H5Utils.privacy.rawValue)") + self.navigationController?.pushViewController(web, animated: true) + } + + private lazy var sepView: UIView = { + let view = UIView() + view.backgroundColor = ThemeColor(hexStr: "#5E6175") + return view + }() + + private lazy var logoImgView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "about_icon") + imageView.isUserInteractionEnabled = true + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleAspectFill + return imageView + }() + + private lazy var nickLb: UILabel = { + let label = UILabel() + label.textColor = .white + label.font = UIFont.systemFont(ofSize: 24, weight: .bold) + label.text = "音萌" + return label + }() + + + private lazy var versionLb: UILabel = { + let label = UILabel() + label.textColor = UIColor(white: 1, alpha: 0.8) + label.font = UIFont.systemFont(ofSize: 16, weight: .medium) + label.text = "v\(APPUtils.appVersion)" + return label + }() + + private lazy var privacyView: UIView = { + let view = UIView() + view.backgroundColor = ThemeColor(hexStr: "#5E6175") + let tap = UITapGestureRecognizer(target: self, action: #selector(privacyRecognizer)) + view.addGestureRecognizer(tap) + return view + }() + + private lazy var titleLb: UILabel = { + let label = UILabel() + label.textColor = .white + label.text = "隐私政策协议" + label.font = UIFont.systemFont(ofSize: 16, weight: .medium) + return label + }() + + private lazy var detailImgView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "user_function_more") + imageView.isUserInteractionEnabled = true + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleAspectFill + return imageView + }() + + + +} diff --git a/yinmeng-ios/Modules/User/VC/UserInfoVC.swift b/yinmeng-ios/Modules/User/VC/UserInfoVC.swift new file mode 100644 index 0000000..ef6afad --- /dev/null +++ b/yinmeng-ios/Modules/User/VC/UserInfoVC.swift @@ -0,0 +1,170 @@ +// +// UserInfoVC.swift +// yinmeng-ios +// +// Created by MaiMang on 2024/2/25. +// + +import UIKit + +class UserInfoVC: BaseViewController, HiddenNavigationBarProtocol { + + override func viewDidLoad() { + super.viewDidLoad() + loadSubView() + } + + private func loadSubView() { + view.addSubview(backImgView) + view.addSubview(titleLb) + view.addSubview(rechargeView) + view.addSubview(mobileView) + view.addSubview(passwordView) + view.addSubview(aboutView) + view.addSubview(logOffView) + view.addSubview(logoutBtn) + + backImgView.snp.makeConstraints { make in + make.edges.equalTo(view) + } + + titleLb.snp.makeConstraints { make in + make.centerX.equalTo(view) + make.top.equalTo(view).offset(StatusBarHeight + 10) + make.height.equalTo(25) + } + + rechargeView.snp.makeConstraints { make in + make.left.right.equalTo(view).inset(28) + make.height.equalTo(68) + make.top.equalTo(view).offset(NavHeight + 20) + } + + mobileView.snp.makeConstraints { make in + make.left.equalTo(view).offset(28) + make.height.equalTo(68) + make.top.equalTo(rechargeView.snp.bottom).offset(12) + make.right.equalTo(passwordView.snp.left).offset(-11) + } + + passwordView.snp.makeConstraints { make in + make.centerY.height.width.equalTo(mobileView) + make.right.equalTo(view).offset(-28) + } + + aboutView.snp.makeConstraints { make in + make.width.centerX.height.equalTo(mobileView) + make.top.equalTo(mobileView.snp.bottom).offset(12) + } + + logOffView.snp.makeConstraints { make in + make.width.centerX.height.equalTo(passwordView) + make.centerY.equalTo(aboutView) + } + + logoutBtn.snp.makeConstraints { make in + make.left.right.equalTo(view).inset(40) + make.height.equalTo(48) + make.top.equalTo(logOffView.snp.bottom).offset(48) + } + + } + + @objc func logoutBtnAction() { + //TODO: 退出登录 + } + + private lazy var backImgView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "auth_login_bg") + imageView.isUserInteractionEnabled = true + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleAspectFill + return imageView + }() + + private lazy var titleLb: UILabel = { + let label = UILabel() + label.textColor = .white + label.font = UIFont.systemFont(ofSize: 18, weight: .medium) + label.text = "我的" + return label + }() + + private lazy var rechargeView: UserFunctionView = { + let view = UserFunctionView() + view.delegate = self + let item = UserFunctionItem(title: "充值", isHiddenIcon: false ,itmeType: .recharge) + view.item = item + return view + }() + + private lazy var mobileView: UserFunctionView = { + let view = UserFunctionView() + view.delegate = self + let item = UserFunctionItem(title: "手机号码", isHiddenIcon: true ,itmeType: .mobile) + view.item = item + return view + }() + + + private lazy var passwordView: UserFunctionView = { + let view = UserFunctionView() + view.delegate = self + let item = UserFunctionItem(title: "设置密码", isHiddenIcon: true ,itmeType: .password) + view.item = item + return view + }() + + private lazy var aboutView: UserFunctionView = { + let view = UserFunctionView() + view.delegate = self + let item = UserFunctionItem(title: "关于", isHiddenIcon: true ,itmeType: .about) + view.item = item + return view + }() + + private lazy var logOffView: UserFunctionView = { + let view = UserFunctionView() + view.delegate = self + let item = UserFunctionItem(title: "注销账号", isHiddenIcon: true ,itmeType: .logoff) + view.item = item + return view + }() + + + private lazy var logoutBtn: UIButton = { + let button = UIButton(type: .custom) + button.setBackgroundImage(UIImage.gradient([ThemeColor(hexStr: "#FFC926"), ThemeColor(hexStr: "#FFE784")], radius: 0), for: .normal) + button.setTitle("退出登录", for: .normal) + button.setTitleColor(UIColor.white, for: .normal) + button.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium) + button.layer.masksToBounds = true + button.layer.cornerRadius = 24 + button.addTarget(self, action: #selector(logoutBtnAction), for: .touchUpInside) + return button + }() + +} + + +extension UserInfoVC: UserFunctionViewProtocol{ + func didClickItem(type: UserFunctionType) { + switch type { + case .recharge: + //TODO: 充值 + print("aaa") + case .mobile: + //TODO: 手机号 + print("aaa") + case .password: + //TODO: 修改密码 + print("aaa") + case .logoff: + let web = WebViewController(url: "yinmeng/\(H5Utils.logoff.rawValue)") + self.navigationController?.pushViewController(web, animated: true) + case .about: + self.navigationController?.pushViewController(AboutUsVC(), animated: true) + } + } +} diff --git a/yinmeng-ios/Modules/User/VM/UserObject.swift b/yinmeng-ios/Modules/User/VM/UserObject.swift index 09f6be0..cdb75f0 100644 --- a/yinmeng-ios/Modules/User/VM/UserObject.swift +++ b/yinmeng-ios/Modules/User/VM/UserObject.swift @@ -7,6 +7,20 @@ import Foundation +enum UserFunctionType:Int { + case recharge + case mobile + case password + case about + case logoff +} + +struct UserFunctionItem { + var title:String = "" + var isHiddenIcon:Bool = false + var itmeType:UserFunctionType = .recharge +} + struct UserObject: HandyJSON { var uid:Int? = 0 var erbanNo:Int? = 0 diff --git a/yinmeng-ios/Modules/User/View/UserFunctionView.swift b/yinmeng-ios/Modules/User/View/UserFunctionView.swift new file mode 100644 index 0000000..bf1c216 --- /dev/null +++ b/yinmeng-ios/Modules/User/View/UserFunctionView.swift @@ -0,0 +1,98 @@ +// +// UserFunctionView.swift +// yinmeng-ios +// +// Created by MaiMang on 2024/2/26. +// + +import UIKit + +protocol UserFunctionViewProtocol: NSObjectProtocol { + func didClickItem(type: UserFunctionType) +} + +class UserFunctionView: BaseView { + weak var delegate: UserFunctionViewProtocol? + + var item:UserFunctionItem? { + didSet { + guard let item = item else {return} + self.titleLb.text = item.title + self.logoImgView.isHidden = item.isHiddenIcon + } + } + + @objc func tapViewRecognizer() { + if let type = item?.itmeType { + delegate?.didClickItem(type: type) + } + } + + override func loadSubViews() { + super.loadSubViews() + self.layer.masksToBounds = true + self.layer.cornerRadius = 8 + self.backgroundColor = ThemeColor(hexStr: "#525566") + let tap = UITapGestureRecognizer(target: self, action: #selector(tapViewRecognizer)) + addGestureRecognizer(tap) + + addSubview(stackView) + addSubview(moreImgView) + stackView.addArrangedSubview(logoImgView) + stackView.addArrangedSubview(titleLb) + + stackView.snp.makeConstraints { make in + make.left.equalTo(self).offset(24) + make.centerY.equalTo(self) + } + + logoImgView.snp.makeConstraints { make in + make.size.equalTo(CGSize(width: 23, height: 23)) + } + + titleLb.snp.makeConstraints { make in + make.height.equalTo(22) + } + + moreImgView.snp.makeConstraints { make in + make.size.equalTo(CGSize(width: 16, height: 16)) + make.centerY.equalTo(self) + make.right.equalTo(self).offset(-24) + } + } + + private lazy var stackView: UIStackView = { + let stackView = UIStackView() + stackView.distribution = .fill + stackView.axis = .horizontal + stackView.alignment = .center + stackView.spacing = 8 + return stackView + }() + + private lazy var logoImgView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "user_function_diamond") + imageView.isUserInteractionEnabled = true + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleAspectFill + return imageView + }() + + private lazy var titleLb: UILabel = { + let label = UILabel() + label.textColor = .white + label.font = UIFont.systemFont(ofSize: 16, weight: .medium) + return label + }() + + private lazy var moreImgView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "user_function_more") + imageView.isUserInteractionEnabled = true + imageView.layer.masksToBounds = true + imageView.contentMode = .scaleAspectFill + return imageView + }() + +}