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
f38d9c52
Commit
f38d9c52
authored
Jun 25, 2024
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑接口联调
parent
29d18c60
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
328 additions
and
53 deletions
+328
-53
YHInformationAuthorizationStepOneViewController.swift
...)/C/YHInformationAuthorizationStepOneViewController.swift
+1
-0
YHInformationAuthorizationStepTwoViewController.swift
...)/C/YHInformationAuthorizationStepTwoViewController.swift
+6
-2
YHMyNameCardViewController.swift
.../Modules/Community(社区)/C/YHMyNameCardViewController.swift
+6
-1
YHPeopleViewController.swift
...sses/Modules/Community(社区)/C/YHPeopleViewController.swift
+4
-7
YHMyInformationItemCell.swift
...ses/Modules/Community(社区)/V/YHMyInformationItemCell.swift
+9
-1
YHPeopleSuccessView.swift
...Classes/Modules/Community(社区)/V/YHPeopleSuccessView.swift
+0
-1
YHEditBaseUserInfoViewController.swift
...我的)/MyCard(我的名片)/C/YHEditBaseUserInfoViewController.swift
+18
-2
YHEditHonorViewController.swift
...s/Mine(我的)/MyCard(我的名片)/C/YHEditHonorViewController.swift
+9
-1
YHEditInterestViewController.swift
...ine(我的)/MyCard(我的名片)/C/YHEditInterestViewController.swift
+30
-4
YHEditPersonalProfileViewController.swift
.../MyCard(我的名片)/C/YHEditPersonalProfileViewController.swift
+9
-1
YHEditSchoolViewController.swift
.../Mine(我的)/MyCard(我的名片)/C/YHEditSchoolViewController.swift
+8
-1
YHEditWorkViewController.swift
...es/Mine(我的)/MyCard(我的名片)/C/YHEditWorkViewController.swift
+8
-1
YHEditBaseInfoFootView.swift
...ules/Mine(我的)/MyCard(我的名片)/V/YHEditBaseInfoFootView.swift
+1
-0
YHEditViewModel.swift
...es/Modules/Mine(我的)/MyCard(我的名片)/VM/YHEditViewModel.swift
+140
-1
YHConstantArrayData.swift
galaxy/galaxy/Classes/Tools/Helper/YHConstantArrayData.swift
+12
-12
YHAllApiName.swift
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
+1
-0
YHNetRequest.swift
galaxy/galaxy/Classes/Tools/NetWork/YHNetRequest.swift
+18
-11
YHOSSManager.swift
galaxy/galaxy/Classes/Tools/Upload/YHOSSManager.swift
+48
-7
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/C/YHInformationAuthorizationStepOneViewController.swift
View file @
f38d9c52
...
@@ -195,6 +195,7 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
...
@@ -195,6 +195,7 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
viewModel
.
requestSaveUserInfo
{[
weak
self
]
success
,
error
in
viewModel
.
requestSaveUserInfo
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
vc
=
YHInformationAuthorizationStepTwoViewController
()
let
vc
=
YHInformationAuthorizationStepTwoViewController
()
vc
.
name
=
self
.
viewModel
.
model
.
username
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/C/YHInformationAuthorizationStepTwoViewController.swift
View file @
f38d9c52
...
@@ -16,7 +16,7 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
...
@@ -16,7 +16,7 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
var
items
:
[
YHSettingItem
]
=
[
YHSettingItem
(
type
:
.
normal
,
title
:
"允许您的信息在名片中使用"
,
subTitle
:
"开启后,您的信息将自动同步至您的个人名片,并对您的好友公开可见"
,
isSelect
:
true
,
isShowAlert
:
false
)]
var
items
:
[
YHSettingItem
]
=
[
YHSettingItem
(
type
:
.
normal
,
title
:
"允许您的信息在名片中使用"
,
subTitle
:
"开启后,您的信息将自动同步至您的个人名片,并对您的好友公开可见"
,
isSelect
:
true
,
isShowAlert
:
false
)]
var
viewModel
:
YHInformationAuthorizeViewModel
=
YHInformationAuthorizeViewModel
()
var
viewModel
:
YHInformationAuthorizeViewModel
=
YHInformationAuthorizeViewModel
()
var
stepFlag
:
Bool
=
true
var
stepFlag
:
Bool
=
true
var
name
:
String
=
""
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
setView
()
setView
()
...
@@ -116,7 +116,11 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
...
@@ -116,7 +116,11 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
viewModel
.
requestAuthorizationSubmit
{[
weak
self
]
success
,
error
in
viewModel
.
requestAuthorizationSubmit
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
self
.
navigationController
?
.
popToRootViewController
(
animated
:
true
)
let
view
=
YHPeopleSuccessView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
KScreenHeight
))
view
.
titleLabel
.
text
=
"Hi,
\(
self
.
name
)\n
您的人脉网络已激活"
let
window
=
UIApplication
.
shared
.
yhKeyWindow
()
window
?
.
addSubview
(
view
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/C/YHMyNameCardViewController.swift
View file @
f38d9c52
...
@@ -121,9 +121,11 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -121,9 +121,11 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
if
cardInfo
.
type
==
.
honor
{
if
cardInfo
.
type
==
.
honor
{
let
vc
=
YHEditHonorViewController
()
let
vc
=
YHEditHonorViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
else
if
cardInfo
.
type
==
.
introduce
{
}
else
if
cardInfo
.
type
==
.
introduce
{
let
vc
=
YHEditPersonalProfileViewController
()
let
vc
=
YHEditPersonalProfileViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
}
...
@@ -136,6 +138,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -136,6 +138,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
eduCell
.
editBlock
=
{
[
weak
self
]
in
eduCell
.
editBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
vc
=
YHEditSchoolViewController
()
let
vc
=
YHEditSchoolViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
return
eduCell
return
eduCell
...
@@ -147,6 +150,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -147,6 +150,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
workCell
.
editBlock
=
{
[
weak
self
]
in
workCell
.
editBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
vc
=
YHEditWorkViewController
()
let
vc
=
YHEditWorkViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
return
workCell
return
workCell
...
@@ -158,6 +162,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -158,6 +162,7 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
topicCell
.
editBlock
=
{
[
weak
self
]
in
topicCell
.
editBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
vc
=
YHEditInterestViewController
()
let
vc
=
YHEditInterestViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
return
topicCell
return
topicCell
...
@@ -169,9 +174,9 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -169,9 +174,9 @@ extension YHMyNameCardViewController: UITableViewDelegate, UITableViewDataSource
cell
.
editBlock
=
{
[
weak
self
]
in
cell
.
editBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
vc
=
YHEditBaseUserInfoViewController
()
let
vc
=
YHEditBaseUserInfoViewController
()
vc
.
model
=
self
.
viewModel
.
nameCardInfo
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
return
cell
return
cell
}
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/C/YHPeopleViewController.swift
View file @
f38d9c52
...
@@ -148,14 +148,11 @@ class YHPeopleViewController: YHBaseViewController {
...
@@ -148,14 +148,11 @@ class YHPeopleViewController: YHBaseViewController {
@objc
func
didMatchBtnClicked
()
{
@objc
func
didMatchBtnClicked
()
{
if
true
{
//
if true {
startMatchUsers
()
//
startMatchUsers()
return
//
return
}
//
}
// let view = YHPeopleSuccessView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
// let window = UIApplication.shared.yhKeyWindow()
// window?.addSubview(view)
let
vc
=
YHInformationAuthorizationStepOneViewController
()
let
vc
=
YHInformationAuthorizationStepOneViewController
()
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/V/YHMyInformationItemCell.swift
View file @
f38d9c52
...
@@ -116,6 +116,14 @@ class YHMyInformationItemCell: UITableViewCell {
...
@@ -116,6 +116,14 @@ class YHMyInformationItemCell: UITableViewCell {
titleLabel
.
attributedText
=
questionAttrStr
titleLabel
.
attributedText
=
questionAttrStr
messageTextField
.
placeholder
=
dataSource
.
prompts
messageTextField
.
placeholder
=
dataSource
.
prompts
messageTextField
.
text
=
dataSource
.
message
messageTextField
.
text
=
dataSource
.
message
if
dataSource
.
type
==
.
constellation
{
let
arr
=
YHConstantArrayData
.
arrDegreeConstellation
arr
.
forEach
{
item
in
if
item
[
"id"
]
==
dataSource
.
message
{
messageTextField
.
text
=
item
[
"title"
]
}
}
}
if
dataSource
.
isUserKeyBoard
??
false
{
if
dataSource
.
isUserKeyBoard
??
false
{
nextStepImageView
.
isHidden
=
true
nextStepImageView
.
isHidden
=
true
centerButton
.
isHidden
=
true
centerButton
.
isHidden
=
true
...
@@ -175,7 +183,7 @@ class YHMyInformationItemCell: UITableViewCell {
...
@@ -175,7 +183,7 @@ class YHMyInformationItemCell: UITableViewCell {
case
.
constellation
:
case
.
constellation
:
YHOtherPickerView
.
show
(
type
:
.
constellation
,
selectTitle
:
self
.
dataSource
?
.
message
??
""
)
{
item
in
YHOtherPickerView
.
show
(
type
:
.
constellation
,
selectTitle
:
self
.
dataSource
?
.
message
??
""
)
{
item
in
print
(
item
)
print
(
item
)
self
.
dataSource
?
.
message
=
item
.
title
self
.
dataSource
?
.
message
=
item
.
index
self
.
updateAllViews
()
self
.
updateAllViews
()
if
let
block
=
self
.
block
{
if
let
block
=
self
.
block
{
block
(
self
.
dataSource
??
YHUserInformationModel
())
block
(
self
.
dataSource
??
YHUserInformationModel
())
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/V/YHPeopleSuccessView.swift
View file @
f38d9c52
...
@@ -16,7 +16,6 @@ class YHPeopleSuccessView: UIView {
...
@@ -16,7 +16,6 @@ class YHPeopleSuccessView: UIView {
var
bottomImageView
:
UIImageView
!
var
bottomImageView
:
UIImageView
!
var
bottomButton
:
UIButton
!
var
bottomButton
:
UIButton
!
override
init
(
frame
:
CGRect
)
{
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
backgroundColor
=
UIColor
(
white
:
0.5
,
alpha
:
0.1
)
backgroundColor
=
UIColor
(
white
:
0.5
,
alpha
:
0.1
)
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditBaseUserInfoViewController.swift
View file @
f38d9c52
...
@@ -128,15 +128,31 @@ class YHEditBaseUserInfoViewController: YHBaseViewController {
...
@@ -128,15 +128,31 @@ class YHEditBaseUserInfoViewController: YHBaseViewController {
YHImagePickerView
.
show
()
{[
weak
self
]
image
in
YHImagePickerView
.
show
()
{[
weak
self
]
image
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
photoImageView
.
image
=
image
self
.
photoImageView
.
image
=
image
self
.
viewModel
.
uploadImage
(
image
,
true
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
self
.
model
.
avatar
=
success
??
""
}
}
}
}
}
@objc
func
changeHead
()
{
@objc
func
changeHead
()
{
viewModel
.
requestChangeHead
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
let
url
=
URL
(
string
:
self
.
viewModel
.
model
.
avatar
)
self
.
photoImageView
.
kf
.
setImage
(
with
:
url
)
}
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
self
.
viewModel
.
model
.
signature
=
footView
.
messageTextField
.
text
viewModel
.
requestSaveUserInfo
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditHonorViewController.swift
View file @
f38d9c52
...
@@ -109,7 +109,15 @@ class YHEditHonorViewController: YHBaseViewController {
...
@@ -109,7 +109,15 @@ class YHEditHonorViewController: YHBaseViewController {
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
viewModel
.
model
.
honor
=
messageTextField
.
text
viewModel
.
requestSaveAward
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditInterestViewController.swift
View file @
f38d9c52
...
@@ -12,8 +12,8 @@ import IQKeyboardManagerSwift
...
@@ -12,8 +12,8 @@ import IQKeyboardManagerSwift
class
YHEditInterestViewController
:
YHBaseViewController
{
class
YHEditInterestViewController
:
YHBaseViewController
{
var
collectionView
:
UICollectionView
!
var
collectionView
:
UICollectionView
!
var
nextButton
:
UIButton
!
var
nextButton
:
UIButton
!
var
normalItems
:
[
YHInterestModel
]
=
[
YHInterestModel
(
name
:
"香港子女教育"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港房产"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港创业"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港就业"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"
香港保险"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港商务"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"企业家"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"ENTJ指挥家"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"ENTP辩论家"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"INTJ建筑师
"
,
isNormal
:
true
,
isSelect
:
false
)]
var
normalItems
:
[
YHInterestModel
]
=
[
YHInterestModel
(
name
:
"香港子女教育"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港房产"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港创业"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港就业"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"
港宝"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港保险"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"香港商务"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"ESTP(企业家)"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"ENTJ(指挥官)"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"ENTP(辩论家)"
,
isNormal
:
true
,
isSelect
:
false
),
YHInterestModel
(
name
:
"INTJ(建筑师)
"
,
isNormal
:
true
,
isSelect
:
false
)]
var
likeItems
:
[
YHInterestModel
]
=
[
YHInterestModel
(
name
:
"
ENTP辩论家"
,
isNormal
:
false
,
isSelect
:
false
),
YHInterestModel
(
name
:
"
+自定义"
,
isNormal
:
false
,
isSelect
:
true
)]
var
likeItems
:
[
YHInterestModel
]
=
[
YHInterestModel
(
name
:
"+自定义"
,
isNormal
:
false
,
isSelect
:
true
)]
var
viewModel
:
YHEditViewModel
=
YHEditViewModel
()
var
viewModel
:
YHEditViewModel
=
YHEditViewModel
()
var
model
:
YHUserNameCardInfo
=
YHUserNameCardInfo
()
var
model
:
YHUserNameCardInfo
=
YHUserNameCardInfo
()
...
@@ -38,7 +38,15 @@ class YHEditInterestViewController: YHBaseViewController {
...
@@ -38,7 +38,15 @@ class YHEditInterestViewController: YHBaseViewController {
func
getData
()
{
func
getData
()
{
viewModel
.
model
=
model
viewModel
.
model
=
model
for
item
in
model
.
topics
{
if
let
index
=
normalItems
.
firstIndex
(
where
:
{
$0
.
name
==
item
})
{
normalItems
[
index
]
.
isSelect
=
!
normalItems
[
index
]
.
isSelect
}
else
{
let
model
=
YHInterestModel
(
name
:
item
,
isNormal
:
false
,
isSelect
:
true
)
self
.
likeItems
.
insert
(
model
,
at
:
likeItems
.
count
-
1
)
}
}
collectionView
.
reloadData
()
}
}
func
setView
()
{
func
setView
()
{
...
@@ -113,7 +121,25 @@ class YHEditInterestViewController: YHBaseViewController {
...
@@ -113,7 +121,25 @@ class YHEditInterestViewController: YHBaseViewController {
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
var
topics
:
[
String
]
=
[]
for
item
in
normalItems
{
if
item
.
isSelect
{
topics
.
append
(
item
.
name
)
}
}
for
like
in
likeItems
{
if
like
.
isSelect
&&
like
.
name
!=
"+自定义"
{
topics
.
append
(
like
.
name
)
}
}
viewModel
.
requestSaveTopics
(
topics
:
topics
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
// 计算文字宽度大小
// 计算文字宽度大小
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditPersonalProfileViewController.swift
View file @
f38d9c52
...
@@ -109,7 +109,15 @@ class YHEditPersonalProfileViewController: YHBaseViewController {
...
@@ -109,7 +109,15 @@ class YHEditPersonalProfileViewController: YHBaseViewController {
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
viewModel
.
model
.
bio
=
messageTextField
.
text
viewModel
.
requestSavePersonalProfile
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditSchoolViewController.swift
View file @
f38d9c52
...
@@ -71,7 +71,14 @@ class YHEditSchoolViewController: YHBaseViewController {
...
@@ -71,7 +71,14 @@ class YHEditSchoolViewController: YHBaseViewController {
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
viewModel
.
requestSaveSchool
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/C/YHEditWorkViewController.swift
View file @
f38d9c52
...
@@ -71,7 +71,14 @@ class YHEditWorkViewController: YHBaseViewController {
...
@@ -71,7 +71,14 @@ class YHEditWorkViewController: YHBaseViewController {
}
}
@objc
func
nextStep
()
{
@objc
func
nextStep
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
viewModel
.
requestSaveWork
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
success
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
else
{
YHHUD
.
flash
(
message
:
"保存失败"
)
}
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/V/YHEditBaseInfoFootView.swift
View file @
f38d9c52
...
@@ -137,6 +137,7 @@ extension YHEditBaseInfoFootView: UITextViewDelegate {
...
@@ -137,6 +137,7 @@ extension YHEditBaseInfoFootView: UITextViewDelegate {
}
}
numberLabel
.
text
=
textView
.
text
.
count
.
string
+
"/20"
numberLabel
.
text
=
textView
.
text
.
count
.
string
+
"/20"
}
}
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
let
newLength
=
(
textView
.
text
as
NSString
)
.
length
+
text
.
count
-
range
.
length
let
newLength
=
(
textView
.
text
as
NSString
)
.
length
+
text
.
count
-
range
.
length
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/MyCard(我的名片)/VM/YHEditViewModel.swift
View file @
f38d9c52
...
@@ -10,11 +10,32 @@ import UIKit
...
@@ -10,11 +10,32 @@ import UIKit
class
YHEditViewModel
:
YHBaseViewModel
{
class
YHEditViewModel
:
YHBaseViewModel
{
var
model
:
YHUserNameCardInfo
=
YHUserNameCardInfo
()
var
model
:
YHUserNameCardInfo
=
YHUserNameCardInfo
()
override
init
()
{
override
init
()
{
super
.
init
()
super
.
init
()
}
}
func
requestChangeHead
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
change
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
self
=
self
else
{
return
}
if
json
.
code
==
200
{
let
dic
=
json
.
data
guard
let
result
=
YHChangeHeadModel
.
deserialize
(
from
:
dic
as?
Dictionary
)
else
{
callBackBlock
(
false
,
nil
)
return
}
self
.
model
.
avatar
=
result
.
avatar
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
getBaseDataSource
()
->
[
YHUserInformationModel
]
{
func
getBaseDataSource
()
->
[
YHUserInformationModel
]
{
let
item1
=
YHUserInformationModel
(
id
:
.
id1
,
title
:
"真实姓名"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入您的真实姓名"
,
message
:
model
.
username
)
let
item1
=
YHUserInformationModel
(
id
:
.
id1
,
title
:
"真实姓名"
,
isUserKeyBoard
:
true
,
prompts
:
"请输入您的真实姓名"
,
message
:
model
.
username
)
let
item2
=
YHUserInformationModel
(
id
:
.
id6
,
title
:
"所在地"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择您的所在地"
,
message
:
model
.
address
.
country
,
type
:
.
country
)
let
item2
=
YHUserInformationModel
(
id
:
.
id6
,
title
:
"所在地"
,
isUserKeyBoard
:
false
,
prompts
:
"请选择您的所在地"
,
message
:
model
.
address
.
country
,
type
:
.
country
)
...
@@ -74,4 +95,122 @@ class YHEditViewModel: YHBaseViewModel {
...
@@ -74,4 +95,122 @@ class YHEditViewModel: YHBaseViewModel {
return
[
item1
,
item2
,
item3
]
return
[
item1
,
item2
,
item3
]
}
}
func
requestSaveUserInfo
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
address
:
[
String
:
Any
]
=
[
"country"
:
model
.
address
.
country
,
"province"
:
model
.
address
.
province
,
"city"
:
model
.
address
.
city
]
let
basic
:
[
String
:
Any
]
=
[
"avatar"
:
model
.
avatar
,
"username"
:
model
.
username
,
"zodiac"
:
model
.
zodiac
,
"address"
:
address
,
"signature"
:
model
.
signature
]
let
params
:
[
String
:
Any
]
=
[
"basic_info"
:
basic
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
requestSavePersonalProfile
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
introduction
:
[
String
:
Any
]
=
[
"bio"
:
model
.
bio
]
let
params
:
[
String
:
Any
]
=
[
"introduction"
:
introduction
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
requestSaveWork
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
work
:
[
String
:
Any
]
=
[
"company_name"
:
model
.
companyName
,
"position"
:
model
.
position
,
"industry"
:
model
.
industry
]
let
params
:
[
String
:
Any
]
=
[
"work"
:
work
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
requestSaveSchool
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
education
:
[
String
:
Any
]
=
[
"college"
:
model
.
college
,
"major"
:
model
.
major
,
"background"
:
model
.
background
]
let
params
:
[
String
:
Any
]
=
[
"education"
:
education
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
requestSaveAward
(
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
award
:
[
String
:
Any
]
=
[
"honor"
:
model
.
honor
]
let
params
:
[
String
:
Any
]
=
[
"award"
:
award
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
func
requestSaveTopics
(
topics
:
[
String
],
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
interest
:
[
String
:
Any
]
=
[
"topics"
:
topics
]
let
params
:
[
String
:
Any
]
=
[
"interest"
:
interest
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
People
.
cardSave
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
_
=
self
else
{
return
}
if
json
.
code
==
200
{
callBackBlock
(
true
,
nil
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
false
,
error
)
}
}
failBlock
:
{
err
in
callBackBlock
(
false
,
err
)
}
}
}
}
galaxy/galaxy/Classes/Tools/Helper/YHConstantArrayData.swift
View file @
f38d9c52
...
@@ -372,51 +372,51 @@ class YHConstantArrayData {
...
@@ -372,51 +372,51 @@ class YHConstantArrayData {
static
let
arrDegreeConstellation
=
[
static
let
arrDegreeConstellation
=
[
[
[
"id"
:
"
1
"
,
"id"
:
"
aquarius
"
,
"title"
:
"水瓶座"
,
"title"
:
"水瓶座"
,
],
],
[
[
"id"
:
"
2
"
,
"id"
:
"
pisces
"
,
"title"
:
"双鱼座"
,
"title"
:
"双鱼座"
,
],
],
[
[
"id"
:
"
3
"
,
"id"
:
"
aries
"
,
"title"
:
"白羊座"
,
"title"
:
"白羊座"
,
],
],
[
[
"id"
:
"
4
"
,
"id"
:
"
taurus
"
,
"title"
:
"金牛座"
,
"title"
:
"金牛座"
,
],
],
[
[
"id"
:
"
5
"
,
"id"
:
"
gemini
"
,
"title"
:
"双子座"
,
"title"
:
"双子座"
,
],
],
[
[
"id"
:
"
6
"
,
"id"
:
"
cancer
"
,
"title"
:
"巨蟹座"
,
"title"
:
"巨蟹座"
,
],
],
[
[
"id"
:
"
7
"
,
"id"
:
"
leo
"
,
"title"
:
"狮子座"
,
"title"
:
"狮子座"
,
],
],
[
[
"id"
:
"
8
"
,
"id"
:
"
virgo
"
,
"title"
:
"处女座"
,
"title"
:
"处女座"
,
],
],
[
[
"id"
:
"
9
"
,
"id"
:
"
libra
"
,
"title"
:
"天秤座"
,
"title"
:
"天秤座"
,
],
],
[
[
"id"
:
"
10
"
,
"id"
:
"
scorpio
"
,
"title"
:
"天蝎座"
,
"title"
:
"天蝎座"
,
],
],
[
[
"id"
:
"
11
"
,
"id"
:
"
sagittarius
"
,
"title"
:
"射手座"
,
"title"
:
"射手座"
,
],
],
[
[
"id"
:
"
12
"
,
"id"
:
"
capricorn
"
,
"title"
:
"摩羯座"
,
"title"
:
"摩羯座"
,
],
],
]
]
...
...
galaxy/galaxy/Classes/Tools/NetWork/YHAllApiName.swift
View file @
f38d9c52
...
@@ -332,6 +332,7 @@ class YHAllApiName {
...
@@ -332,6 +332,7 @@ class YHAllApiName {
static
let
authorizationSubmit
=
"super-app/authorization/submit"
static
let
authorizationSubmit
=
"super-app/authorization/submit"
static
let
userInfo
=
"super-app/user-base/info"
static
let
userInfo
=
"super-app/user-base/info"
static
let
userAuthorization
=
"super-app/user/authorization"
static
let
userAuthorization
=
"super-app/user/authorization"
static
let
cardSave
=
"super-app/business-card/save"
}
}
}
}
galaxy/galaxy/Classes/Tools/NetWork/YHNetRequest.swift
View file @
f38d9c52
...
@@ -77,7 +77,8 @@ class YHNetRequest: NSObject {
...
@@ -77,7 +77,8 @@ class YHNetRequest: NSObject {
private
var
headers
:
HTTPHeaders
?
private
var
headers
:
HTTPHeaders
?
/// 数据请求
/// 数据请求
private
var
httpRequest
:
DataRequest
?
private
var
httpRequest
:
DataRequest
?
private
var
businessCode
:
String
=
"4001001"
override
init
()
{
override
init
()
{
super
.
init
()
super
.
init
()
...
@@ -95,7 +96,7 @@ class YHNetRequest: NSObject {
...
@@ -95,7 +96,7 @@ class YHNetRequest: NSObject {
requestHeader
.
add
(
name
:
"app_version"
,
value
:
version
)
requestHeader
.
add
(
name
:
"app_version"
,
value
:
version
)
requestHeader
.
add
(
name
:
"pass"
,
value
:
""
)
requestHeader
.
add
(
name
:
"pass"
,
value
:
""
)
requestHeader
.
add
(
name
:
"businessCode"
,
value
:
"4001001"
)
//
requestHeader.add(name:"businessCode",value:"4001001")
let
appkey
=
"958364f87222c200a72414f492bf0e26"
let
appkey
=
"958364f87222c200a72414f492bf0e26"
let
signOrgiString
=
"appid="
+
"1"
+
"&"
+
"timestamp="
+
dateStr
+
"&"
+
"appkey="
+
appkey
let
signOrgiString
=
"appid="
+
"1"
+
"&"
+
"timestamp="
+
dateStr
+
"&"
+
"appkey="
+
appkey
...
@@ -113,6 +114,11 @@ class YHNetRequest: NSObject {
...
@@ -113,6 +114,11 @@ class YHNetRequest: NSObject {
headers
=
requestHeader
headers
=
requestHeader
}
}
func
businessCode
(
_
code
:
String
)
->
Self
{
self
.
businessCode
=
code
return
self
}
/// 链式语法
/// 链式语法
func
url
(
_
url
:
String
?)
->
Self
{
func
url
(
_
url
:
String
?)
->
Self
{
self
.
url
=
url
??
""
self
.
url
=
url
??
""
...
@@ -163,7 +169,7 @@ class YHNetRequest: NSObject {
...
@@ -163,7 +169,7 @@ class YHNetRequest: NSObject {
return
httpRequest
return
httpRequest
}
}
let
requestHeaders
=
getHeader
()
var
requestHeaders
=
getHeader
()
#if DEBUG
#if DEBUG
printLog
(
"网络请求头数据:"
)
printLog
(
"网络请求头数据:"
)
...
@@ -175,6 +181,7 @@ class YHNetRequest: NSObject {
...
@@ -175,6 +181,7 @@ class YHNetRequest: NSObject {
AF
.
sessionConfiguration
.
timeoutIntervalForRequest
=
20
AF
.
sessionConfiguration
.
timeoutIntervalForRequest
=
20
let
encoding
=
(
self
.
requestType
==
.
get
?
URLEncoding
(
destination
:
.
queryString
)
:
JSONEncoding
())
as
ParameterEncoding
let
encoding
=
(
self
.
requestType
==
.
get
?
URLEncoding
(
destination
:
.
queryString
)
:
JSONEncoding
())
as
ParameterEncoding
requestHeaders
.
add
(
name
:
"businessCode"
,
value
:
businessCode
)
httpRequest
=
AF
.
request
(
self
.
url
!
,
method
:
self
.
requestType
,
parameters
:
self
.
params
,
encoding
:
encoding
,
headers
:
requestHeaders
,
interceptor
:
nil
,
requestModifier
:
nil
)
httpRequest
=
AF
.
request
(
self
.
url
!
,
method
:
self
.
requestType
,
parameters
:
self
.
params
,
encoding
:
encoding
,
headers
:
requestHeaders
,
interceptor
:
nil
,
requestModifier
:
nil
)
httpRequest
?
.
responseString
(
completionHandler
:
{
string
in
httpRequest
?
.
responseString
(
completionHandler
:
{
string
in
...
@@ -372,26 +379,26 @@ class YHNetRequest: NSObject {
...
@@ -372,26 +379,26 @@ class YHNetRequest: NSObject {
}
}
extension
YHNetRequest
{
extension
YHNetRequest
{
class
func
getRequest
(
url
:
String
,
params
:[
String
:
Any
]
=
[:],
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
class
func
getRequest
(
url
:
String
,
params
:[
String
:
Any
]
=
[:],
_
businessCode
:
String
=
"4001001"
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的参数是===> url =
\(
params
)
"
)
printLog
(
"
\n
发起请求的参数是===> url =
\(
params
)
"
)
return
YHNetRequest
()
.
url
(
url
)
.
requestType
(
.
get
)
.
params
(
params
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
startRequest
()
return
YHNetRequest
()
.
businessCode
(
businessCode
)
.
url
(
url
)
.
requestType
(
.
get
)
.
params
(
params
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
startRequest
()
}
}
class
func
postRequest
(
url
:
String
,
params
:[
String
:
Any
]
=
[:],
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
class
func
postRequest
(
url
:
String
,
params
:[
String
:
Any
]
=
[:],
_
businessCode
:
String
=
"4001001"
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的参数是===> url =
\(
params
)
"
)
printLog
(
"
\n
发起请求的参数是===> url =
\(
params
)
"
)
return
YHNetRequest
()
.
url
(
url
)
.
requestType
(
.
post
)
.
params
(
params
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
startRequest
()
return
YHNetRequest
()
.
businessCode
(
businessCode
)
.
url
(
url
)
.
requestType
(
.
post
)
.
params
(
params
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
startRequest
()
}
}
class
func
uplaodRequest
(
url
:
String
,
headers
:
HTTPHeaders
,
image
:
UIImage
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
class
func
uplaodRequest
(
url
:
String
,
headers
:
HTTPHeaders
,
image
:
UIImage
,
_
businessCode
:
String
=
"4001001"
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
return
YHNetRequest
()
.
url
(
url
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
uploadRequest
(
headers
,
image
)
return
YHNetRequest
()
.
businessCode
(
businessCode
)
.
url
(
url
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
uploadRequest
(
headers
,
image
)
}
}
class
func
uplaodFileRequest
(
url
:
String
,
headers
:
HTTPHeaders
,
fileUrl
:
String
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
class
func
uplaodFileRequest
(
url
:
String
,
headers
:
HTTPHeaders
,
fileUrl
:
String
,
_
businessCode
:
String
=
"4001001"
,
successBlock
:
SuccessResultType
!
,
failBlock
:
FailureHandlerType
!
)
->
Request
?
{
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
printLog
(
"
\n
发起请求的URL是===> url =
\(
url
)
"
)
return
YHNetRequest
()
.
url
(
url
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
uploadFileRequest
(
headers
,
fileUrl
)
return
YHNetRequest
()
.
businessCode
(
businessCode
)
.
url
(
url
)
.
success
(
successBlock
)
.
failed
(
failBlock
)
.
uploadFileRequest
(
headers
,
fileUrl
)
}
}
}
}
galaxy/galaxy/Classes/Tools/Upload/YHOSSManager.swift
View file @
f38d9c52
...
@@ -22,6 +22,7 @@ class YHOSSModel: YHBaseModel {
...
@@ -22,6 +22,7 @@ class YHOSSModel: YHBaseModel {
class
YHOSSManager
:
NSObject
,
URLSessionDelegate
{
class
YHOSSManager
:
NSObject
,
URLSessionDelegate
{
static
let
share
=
YHOSSManager
()
static
let
share
=
YHOSSManager
()
var
model
:
YHOSSModel
=
YHOSSModel
()
var
model
:
YHOSSModel
=
YHOSSModel
()
var
publicModel
:
YHOSSModel
=
YHOSSModel
()
var
mProvider
:
OSSStsTokenCredentialProvider
!
var
mProvider
:
OSSStsTokenCredentialProvider
!
var
mClient
:
OSSClient
!
var
mClient
:
OSSClient
!
var
fileName
:
[
String
]
=
[]
var
fileName
:
[
String
]
=
[]
...
@@ -59,8 +60,20 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -59,8 +60,20 @@ class YHOSSManager: NSObject, URLSessionDelegate {
return
return
}
}
self
.
model
=
resultModel
self
.
model
=
resultModel
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
model
.
accessKeyId
,
secretKeyId
:
self
.
model
.
accessKeySecret
,
securityToken
:
self
.
model
.
securityToken
)
if
let
block
=
completionHandler
{
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
model
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
block
()
}
}
failBlock
:
{
err
in
}
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
,
params
:
param
,
"5000000"
)
{
[
weak
self
]
json
,
code
in
//1. json字符串 转 对象
guard
let
self
=
self
else
{
return
}
let
dic
=
json
.
data
guard
let
resultModel
=
YHOSSModel
.
deserialize
(
from
:
dic
as?
Dictionary
)
else
{
return
}
self
.
publicModel
=
resultModel
if
let
block
=
completionHandler
{
if
let
block
=
completionHandler
{
block
()
block
()
}
}
...
@@ -75,10 +88,21 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -75,10 +88,21 @@ class YHOSSManager: NSObject, URLSessionDelegate {
callBackBlock
(
nil
,
YHErrorModel
())
callBackBlock
(
nil
,
YHErrorModel
())
return
return
}
}
if
isPublic
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
publicModel
.
accessKeyId
,
secretKeyId
:
self
.
publicModel
.
accessKeySecret
,
securityToken
:
self
.
publicModel
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
publicModel
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
else
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
model
.
accessKeyId
,
secretKeyId
:
self
.
model
.
accessKeySecret
,
securityToken
:
self
.
model
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
model
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
DispatchQueue
.
global
()
.
async
{
DispatchQueue
.
global
()
.
async
{
request
.
uploadingData
=
imageData
request
.
uploadingData
=
imageData
request
.
bucketName
=
self
.
model
.
bucket
if
isPublic
{
request
.
bucketName
=
self
.
publicModel
.
bucket
}
else
{
request
.
bucketName
=
self
.
model
.
bucket
}
let
timestamp
=
Date
()
.
timeIntervalSince1970
let
timestamp
=
Date
()
.
timeIntervalSince1970
let
randomInt
=
Int
.
random
(
in
:
1
...
100
)
// 随机生成1到10之间的整数
let
randomInt
=
Int
.
random
(
in
:
1
...
100
)
// 随机生成1到10之间的整数
let
name
=
"
\(
UInt64
(
timestamp
)
)
"
+
"
\(
randomInt
)
"
+
".jpg"
let
name
=
"
\(
UInt64
(
timestamp
)
)
"
+
"
\(
randomInt
)
"
+
".jpg"
...
@@ -109,7 +133,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -109,7 +133,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
let
currentDateMMdd
=
dateFormatter
.
string
(
from
:
Date
())
let
currentDateMMdd
=
dateFormatter
.
string
(
from
:
Date
())
var
string
=
""
var
string
=
""
if
isPublic
{
if
isPublic
{
string
=
"https://"
+
self
.
m
odel
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"5000000"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
string
=
"https://"
+
self
.
publicM
odel
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"5000000"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
}
else
{
}
else
{
string
=
"https://"
+
self
.
model
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"4001001"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
string
=
"https://"
+
self
.
model
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"4001001"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
}
}
...
@@ -127,11 +151,21 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -127,11 +151,21 @@ class YHOSSManager: NSObject, URLSessionDelegate {
callBackBlock
(
nil
,
YHErrorModel
())
callBackBlock
(
nil
,
YHErrorModel
())
return
return
}
}
if
isPublic
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
publicModel
.
accessKeyId
,
secretKeyId
:
self
.
publicModel
.
accessKeySecret
,
securityToken
:
self
.
publicModel
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
publicModel
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
else
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
model
.
accessKeyId
,
secretKeyId
:
self
.
model
.
accessKeySecret
,
securityToken
:
self
.
model
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
model
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
DispatchQueue
.
global
()
.
async
{
DispatchQueue
.
global
()
.
async
{
let
fileExtension
=
URL
(
fileURLWithPath
:
file
)
.
pathExtension
.
lowercased
()
let
fileExtension
=
URL
(
fileURLWithPath
:
file
)
.
pathExtension
.
lowercased
()
request
.
uploadingData
=
fileData
request
.
uploadingData
=
fileData
request
.
bucketName
=
self
.
model
.
bucket
if
isPublic
{
request
.
bucketName
=
self
.
publicModel
.
bucket
}
else
{
request
.
bucketName
=
self
.
model
.
bucket
}
let
timestamp
=
Date
()
.
timeIntervalSince1970
let
timestamp
=
Date
()
.
timeIntervalSince1970
let
name
=
"
\(
UInt64
(
timestamp
)
)
"
+
".
\(
fileExtension
)
"
let
name
=
"
\(
UInt64
(
timestamp
)
)
"
+
".
\(
fileExtension
)
"
self
.
fileName
.
append
(
name
)
self
.
fileName
.
append
(
name
)
...
@@ -163,7 +197,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -163,7 +197,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
let
currentDateMMdd
=
dateFormatter
.
string
(
from
:
Date
())
let
currentDateMMdd
=
dateFormatter
.
string
(
from
:
Date
())
var
string
=
""
var
string
=
""
if
isPublic
{
if
isPublic
{
string
=
"https://"
+
self
.
m
odel
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"5000000"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
string
=
"https://"
+
self
.
publicM
odel
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"5000000"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
}
else
{
}
else
{
string
=
"https://"
+
self
.
model
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"4001001"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
string
=
"https://"
+
self
.
model
.
bucket
+
"."
+
"oss-cn-shenzhen.aliyuncs.com/"
+
"4001001"
+
"/"
+
currentDateMMdd
+
"/"
+
"
\(
self
.
fileName
.
first
??
""
)
"
}
}
...
@@ -176,6 +210,13 @@ class YHOSSManager: NSObject, URLSessionDelegate {
...
@@ -176,6 +210,13 @@ class YHOSSManager: NSObject, URLSessionDelegate {
}
}
func
getPublic
(
url
:
String
,
_
isPublic
:
Bool
=
false
,
callBackBlock
:
@escaping
(
_
success
:
String
?,
_
error
:
YHErrorModel
?)
->
())
{
func
getPublic
(
url
:
String
,
_
isPublic
:
Bool
=
false
,
callBackBlock
:
@escaping
(
_
success
:
String
?,
_
error
:
YHErrorModel
?)
->
())
{
if
isPublic
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
publicModel
.
accessKeyId
,
secretKeyId
:
self
.
publicModel
.
accessKeySecret
,
securityToken
:
self
.
publicModel
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
publicModel
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
else
{
self
.
mProvider
=
OSSStsTokenCredentialProvider
(
accessKeyId
:
self
.
model
.
accessKeyId
,
secretKeyId
:
self
.
model
.
accessKeySecret
,
securityToken
:
self
.
model
.
securityToken
)
self
.
mClient
=
OSSClient
(
endpoint
:
self
.
model
.
endpoint
,
credentialProvider
:
self
.
mProvider
)
}
DispatchQueue
.
global
()
.
async
{
DispatchQueue
.
global
()
.
async
{
let
bucketName
=
self
.
getBucket
(
url
)
let
bucketName
=
self
.
getBucket
(
url
)
...
...
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