Commit b4887f63 authored by 刘俊宏's avatar 刘俊宏

完成极光业务推送

parent 7f18d5f1
...@@ -311,6 +311,7 @@ ...@@ -311,6 +311,7 @@
F905A7D8246CF82400E3A74D /* SwipeCellKit in Frameworks */ = {isa = PBXBuildFile; productRef = F905A7D7246CF82400E3A74D /* SwipeCellKit */; }; F905A7D8246CF82400E3A74D /* SwipeCellKit in Frameworks */ = {isa = PBXBuildFile; productRef = F905A7D7246CF82400E3A74D /* SwipeCellKit */; };
F9171EFC245128B200359C2B /* Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9171EFB245128B200359C2B /* Interface.swift */; }; F9171EFC245128B200359C2B /* Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9171EFB245128B200359C2B /* Interface.swift */; };
F9171F0224513C5B00359C2B /* UpDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9171F0124513C5B00359C2B /* UpDataModel.swift */; }; F9171F0224513C5B00359C2B /* UpDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9171F0124513C5B00359C2B /* UpDataModel.swift */; };
F9217E012485E6E800C4CF67 /* MessageListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9217E002485E6E800C4CF67 /* MessageListModel.swift */; };
F933C42E2484A66C0058940C /* WorkTestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933C42D2484A66C0058940C /* WorkTestModel.swift */; }; F933C42E2484A66C0058940C /* WorkTestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933C42D2484A66C0058940C /* WorkTestModel.swift */; };
F933F6C02452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6AF2452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift */; }; F933F6C02452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6AF2452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift */; };
F933F6C12452C68B00189561 /* PKHUDAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6B02452C68B00189561 /* PKHUDAnimation.swift */; }; F933F6C12452C68B00189561 /* PKHUDAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F933F6B02452C68B00189561 /* PKHUDAnimation.swift */; };
...@@ -818,6 +819,7 @@ ...@@ -818,6 +819,7 @@
F9023F702449ACA800DD5A63 /* TitleAndSwitchCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TitleAndSwitchCell.xib; sourceTree = "<group>"; }; F9023F702449ACA800DD5A63 /* TitleAndSwitchCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TitleAndSwitchCell.xib; sourceTree = "<group>"; };
F9171EFB245128B200359C2B /* Interface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interface.swift; sourceTree = "<group>"; }; F9171EFB245128B200359C2B /* Interface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interface.swift; sourceTree = "<group>"; };
F9171F0124513C5B00359C2B /* UpDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpDataModel.swift; sourceTree = "<group>"; }; F9171F0124513C5B00359C2B /* UpDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpDataModel.swift; sourceTree = "<group>"; };
F9217E002485E6E800C4CF67 /* MessageListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListModel.swift; sourceTree = "<group>"; };
F933C42D2484A66C0058940C /* WorkTestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkTestModel.swift; sourceTree = "<group>"; }; F933C42D2484A66C0058940C /* WorkTestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkTestModel.swift; sourceTree = "<group>"; };
F933F6AF2452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSystemActivityIndicatorView.swift; sourceTree = "<group>"; }; F933F6AF2452C68B00189561 /* PKHUDSystemActivityIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSystemActivityIndicatorView.swift; sourceTree = "<group>"; };
F933F6B02452C68B00189561 /* PKHUDAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDAnimation.swift; sourceTree = "<group>"; }; F933F6B02452C68B00189561 /* PKHUDAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDAnimation.swift; sourceTree = "<group>"; };
...@@ -2227,6 +2229,7 @@ ...@@ -2227,6 +2229,7 @@
F950FDAA2451634B00C40530 /* LocationGeliPayModel.swift */, F950FDAA2451634B00C40530 /* LocationGeliPayModel.swift */,
F94A314624624E9500FEC38E /* GetGelipayInfoModel.swift */, F94A314624624E9500FEC38E /* GetGelipayInfoModel.swift */,
F94A314824624FA400FEC38E /* ShopAdministratorInfoModel.swift */, F94A314824624FA400FEC38E /* ShopAdministratorInfoModel.swift */,
F9217E002485E6E800C4CF67 /* MessageListModel.swift */,
); );
path = PersonCenterModel; path = PersonCenterModel;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2959,6 +2962,7 @@ ...@@ -2959,6 +2962,7 @@
F9023F692449A50900DD5A63 /* TitleContentCell.swift in Sources */, F9023F692449A50900DD5A63 /* TitleContentCell.swift in Sources */,
F95A9ED8245520E500867849 /* OrderListVC.swift in Sources */, F95A9ED8245520E500867849 /* OrderListVC.swift in Sources */,
E03549A8245820C2008BD021 /* PiCiXuanZeCell.swift in Sources */, E03549A8245820C2008BD021 /* PiCiXuanZeCell.swift in Sources */,
F9217E012485E6E800C4CF67 /* MessageListModel.swift in Sources */,
F956D59E246A2D9C003FF510 /* LMNTextStorage+Export.m in Sources */, F956D59E246A2D9C003FF510 /* LMNTextStorage+Export.m in Sources */,
E0337EF12464F69000952EF4 /* YingFuZKListViewController.swift in Sources */, E0337EF12464F69000952EF4 /* YingFuZKListViewController.swift in Sources */,
E099B588246BF8FA009F587F /* OrderDViewController.swift in Sources */, E099B588246BF8FA009F587F /* OrderDViewController.swift in Sources */,
......
...@@ -12,7 +12,9 @@ import ESTabBarController_swift ...@@ -12,7 +12,9 @@ import ESTabBarController_swift
@available(iOS 10.0, *) @available(iOS 10.0, *)
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarControllerDelegate{ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarControllerDelegate, JPUSHRegisterDelegate{
var window:UIWindow? var window:UIWindow?
...@@ -25,8 +27,106 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -25,8 +27,106 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
}else{ }else{
addTabBarVcs(isAgain: false) addTabBarVcs(isAgain: false)
} }
setting_Jpush(application: application, launchOptions: launchOptions)
UIApplication.shared.applicationIconBadgeNumber = 0
return true return true
}
func setting_Jpush(application:UIApplication,launchOptions:[UIApplication.LaunchOptionsKey: Any]?) {
if #available(iOS 10.0, *){
let entiity = JPUSHRegisterEntity()
entiity.types = Int(UNAuthorizationOptions.alert.rawValue |
UNAuthorizationOptions.badge.rawValue |
UNAuthorizationOptions.sound.rawValue)
JPUSHService.register(forRemoteNotificationConfig: entiity, delegate: self)
} else if #available(iOS 8.0, *) {
let types = UIUserNotificationType.badge.rawValue |
UIUserNotificationType.sound.rawValue |
UIUserNotificationType.alert.rawValue
JPUSHService.register(forRemoteNotificationTypes: types, categories: nil)
}else {
let type = UIRemoteNotificationType.badge.rawValue |
UIRemoteNotificationType.sound.rawValue |
UIRemoteNotificationType.alert.rawValue
JPUSHService.register(forRemoteNotificationTypes: type, categories: nil)
}
// 根据环境的不同,设置不同的apsForProduction值,具体看下面参数说明
JPUSHService.setup(withOption: launchOptions,
appKey: "3ecbdeacab51eb48e1219a96",
channel: "App Store",
apsForProduction: true)
//注册别名
}
// 注册deviceToken
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
JPUSHService.registerDeviceToken(deviceToken)
}
//IOS 12
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, openSettingsFor notification: UNNotification!) {
if notification != nil && (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))! {
//从通知界面直接进入应用
let userInfo = notification?.request.content.userInfo
print("1--",userInfo as Any)
}else{
//从通知设置界面进入应用
let userInfo = notification?.request.content.userInfo
print("1-11-",userInfo as Any)
}
}
//IOS 10
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, willPresent notification: UNNotification!, withCompletionHandler completionHandler: ((Int) -> Void)!) {
let userInfo = notification.request.content.userInfo
if (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))!{
JPUSHService.handleRemoteNotification(userInfo)
//前台内容先到这
print("2--",userInfo as Any)
}
completionHandler(Int(UNAuthorizationOptions.alert.rawValue))// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
}
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, didReceive response: UNNotificationResponse!, withCompletionHandler completionHandler: (() -> Void)!) {
let userInfo = response.notification.request.content.userInfo
if (response.notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))!{
JPUSHService.handleRemoteNotification(userInfo)
//点击都走这
print("3--",userInfo as Any)
switch tabBarC.selectedIndex {
case 0:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "jpushServiceNotification0"), object: nil, userInfo: userInfo)
break
case 1:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "jpushServiceNotification1"), object: nil, userInfo: userInfo)
break
case 2:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "jpushServiceNotification2"), object: nil, userInfo: userInfo)
break
case 3:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "jpushServiceNotification3"), object: nil, userInfo: userInfo)
break
case 4:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "jpushServiceNotification4"), object: nil, userInfo: userInfo)
break
default:
break
}
}
completionHandler()
}
//监测通知授权状态返回的结果
func jpushNotificationAuthorization(_ status: JPAuthorizationStatus, withInfo info: [AnyHashable : Any]!) {
} }
...@@ -86,15 +186,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -86,15 +186,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
} }
// 接受数据 // 接受数据
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("444--",userInfo as Any)
completionHandler(.newData) completionHandler(.newData)
} }
// 接受数据 // 接受数据
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print("555--",userInfo as Any)
} }
// 进入前台的时候,清空角标 // 进入前台的时候,清空角标
...@@ -106,6 +204,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -106,6 +204,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
func applicationWillResignActive(_ application: UIApplication) { func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
UIApplication.shared.applicationIconBadgeNumber = 0
} }
func applicationDidEnterBackground(_ application: UIApplication) { func applicationDidEnterBackground(_ application: UIApplication) {
...@@ -127,6 +227,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -127,6 +227,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
} }
//MARK:--tabbarVCs //MARK:--tabbarVCs
weak var tabBarC:ESTabBarController!
func addTabBarVcs (isAgain:Bool) { func addTabBarVcs (isAgain:Bool) {
let tabBarController = ESTabBarController() let tabBarController = ESTabBarController()
tabBarController.delegate = self tabBarController.delegate = self
...@@ -136,30 +237,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -136,30 +237,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
tabBarController.tabBar.backgroundImage = img tabBarController.tabBar.backgroundImage = img
NotificationCenter.default.addObserver(self, selector: #selector(popLogout), name: NSNotification.Name(rawValue: "logout"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(popLogout), name: NSNotification.Name(rawValue: "logout"), object: nil)
tabBarC = tabBarController
let v1 = OrderListViewController() let v1 = OrderListViewController()
let v2 = GoodsManageListVC() let v2 = GoodsManageListVC()
// let v3 = WorkCViewController() let v3 = WorkCViewController()
let v4 = WarehoseMangementListVC() let v4 = WarehoseMangementListVC()
let v5 = PersonCenterViewController() let v5 = PersonCenterViewController()
v1.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "订单管理", image: UIImage(named: "tab_btn_dingdao_nor"), selectedImage: UIImage(named: "tab_btn_dingdan_hig")) v1.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "订单管理", image: UIImage(named: "tab_btn_dingdao_nor"), selectedImage: UIImage(named: "tab_btn_dingdan_hig"))
v2.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "商品管理", image: UIImage(named: "tab_btn_shangpin_nor"), selectedImage: UIImage(named: "tab_btn_shangpin_hig")) v2.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "商品管理", image: UIImage(named: "tab_btn_shangpin_nor"), selectedImage: UIImage(named: "tab_btn_shangpin_hig"))
// v3.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "工作中心", image: UIImage(named: "tab_btn_gongzuo_nor"), selectedImage: UIImage(named: "tab_btn_gongzuo_hig")) v3.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "工作中心", image: UIImage(named: "tab_btn_gongzuo_nor"), selectedImage: UIImage(named: "tab_btn_gongzuo_hig"))
v4.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "仓库管理", image: UIImage(named: "tab_btn_cangku_nor"), selectedImage: UIImage(named: "tab_btn_cangku_hig")) v4.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "仓库管理", image: UIImage(named: "tab_btn_cangku_nor"), selectedImage: UIImage(named: "tab_btn_cangku_hig"))
v5.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "个人中心", image: UIImage(named: "tab_btn_geren_nor"), selectedImage: UIImage(named: "tab_btn_geren_hig")) v5.tabBarItem = ESTabBarItem.init(ExampleBouncesContentView(), title: "个人中心", image: UIImage(named: "tab_btn_geren_nor"), selectedImage: UIImage(named: "tab_btn_geren_hig"))
// Create the SwiftUI view that provides the window contents. // Create the SwiftUI view that provides the window contents.
// tabBarController.viewControllers = [v1, v2, v3, v4, v5] tabBarController.viewControllers = [v1, v2, v3, v4, v5]
tabBarController.viewControllers = [v1, v2, v4, v5]
// tabBarController.selectedIndex = 2 tabBarController.selectedIndex = 2
let contentView = tabBarController let contentView = tabBarController
// if let windowScene = sceneC as? UIWindowScene { // if let windowScene = sceneC as? UIWindowScene {
if isAgain { if isAgain {
let transtition = CATransition() let transtition = CATransition()
...@@ -176,14 +277,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -176,14 +277,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
window.makeKeyAndVisible() window.makeKeyAndVisible()
} }
// } NotificationCenter.default.addObserver(self, selector: #selector(changgeTabItem(notion:)), name: NSNotification.Name(rawValue: "changgeTabItem"), object: nil)
//测试代码 }
// if let tabBarItem = v2.tabBarItem as? ESTabBarItem { //MARK:--切换tab
// DispatchQueue.main.asyncAfter(deadline: .now() + 2 ) { @objc func changgeTabItem(notion:Notification) {
// tabBarItem.badgeValue = "1" let dic = notion.userInfo
// } tabBarC.selectedIndex = dic!["tag"] as Any as! Int
// }
} }
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
//添加通知,才加载数据 //添加通知,才加载数据
...@@ -226,7 +326,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon ...@@ -226,7 +326,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
// //
// func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// // Override point for customization after application launch. // // Override point for customization after application launch.
//// setting_Jpush(application: application, launchOptions: launchOptions) // setting_Jpush(application: application, launchOptions: launchOptions)
// //
// //
// return true // return true
......
...@@ -37,8 +37,8 @@ class BaseViewController: UIViewController ,NavBarViewDelegate{ ...@@ -37,8 +37,8 @@ class BaseViewController: UIViewController ,NavBarViewDelegate{
self.view.backgroundColor = UIColor(named: "app底色") self.view.backgroundColor = UIColor(named: "app底色")
footerMJ.setTitle("暂无内容", for: .noMoreData) footerMJ.setTitle("暂无内容", for: .noMoreData)
}
}
override func didReceiveMemoryWarning() { override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning() super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
......
...@@ -128,6 +128,9 @@ extension NetworkRequest { ...@@ -128,6 +128,9 @@ extension NetworkRequest {
delay(1.5) { delay(1.5) {
UserDefaults.standard.removeObject(forKey: "user_token") UserDefaults.standard.removeObject(forKey: "user_token")
NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil) NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil)
JPUSHService.deleteAlias({ (resCode, alias, num) in
}, seq: 1433223)
} }
}else if json["code"].intValue == 11 { }else if json["code"].intValue == 11 {
HUD.flash(.label(json["message"].stringValue), delay: 1.5) HUD.flash(.label(json["message"].stringValue), delay: 1.5)
......
...@@ -126,5 +126,7 @@ ...@@ -126,5 +126,7 @@
<string>Warehouse/OutGoodsDetail</string> <string>Warehouse/OutGoodsDetail</string>
<key>手机号登录</key> <key>手机号登录</key>
<string>Passport/mobileLogin</string> <string>Passport/mobileLogin</string>
<key>消息列表</key>
<string>Admin/messageList</string>
</dict> </dict>
</plist> </plist>
...@@ -163,7 +163,17 @@ func saveFile(image: UIImage,_ params:[String:Any],success:@escaping (_ res:Any) ...@@ -163,7 +163,17 @@ func saveFile(image: UIImage,_ params:[String:Any],success:@escaping (_ res:Any)
//MARK:--手机号登 //MARK:--手机号登
//params-key(mobile(手机号),auth_code(登录验证码(必须先发送验证码) )) //params-key(mobile(手机号),auth_code(登录验证码(必须先发送验证码) ))
func mobileLogin(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) { func mobileLogin(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("登录", params, { (rep:DataResponse<LoginModel>) in NetworkRequest.sharedInstance.postRequest("手机号登录", params, { (rep:DataResponse<LoginModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
//MARK:--消息列表
//params-key(user_token)
func messageList(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("消息列表", params, { (rep:DataResponse<MessageListModel>) in
}, success: { (data) in }, success: { (data) in
success(data) success(data)
}) { (error) in }) { (error) in
......
//
// MessageListModel.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/6/2.
// Copyright © 2020 junye lu. All rights reserved.
//
import Foundation
import ObjectMapper
//消息列表
class MessageListModel: Mappable {
var code:Int?
var message : String?
var data : Array<MessageListDataModel>?
required init?( map: Map) {
}
func mapping(map: Map) {
code <- map["code"]
message <- map["message"]
data <- map["data"]
}
}
class MessageListDataModel: Mappable {
var pm_id : Int? //消息id
var message : String? //消息内容
var create_time : Double? //时间
var shop_id : Int?
var title : String? //消息标题
required init?( map: Map) {
}
func mapping(map: Map) {
pm_id <- map["pm_id"]
message <- map["message"]
create_time <- map["create_time"]
shop_id <- map["shop_id"]
title <- map["title"]
}
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="120" id="KGk-i7-Jjw" customClass="MsgCenterCell" customModule="GeliBusinessPlatform" customModuleProvider="target"> <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="120" id="KGk-i7-Jjw" customClass="MsgCenterCell" customModule="TestClass" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="120"/> <rect key="frame" x="0.0" y="0.0" width="375" height="120"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
<rect key="frame" x="220" y="18.5" width="110" height="11"/> <rect key="frame" x="220" y="18.5" width="110" height="11"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="11" id="nxW-7d-8Z8"/> <constraint firstAttribute="height" constant="11" id="nxW-7d-8Z8"/>
<constraint firstAttribute="width" constant="110" id="ubi-9M-h88"/>
</constraints> </constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/> <fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" name="灰色字体颜色"/> <color key="textColor" name="灰色字体颜色"/>
......
...@@ -74,6 +74,13 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -74,6 +74,13 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
make.height.equalTo(20) make.height.equalTo(20)
} }
*/ */
NotificationCenter.default.addObserver(self, selector: #selector(jpushServiceNotification(notion:)), name: NSNotification.Name(rawValue: "jpushServiceNotification4"), object: nil)
}
//MARK:--jpushServiceNotification
@objc func jpushServiceNotification(notion:Notification) {
let vc = MsgCenterViewController()
self.navigationController?.pushViewController(vc, animated: true)
} }
//MARK: -方法 //MARK: -方法
@IBAction func editAction(_ sender: Any) { @IBAction func editAction(_ sender: Any) {
...@@ -89,9 +96,8 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -89,9 +96,8 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
//MARK:--跳转消息中心 //MARK:--跳转消息中心
@IBAction func toMsgCenterAction(_ sender: Any) { @IBAction func toMsgCenterAction(_ sender: Any) {
print("跳转消息中心") print("跳转消息中心")
HUD.flash(.label("敬请期待"),delay: 1.2) let vc = MsgCenterViewController()
// let vc = MsgCenterViewController() self.navigationController?.pushViewController(vc, animated: true)
// self.navigationController?.pushViewController(vc, animated: true)
} }
//MARK: -Cell delegate方法 //MARK: -Cell delegate方法
......
...@@ -44,8 +44,14 @@ class WarehoseMangementListVC: BaseViewController, UISearchBarDelegate, UITableV ...@@ -44,8 +44,14 @@ class WarehoseMangementListVC: BaseViewController, UISearchBarDelegate, UITableV
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData)) footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
self.tableV!.mj_footer = footerMJ self.tableV!.mj_footer = footerMJ
self.tableV?.mj_header?.beginRefreshing() self.tableV?.mj_header?.beginRefreshing()
} NotificationCenter.default.addObserver(self, selector: #selector(jpushServiceNotification(notion:)), name: NSNotification.Name(rawValue: "jpushServiceNotification3"), object: nil)
}
//MARK:--jpushServiceNotification
@objc func jpushServiceNotification(notion:Notification) {
let vc = MsgCenterViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
@objc func loadData(){ @objc func loadData(){
print("加载数据") print("加载数据")
isUpData = true isUpData = true
......
...@@ -84,8 +84,14 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -84,8 +84,14 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData)) footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
self.collection!.mj_footer = footerMJ self.collection!.mj_footer = footerMJ
self.collection?.mj_header?.beginRefreshing() self.collection?.mj_header?.beginRefreshing()
NotificationCenter.default.addObserver(self, selector: #selector(jpushServiceNotification(notion:)), name: NSNotification.Name(rawValue: "jpushServiceNotification1"), object: nil)
} }
//MARK:--jpushServiceNotification
@objc func jpushServiceNotification(notion:Notification) {
let vc = MsgCenterViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK:--整理排序数据 //MARK:--整理排序数据
func getSortData (){ func getSortData (){
for i in 0..<selectIndexArr.count{ for i in 0..<selectIndexArr.count{
......
...@@ -48,6 +48,13 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD ...@@ -48,6 +48,13 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setTabv() setTabv()
NotificationCenter.default.addObserver(self, selector: #selector(jpushServiceNotification(notion:)), name: NSNotification.Name(rawValue: "jpushServiceNotification2"), object: nil)
}
//MARK:--jpushServiceNotification
@objc func jpushServiceNotification(notion:Notification) {
let vc = MsgCenterViewController()
self.navigationController?.pushViewController(vc, animated: true)
} }
//MARK:--二维码方法 //MARK:--二维码方法
@IBAction func codeAction(_ sender: UIButton) { @IBAction func codeAction(_ sender: UIButton) {
......
...@@ -13,7 +13,7 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -13,7 +13,7 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
//MARK: -animateView //MARK: -animateView
private let animations = AnimationType.from(direction: .bottom, offset: 150) private let animations = [AnimationType.from(direction: .bottom, offset: 300*glscale)]
var msgTbv:UITableView? var msgTbv:UITableView?
...@@ -35,7 +35,66 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -35,7 +35,66 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
}) })
msgTbv?.register(UINib(nibName: "MsgCenterCell", bundle: nil), forCellReuseIdentifier: "MsgCenterCell") msgTbv?.register(UINib(nibName: "MsgCenterCell", bundle: nil), forCellReuseIdentifier: "MsgCenterCell")
//下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
self.msgTbv!.mj_header = headerMJ
//上拉加载相关设置
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
self.msgTbv!.mj_footer = footerMJ
self.msgTbv?.mj_header?.beginRefreshing()
}
var dataModelArr:Array<MessageListDataModel> = []
var page = 1
//加载数据
@objc func loadData(){
page = 1
let UserToken = UserDefaults.standard.value(forKey: "user_token")
messageList(["page":page as Any,"user_token":UserToken as Any], success: { (data) in
let dataM = data as! MessageListModel
self.dataModelArr.removeAll()
dataM.data?.forEach({ (model) in
self.dataModelArr.append(model)
})
self.msgTbv?.reloadData()
self.page = 2
self.msgTbv?.mj_header?.endRefreshing()
self.msgTbv?.performBatchUpdates({
UIView.animate(views: self.msgTbv!.visibleCells,
animations: self.animations, completion: {
})
}, completion: nil)
if dataM.data?.count == 0 {
self.msgTbv?.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.msgTbv?.mj_footer?.endRefreshing()
}
}) { (error) in
self.msgTbv?.mj_header?.endRefreshing()
}
}
//加载更多数据
@objc func loadMoreData() {
let UserToken = UserDefaults.standard.value(forKey: "user_token")
messageList(["page":page as Any,"user_token":UserToken as Any], success: { (data) in
let dataM = data as! MessageListModel
if dataM.data?.count == 0 {
self.msgTbv?.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.page += 1
dataM.data?.forEach({ (model) in
self.dataModelArr.append(model)
})
self.msgTbv?.reloadData()
self.msgTbv?.mj_footer?.endRefreshing()
}
}) { (error) in
self.msgTbv?.mj_footer?.endRefreshing()
}
} }
...@@ -44,22 +103,28 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -44,22 +103,28 @@ class MsgCenterViewController: BaseViewController,UITableViewDelegate,UITableVie
return 120 return 120
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10 return self.dataModelArr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MsgCenterCell") as! MsgCenterCell let cell = tableView.dequeueReusableCell(withIdentifier: "MsgCenterCell") as! MsgCenterCell
if cell.isShow == false {//未显示 // if cell.isShow == false {//未显示
cell.titleLbl.showSkeleton(transition: .crossDissolve(0.25)) // cell.titleLbl.showSkeleton(transition: .crossDissolve(0.25))
cell.dateLbl.showSkeleton(transition: .crossDissolve(0.25)) // cell.dateLbl.showSkeleton(transition: .crossDissolve(0.25))
cell.contentLbl.showSkeleton(transition: .crossDissolve(0.25)) // cell.contentLbl.showSkeleton(transition: .crossDissolve(0.25))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) { // DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) {
cell.isShow = true//已显示 // cell.isShow = true//已显示
cell.titleLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25)) // cell.titleLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25))
cell.dateLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25)) // cell.dateLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25))
cell.contentLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25)) // cell.contentLbl.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25))
} // }
} // }
let rowModel = self.dataModelArr[indexPath.row]
cell.titleLbl.text = rowModel.title
cell.dateLbl.text = TimeByDouble(sender: rowModel.create_time!)
cell.contentLbl.text = rowModel.message
return cell return cell
} }
......
...@@ -201,9 +201,9 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel ...@@ -201,9 +201,9 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
self.delegate?.successLogin() self.delegate?.successLogin()
// JPUSHService.setAlias(self.phoneTF.text, completion: { (resCode, alias, num) in JPUSHService.setAlias(dataM.data?.user_token, completion: { (resCode, alias, num) in
//
// }, seq: 1433223) }, seq: 1433223)
}) { (error) in }) { (error) in
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
} }
...@@ -230,9 +230,10 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel ...@@ -230,9 +230,10 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
self.delegate?.successLogin() self.delegate?.successLogin()
// JPUSHService.setAlias(self.phoneTF.text, completion: { (resCode, alias, num) in JPUSHService.setAlias(dataM.data?.user_token, completion: { (resCode, alias, num) in
//
// }, seq: 1433223) }, seq: 1433223)
}) { (error) in }) { (error) in
self.loginBtn.isLoading = false self.loginBtn.isLoading = false
} }
......
...@@ -68,6 +68,13 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa ...@@ -68,6 +68,13 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa
//MARK:--添加个刷新通知 //MARK:--添加个刷新通知
NotificationCenter.default.addObserver(self, selector: #selector(refreshingByOrderHavChange), name: NSNotification.Name(rawValue: "orderChange"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(refreshingByOrderHavChange), name: NSNotification.Name(rawValue: "orderChange"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(jpushServiceNotification(notion:)), name: NSNotification.Name(rawValue: "jpushServiceNotification0"), object: nil)
}
//MARK:--jpushServiceNotification
@objc func jpushServiceNotification(notion:Notification) {
let vc = MsgCenterViewController()
self.navigationController?.pushViewController(vc, animated: true)
} }
@objc func refreshingByOrderHavChange(){ @objc func refreshingByOrderHavChange(){
viewControllers.forEach { (vc) in viewControllers.forEach { (vc) in
......
...@@ -53,9 +53,10 @@ class AccountViewController: BaseViewController{ ...@@ -53,9 +53,10 @@ class AccountViewController: BaseViewController{
print("退出登录") print("退出登录")
//模拟退出登录 //模拟退出登录
UserDefaults.standard.removeObject(forKey: "user_token") UserDefaults.standard.removeObject(forKey: "user_token")
// UserDefaults.standard.synchronize()
NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil) NotificationCenter.default.post(name: Notification.Name(rawValue: "logout"), object: nil)
JPUSHService.deleteAlias({ (resCode, alias, num) in
}, seq: 1433223)
} }
} }
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