Commit 99fdfc29 authored by David黄金龙's avatar David黄金龙

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

* 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  //  通知
  //  消息
  //  消息
parents 7bc3cf82 eb7f0cb5
......@@ -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 */; };
......@@ -467,7 +467,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>"; };
......@@ -968,7 +968,7 @@
isa = PBXGroup;
children = (
04174D712BCD5B74000BA46D /* YHMessageSessionCell.swift */,
04174D722BCD5B74000BA46D /* YHInformationFillCell.swift */,
04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -2861,7 +2861,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 */,
......
......@@ -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
......
......@@ -54,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
}()
......@@ -123,7 +123,9 @@ class YHMessageDetailListVC: YHBaseViewController {
emptyDataTipsView.isHidden = msgArr.count > 0
self.tableView.reloadData {
[weak self] in
self?.addUpAppearUnreadMessages()
guard let self = self else { return }
self.addUpAppearUnreadMessages()
self.markAppearMessagsReaded()
}
}
}
......@@ -163,10 +165,8 @@ class YHMessageDetailListVC: YHBaseViewController {
}
}
if msgIds.count <= 0 { return }
YHHUD.show(.progress(message: "标记已读中..."))
self.viewModel.readMessages(type: self.type, msgIds: msgIds, isAllRead:false) {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
if success {
for msgItem in resultArr {
......@@ -175,15 +175,13 @@ class YHMessageDetailListVC: YHBaseViewController {
self.tableView.reloadData()
return
}
var msg = "标记已读失败"
if let error = error {
if error.errorMsg.count > 0 {
msg = error.errorMsg
}
}
YHHUD.flash(message: msg)
// var msg = "标记已读失败"
// if let error = error {
// if error.errorMsg.count > 0 {
// msg = error.errorMsg
// }
// }
// YHHUD.flash(message: msg)
}
}
}
......@@ -196,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
}
......
......@@ -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")
}
}
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