Commit 59f35b57 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:
  // 消息
  // 消息
  // 消息
  //  消息
  // 消息
  // 消息
  11版本包
  服务中心闪动问题
parents 70173896 e354f530
......@@ -2984,7 +2984,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3185,7 +3185,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......@@ -3227,7 +3227,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
......
......@@ -62,11 +62,11 @@ extension AppDelegate: JPUSHRegisterDelegate {
}
//后台进前台
func applicationDidEnterBackground(_ application: UIApplication) {
//销毁通知红点
// UIApplication.shared.applicationIconBadgeNumber = 0
// JPUSHService.setBadge(0)
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
func applicationWillEnterForeground(_ application: UIApplication) {
DispatchQueue.main.async {
// 请求消息页面通知权限通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didReqeustNotifyPermissionNotification, object: nil)
}
}
func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: ((Int) -> Void)) {
......@@ -77,6 +77,13 @@ extension AppDelegate: JPUSHRegisterDelegate {
}
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue))
// 显示通知时需要刷新消息列表和消息未读总数
DispatchQueue.main.async {
// 请求消息未读总数通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
// 请求消息列表通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
}
}
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) {
......
......@@ -179,15 +179,15 @@ extension YHHomePageViewModel {
func getList(_ firstPageFlag : Bool, _ classifyID: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": page_Size,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
if firstPageFlag {
params = ["page": 1,
"page_size": page_Size,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
} else {
params = ["page": curPageIndex + 1,
"page_size": page_Size,
"page_size": searchPageSize,
"classify_id[0]": classifyID]
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
......
......@@ -15,9 +15,10 @@ class YHServerHKLifeViewController: YHBaseViewController {
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var classId: Int = 0
var cell: YHServerHKLifeViewCell!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
cell.tableFootView.items = dataSouce
}
}
var homeTableView: UITableView = {
......@@ -105,7 +106,7 @@ extension YHServerHKLifeViewController {
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
make.bottom.equalToSuperview()
}
homeTableView.delegate = self
homeTableView.dataSource = self
......@@ -159,11 +160,11 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.tableFootView.myCollectView.es.removeRefreshFooter()
cell0.selectionStyle = .none
return cell0
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.tableFootView.items = dataSouce
cell.tableFootView.myCollectView.es.removeRefreshFooter()
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......
......@@ -12,12 +12,12 @@ class YHServerNoOrderView: UIView {
typealias SectionBlock = (YHClassifyModel) -> ()
var sectionBlock: SectionBlock?
var loadMoreBlock: SectionBlock?
var cell: YHServerHKLifeViewCell!
var tableHeadView: YHServerTableHeadView!
var sectionView: YHServiceSectionView!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.homeTableView.reloadData()
cell.tableFootView.items = dataSouce
}
}
var homeTableView: UITableView = {
......@@ -114,11 +114,11 @@ extension YHServerNoOrderView : UITableViewDelegate,UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell0.tableFootView.items = dataSouce
cell0.tableFootView.myCollectView.es.removeRefreshFooter()
cell0.selectionStyle = .none
return cell0
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.tableFootView.items = dataSouce
cell.tableFootView.myCollectView.es.removeRefreshFooter()
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......
......@@ -37,6 +37,10 @@ class YHMessageDetailListVC: YHBaseViewController {
[weak self] in
guard let self = self else { return }
YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") {
if self.msgArr.count <= 0 {
YHHUD.flash(message: "暂无消息~")
return
}
self.markAllMsgsRead()
}
}
......@@ -198,6 +202,7 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.row && indexPath.row < msgArr.count {
let item = msgArr[indexPath.row]
cell.updateModel(item)
cell.updateBottomBtn(type: self.type)
}
return cell
}
......@@ -208,6 +213,39 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < msgArr.count {
let item = msgArr[indexPath.row]
printLog("order_id: \(item.orderId)")
if self.type == YHMessageType.infoFill.rawValue { // 资料填写
if let orderId = Int(item.orderId), orderId > 0 {
let vc = YHInformationPerfectListVC()
vc.orderId = orderId
navigationController?.pushViewController(vc)
}
} else if self.type == YHMessageType.cerUpload.rawValue { // 证件上传
if let orderId = Int(item.orderId), orderId > 0 {
let vc = YHMineCertificateEntryViewController()
vc.orderId = orderId
navigationController?.pushViewController(vc)
}
} else if self.type == YHMessageType.draft.rawValue { // 文书定稿
if let orderId = Int(item.orderId), orderId > 0 {
let vc = YHMyDocumentsListViewController()
vc.orderId = orderId
navigationController?.pushViewController(vc)
}
} else if self.type == YHMessageType.fileSign.rawValue { // 文件签字
if let orderId = Int(item.orderId), orderId > 0 {
let vc = YHMySignatureListViewController()
vc.orderId = orderId
navigationController?.pushViewController(vc)
}
}
}
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......@@ -242,10 +280,11 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
// 累计出现在屏幕上的未读消息集合
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]
let visibleCells = tableView.visibleCells as! [YHDetailMessageCell]
if visibleCells.count <= 0 { return }
for cell in visibleCells {
if let msgItem = cell.model {
if !msgItem.isRead {
if !visiblemsgIdSet.contains(msgItem.id) {
visiblemsgIdSet.insert(msgItem.id)
......@@ -254,6 +293,7 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
}
}
}
printLog("visiblemsgIdSet:/n \(visiblemsgIdSet)")
}
}
......@@ -15,11 +15,11 @@ class YHMessageListVC: YHBaseViewController {
let model = YHMsgViewModel()
return model
}()
var isNotifyEnabled = false
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.sectionHeaderHeight = 42.0
tableView.estimatedSectionHeaderHeight = 1.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
......@@ -49,6 +49,10 @@ class YHMessageListVC: YHBaseViewController {
bar.rightBtnClick = {
[weak self] in
guard let self = self else { return }
if self.msgArr.count <= 0 {
YHHUD.flash(message: "暂无消息~")
return
}
YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") {
self.markAllMsgsRead()
}
......@@ -92,12 +96,13 @@ class YHMessageListVC: YHBaseViewController {
super.viewWillAppear(animated)
YHLoginManager.shared.needJumpToMsgTabFlag = false
getUnreadMsgList()
checkNotificationPermisson()
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
}
func setupUI() {
addObservers()
gk_navigationBar.isHidden = true
view.backgroundColor = .white
view.addSubview(navBar)
......@@ -112,22 +117,29 @@ class YHMessageListVC: YHBaseViewController {
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
}
func addObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getUnreadMsgList), name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getUnreadMsgList), name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(checkNotificationPermisson), name: YhConstant.YhNotification.didReqeustNotifyPermissionNotification, object: nil)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
}
@objc func logoutSuccess() {
}
func getUnreadMsgList() {
@objc func getUnreadMsgList() {
self.viewModel.getUnreadMsgList {
[weak self] success, error in
guard let self = self else { return }
......@@ -182,6 +194,42 @@ class YHMessageListVC: YHBaseViewController {
}
}
}
@objc func checkNotificationPermisson() {
checkNotificationAuthorizationStatus {
[weak self] granted in
guard let self = self else { return }
DispatchQueue.main.async {
self.isNotifyEnabled = granted
self.tableView.reloadData()
}
}
}
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 YHMessageListVC {
......@@ -202,6 +250,10 @@ extension YHMessageListVC {
extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return msgArr.count
}
......@@ -232,8 +284,11 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
if !isNotifyEnabled {
return 42.0
}
return 1.0
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 1.0
......@@ -246,6 +301,10 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if isNotifyEnabled {
return UIView()
}
let view = UIView()
view.backgroundColor = UIColor(hex: 0x3570DC, alpha: 0.06)
......@@ -269,10 +328,11 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
make.right.equalTo(enableBtn.snp.left).offset(-20)
make.centerY.equalToSuperview()
}
enableBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 26, height: 18))
make.size.equalTo(CGSize(width: 26, height: 42.0))
make.right.equalToSuperview().offset(-20)
make.centerY.equalToSuperview()
make.top.bottom.equalToSuperview()
}
return view
}
......
......@@ -31,6 +31,7 @@ class YHMessageInfoModel: SmartCodable {
case unreadCount = "unread_count"
case lastMessage = "last_message"
case lastMessageTime = "last_message_time"
case type = "type"
}
func getTitle() -> String {
......@@ -62,18 +63,21 @@ class YHMsgListModel: SmartCodable {
}
class YHDetailMessageModel: SmartCodable {
var id: String = ""
var title: String = ""
var content: String = ""
var time: Int = 0
var isRead: Bool = false
var orderId: Int = 0
var orderId: String = ""
required init() {
}
enum CodingKeys: String, CodingKey {
case id, title, content, time
case isRead = "is_read"
case orderId = "order_id"
}
}
......@@ -21,6 +21,7 @@ class YHDetailMessageCell: UITableViewCell {
var bottomBtn:UIButton!
var lineView:UIView!
var timeLabel:UILabel!
var model:YHDetailMessageModel?
required init?(coder: NSCoder) {
super.init(coder: coder)
......@@ -32,12 +33,28 @@ class YHDetailMessageCell: UITableViewCell {
}
func updateModel(_ model: YHDetailMessageModel) {
self.model = model
titleLabel.text = model.title
detailLabel.text = model.content
unreadPointView.isHidden = model.isRead
timeLabel.text = formatTimestamp(Double(model.time))
}
func updateBottomBtn(type:Int) {
if type == YHMessageType.infoFill.rawValue {
bottomBtn.setTitle("去填写".local, for: .normal)
} else if type == YHMessageType.cerUpload.rawValue {
bottomBtn.setTitle("去上传".local, for: .normal)
} else if type == YHMessageType.draft.rawValue {
bottomBtn.setTitle("去定稿".local, for: .normal)
} else if type == YHMessageType.fileSign.rawValue {
bottomBtn.setTitle("去签字".local, for: .normal)
}
}
func formatTimestamp(_ timestamp: TimeInterval) -> String {
let currentDate = Date()
let calendar = Calendar.current
......@@ -104,6 +121,7 @@ class YHDetailMessageCell: UITableViewCell {
whiteView.addSubview(lineView)
bottomBtn = UIButton()
bottomBtn.isUserInteractionEnabled = false
bottomBtn.setTitle("去填写".local, for: .normal)
bottomBtn.setTitleColor(UIColor(hex: 0x3570DC), for: .normal)
bottomBtn.titleLabel?.font = .PFSC_R(ofSize: 14)
......
......@@ -32,6 +32,22 @@ class YHMyNotifySettingVC: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
checkNotifyPermission()
}
func setupUI() {
gk_navTitle = "通知设置".local
view.backgroundColor = .white
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
NotificationCenter.default.addObserver(self, selector: #selector(checkNotifyPermission), name: YhConstant.YhNotification.didReqeustNotifyPermissionNotification, object: nil)
}
@objc func checkNotifyPermission() {
checkNotificationAuthorizationStatus {
[weak self] granted in
guard let self = self else { return }
......@@ -46,17 +62,6 @@ class YHMyNotifySettingVC: YHBaseViewController {
}
}
func setupUI() {
gk_navTitle = "通知设置".local
view.backgroundColor = .white
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
}
func checkNotificationAuthorizationStatus(_ callBack:((Bool)->())?) {
UNUserNotificationCenter.current().getNotificationSettings { settings in
var enableStatus = false
......
......@@ -137,6 +137,10 @@ class YHMyPermissionSettingVC: YHBaseViewController {
completion(false)
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
......
......@@ -202,5 +202,11 @@ extension YhConstant {
// 请求消息未读总数通知
public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal")
// 请求消息未读列表通知
public static let didRequestUnreadMsgListNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadList")
// 请求通知权限通知
public static let didReqeustNotifyPermissionNotification = Notification.Name(rawValue: "com.yinhe.msgPage.notifyPermission")
}
}
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