Commit aae685f3 authored by pete谢兆麟's avatar pete谢兆麟

Merge commit '99fdfc29' into xiezhaolin

parents 451b2b7f 99fdfc29
......@@ -18,7 +18,7 @@
04174D772BCD5B74000BA46D /* YHMessageDetailListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */; };
04174D782BCD5B74000BA46D /* YHMessageListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6F2BCD5B74000BA46D /* YHMessageListVC.swift */; };
04174D792BCD5B74000BA46D /* YHMessageSessionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D712BCD5B74000BA46D /* YHMessageSessionCell.swift */; };
04174D7A2BCD5B74000BA46D /* YHInformationFillCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D722BCD5B74000BA46D /* YHInformationFillCell.swift */; };
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */; };
0425E63D2BA9345200A5E763 /* YHSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */; };
0425E6402BA9357D00A5E763 /* YHScemeItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */; };
0425E6422BA95B1B00A5E763 /* YHSchemeTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */; };
......@@ -313,6 +313,7 @@
A53B61122BB128AF0010B573 /* YHFileListItemsView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53B61112BB128AF0010B573 /* YHFileListItemsView2.swift */; };
A53B61192BB3C9960010B573 /* YHMyDocListHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53B61182BB3C9960010B573 /* YHMyDocListHeaderView.swift */; };
A53D38202BC243F1006AE6F7 /* YHStartPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53D381F2BC243F1006AE6F7 /* YHStartPageViewController.swift */; };
A53F05ED2BCE86E50071D35A /* YHAgreementAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53F05EC2BCE86E50071D35A /* YHAgreementAlertView.swift */; };
A53F42B92BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53F42B82BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift */; };
A53F42BB2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53F42BA2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift */; };
A554A5122B99715000EA5973 /* YHConstantArrayData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A554A5112B99715000EA5973 /* YHConstantArrayData.swift */; };
......@@ -467,7 +468,7 @@
04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageDetailListVC.swift; sourceTree = "<group>"; };
04174D6F2BCD5B74000BA46D /* YHMessageListVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageListVC.swift; sourceTree = "<group>"; };
04174D712BCD5B74000BA46D /* YHMessageSessionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageSessionCell.swift; sourceTree = "<group>"; };
04174D722BCD5B74000BA46D /* YHInformationFillCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHInformationFillCell.swift; sourceTree = "<group>"; };
04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDetailMessageCell.swift; sourceTree = "<group>"; };
0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableViewCell.swift; sourceTree = "<group>"; };
0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHScemeItemModel.swift; sourceTree = "<group>"; };
0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableFooterView.swift; sourceTree = "<group>"; };
......@@ -765,6 +766,7 @@
A53B61112BB128AF0010B573 /* YHFileListItemsView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFileListItemsView2.swift; sourceTree = "<group>"; };
A53B61182BB3C9960010B573 /* YHMyDocListHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyDocListHeaderView.swift; sourceTree = "<group>"; };
A53D381F2BC243F1006AE6F7 /* YHStartPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHStartPageViewController.swift; sourceTree = "<group>"; };
A53F05EC2BCE86E50071D35A /* YHAgreementAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAgreementAlertView.swift; sourceTree = "<group>"; };
A53F42B82BC3DCA9009CAC70 /* YHHomeKingKongBlockModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeKingKongBlockModel.swift; sourceTree = "<group>"; };
A53F42BA2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeKingKongBlockItem.swift; sourceTree = "<group>"; };
A554A5112B99715000EA5973 /* YHConstantArrayData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHConstantArrayData.swift; sourceTree = "<group>"; };
......@@ -968,7 +970,7 @@
isa = PBXGroup;
children = (
04174D712BCD5B74000BA46D /* YHMessageSessionCell.swift */,
04174D722BCD5B74000BA46D /* YHInformationFillCell.swift */,
04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -2236,6 +2238,7 @@
044414082BC3CE8500784A14 /* YHHomeCollectionLayout.swift */,
A50A747D2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift */,
048787D22BCE6B7D0036E221 /* YHServiceOrderAlertView.swift */,
A53F05EC2BCE86E50071D35A /* YHAgreementAlertView.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -2745,6 +2748,7 @@
A5ACE9492B4564F7002C94D2 /* YHHUDSuccessView.swift in Sources */,
045EEE9C2B9F171A0022A143 /* YHCompanyViewModel.swift in Sources */,
A58556BA2B6BCF1A003746B2 /* YHPersonInfoFillStepModel.swift in Sources */,
A53F05ED2BCE86E50071D35A /* YHAgreementAlertView.swift in Sources */,
045EEEC92B9F171A0022A143 /* YHOtherInfoSessionView.swift in Sources */,
045EEEE22B9F171A0022A143 /* YHMySignatureDetailViewModel.swift in Sources */,
045EEE7D2B9F171A0022A143 /* YHWorkExpDataModel.swift in Sources */,
......@@ -2861,7 +2865,7 @@
A5ACE9352B4564F7002C94D2 /* YHNetRequest.swift in Sources */,
A5FD63CB2B63D6C300D1D9DA /* YHInformationFillTipsCell.swift in Sources */,
045EEF1F2B9F171A0022A143 /* YHDatePickView.swift in Sources */,
04174D7A2BCD5B74000BA46D /* YHInformationFillCell.swift in Sources */,
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */,
045EEE972B9F171A0022A143 /* YHPreviewInfoWorkExpView.swift in Sources */,
044414012BC3979800784A14 /* YHServerHKLifeViewController.swift in Sources */,
04D5C5662B8ED92600190021 /* YHBaseModel.swift in Sources */,
......@@ -2976,7 +2980,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3177,7 +3181,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3219,7 +3223,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......
......@@ -20,6 +20,9 @@ class YHTabBarViewController: ESTabBarController {
super.viewDidLoad()
handleTabBarLine()
addObservers()
if YHLoginManager.shared.isLogin() {
getTotalUnreadMsgCount()
}
}
func addObservers() {
......@@ -27,6 +30,7 @@ class YHTabBarViewController: ESTabBarController {
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(clearAllUnreadMsg), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(switchToMsgTab), name: YhConstant.YhNotification.didSwithToMsgTabNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
}
}
......@@ -59,17 +63,18 @@ extension YHTabBarViewController {
@objc func clearAllUnreadMsg() {
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
msgListVC.tabBarItem.badgeValue = ""
msgListVC.tabBarItem.badgeValue = nil
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
func getTotalUnreadMsgCount() {
self.viewModel.requestTotalUnreadMsgCount {
// 请求未读消息总数
@objc func getTotalUnreadMsgCount() {
self.viewModel.requestTotalUnreadMsgCount {
[weak self] success, error in
guard let self = self else { return }
if !success { return }
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
let count = self.viewModel.unreadTotalCount
......
......@@ -232,7 +232,7 @@ extension YHHomePageViewController : UITabBarControllerDelegate {
vc.modalPresentationStyle = .custom
UIViewController.current?.navigationController?.present(vc, animated: true)
YHLoginManager.shared.loginSuccessActionBlock = {[weak self] in
guard let self = self else { return }
guard self != nil else { return }
tabBarController.selectedIndex = index
YHLoginManager.shared.loginSuccessActionBlock = nil
}
......
......@@ -35,8 +35,13 @@ class YHStartPageViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initView()
self.startTimer()
}
lazy var agreeAlertView : YHAgreementAlertView = {
let view = YHAgreementAlertView()
view.isHidden = true
return view
}()
}
......@@ -89,6 +94,46 @@ private extension YHStartPageViewController {
make.height.equalTo(28)
}
closeBtn.addTarget(self, action: #selector(clickCancelBtn), for: .touchUpInside)
view.addSubview(agreeAlertView)
agreeAlertView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
if let key = UserDefaults.standard.value(forKey: "userAgreeProtocal") as? String,key.contains("true") {
startTimer()
} else {
agreeAlertView.isHidden = false
cancelTimer()
closeBtn.isHidden = true
agreeAlertView.agreeBlock = {
UserDefaults.standard.set("true", forKey: "userAgreeProtocal")
UserDefaults.standard.synchronize()
self.closeBtn.isHidden = false
self.startTimer()
}
agreeAlertView.cancelBlock = {
//点击了取消按钮
YHCommonAlertView.show("", "确认退出智汇银河App?", "退出", "继续使用") {
//退出
exit(0)
} callBack: {
//继续使用
self.view.addSubview(self.agreeAlertView)
self.agreeAlertView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
self.agreeAlertView.isHidden = false
self.cancelTimer()
self.closeBtn.isHidden = true
}
}
}
}
@objc func clickCancelBtn() {
......
//
// YHAgreementAlertView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAgreementAlertView: UIView {
typealias AgreeBlock = () -> ()
var agreeBlock: AgreeBlock?
var cancelBlock:AgreeBlock?
var centerView: UIView!
var titleLabel: UILabel!
var lineView: UIView!
var messageLabel: UILabel!
var agreeButton: UIButton!
var disAgressButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
addSubview(centerView)
centerView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.left.equalTo(38)
make.right.equalTo(-38)
}
titleLabel = {
let label = UILabel()
label.textAlignment = .center
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_M(ofSize: 17)
label.numberOfLines = 0
label.text = "欢迎使用智汇银河App"
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(22)
make.right.equalTo(-22)
make.top.equalTo(kMargin)
}
lineView = {
let line = UIView()
line.backgroundColor = UIColor(hex: 0xF0F0F0)
return line
}()
centerView.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.height.equalTo(1)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
}
messageLabel = {
let label = UILabel()
label.textAlignment = .center
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_R(ofSize: 16)
label.numberOfLines = 0
label.text = "感谢您信任并使用智汇银河App,我们将通过《智汇银河App隐私协议》和《智汇银河App用户条款》帮助您了解我们收集、使用、存储和共享个人信息的情况,特别是我们所采取的个人信息类型和用途的对应关系。此外,您还能了解到您所享受的相关权利以及实现途径。认真阅读之后,如您同意,请点击下方的按钮开始接受我们的服务。"
return label
}()
centerView.addSubview(messageLabel)
messageLabel.snp.makeConstraints { make in
make.left.equalTo(21)
make.right.equalTo(-21)
make.top.equalTo(lineView.snp.bottom).offset(kMargin)
}
disAgressButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor(hex:0xffffff)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("取消", for: .normal)
button.setTitleColor( UIColor(hex:0x3c86f8), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.layer.borderWidth = 1
button.layer.borderColor = UIColor(hex: 0x3c86f8).cgColor
button.addTarget(self, action: #selector(disagree), for: .touchUpInside)
return button
}()
let itemW = (KScreenWidth - kMargin * 2 - 10 - 38 * 2) / 2.0
centerView.addSubview(disAgressButton)
disAgressButton.snp.makeConstraints { make in
make.top.equalTo(messageLabel.snp.bottom).offset(21)
make.left.equalTo(kMargin)
make.bottom.equalTo(-kMargin)
make.height.equalTo(45)
make.width.equalTo(itemW)
}
agreeButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor(hex:0x3c86f8)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("确认", for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.addTarget(self, action: #selector(agree), for: .touchUpInside)
return button
}()
centerView.addSubview(agreeButton)
agreeButton.snp.makeConstraints { make in
make.height.equalTo(disAgressButton.snp.height)
make.top.equalTo(disAgressButton.snp.top)
make.width.equalTo(itemW)
make.left.equalTo(disAgressButton.snp.right).offset(10)
}
}
@objc func agree() {
if let block = self.agreeBlock {
block()
}
dismiss()
}
@objc private func handleTap(_ sender: AnyObject?) {
print("处理点击手势")
dismiss()
}
@objc func disagree() {
if let block = self.cancelBlock {
block()
}
dismiss()
}
func dismiss() {
removeFromSuperview()
}
}
extension YHAgreementAlertView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldReceive touch:UITouch) -> Bool {
if touch.view == self {
return true
}
return false
}
}
......@@ -68,12 +68,10 @@ class YHServiceCenterMainViewController: YHBaseViewController {
self.navigationController?.pushViewController(vc)
}
noDataView.clickBackBtnClickBlock = {[weak self] in
guard let self = self else { return }
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = 0
}
guard self != nil else { return }
goTabBarBy(tabType: .home)
}
noDataView.clickShowBtnClickBlock = {[weak self] in
noDataView.clickShowBtnClickBlock = {
YHServiceOrderAlertView.show()
}
}
......
......@@ -11,6 +11,7 @@ import UIKit
class YHCommonAlertView: UIView {
typealias AgreeBlock = () -> ()
var agreeBlock: AgreeBlock?
var cancelBlcok: AgreeBlock?
var centerView: UIView!
var titleLabel: UILabel!
var lineView: UIView!
......@@ -18,9 +19,10 @@ class YHCommonAlertView: UIView {
var agreeButton: UIButton!
var disAgressButton: UIButton!
static func show(_ title: String? = nil, _ message: String? = nil, _ leftButtonString: String? = nil, _ rightButtonString: String? = nil, callBack: @escaping (() -> Void)) {
static func show(_ title: String? = nil, _ message: String? = nil, _ leftButtonString: String? = nil, _ rightButtonString: String? = nil,cancelCallBack: (() -> Void)? = nil, callBack: @escaping (() -> Void)) {
let view = YHCommonAlertView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.agreeBlock = callBack
view.cancelBlcok = cancelCallBack
view.setContent(title, message, leftButtonString, rightButtonString)
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
......@@ -54,6 +56,10 @@ class YHCommonAlertView: UIView {
make.height.lessThanOrEqualTo(60)
make.top.equalTo(37)
}
lineView.isHidden = true
} else {
lineView.isHidden = false
}
}
......@@ -176,6 +182,9 @@ class YHCommonAlertView: UIView {
}
@objc func disagree() {
if let block = self.cancelBlcok {
block()
}
dismiss()
}
......
......@@ -12,6 +12,9 @@ class YHMessageDetailListVC: YHBaseViewController {
var type:Int = -1
var msgArr:[YHDetailMessageModel] = []
// 滑动过程中出现在屏幕上的未读消息集合
var visiblemsgIdSet = Set<String>()
var visibleMsgArr = [YHDetailMessageModel]()
lazy var viewModel = {
let model = YHMsgViewModel()
......@@ -51,7 +54,7 @@ class YHMessageDetailListVC: YHBaseViewController {
tableView.backgroundColor = UIColor(hex:0xF8F8F8)
tableView.backgroundView = emptyDataTipsView
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHInformationFillCell.self, forCellReuseIdentifier: YHInformationFillCell.cellReuseIdentifier)
tableView.register(YHDetailMessageCell.self, forCellReuseIdentifier: YHDetailMessageCell.cellReuseIdentifier)
return tableView
}()
......@@ -118,7 +121,12 @@ class YHMessageDetailListVC: YHBaseViewController {
msgArr.removeAll()
msgArr.append(contentsOf: self.viewModel.msgDetailList)
emptyDataTipsView.isHidden = msgArr.count > 0
self.tableView.reloadData()
self.tableView.reloadData {
[weak self] in
guard let self = self else { return }
self.addUpAppearUnreadMessages()
self.markAppearMessagsReaded()
}
}
}
......@@ -136,17 +144,46 @@ class YHMessageDetailListVC: YHBaseViewController {
self.tableView.reloadData()
return
}
var msg = "清除失败"
if let error = error {
var msg = "清除失败"
if error.errorMsg.count > 0 {
msg = error.errorMsg
}
YHHUD.flash(message: msg)
return
}
YHHUD.flash(message: msg)
}
}
func markAppearMessagsReaded() {
var msgIds:[Int] = []
var resultArr:[YHDetailMessageModel] = []
for msgItem in visibleMsgArr {
if let msgId = Int(msgItem.id), msgItem.isRead == false {
msgIds.append(msgId)
resultArr.append(msgItem)
}
}
if msgIds.count <= 0 { return }
self.viewModel.readMessages(type: self.type, msgIds: msgIds, isAllRead:false) {
[weak self] success, error in
guard let self = self else { return }
if success {
for msgItem in resultArr {
msgItem.isRead = true
}
self.tableView.reloadData()
return
}
// var msg = "标记已读失败"
// if let error = error {
// if error.errorMsg.count > 0 {
// msg = error.errorMsg
// }
// }
// YHHUD.flash(message: msg)
}
}
}
extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
......@@ -157,7 +194,11 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHInformationFillCell.cellReuseIdentifier, for: indexPath) as! YHInformationFillCell
let cell = tableView.dequeueReusableCell(withIdentifier: YHDetailMessageCell.cellReuseIdentifier, for: indexPath) as! YHDetailMessageCell
if 0 <= indexPath.row && indexPath.row < msgArr.count {
let item = msgArr[indexPath.row]
cell.updateModel(item)
}
return cell
}
......@@ -187,5 +228,32 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
return UIView()
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if scrollView == tableView && !decelerate {
// 在这里处理滑动停止事件
print("TableView 滑动停止")
markAppearMessagsReaded()
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
addUpAppearUnreadMessages()
}
// 累计出现在屏幕上的未读消息集合
func addUpAppearUnreadMessages() {
guard let visibleIndexPaths = tableView.indexPathsForVisibleRows else { return }
for indexPath in visibleIndexPaths {
if 0 <= indexPath.row && indexPath.row < msgArr.count {
let msgItem = msgArr[indexPath.row]
if !msgItem.isRead {
if !visiblemsgIdSet.contains(msgItem.id) {
visiblemsgIdSet.insert(msgItem.id)
visibleMsgArr.append(msgItem)
}
}
}
}
}
}
......@@ -91,6 +91,8 @@ class YHMessageListVC: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getUnreadMsgList()
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
}
func setupUI() {
......
......@@ -9,9 +9,9 @@
import UIKit
import AttributedString
class YHInformationFillCell: UITableViewCell {
class YHDetailMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHInformationFillCell"
static let cellReuseIdentifier = "YHDetailMessageCell"
static let unreadPointWidth = 6.0
var whiteView:UIView!
......@@ -94,7 +94,6 @@ class YHInformationFillCell: UITableViewCell {
unreadPointView.clipsToBounds = true
whiteView.addSubview(unreadPointView)
detailLabel = UILabel()
detailLabel.textAlignment = .left
detailLabel.numberOfLines = 0
......@@ -153,8 +152,6 @@ class YHInformationFillCell: UITableViewCell {
make.left.right.bottom.equalToSuperview()
make.height.equalTo(52)
}
updateModel()
}
@objc func didBottomBtnClicked() {
......
......@@ -146,7 +146,7 @@ class YHMsgViewModel: NSObject {
func requestTotalUnreadMsgCount(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadTotalCountApi
let _ = YHNetRequest.postRequest(url: strUrl) {
let _ = YHNetRequest.getRequest(url: strUrl) {
json, code in
let dic = json.data as? [String : Any]
printLog("model 是 ==> \(json)")
......
......@@ -30,6 +30,22 @@ class YHMyNotifySettingVC: YHBaseViewController {
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
checkNotificationAuthorizationStatus {
[weak self] granted in
guard let self = self else { return }
for item in items {
if item.type == .notify {
item.enableStatus = granted
}
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
func setupUI() {
gk_navTitle = "通知设置".local
view.backgroundColor = .white
......@@ -40,6 +56,31 @@ class YHMyNotifySettingVC: YHBaseViewController {
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
}
func checkNotificationAuthorizationStatus(_ callBack:((Bool)->())?) {
UNUserNotificationCenter.current().getNotificationSettings { settings in
var enableStatus = false
switch settings.authorizationStatus {
case .authorized:
print("通知已授权")
enableStatus = true
case .denied:
print("通知被拒绝")
enableStatus = false
case .notDetermined:
print("通知权限尚未确定")
enableStatus = false
case .provisional:
print("通知以临时方式授权")
enableStatus = false
case .ephemeral:
enableStatus = false
@unknown default:
break
}
callBack?(enableStatus)
}
}
}
extension YHMyNotifySettingVC: UITableViewDelegate, UITableViewDataSource {
......
......@@ -27,10 +27,12 @@ enum YHPersonalModuleItemType: Int {
case aboutUs
}
struct PersonalModuleItem {
class PersonalModuleItem {
var icon: String?
var title: String
var type:YHPersonalModuleItemType = .none
var isShowRedPoint:Bool = false
init(icon: String? = nil, title: String, type:YHPersonalModuleItemType) {
self.icon = icon
self.title = title
......@@ -40,8 +42,9 @@ struct PersonalModuleItem {
class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
let viewModel: YHMyLikeViewModel = YHMyLikeViewModel()
let likeViewModel: YHMyLikeViewModel = YHMyLikeViewModel()
let msgViewModel: YHMsgViewModel = YHMsgViewModel()
lazy var tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style:.grouped)
if #available(iOS 11.0, *) {
......@@ -144,6 +147,7 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestLikeCollectionCount()
getTotalUnreadMsgCount()
}
@objc func clickBtn() {
......@@ -179,10 +183,29 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
func requestLikeCollectionCount() {
self.viewModel.getLikeCollectionRecentScanCountInfo {
self.likeViewModel.getLikeCollectionRecentScanCountInfo {
[weak self] success, error in
guard let self = self else { return }
self.headerView.updateLikeCollectCount(self.likeViewModel.likeCollectCountInfo)
}
}
// 请求未读消息总数
func getTotalUnreadMsgCount() {
self.msgViewModel.requestTotalUnreadMsgCount {
[weak self] success, error in
guard let self = self else { return }
self.headerView.updateLikeCollectCount(self.viewModel.likeCollectCountInfo)
if !success { return }
DispatchQueue.main.async {
let count = self.msgViewModel.unreadTotalCount
for item in self.items {
if item.type == .myMessage {
item.isShowRedPoint = count > 0
break
}
}
self.tableView .reloadData()
}
}
}
}
......
......@@ -11,7 +11,8 @@ import SnapKit
class YHPersonalCenterCell: UITableViewCell {
static let cellReuseIdentifier = "YHPersonalCenterCell"
static let redPointWidth = 6.0
lazy var iconImgView:UIImageView = {
let icon = UIImageView(image: UIImage(named: "mine_manager"))
return icon
......@@ -25,6 +26,14 @@ class YHPersonalCenterCell: UITableViewCell {
return label
}()
lazy var redPointView:UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0xF81D22)
view.layer.cornerRadius = Self.redPointWidth/2.0
view.clipsToBounds = true
return view
}()
lazy var arrowImgView:UIImageView = {
let arrowImgView = UIImageView(image: UIImage(named: "mine_arrow_right"))
return arrowImgView
......@@ -46,6 +55,7 @@ class YHPersonalCenterCell: UITableViewCell {
iconImgView.image = nil
}
titleLabel.text = item.title;
redPointView.isHidden = !item.isShowRedPoint
}
func setupUI() {
......@@ -56,6 +66,7 @@ class YHPersonalCenterCell: UITableViewCell {
contentView.addSubview(iconImgView)
contentView.addSubview(titleLabel)
contentView.addSubview(arrowImgView)
contentView.addSubview(redPointView)
iconImgView.snp.makeConstraints { make in
make.left.equalTo(contentView.snp.left).offset(27)
......@@ -66,7 +77,13 @@ class YHPersonalCenterCell: UITableViewCell {
titleLabel.snp.makeConstraints { make in
make.centerY.equalTo(contentView)
make.left.equalTo(iconImgView.snp.right).offset(10)
make.right.equalTo(arrowImgView.snp.left).offset(-20)
make.right.equalTo(redPointView.snp.left).offset(-5)
}
redPointView.snp.makeConstraints { make in
make.width.height.equalTo(Self.redPointWidth)
make.centerY.equalToSuperview()
make.right.equalTo(arrowImgView.snp.left).offset(-5)
}
arrowImgView.snp.makeConstraints { make in
......
......@@ -202,5 +202,8 @@ extension YhConstant {
// 自动转换到消息tab
public static let didSwithToMsgTabNotification = Notification.Name(rawValue: "com.yinhe.msgPage.switch")
// 请求消息未读总数通知
public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal")
}
}
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "摄图网_501771221_家庭亲子户外露营玩耍(企业商用) 1@2x.png",
"filename" : "启动页@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "摄图网_501771221_家庭亲子户外露营玩耍(企业商用) 1@3x.png",
"filename" : "启动页@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment