Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GeliBusinessPlatform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ljy
GeliBusinessPlatform
Commits
15fb54d9
Commit
15fb54d9
authored
5 years ago
by
刘俊宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成图片上传接口
parent
b14017e4
master
1.6.1
11shipei
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
33 deletions
+102
-33
GeliBusinessPlatform.xcodeproj/project.pbxproj
GeliBusinessPlatform.xcodeproj/project.pbxproj
+4
-0
GeliBusinessPlatform.xcworkspace/xcuserdata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
...ata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/Define/NetworkRequest.swift
GeliBusinessPlatform/Define/NetworkRequest.swift
+3
-3
GeliBusinessPlatform/Model/Interface.swift
GeliBusinessPlatform/Model/Interface.swift
+11
-1
GeliBusinessPlatform/Model/SaveFileModel.swift
GeliBusinessPlatform/Model/SaveFileModel.swift
+36
-0
GeliBusinessPlatform/ViewController/个人中心/PersonCenterViewController.swift
...form/ViewController/个人中心/PersonCenterViewController.swift
+48
-29
No files found.
GeliBusinessPlatform.xcodeproj/project.pbxproj
View file @
15fb54d9
...
...
@@ -354,6 +354,7 @@
F961D271245016B7007FBE70
/* SelectContentView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F961D270245016B7007FBE70
/* SelectContentView.swift */
;
};
F961D27524503CCF007FBE70
/* OrderSelectMoreView.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F961D27424503CCF007FBE70
/* OrderSelectMoreView.xib */
;
};
F961D27724503F51007FBE70
/* OrderSelectMoreView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F961D27624503F51007FBE70
/* OrderSelectMoreView.swift */
;
};
F96407642468DEB400A05E12
/* SaveFileModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F96407632468DEB400A05E12
/* SaveFileModel.swift */
;
};
F969BF07244EC38000C79953
/* GoodsCollectionViewCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F969BF05244EC38000C79953
/* GoodsCollectionViewCell.swift */
;
};
F969BF08244EC38000C79953
/* GoodsCollectionViewCell.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F969BF06244EC38000C79953
/* GoodsCollectionViewCell.xib */
;
};
F969BF1E244EE67900C79953
/* GoodsManageListVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
F969BF1C244EE67900C79953
/* GoodsManageListVC.swift */
;
};
...
...
@@ -773,6 +774,7 @@
F961D270245016B7007FBE70
/* SelectContentView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SelectContentView.swift
;
sourceTree
=
"<group>"
;
};
F961D27424503CCF007FBE70
/* OrderSelectMoreView.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
OrderSelectMoreView.xib
;
sourceTree
=
"<group>"
;
};
F961D27624503F51007FBE70
/* OrderSelectMoreView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OrderSelectMoreView.swift
;
sourceTree
=
"<group>"
;
};
F96407632468DEB400A05E12
/* SaveFileModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SaveFileModel.swift
;
sourceTree
=
"<group>"
;
};
F969BF05244EC38000C79953
/* GoodsCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GoodsCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
F969BF06244EC38000C79953
/* GoodsCollectionViewCell.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
GoodsCollectionViewCell.xib
;
sourceTree
=
"<group>"
;
};
F969BF1C244EE67900C79953
/* GoodsManageListVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GoodsManageListVC.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1236,6 +1238,7 @@
F94A314824624FA400FEC38E
/* ShopAdministratorInfoModel.swift */
,
F94A314A246250DB00FEC38E
/* GoodsDetailModel.swift */
,
F94A314C2462582F00FEC38E
/* GeneralInfoModel.swift */
,
F96407632468DEB400A05E12
/* SaveFileModel.swift */
,
);
path
=
Model
;
sourceTree
=
"<group>"
;
...
...
@@ -2324,6 +2327,7 @@
F9956B2524640D34001A617D
/* GoodsClassModel.swift in Sources */
,
F961D26B24500FF6007FBE70
/* HeaderSelectView.swift in Sources */
,
E09F4C9D2452BEBB00BE033D
/* JiPaiFangShiViewController.swift in Sources */
,
F96407642468DEB400A05E12
/* SaveFileModel.swift in Sources */
,
E0D4166424483058008DCAB4
/* ChangePassViewController.swift in Sources */
,
F933F6C12452C68B00189561
/* PKHUDAnimation.swift in Sources */
,
E0C4F4A7244EC82A00CC7E2F
/* TitleAndBtnCell.swift in Sources */
,
...
...
This diff is collapsed.
Click to expand it.
GeliBusinessPlatform.xcworkspace/xcuserdata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
View file @
15fb54d9
No preview for this file type
This diff is collapsed.
Click to expand it.
GeliBusinessPlatform/Define/NetworkRequest.swift
View file @
15fb54d9
...
...
@@ -145,7 +145,7 @@ extension NetworkRequest {
}
//MARK: - 照片上传
func
uploadImage
(
url
:
String
,
image
:
UIImage
,
params
:
[
String
:
String
],
success
:
@escaping
(
_
result
:
[
String
:
Any
])
->
(),
failure
:
@escaping
(
_
error
:
Error
)
->
())
{
func
uploadImage
(
url
:
String
,
image
:
UIImage
,
params
:
[
String
:
Any
],
success
:
@escaping
(
_
result
:
[
String
:
Any
])
->
(),
failure
:
@escaping
(
_
error
:
Error
)
->
())
{
let
paths
=
Bundle
.
main
.
path
(
forResource
:
"Interface_Z"
,
ofType
:
"plist"
)
let
dic
=
NSDictionary
(
contentsOfFile
:
(
paths
!
as
String
))
...
...
@@ -156,11 +156,11 @@ extension NetworkRequest {
let
data
=
image
.
jpegData
(
compressionQuality
:
0.8
)
let
fileName
=
String
.
init
(
describing
:
NSDate
())
+
".png"
// withName:是根据文档决定传入的字符串
multipartFormData
.
append
(
data
!
,
withName
:
"
image"
,
fileName
:
fileName
,
mimeType
:
"image/png
"
)
multipartFormData
.
append
(
data
!
,
withName
:
"
file"
,
fileName
:
fileName
,
mimeType
:
"file
"
)
// 遍历添加参数
for
(
key
,
value
)
in
params
{
// string 转 data
multipartFormData
.
append
(
value
.
data
(
using
:
String
.
Encoding
.
utf8
)
!
,
withName
:
key
)
multipartFormData
.
append
(
(
value
as
AnyObject
)
.
data
(
using
:
String
.
Encoding
.
utf8
.
rawValue
)
!
,
withName
:
key
)
}
},
to
:
SERVERCE_HOST
+
dicstr
,
encodingCompletion
:
{
(
encodingResult
)
in
...
...
This diff is collapsed.
Click to expand it.
GeliBusinessPlatform/Model/Interface.swift
View file @
15fb54d9
...
...
@@ -8,7 +8,8 @@
import
Foundation
import
Alamofire
import
SwiftyJSON
import
ObjectMapper
//MARK:--登录
//params-key(user_name(用户名),pwd(密码))
func
login
(
_
params
:[
String
:
Any
],
success
:
@escaping
(
_
res
:
Any
)
->
(),
failture
:
@escaping
(
_
error
:
Error
)
->
())
{
...
...
@@ -240,3 +241,12 @@ func goodsEdit(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:
failture
(
error
)
}
}
func
saveFile
(
image
:
UIImage
,
_
params
:[
String
:
Any
],
success
:
@escaping
(
_
res
:
Any
)
->
(),
failture
:
@escaping
(
_
error
:
Error
)
->
())
{
NetworkRequest
.
sharedInstance
.
uploadImage
(
url
:
"图片(文件)上传"
,
image
:
image
,
params
:
params
,
success
:
{
(
data
)
in
let
model
=
Mapper
<
SaveFileModel
>
()
.
map
(
JSONObject
:
data
)
success
(
model
as
Any
)
})
{
(
error
)
in
failture
(
error
)
}
}
This diff is collapsed.
Click to expand it.
GeliBusinessPlatform/Model/SaveFileModel.swift
0 → 100644
View file @
15fb54d9
//
// SaveFileModel.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/5/11.
// Copyright © 2020 junye lu. All rights reserved.
//
import
Foundation
import
ObjectMapper
//图片(文件)上传
class
SaveFileModel
:
Mappable
{
var
code
:
Int
?
var
message
:
String
?
var
data
:
SaveFileDataModel
?
required
init
?(
map
:
Map
)
{
}
func
mapping
(
map
:
Map
)
{
code
<-
map
[
"code"
]
message
<-
map
[
"message"
]
data
<-
map
[
"data"
]
}
}
class
SaveFileDataModel
:
Mappable
{
var
url
:
String
?
//返回一个文件地址
required
init
?(
map
:
Map
)
{
}
func
mapping
(
map
:
Map
)
{
url
<-
map
[
"url"
]
}
}
This diff is collapsed.
Click to expand it.
GeliBusinessPlatform/ViewController/个人中心/PersonCenterViewController.swift
View file @
15fb54d9
...
...
@@ -8,9 +8,10 @@
import
UIKit
import
Photos
import
Alamofire
class
PersonCenterViewController
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
{
@IBOutlet
weak
var
shopNameLbl
:
UILabel
!
@IBOutlet
weak
var
iconImg
:
UIImageView
!
@IBOutlet
weak
var
nameLbl
:
UILabel
!
...
...
@@ -24,7 +25,7 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
let
UserToken
=
UserDefaults
.
standard
.
value
(
forKey
:
"user_token"
)
adminInfo
([
"user_token"
:
UserToken
as
Any
],
success
:
{
(
data
)
in
self
.
dataModel
=
(
data
as!
AdminInfoModel
)
// self.iconImg.kf.setImage(with: URL(string: SERVERCE_HOST + (self.dataModel?.data?.shop_img)!))
// self.iconImg.kf.setImage(with: URL(string: SERVERCE_HOST + (self.dataModel?.data?.shop_img)!))
self
.
shopNameLbl
.
text
=
self
.
dataModel
?
.
data
?
.
stall_name
self
.
nameLbl
.
text
=
self
.
dataModel
?
.
data
?
.
admin_name
})
{
(
error
)
in
...
...
@@ -57,16 +58,16 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
// Do any additional setup after loading the view.
/*
自适应字体大小后重新编辑背景框
shopNameLbl.text = "123"
shopNameLbl.sizeToFit()
shopNameLbl.snp.makeConstraints { (make) in
make.left.equalTo(nameLbl.snp_left)
make.top.equalTo(nameLbl.snp_bottom).offset(10)
make.width.equalTo(shopNameLbl.frame.size.width+8)
make.height.equalTo(20)
}
*/
自适应字体大小后重新编辑背景框
shopNameLbl.text = "123"
shopNameLbl.sizeToFit()
shopNameLbl.snp.makeConstraints { (make) in
make.left.equalTo(nameLbl.snp_left)
make.top.equalTo(nameLbl.snp_bottom).offset(10)
make.width.equalTo(shopNameLbl.frame.size.width+8)
make.height.equalTo(20)
}
*/
}
//MARK: -方法
@IBAction
func
editAction
(
_
sender
:
Any
)
{
...
...
@@ -77,7 +78,7 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
let
vc
=
AccountViewController
()
vc
.
dataModel
=
self
.
dataModel
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
//MARK:--跳转消息中心
@IBAction
func
toMsgCenterAction
(
_
sender
:
Any
)
{
...
...
@@ -85,8 +86,8 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
let
vc
=
MsgCenterViewController
()
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
//MARK: -Cell delegate方法
//MARK: -Cell delegate方法
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
print
(
indexPath
.
row
)
if
indexPath
.
row
==
0
{
...
...
@@ -99,31 +100,49 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
else
if
indexPath
.
row
==
2
{
//权限设置-弹窗
_
=
self
.
presentHGImagePicker
(
maxSelected
:
2
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
for
asset
in
assets
{
print
(
asset
)
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
nil
,
resultHandler
:
{
(
imge
,
_
:
[
AnyHashable
:
Any
]?)
in
})
let
option
=
PHImageRequestOptions
()
option
.
isSynchronous
=
true
option
.
isNetworkAccessAllowed
=
true
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
imge
,
_
:
[
AnyHashable
:
Any
]?)
in
print
(
"上传图片==
\(
imge
)
"
)
let
UserToken
=
UserDefaults
.
standard
.
value
(
forKey
:
"user_token"
)
let
upLoadImg
=
imge
as!
UIImage
saveFile
(
image
:
upLoadImg
,
[
"user_token"
:
UserToken
as
Any
],
success
:
{
(
data
)
in
let
dataM
=
data
as!
SaveFileModel
if
dataM
.
code
==
1
{
print
(
"图片上传成功
\(
dataM
.
data
?
.
url
)
"
)
}
})
{
(
error
)
in
print
(
"图片上传失败
\(
error
)
"
)
}
})
}
}
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
50*
glscale
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
50*
glscale
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
listArray
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
var
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"listCell"
)
as!
PersonCenterCell
cell
.
titleLbl
.
text
=
listArray
[
indexPath
.
row
]
return
cell
}
}
}
This diff is collapsed.
Click to expand it.
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