Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
a6298044
Commit
a6298044
authored
Sep 07, 2024
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页银河管家逻辑刷新优化
parent
c6ae0625
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
19 deletions
+79
-19
YHButlerServiceManager.swift
...s/ButlerServiceManager(银河管家)/YHButlerServiceManager.swift
+43
-14
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+30
-3
YHOrderTipsView.swift
...y/galaxy/Classes/Modules/Home(首页)/V/YHOrderTipsView.swift
+6
-2
No files found.
galaxy/galaxy/Classes/Modules/ButlerServiceManager(银河管家)/YHButlerServiceManager.swift
View file @
a6298044
...
@@ -37,9 +37,11 @@ class YHButlerServiceManager: NSObject {
...
@@ -37,9 +37,11 @@ class YHButlerServiceManager: NSObject {
let
qyOption
=
QYSDKOption
(
appKey
:
YhConstant
.
QiYuSDK
.
appKey
)
let
qyOption
=
QYSDKOption
(
appKey
:
YhConstant
.
QiYuSDK
.
appKey
)
qyOption
.
appName
=
YhConstant
.
QiYuSDK
.
appName
qyOption
.
appName
=
YhConstant
.
QiYuSDK
.
appName
QYSDK
.
shared
()
.
register
(
with
:
qyOption
)
QYSDK
.
shared
()
.
register
(
with
:
qyOption
)
lastMessage
=
getLastMessage
()
updateSDKAccountInfo
(
completion
:
{
[
weak
self
]
_
in
self
?
.
lastMessage
=
self
?
.
getLastMessage
()
})
}
}
/// 必须在初始化后调用
/// 必须在初始化后调用
func
getLastMessage
()
->
YHButlerServiceMessage
?
{
func
getLastMessage
()
->
YHButlerServiceMessage
?
{
guard
let
message
=
getSessionList
()
.
first
else
{
guard
let
message
=
getSessionList
()
.
first
else
{
...
@@ -84,11 +86,7 @@ class YHButlerServiceManager: NSObject {
...
@@ -84,11 +86,7 @@ class YHButlerServiceManager: NSObject {
return
return
}
}
getUserInfoViewModel
.
getUserInfomation
(
userId
)
{
[
weak
self
]
dataString
,
error
in
getUserInfoViewModel
.
getUserInfomation
(
userId
)
{
[
weak
self
]
dataString
,
error
in
guard
let
dataString
=
dataString
else
{
self
?
.
updateUserInfo
(
userId
:
userId
,
userData
:
dataString
??
""
,
completion
:
{
success
in
completion
(
false
)
return
}
self
?
.
updateUserInfo
(
userId
:
userId
,
userData
:
dataString
,
completion
:
{
success
in
gotoSessionVC
()
gotoSessionVC
()
})
})
}
}
...
@@ -106,20 +104,49 @@ extension YHButlerServiceManager {
...
@@ -106,20 +104,49 @@ extension YHButlerServiceManager {
// MARK: - 私有登录登出的处理逻辑
// MARK: - 私有登录登出的处理逻辑
@objc
private
func
loginSuccess
()
{
@objc
private
func
loginSuccess
()
{
setupInfomationForQiYu
(
completion
:
{
_
in
})
}
@objc
private
func
logoutSuccess
()
{
// 如果登出时需要关闭聊天页
/*
if let controller = QYSDK.shared().sessionViewController(), controller.isViewLoaded && controller.view.window != nil {
controller.closeSession(true) { _, _ in
//
}
}
*/
logoutCurrentUser
{
_
in
//
}
}
private
func
setupInfomationForQiYu
(
completion
:
@escaping
(
Bool
)
->
Void
)
{
guard
let
userId
=
YHLoginManager
.
shared
.
userModel
?
.
id
,
userId
.
count
>
0
else
{
guard
let
userId
=
YHLoginManager
.
shared
.
userModel
?
.
id
,
userId
.
count
>
0
else
{
completion
(
false
)
return
return
}
}
getUserInfoViewModel
.
getUserInfomation
(
userId
)
{
[
weak
self
]
dataString
,
error
in
getUserInfoViewModel
.
getUserInfomation
(
userId
)
{
[
weak
self
]
dataString
,
error
in
guard
let
dataString
=
dataString
else
{
self
?
.
updateUserInfo
(
userId
:
userId
,
userData
:
dataString
??
""
,
completion
:
{
success
in
return
completion
(
success
)
}
})
self
?
.
updateUserInfo
(
userId
:
userId
,
userData
:
dataString
,
completion
:
{
_
in
})
}
}
}
}
@objc
private
func
logoutSuccess
()
{
/// 启动先判断是否当前登录账号是SDK账号,如果不相同,先登出,再用新账号信息写入
logoutCurrentUser
{
_
in
private
func
updateSDKAccountInfo
(
completion
:
@escaping
(
Bool
)
->
Void
)
{
//
guard
let
userId
=
YHLoginManager
.
shared
.
userModel
?
.
id
,
userId
.
count
>
0
,
QYSDK
.
shared
()
.
currentUserID
()
!=
userId
else
{
completion
(
true
)
return
}
logoutCurrentUser
{
[
weak
self
]
success
in
if
success
{
self
?
.
setupInfomationForQiYu
(
completion
:
{
done
in
completion
(
done
)
})
}
else
{
completion
(
success
)
}
}
}
}
}
}
}
...
@@ -146,6 +173,8 @@ extension YHButlerServiceManager {
...
@@ -146,6 +173,8 @@ extension YHButlerServiceManager {
/// 清空未读数
/// 清空未读数
func
clearUnreadCount
()
{
func
clearUnreadCount
()
{
conversationManager
?
.
clearUnreadCount
()
conversationManager
?
.
clearUnreadCount
()
// 清空已读消息后刷新最新消息状态
lastMessage
=
getLastMessage
()
printLog
(
"$$$$clearUnreadCount"
)
printLog
(
"$$$$clearUnreadCount"
)
os_log
(
"#####clearUnreadCount"
)
os_log
(
"#####clearUnreadCount"
)
}
}
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
a6298044
...
@@ -13,6 +13,8 @@ import SmartCodable
...
@@ -13,6 +13,8 @@ import SmartCodable
import
JXSegmentedView
import
JXSegmentedView
class
YHHomePageViewController
:
YHBaseViewController
{
class
YHHomePageViewController
:
YHBaseViewController
{
private
var
needUpdateMgrItem
=
false
private
var
isTopMostAndVisible
=
true
lazy
var
viewModel
:
YHHomePageViewModel
=
{
lazy
var
viewModel
:
YHHomePageViewModel
=
{
let
viewModel
=
YHHomePageViewModel
()
let
viewModel
=
YHHomePageViewModel
()
...
@@ -53,10 +55,28 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -53,10 +55,28 @@ class YHHomePageViewController: YHBaseViewController {
//2、请求新的数据
//2、请求新的数据
getData
()
getData
()
//3、接收七鱼推送通知
setupNotification
()
setupNotification
()
}
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
isTopMostAndVisible
=
false
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
isTopMostAndVisible
=
true
}
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
if
needUpdateMgrItem
{
needUpdateMgrItem
=
false
updateMgrItem
()
}
}
deinit
{
deinit
{
NotificationCenter
.
default
.
removeObserver
(
self
)
NotificationCenter
.
default
.
removeObserver
(
self
)
}
}
...
@@ -72,7 +92,8 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -72,7 +92,8 @@ class YHHomePageViewController: YHBaseViewController {
YHHUD
.
hide
()
YHHUD
.
hide
()
if
success
{
if
success
{
YHButlerServiceManager
.
shared
.
clearUnreadCount
()
YHButlerServiceManager
.
shared
.
clearUnreadCount
()
self
.
updateMgrItem
()
// 需要回到页面再刷新已读,因为不在当前页
self
.
needUpdateMgrItem
=
true
}
}
})
})
}
}
...
@@ -83,6 +104,7 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -83,6 +104,7 @@ class YHHomePageViewController: YHBaseViewController {
//MARK: - 私有方法
//MARK: - 私有方法
private
extension
YHHomePageViewController
{
private
extension
YHHomePageViewController
{
func
updateMgrItem
()
{
func
updateMgrItem
()
{
needUpdateMgrItem
=
false
let
showButler
=
true
let
showButler
=
true
let
serviceMessage
=
YHButlerServiceManager
.
shared
.
lastMessage
let
serviceMessage
=
YHButlerServiceManager
.
shared
.
lastMessage
...
@@ -278,7 +300,12 @@ private extension YHHomePageViewController {
...
@@ -278,7 +300,12 @@ private extension YHHomePageViewController {
}
}
@objc
func
didQiYuReceiveNewMsg
()
{
@objc
func
didQiYuReceiveNewMsg
()
{
updateMgrItem
()
if
!
isTopMostAndVisible
{
// 需要回到页面再刷新已读,因为不在当前页
self
.
needUpdateMgrItem
=
true
}
else
{
updateMgrItem
()
}
}
}
func
setupNotification
()
{
func
setupNotification
()
{
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHOrderTipsView.swift
View file @
a6298044
...
@@ -34,6 +34,7 @@ class YHOrderTipsView: UIView {
...
@@ -34,6 +34,7 @@ class YHOrderTipsView: UIView {
fileprivate
static
let
viewH3
:
CGFloat
=
226.0
fileprivate
static
let
viewH3
:
CGFloat
=
226.0
private
var
orderTipsViewStyle
:
YHOrderTipsViewStyleType
=
.
none
private
var
orderTipsViewStyle
:
YHOrderTipsViewStyleType
=
.
none
private
var
didFirstLayoutItems
=
false
var
tipViewH
:
CGFloat
{
var
tipViewH
:
CGFloat
{
return
orderTipsViewStyle
.
getHeight
()
return
orderTipsViewStyle
.
getHeight
()
...
@@ -65,10 +66,13 @@ class YHOrderTipsView: UIView {
...
@@ -65,10 +66,13 @@ class YHOrderTipsView: UIView {
var
customerServiceMessage
:
YHButlerServiceHomeInfoMessage
?
{
var
customerServiceMessage
:
YHButlerServiceHomeInfoMessage
?
{
didSet
{
didSet
{
updateItems
()
if
let
oldId
=
oldValue
?
.
serviceMessage
?
.
id
,
oldId
.
count
>
0
,
oldId
==
customerServiceMessage
?
.
serviceMessage
?
.
id
,
oldValue
?
.
showButler
==
customerServiceMessage
?
.
showButler
,
oldValue
?
.
serviceMessage
?
.
isRead
!=
customerServiceMessage
?
.
serviceMessage
?
.
isRead
{
if
let
oldId
=
oldValue
?
.
serviceMessage
?
.
id
,
oldId
.
count
>
0
,
oldId
==
customerServiceMessage
?
.
serviceMessage
?
.
id
,
oldValue
?
.
showButler
==
customerServiceMessage
?
.
showButler
,
oldValue
?
.
serviceMessage
?
.
isRead
!=
customerServiceMessage
?
.
serviceMessage
?
.
isRead
{
if
!
didFirstLayoutItems
{
updateItems
()
}
mgrItem
.
updateMessageState
(
didReadMessage
:
customerServiceMessage
?
.
serviceMessage
?
.
isRead
??
true
)
mgrItem
.
updateMessageState
(
didReadMessage
:
customerServiceMessage
?
.
serviceMessage
?
.
isRead
??
true
)
}
else
{
}
else
{
updateItems
()
mgrItem
.
updateManagerTipsItemView
(
message
:
customerServiceMessage
?
.
serviceMessage
?
.
content
,
didReadMessage
:
customerServiceMessage
?
.
serviceMessage
?
.
isRead
==
true
)
mgrItem
.
updateManagerTipsItemView
(
message
:
customerServiceMessage
?
.
serviceMessage
?
.
content
,
didReadMessage
:
customerServiceMessage
?
.
serviceMessage
?
.
isRead
==
true
)
}
}
}
}
...
@@ -286,7 +290,7 @@ private extension YHOrderTipsView {
...
@@ -286,7 +290,7 @@ private extension YHOrderTipsView {
make
.
height
.
equalTo
(
YHOrderTipsItemView
.
viewH
)
make
.
height
.
equalTo
(
YHOrderTipsItemView
.
viewH
)
}
}
}
}
didFirstLayoutItems
=
true
// setNeedsLayout()
// setNeedsLayout()
// layoutIfNeeded()
// layoutIfNeeded()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment