Commit 4a31d2f8 authored by Steven杜宇's avatar Steven杜宇

// 推送

parent 3464e93f
...@@ -22,6 +22,8 @@ import HyphenateChat ...@@ -22,6 +22,8 @@ import HyphenateChat
@main @main
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
private lazy var liveViewModel = YHLiveSalesViewModel() private lazy var liveViewModel = YHLiveSalesViewModel()
let viewModel = YHMsgViewModel()
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
......
...@@ -120,15 +120,18 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -120,15 +120,18 @@ extension AppDelegate: JPUSHRegisterDelegate {
goToMessagePage() goToMessagePage()
if let msgType = userInfo["msg_type"] as? Int, msgType == YHMessageType.article.rawValue { if let msgType = userInfo["msg_type"] as? Int, msgType == YHMessageType.article.rawValue {
let model = YHNewsModel() let model = YHNewsModel()
model.id = userInfo["msg_id"] as? String ?? "" let taskId = userInfo["task_id"] as? Int ?? 0
model.article_id = userInfo["article_id"] as? Int ?? 0 model.article_id = userInfo["article_id"] as? Int ?? 0
model.news_type = userInfo["news_type"] as? Int ?? 0 model.news_type = userInfo["news_type"] as? Int ?? 0
model.cover_img = userInfo["cover_img"] as? String ?? "" model.cover_img = userInfo["cover_img"] as? String ?? ""
model.url = userInfo["url"] as? String ?? "" model.url = userInfo["url"] as? String ?? ""
model.media_url = userInfo["media_url"] as? String ?? "" model.media_url = userInfo["media_url"] as? String ?? ""
model.media_transcode_url = userInfo["media_transcode_url"] as? String ?? "" model.media_transcode_url = userInfo["media_transcode_url"] as? String ?? ""
printLog("DDDDY: \(model.id)")
yh_newsList.enterDetail(model) yh_newsList.enterDetail(model)
yh_newsList.markRead(model) self.viewModel.readMessage(taskId: taskId) { _, _ in
}
} }
}) })
} }
......
...@@ -140,6 +140,25 @@ class YHMsgViewModel: NSObject { ...@@ -140,6 +140,25 @@ class YHMsgViewModel: NSObject {
} }
} }
func readMessage(taskId: Int, _ callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.readPushMsgApi
let params: [String: Any] = ["type": YHMessageType.article.rawValue,
"task_id": taskId]
_ = YHNetRequest.postRequest(url: strUrl, params: params) { json, _ in
printLog("model 是 ==> \(json)")
if json.code == 200 {
callBackBlock(true, nil)
} else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { error in
callBackBlock(false, error)
}
}
func requestTotalUnreadMsgCount(_ callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) { func requestTotalUnreadMsgCount(_ callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadTotalCountApi let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadTotalCountApi
......
...@@ -433,6 +433,7 @@ class YHAllApiName { ...@@ -433,6 +433,7 @@ class YHAllApiName {
static let msgDetaiListApi = "infoflow/message/list/v2" static let msgDetaiListApi = "infoflow/message/list/v2"
// 标记消息已读 // 标记消息已读
static let readMsgApi = "infoflow/read-push" static let readMsgApi = "infoflow/read-push"
static let readPushMsgApi = "infoflow/read-push-from-bar"
// 获取未读消息总数 // 获取未读消息总数
static let unreadTotalCountApi = "infoflow/unread-total" static let unreadTotalCountApi = "infoflow/unread-total"
// 报备设备信息 // 报备设备信息
......
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