Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
AoleiSports
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 5ea859e5
由
ilCode
编写于
2024-06-21 18:21:30 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
情报功能
1 个父辈
63e4bec0
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
486 行增加
和
16 行删除
AoleiSports.xcodeproj/project.pbxproj
AoleiSports/Src/Information/InfoController.swift
AoleiSports/Src/Information/InfoDetailController.swift
AoleiSports/Src/Information/InfoModel.swift
AoleiSports/Src/Information/JcInfoDetailModel.swift
AoleiSports/Src/Information/MatchInfoCell.swift
AoleiSports/Src/Information/MatchInfoDetailCell.swift
AoleiSports/Src/User/LoginController.swift
AoleiSports/Src/User/UserManager.swift
AoleiSports/Src/User/UserModel.swift
AoleiSports/Src/User/UserProvider.swift
AoleiSports/Src/Utils/AppInfo.swift
AoleiSports/Src/Utils/DateTools.swift
AoleiSports/Src/Utils/ServerApi.swift
AoleiSports/Src/Utils/UserDefaultTools.swift
AoleiSports.xcodeproj/project.pbxproj
查看文件 @
5ea859e
...
...
@@ -71,7 +71,10 @@
5E9A1A502C0F1F5200321AC5 /* R.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9A1A4F2C0F1F5200321AC5 /* R.generated.swift */; };
5E9A1A522C0F205A00321AC5 /* LeagueController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9A1A512C0F205A00321AC5 /* LeagueController.swift */; };
5EA670622C104D2800CEEA01 /* LoggerTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EA670612C104D2800CEEA01 /* LoggerTools.swift */; };
5EA9FDCB2C25690100654E93 /* MatchInfoDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EA9FDCA2C25690100654E93 /* MatchInfoDetailCell.swift */; };
5EA9FDCD2C256C4A00654E93 /* JcInfoDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EA9FDCC2C256C4A00654E93 /* JcInfoDetailModel.swift */; };
5EAA223F2C17F87800404739 /* UIView+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EAA223E2C17F87800404739 /* UIView+Ext.swift */; };
5EB4F8B22C23D1B300A3667D /* DateTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB4F8B12C23D1B300A3667D /* DateTools.swift */; };
5EC03E4A2C1155530068A5CB /* NetworkTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E492C1155530068A5CB /* NetworkTools.swift */; };
5EC03E4E2C1155720068A5CB /* CacheTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4D2C1155720068A5CB /* CacheTools.swift */; };
5EC03E502C118A420068A5CB /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4F2C118A420068A5CB /* AppInfo.swift */; };
...
...
@@ -151,7 +154,10 @@
5E9A1A4F2C0F1F5200321AC5 /* R.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = R.generated.swift; sourceTree = SOURCE_ROOT; };
5E9A1A512C0F205A00321AC5 /* LeagueController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeagueController.swift; sourceTree = "<group>"; };
5EA670612C104D2800CEEA01 /* LoggerTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerTools.swift; sourceTree = "<group>"; };
5EA9FDCA2C25690100654E93 /* MatchInfoDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchInfoDetailCell.swift; sourceTree = "<group>"; };
5EA9FDCC2C256C4A00654E93 /* JcInfoDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JcInfoDetailModel.swift; sourceTree = "<group>"; };
5EAA223E2C17F87800404739 /* UIView+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Ext.swift"; sourceTree = "<group>"; };
5EB4F8B12C23D1B300A3667D /* DateTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTools.swift; sourceTree = "<group>"; };
5EC03E492C1155530068A5CB /* NetworkTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkTools.swift; sourceTree = "<group>"; };
5EC03E4D2C1155720068A5CB /* CacheTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheTools.swift; sourceTree = "<group>"; };
5EC03E4F2C118A420068A5CB /* AppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; };
...
...
@@ -209,6 +215,8 @@
5E47C9782C20157C002EA39E /* InfoDetailController.swift */,
5E47C9742C1FD35E002EA39E /* InfoProvider.swift */,
5E47C9762C1FD7F6002EA39E /* InfoModel.swift */,
5EA9FDCA2C25690100654E93 /* MatchInfoDetailCell.swift */,
5EA9FDCC2C256C4A00654E93 /* JcInfoDetailModel.swift */,
);
path = Information;
sourceTree = "<group>";
...
...
@@ -360,6 +368,7 @@
5EC03E4F2C118A420068A5CB /* AppInfo.swift */,
5E1E66AF2C194337009339F0 /* LayoutTools.swift */,
5E65F8962C22CAF40082D374 /* UserDefaultTools.swift */,
5EB4F8B12C23D1B300A3667D /* DateTools.swift */,
);
path = Utils;
sourceTree = "<group>";
...
...
@@ -581,8 +590,10 @@
5E9A1A292C0EF51600321AC5 /* GKNavigationBarDefine.swift in Sources */,
5E9A1A4E2C0F1A2E00321AC5 /* FontTools.swift in Sources */,
5E66B2D92C1C295100590452 /* UIButton+Ext.swift in Sources */,
5EA9FDCD2C256C4A00654E93 /* JcInfoDetailModel.swift in Sources */,
5E9A1A502C0F1F5200321AC5 /* R.generated.swift in Sources */,
5E1E66B42C19AAC7009339F0 /* UpdateProfileController.swift in Sources */,
5EA9FDCB2C25690100654E93 /* MatchInfoDetailCell.swift in Sources */,
5E93B4882C1A7DA200CD6536 /* BaseTableViewCell.swift in Sources */,
5E9A1A272C0EF51600321AC5 /* GKBaseAnimatedTransition.swift in Sources */,
5EC6E64E2C2192C9006F778C /* MatchInfoCell.swift in Sources */,
...
...
@@ -591,6 +602,7 @@
5EAA223F2C17F87800404739 /* UIView+Ext.swift in Sources */,
5E93B48A2C1A935F00CD6536 /* PrivacyController.swift in Sources */,
5E9A1A262C0EF51600321AC5 /* Bundle+GKExtension.swift in Sources */,
5EB4F8B22C23D1B300A3667D /* DateTools.swift in Sources */,
5E9A1A2E2C0EF51600321AC5 /* GKPushAnimatedTransition.swift in Sources */,
5E66B2D72C1BE2ED00590452 /* UIImage+Ext.swift in Sources */,
5E9A1A302C0EF51600321AC5 /* UIImage+GKExtension.swift in Sources */,
...
...
AoleiSports/Src/Information/InfoController.swift
查看文件 @
5ea859e
...
...
@@ -17,7 +17,6 @@ class InfoController: BaseController {
let
tv
=
UITableView
(
frame
:
CGRect
(
x
:
0
,
y
:
kNavBarH
,
width
:
kScreenW
,
height
:
kScreenH
-
kNavBarH
-
kTabBarH
),
style
:
.
plain
)
tv
.
delegate
=
self
tv
.
dataSource
=
self
tv
.
rowHeight
=
100
tv
.
backgroundColor
=
kMainBgColor
tv
.
register
(
MatchInfoCell
.
self
,
forCellReuseIdentifier
:
MatchInfoCellId
)
tv
.
es
.
addPullToRefresh
(
animator
:
RefreshHeaderAnimator
(
frame
:
.
zero
))
{
[
weak
self
]
in
...
...
@@ -103,8 +102,10 @@ extension InfoController: UITableViewDelegate, UITableViewDataSource {
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
let
model
=
provider
?
.
infoDataList
.
value
[
indexPath
.
row
]
let
infoDetail
=
InfoDetailController
()
infoDetail
.
model
=
provider
?
.
infoDataList
.
value
[
indexPath
.
row
]
infoDetail
.
model
=
model
infoDetail
.
groupDatas
=
JcInfoDetailGroupModel
.
assembleGroupData
(
infoModel
:
model
)
navigationController
?
.
pushViewController
(
infoDetail
,
animated
:
true
)
}
}
AoleiSports/Src/Information/InfoDetailController.swift
查看文件 @
5ea859e
...
...
@@ -10,10 +10,117 @@ import UIKit
// 情报详情页面
class
InfoDetailController
:
BaseController
{
var
model
:
InfoModel
?
var
groupDatas
:
[
JcInfoDetailGroupModel
]
=
[]
private
let
MatchInfoDetailCellId
=
"MatchInfoDetailCellId"
private
lazy
var
topTitleLab
:
UILabel
=
{
let
lab
=
UILabel
()
lab
.
text
=
model
?
.
getTopTitle
()
lab
.
textColor
=
kMainTitleColor
lab
.
font
=
kFontSize
(
16
)
return
lab
}()
private
lazy
var
hotTagLab
:
UILabel
=
{
let
lab
=
UILabel
()
lab
.
text
=
"热门"
lab
.
textColor
=
kWhite
lab
.
textAlignment
=
.
center
lab
.
font
=
kFontSize
(
16
)
lab
.
backgroundColor
=
UIColor
.
colorWith
(
hexString
:
"FFBC81"
)
return
lab
}()
private
lazy
var
header
:
UIView
=
{
let
view
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
kScreenW
,
height
:
40
))
view
.
backgroundColor
=
UIColor
.
colorWith
(
hexString
:
"F9F9F9"
)
view
.
addSubview
(
topTitleLab
)
view
.
addSubview
(
hotTagLab
)
topTitleLab
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
offset
(
10
)
make
.
centerY
.
equalToSuperview
()
}
hotTagLab
.
snp
.
makeConstraints
{
make
in
make
.
right
.
equalToSuperview
()
.
offset
(
-
10
)
make
.
centerY
.
equalToSuperview
()
make
.
size
.
equalTo
(
CGSize
(
width
:
46
,
height
:
24
))
}
return
view
}()
private
lazy
var
infoDetailView
:
UITableView
=
{
let
tv
=
UITableView
(
frame
:
CGRect
(
x
:
0
,
y
:
kNavBarH
,
width
:
kScreenW
,
height
:
kScreenH
-
kNavBarH
),
style
:
.
grouped
)
tv
.
dataSource
=
self
tv
.
delegate
=
self
tv
.
tableHeaderView
=
header
tv
.
backgroundColor
=
kMainBgColor
tv
.
showsVerticalScrollIndicator
=
false
tv
.
register
(
MatchInfoDetailCell
.
self
,
forCellReuseIdentifier
:
MatchInfoDetailCellId
)
return
tv
}()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navTitle
=
(
model
?
.
hostName
??
""
)
+
"VS"
+
(
model
?
.
guestName
??
""
)
gk_navLineHidden
=
true
view
.
addSubview
(
infoDetailView
)
}
}
//MARK: - UITableViewDataSource
extension
InfoDetailController
:
UITableViewDataSource
,
UITableViewDelegate
{
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
groupDatas
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
let
groupModel
=
groupDatas
[
section
]
return
groupModel
.
infos
?
.
count
??
0
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
groupModel
=
groupDatas
[
indexPath
.
section
]
let
info
=
groupModel
.
infos
?[
indexPath
.
row
]
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
MatchInfoDetailCellId
,
for
:
indexPath
)
as!
MatchInfoDetailCell
cell
.
info
=
info
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
groupModel
=
groupDatas
[
section
]
var
headerH
=
0.001
if
let
groupTitle
=
groupModel
.
title
,
!
groupTitle
.
isEmpty
{
headerH
=
30
}
let
headSecView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
kScreenW
,
height
:
headerH
))
headSecView
.
backgroundColor
=
kWhite
let
groupTitleLab
=
UILabel
(
frame
:
CGRect
(
x
:
30
,
y
:
0
,
width
:
kScreenW
-
60
,
height
:
headerH
))
groupTitleLab
.
text
=
groupModel
.
title
groupTitleLab
.
textColor
=
kMainTitleColor
groupTitleLab
.
font
=
kBoldFontSize
(
18
)
headSecView
.
addSubview
(
groupTitleLab
)
return
headSecView
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
10
,
height
:
0.001
))
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
let
groupModel
=
groupDatas
[
section
]
if
let
title
=
groupModel
.
title
,
!
title
.
isEmpty
{
return
30
}
return
0.001
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
return
0.001
}
}
AoleiSports/Src/Information/InfoModel.swift
查看文件 @
5ea859e
...
...
@@ -26,9 +26,12 @@ class InfoModel: Mappable {
var
matchRound
:
String
?
var
sportsInfoCount
:
Int
?
var
jcInfo
:
String
?
var
temperature
:
String
?
var
hostTeam
:
[
String
:
Any
]?
var
guestTeam
:
[
String
:
Any
]?
var
isLast
:
Bool
?
required
init
?(
map
:
ObjectMapper
.
Map
)
{
}
...
...
@@ -53,5 +56,92 @@ class InfoModel: Mappable {
matchRound
<-
map
[
"MatchRound"
]
sportsInfoCount
<-
map
[
"SportsInfoCount"
]
jcInfo
<-
map
[
"JcInfo"
]
temperature
<-
map
[
"Temperature"
]
hostTeam
<-
map
[
"HostTeam"
]
guestTeam
<-
map
[
"GuestTeam"
]
}
func
getGameAndNumInfo
()
->
String
{
let
game
=
gameName
??
""
let
issue
=
DateTools
.
dayOfWeek
(
from
:
issueName
)
let
number
=
matchNumber
??
""
return
"
\(
game
)
\(
issue
+
number
)
"
}
func
getTemperatureInfo
()
->
NSAttributedString
{
guard
let
temperature
=
temperature
,
!
temperature
.
isEmpty
else
{
return
NSAttributedString
()
}
let
fullText
=
"温度:
\(
temperature
)
"
let
attributedString
=
NSMutableAttributedString
(
string
:
fullText
)
let
temperatureTextRange
=
NSRange
(
location
:
0
,
length
:
"温度:"
.
count
)
let
temperatureValueRange
=
NSRange
(
location
:
"温度:"
.
count
,
length
:
temperature
.
count
)
attributedString
.
addAttribute
(
.
foregroundColor
,
value
:
UIColor
.
colorWith
(
hexString
:
"999999"
),
range
:
temperatureTextRange
)
attributedString
.
addAttribute
(
.
foregroundColor
,
value
:
kMainTitleColor
,
range
:
temperatureValueRange
)
return
attributedString
}
func
getHostTeamIcon
()
->
String
{
guard
let
hostTeam
=
hostTeam
,
let
logoFullPath
=
hostTeam
[
"LogoFullPath"
]
as?
String
else
{
return
""
}
return
logoFullPath
}
func
getGuestTeamIcon
()
->
String
{
guard
let
guestTeam
=
guestTeam
,
let
logoFullPath
=
guestTeam
[
"LogoFullPath"
]
as?
String
else
{
return
""
}
return
logoFullPath
}
func
getFormatMatchTime
(
format
:
String
=
"HH:mm"
)
->
String
{
// 检查输入字符串是否为非空
guard
let
oriTime
=
matchTime
else
{
return
""
}
// 创建日期格式化器来解析 ISO 8601 格式的日期
let
isoDateFormatter
=
ISO8601DateFormatter
()
isoDateFormatter
.
formatOptions
=
[
.
withInternetDateTime
,
.
withFractionalSeconds
]
guard
let
date
=
isoDateFormatter
.
date
(
from
:
oriTime
)
else
{
return
""
}
// 创建日期格式化器来格式化日期为目标格式
let
targetDateFormatter
=
DateFormatter
()
targetDateFormatter
.
dateFormat
=
format
// 返回格式化后的日期字符串
return
targetDateFormatter
.
string
(
from
:
date
)
}
// 获取情报详情
func
getJcInfoDetail
()
->
JcInfoDetailModel
?
{
let
tmpJcInfo
=
jcInfo
??
"{}"
if
let
jsonData
=
tmpJcInfo
.
data
(
using
:
.
utf8
)
{
do
{
let
jsonObj
=
try
JSONSerialization
.
jsonObject
(
with
:
jsonData
,
options
:
[])
as?
[
String
:
Any
]
??
[:]
return
JcInfoDetailModel
(
JSON
:
jsonObj
)
}
catch
{
return
nil
}
}
return
nil
}
func
getTopTitle
()
->
String
{
let
game
=
gameName
??
""
let
matchTime
=
getFormatMatchTime
(
format
:
"MM-dd HH:mm"
)
return
game
+
" "
+
matchTime
}
}
AoleiSports/Src/Information/JcInfoDetailModel.swift
0 → 100644
查看文件 @
5ea859e
//
// JcInfoDetailModel.swift
// AoleiSports
//
// Created by ilCode on 2024/6/21.
//
import
Foundation
struct
JcInfoDetailModel
:
Mappable
{
var
predictionDesc
:
[
String
]?
var
hostGood
:
[
String
]?
var
hostBad
:
[
String
]?
var
guestGood
:
[
String
]?
var
guestBad
:
[
String
]?
init
?(
map
:
ObjectMapper
.
Map
)
{
}
mutating
func
mapping
(
map
:
ObjectMapper
.
Map
)
{
predictionDesc
<-
map
[
"PredictionDesc"
]
hostGood
<-
map
[
"HostGood"
]
hostBad
<-
map
[
"HostBad"
]
guestGood
<-
map
[
"GuestGood"
]
guestBad
<-
map
[
"GuestBad"
]
}
func
getHostInfoCount
()
->
Int
{
let
hostGoodCount
=
(
hostGood
??
[])
.
count
let
hostBadCount
=
(
hostBad
??
[])
.
count
let
hostTotalCount
=
hostGoodCount
+
hostBadCount
return
hostTotalCount
}
func
getGuestInfoCount
()
->
Int
{
let
guestGoodCount
=
(
guestGood
??
[])
.
count
let
guestBadCount
=
(
guestBad
??
[])
.
count
let
guestTotalCount
=
guestGoodCount
+
guestBadCount
return
guestTotalCount
}
func
getHostOrGuestInfoCountStr
(
isHost
:
Bool
=
true
)
->
String
{
let
infoCount
=
isHost
?
getHostInfoCount
()
:
getGuestInfoCount
()
return
infoCount
>
0
?
"[
\(
infoCount
)
]"
:
""
}
func
getTotalInfoCountStr
()
->
String
{
let
host
=
getHostInfoCount
()
let
mid
=
(
predictionDesc
??
[])
.
count
let
guest
=
getGuestInfoCount
()
return
(
host
+
mid
+
guest
)
>
0
?
"共
\(
host
+
mid
+
guest
)
条情报"
:
""
}
func
getOneHostOrGuestInfo
(
isHost
:
Bool
=
true
)
->
String
{
let
good
=
isHost
?
hostGood
:
guestGood
let
bad
=
isHost
?
hostBad
:
guestBad
if
let
tmpGood
=
good
,
let
oneGood
=
tmpGood
.
first
{
return
oneGood
}
if
let
tmpBad
=
bad
,
let
oneBad
=
tmpBad
.
first
{
return
oneBad
}
return
""
}
func
getOneMidInfo
(
isHost
:
Bool
=
true
)
->
String
{
if
let
tmpMid
=
predictionDesc
,
let
oneMid
=
tmpMid
.
first
{
return
oneMid
}
return
""
}
}
struct
JcInfoDetailGroupModel
{
let
title
:
String
?
let
infos
:
[
String
]?
// 组装情报详情分组数据
static
func
assembleGroupData
(
infoModel
:
InfoModel
?)
->
[
JcInfoDetailGroupModel
]
{
guard
let
tmpInfoModel
=
infoModel
,
let
tmpDetailModel
=
tmpInfoModel
.
getJcInfoDetail
(),
let
hostName
=
tmpInfoModel
.
hostName
,
let
guestName
=
tmpInfoModel
.
guestName
else
{
return
[]
}
var
tmpGroupList
:
[
JcInfoDetailGroupModel
]
=
[]
// 中立情报
if
let
midArr
=
tmpDetailModel
.
predictionDesc
,
!
midArr
.
isEmpty
{
tmpGroupList
.
append
(
JcInfoDetailGroupModel
(
title
:
""
,
infos
:
midArr
))
}
// 主队好情报
if
let
hostGoodArr
=
tmpDetailModel
.
hostGood
,
!
hostGoodArr
.
isEmpty
{
tmpGroupList
.
append
(
JcInfoDetailGroupModel
(
title
:
"
\(
hostName
)
有利消息"
,
infos
:
hostGoodArr
))
}
// 主队坏情报
if
let
hostBadArr
=
tmpDetailModel
.
hostBad
,
!
hostBadArr
.
isEmpty
{
tmpGroupList
.
append
(
JcInfoDetailGroupModel
(
title
:
"
\(
hostName
)
不利消息"
,
infos
:
hostBadArr
))
}
// 客队好情报
if
let
guestGoodArr
=
tmpDetailModel
.
guestGood
,
!
guestGoodArr
.
isEmpty
{
tmpGroupList
.
append
(
JcInfoDetailGroupModel
(
title
:
"
\(
guestName
)
有利消息"
,
infos
:
guestGoodArr
))
}
// 客队坏情报
if
let
guestBadArr
=
tmpDetailModel
.
guestBad
,
!
guestBadArr
.
isEmpty
{
tmpGroupList
.
append
(
JcInfoDetailGroupModel
(
title
:
"
\(
guestName
)
不利消息"
,
infos
:
guestBadArr
))
}
return
tmpGroupList
}
}
AoleiSports/Src/Information/MatchInfoCell.swift
查看文件 @
5ea859e
此文件的差异被折叠,
点击展开。
AoleiSports/Src/Information/MatchInfoDetailCell.swift
0 → 100644
查看文件 @
5ea859e
//
// MatchInfoDetailCell.swift
// AoleiSports
//
// Created by ilCode on 2024/6/21.
//
import
UIKit
class
MatchInfoDetailCell
:
BaseTableViewCell
{
private
lazy
var
dotView
:
UIView
=
{
let
view
=
UIView
()
view
.
backgroundColor
=
UIColor
.
colorWith
(
hexString
:
"FFBEC1"
)
view
.
corners
(
radius
:
5
)
return
view
}()
private
lazy
var
infoLab
:
UILabel
=
{
let
lab
=
UILabel
()
lab
.
textColor
=
kMainTitleColor
lab
.
numberOfLines
=
0
lab
.
font
=
kFontSize
(
14
)
return
lab
}()
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
contentView
.
backgroundColor
=
kWhite
contentView
.
addSubview
(
dotView
)
contentView
.
addSubview
(
infoLab
)
dotView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
offset
(
12
)
make
.
left
.
equalToSuperview
()
.
offset
(
10
)
make
.
size
.
equalTo
(
CGSize
(
width
:
10
,
height
:
10
))
}
infoLab
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
offset
(
10
)
make
.
left
.
equalTo
(
dotView
.
snp
.
right
)
.
offset
(
10
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
10
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
10
)
}
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
var
info
:
String
?
{
didSet
{
infoLab
.
text
=
info
}
}
}
AoleiSports/Src/User/LoginController.swift
查看文件 @
5ea859e
...
...
@@ -468,8 +468,22 @@ class LoginController: BaseController {
}
@objc
private
func
guestLoginTapped
()
{
dealReadPrivacy
()
if
!
agreementCheckBox
.
isSelected
{
agreementCheckBox
.
shakeAnimation
()
return
}
view
.
makeToastActivity
(
.
center
)
UserProvider
<
LoginOrRegisterTarget
>.
guestLoginRequest
{
logicResult
in
self
.
view
.
hideToastActivity
()
if
case
.
failure
(
let
failure
)
=
logicResult
{
self
.
view
.
makeToast
(
failure
.
localizedDescription
,
position
:
.
center
)
return
}
self
.
view
.
makeToast
(
"登录成功"
,
position
:
.
center
)
self
.
dismiss
(
animated
:
true
)
}
}
private
func
dealReadPrivacy
()
{
...
...
AoleiSports/Src/User/UserManager.swift
查看文件 @
5ea859e
...
...
@@ -13,7 +13,11 @@ class UserManager {
var
isLogged
:
Bool
{
return
userModel
.
value
!=
nil
}
var
userId
:
Int
?
{
return
userModel
.
value
?
.
userId
}
private(set)
var
userModel
=
BehaviorRelay
<
UserModel
?
>
(
value
:
nil
)
private
init
()
{
...
...
@@ -21,28 +25,29 @@ class UserManager {
}
func
saveUserData
(
userModel
:
UserModel
?)
{
guard
let
tmpUserModel
=
userModel
else
{
guard
let
tmpUserModel
=
userModel
,
let
userId
=
tmpUserModel
.
userId
else
{
return
}
// 更新 BehaviorRelay
self
.
userModel
.
accept
(
tmpUserModel
)
// 保存到 UserDefaults
let
userModelJSON
=
tmpUserModel
.
toJSON
()
if
let
userData
=
try
?
JSONSerialization
.
data
(
withJSONObject
:
userModelJSON
)
{
Defaults
[
\
.
userModelKey
]
=
userData
UserDefaults
.
standard
.
set
(
userData
,
forKey
:
UserDefaultsKeys
.
userModelKey
(
userId
:
userId
))
}
}
func
clearUserData
()
{
self
.
userModel
.
accept
(
nil
)
Defaults
[
\
.
userModelKey
]
=
nil
if
let
tmpUseId
=
userId
{
UserDefaults
.
standard
.
removeObject
(
forKey
:
UserDefaultsKeys
.
userModelKey
(
userId
:
tmpUseId
))
}
}
private
func
loadUserData
()
{
if
let
userData
=
Defaults
[
\
.
userModelKey
],
if
let
tmpUseId
=
userId
,
let
userData
=
UserDefaults
.
standard
.
data
(
forKey
:
UserDefaultsKeys
.
userModelKey
(
userId
:
tmpUseId
)),
let
userModelJSON
=
try
?
JSONSerialization
.
jsonObject
(
with
:
userData
)
as?
[
String
:
Any
],
let
userModel
=
UserModel
(
JSON
:
userModelJSON
)
{
self
.
userModel
.
accept
(
userModel
)
...
...
AoleiSports/Src/User/UserModel.swift
查看文件 @
5ea859e
...
...
@@ -8,16 +8,18 @@
import
Foundation
struct
UserModel
:
Mappable
{
var
userId
:
Int
?
var
appToken
:
String
?
var
usrName
:
String
?
var
mobile
:
String
?
var
faceImageCode
:
String
?
init
?(
map
:
Map
)
{
}
mutating
func
mapping
(
map
:
Map
)
{
userId
<-
map
[
"Id"
]
appToken
<-
map
[
"AppToken"
]
usrName
<-
map
[
"Name"
]
mobile
<-
map
[
"Mobile"
]
...
...
AoleiSports/Src/User/UserProvider.swift
查看文件 @
5ea859e
...
...
@@ -16,6 +16,8 @@ enum LoginOrRegisterTarget: TargetType {
case
mobileCodeLogin
(
mobile
:
String
,
code
:
String
)
// 密码登录
case
pwdLogin
(
name
:
String
,
pwd
:
String
)
// 游客登录
case
guestLogin
// 退出登录
case
logout
...
...
@@ -52,7 +54,16 @@ enum LoginOrRegisterTarget: TargetType {
}
"""
]
return
.
requestParameters
(
parameters
:
parameters
,
encoding
:
JSONEncoding
.
default
)
case
.
guestLogin
:
let
guestId
=
AppInfo
.
getUKey
()
let
parameters
=
[
"query"
:
"""
mutation {
\(
APIs
.
kGuestLogin
)
(open_id: "
\
(
guestId
)
", token: "
\
(
guestId
)
")
}
"""
]
return
.
requestParameters
(
parameters
:
parameters
,
encoding
:
JSONEncoding
.
default
)
case
.
logout
:
let
parameters
=
[
"query"
:
"""
mutation {
...
...
@@ -147,6 +158,28 @@ class UserProvider<Target: TargetType>: BaseMoyaProvider<Target> {
}
}
// 游客登录请求
static
func
guestLoginRequest
(
completion
:
@escaping
(
Result
<
Bool
,
AsError
>
)
->
Void
)
{
moyaPost
(
api
:
APIs
.
kGuestLogin
,
target
:
LoginOrRegisterTarget
.
guestLogin
)
{
midResult
in
DDLogInfo
(
"游客登录请求接口数据:
\(
midResult
)
"
)
switch
midResult
{
case
let
.
success
(
midSuccessResult
):
let
appToken
=
midSuccessResult
[
"AppToken"
]
as?
String
var
resultDic
=
midSuccessResult
[
"Result"
]
as?
[
String
:
Any
]
??
[:]
resultDic
[
"Name"
]
=
"guest"
resultDic
[
"AppToken"
]
=
appToken
let
userModel
=
UserModel
(
JSON
:
resultDic
)
UserManager
.
shared
.
saveUserData
(
userModel
:
userModel
)
completion
(
.
success
(
true
))
case
.
failure
(
let
err
):
completion
(
.
failure
(
err
))
}
}
}
// 退出登录请求
static
func
logoutRequest
(
completion
:
@escaping
(
Result
<
Bool
,
AsError
>
)
->
Void
)
{
moyaPost
(
api
:
APIs
.
kLogout
,
target
:
LoginOrRegisterTarget
.
logout
)
{
midResult
in
...
...
AoleiSports/Src/Utils/AppInfo.swift
查看文件 @
5ea859e
...
...
@@ -19,7 +19,7 @@ struct AppInfo: Codable {
}
static
func
getAppInfo
()
->
String
{
let
info
=
AppInfo
(
uniqueId
:
getUKey
())
let
info
=
AppInfo
(
uniqueId
:
getUKey
())
return
"{
\"
packageName
\"
:
\"\(
info
.
packageName
)\"
,
\"
os
\"
:
\"\(
info
.
os
)\"
,
\"
uniqueId
\"
:
\"\(
info
.
uniqueId
)\"
,
\"
version
\"
:
\"\(
info
.
version
)\"
,
\"
promoterId
\"
:
\"\(
info
.
promoterId
)\"
}"
}
...
...
AoleiSports/Src/Utils/DateTools.swift
0 → 100644
查看文件 @
5ea859e
//
// DateTools.swift
// AoleiSports
//
// Created by ilCode on 2024/6/20.
//
import
Foundation
struct
DateTools
{
// 周几显示
static
func
dayOfWeek
(
from
dateString
:
String
?)
->
String
{
guard
let
dateString
=
dateString
,
!
dateString
.
isEmpty
else
{
return
""
}
let
dateFormatter
:
DateFormatter
=
{
let
formatter
=
DateFormatter
()
formatter
.
dateFormat
=
"yyyy-MM-dd"
return
formatter
}()
guard
let
date
=
dateFormatter
.
date
(
from
:
dateString
)
else
{
return
""
}
let
calendar
=
Calendar
.
current
let
weekday
=
calendar
.
component
(
.
weekday
,
from
:
date
)
let
weekdays
=
[
""
,
"周日"
,
"周一"
,
"周二"
,
"周三"
,
"周四"
,
"周五"
,
"周六"
]
let
tmpWeek
=
weekdays
[
weekday
]
return
tmpWeek
.
count
>
0
?
(
tmpWeek
)
:
""
}
}
AoleiSports/Src/Utils/ServerApi.swift
查看文件 @
5ea859e
...
...
@@ -20,6 +20,8 @@ struct APIs {
static
let
kSmsLogin
=
"ydn_sms_login"
// 密码登录
static
let
kPwdLogin
=
"ydn_login"
// 游客登录
static
let
kGuestLogin
=
"ydn_apple_login"
// 退出登录
static
let
kLogout
=
"ydn_logout"
...
...
AoleiSports/Src/Utils/UserDefaultTools.swift
查看文件 @
5ea859e
...
...
@@ -7,6 +7,8 @@
import
Foundation
extension
DefaultsKeys
{
var
userModelKey
:
DefaultsKey
<
Data
?
>
{
.
init
(
"userModelKey"
)
}
struct
UserDefaultsKeys
{
static
func
userModelKey
(
userId
:
Int
)
->
String
{
"userModelKey_
\(
userId
)
"
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论