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
9f3a4b1f
Commit
9f3a4b1f
authored
May 15, 2020
by
lujunye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字典修改成model
parent
42fea0c7
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
957 additions
and
785 deletions
+957
-785
GeliBusinessPlatform.xcodeproj/project.pbxproj
GeliBusinessPlatform.xcodeproj/project.pbxproj
+4
-0
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
...erdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/View/Cell/AddImgCell.swift
GeliBusinessPlatform/View/Cell/AddImgCell.swift
+50
-24
GeliBusinessPlatform/View/Cell/YuShouWeiKuanFaHuoCell.swift
GeliBusinessPlatform/View/Cell/YuShouWeiKuanFaHuoCell.swift
+10
-4
GeliBusinessPlatform/ViewController/商品详情/EditProductViewController.swift
...tform/ViewController/商品详情/EditProductViewController.swift
+650
-650
GeliBusinessPlatform/ViewController/商品详情/ProductDetailViewController.swift
...orm/ViewController/商品详情/ProductDetailViewController.swift
+160
-59
GeliBusinessPlatform/ViewController/新增规格/CreatNewSpecsViewController.swift
...orm/ViewController/新增规格/CreatNewSpecsViewController.swift
+47
-44
GeliBusinessPlatform/ViewController/新增规格/GuiGeModel.swift
GeliBusinessPlatform/ViewController/新增规格/GuiGeModel.swift
+33
-0
GeliBusinessPlatform/ViewController/新增规格/PuTongJieTiCell.swift
...usinessPlatform/ViewController/新增规格/PuTongJieTiCell.swift
+2
-3
GeliBusinessPlatform/ViewController/新增规格/YuShouCell.xib
GeliBusinessPlatform/ViewController/新增规格/YuShouCell.xib
+1
-1
No files found.
GeliBusinessPlatform.xcodeproj/project.pbxproj
View file @
9f3a4b1f
...
...
@@ -257,6 +257,7 @@
E0DDCB19244AE2AC00DF54C7
/* XiuGaiYuShouJiaViewController.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0DDCB17244AE2AC00DF54C7
/* XiuGaiYuShouJiaViewController.xib */
;
};
E0DDCB1D244AE81800DF54C7
/* GuanLianKeHuCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0DDCB1B244AE81800DF54C7
/* GuanLianKeHuCell.swift */
;
};
E0DDCB1E244AE81800DF54C7
/* GuanLianKeHuCell.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0DDCB1C244AE81800DF54C7
/* GuanLianKeHuCell.xib */
;
};
E0E8ABFD246E359700E3BB54
/* GuiGeModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0E8ABFC246E359700E3BB54
/* GuiGeModel.swift */
;
};
E0F1BE382469220D003015B2
/* RongSticker.bundle in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0F1BE2A24692208003015B2
/* RongSticker.bundle */
;
};
E0F1BE392469220D003015B2
/* RCColor.plist in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0F1BE2B24692208003015B2
/* RCColor.plist */
;
};
E0F1BE3A2469220D003015B2
/* libvo-amrwbenc.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
E0F1BE2C24692208003015B2
/* libvo-amrwbenc.a */
;
};
...
...
@@ -737,6 +738,7 @@
E0DDCB17244AE2AC00DF54C7
/* XiuGaiYuShouJiaViewController.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
XiuGaiYuShouJiaViewController.xib
;
sourceTree
=
"<group>"
;
};
E0DDCB1B244AE81800DF54C7
/* GuanLianKeHuCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GuanLianKeHuCell.swift
;
sourceTree
=
"<group>"
;
};
E0DDCB1C244AE81800DF54C7
/* GuanLianKeHuCell.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
GuanLianKeHuCell.xib
;
sourceTree
=
"<group>"
;
};
E0E8ABFC246E359700E3BB54
/* GuiGeModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GuiGeModel.swift
;
sourceTree
=
"<group>"
;
};
E0F1BE2A24692208003015B2
/* RongSticker.bundle */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.plug-in"
;
path
=
RongSticker.bundle
;
sourceTree
=
"<group>"
;
};
E0F1BE2B24692208003015B2
/* RCColor.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
RCColor.plist
;
sourceTree
=
"<group>"
;
};
E0F1BE2C24692208003015B2
/* libvo-amrwbenc.a */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.ar
;
path
=
"libvo-amrwbenc.a"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1247,6 +1249,7 @@
E0336DD2244EC3CA00380BE9
/* 新增规格 */
=
{
isa
=
PBXGroup
;
children
=
(
E0E8ABFC246E359700E3BB54
/* GuiGeModel.swift */
,
E0336DD3244EC40000380BE9
/* CreatNewSpecsViewController.swift */
,
E0336DD4244EC40000380BE9
/* CreatNewSpecsViewController.xib */
,
E0C4F4B3244EE9EE00CC7E2F
/* YuShouCell.swift */
,
...
...
@@ -2656,6 +2659,7 @@
E09F4CA22452D18800BE033D
/* ZengZhiServicesViewController.swift in Sources */
,
F94A315B24628C7E00FEC38E
/* WorkItemTableViewCell.swift in Sources */
,
E0DDCB18244AE2AC00DF54C7
/* XiuGaiYuShouJiaViewController.swift in Sources */
,
E0E8ABFD246E359700E3BB54
/* GuiGeModel.swift in Sources */
,
F950FDEA2451920200C40530
/* DIYCalendarCell.swift in Sources */
,
F950FDE224518B9500C40530
/* FSCalendarCalculator.m in Sources */
,
E0D197C12448431C002B080C
/* BabyToy.m in Sources */
,
...
...
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
View file @
9f3a4b1f
No preview for this file type
GeliBusinessPlatform/View/Cell/AddImgCell.swift
View file @
9f3a4b1f
...
...
@@ -7,9 +7,10 @@
//
import
UIKit
@objc
protocol
AddImgCellDelegate
{
@objc
optional
func
AddImgCellBtnClick
(
cell
:
AddImgCell
)
@objc
optional
func
DelImgCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
protocol
AddImgCellDelegate
{
func
AddImgCellBtnClick
(
cell
:
AddImgCell
)
func
DelImgCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
func
ChangeCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
}
class
AddImgCell
:
UITableViewCell
{
var
delegate
:
AddImgCellDelegate
?
...
...
@@ -20,26 +21,27 @@ class AddImgCell: UITableViewCell {
}
}
@IBAction
func
btnClick
(
_
sender
:
Any
)
{
delegate
?
.
AddImgCellBtnClick
?
(
cell
:
self
)
delegate
?
.
AddImgCellBtnClick
(
cell
:
self
)
}
var
isSingle
:
Bool
?
var
imgs
:
NSArray
?
{
var
imgs
:
Array
<
UIImage
>
=
[]
{
didSet
{
if
imgs
!.
count
>
0
{
print
(
imgs
.
count
)
if
imgs
.
count
>
0
{
if
scrollView
==
nil
{
let
scrView
=
UIScrollView
(
frame
:
CGRect
(
x
:
0
,
y
:
nameLbl
.
frame
.
maxY
,
width
:
fullScreenWidth
,
height
:
self
.
bounds
.
size
.
height
-
nameLbl
.
frame
.
maxY
))
let
scrView
=
UIScrollView
(
frame
:
CGRect
(
x
:
addBtn
.
frame
.
minX
,
y
:
addBtn
.
frame
.
minY
,
width
:
fullScreenWidth
,
height
:
90
))
scrView
.
showsHorizontalScrollIndicator
=
false
scrView
.
backgroundColor
=
UIColor
.
white
self
.
contentView
.
addSubview
(
scrView
)
scrollView
=
scrView
}
scrollView
?
.
isHidden
=
false
if
isSingle
==
true
{
addBtn
.
isHidden
=
true
setImgUI
(
arr
:
imgs
!
)
setImgUI
(
arr
:
imgs
)
}
else
{
setImgUI
(
arr
:
imgs
!
)
setImgUI
(
arr
:
imgs
)
}
}
else
{
scrollView
?
.
isHidden
=
true
...
...
@@ -56,23 +58,24 @@ class AddImgCell: UITableViewCell {
@IBOutlet
weak
var
nameLbl
:
UILabel
!
@IBOutlet
weak
var
addBtnX
:
NSLayoutConstraint
!
func
setImgUI
(
arr
:
NSArray
){
let
y
=
nameLbl
.
frame
.
max
Y
let
h
=
self
.
bounds
.
size
.
height
-
nameLbl
.
frame
.
maxY
func
setImgUI
(
arr
:
Array
<
UIImage
>
){
let
y
=
addBtn
.
frame
.
min
Y
let
h
:
CGFloat
=
90
if
isSingle
==
false
{
addBtn
.
isHidden
=
false
scrollView
?
.
isHidden
=
false
if
arr
.
count
<
3
{
scrollView
?
.
frame
=
CGRect
(
x
:
0
,
y
:
CGFloat
(
y
),
width
:
CGFloat
(
arr
.
count
)
*
110
,
height
:
h
)
addBtnX
.
constant
=
(
scrollView
?
.
frame
.
maxX
)
!+
10
scrollView
?
.
contentSize
=
CGSize
(
width
:
arr
.
count
*
105
,
height
:
0
)
scrollView
?
.
frame
=
CGRect
(
x
:
15
,
y
:
CGFloat
(
y
),
width
:
CGFloat
(
arr
.
count
)
*
105
,
height
:
h
)
addBtnX
.
constant
=
(
scrollView
?
.
frame
.
maxX
)
!
}
else
if
arr
.
count
==
5
{
addBtn
.
isHidden
=
true
scrollView
?
.
contentSize
=
CGSize
(
width
:
arr
.
count
*
1
10
,
height
:
0
)
scrollView
?
.
frame
=
CGRect
(
x
:
0
,
y
:
CGFloat
(
y
),
width
:
fullScreenWidth
,
height
:
h
)
scrollView
?
.
contentSize
=
CGSize
(
width
:
arr
.
count
*
1
05
,
height
:
0
)
scrollView
?
.
frame
=
CGRect
(
x
:
15
,
y
:
CGFloat
(
y
),
width
:
fullScreenWidth
,
height
:
h
)
}
else
{
scrollView
?
.
contentSize
=
CGSize
(
width
:
arr
.
count
*
1
10
,
height
:
0
)
scrollView
?
.
frame
=
CGRect
(
x
:
0
,
y
:
CGFloat
(
y
),
width
:
fullScreenWidth
*
0.7
,
height
:
h
)
addBtnX
.
constant
=
(
scrollView
?
.
frame
.
maxX
)
!+
10
scrollView
?
.
contentSize
=
CGSize
(
width
:
arr
.
count
*
1
05
,
height
:
0
)
scrollView
?
.
frame
=
CGRect
(
x
:
15
,
y
:
CGFloat
(
y
),
width
:
fullScreenWidth
-
130
,
height
:
h
)
addBtnX
.
constant
=
fullScreenWidth
-
105
}
}
for
i
in
0
..<
arr
.
count
{
...
...
@@ -80,12 +83,31 @@ class AddImgCell: UITableViewCell {
img
.
layer
.
cornerRadius
=
3
img
.
layer
.
masksToBounds
=
true
scrollView
!.
addSubview
(
img
)
img
.
image
=
arr
[
i
]
as!
UIImage
img
.
image
=
arr
[
i
]
img
.
isUserInteractionEnabled
=
true
img
.
snp
.
makeConstraints
{
(
make
)
in
make
.
centerY
.
equalTo
(
scrollView
!.
snp_centerY
)
make
.
width
.
height
.
equalTo
(
90
)
make
.
left
.
equalTo
(
15
+
105*
i
)
make
.
left
.
equalTo
(
105*
i
)
}
let
changeBtn
=
UIButton
()
changeBtn
.
tag
=
i
changeBtn
.
backgroundColor
=
UIColor
(
named
:
"标题字颜色"
)
changeBtn
.
alpha
=
0.5
changeBtn
.
addTarget
(
self
,
action
:
#selector(
changeAction(sender:)
)
,
for
:
.
touchUpInside
)
img
.
addSubview
(
changeBtn
)
changeBtn
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
bottom
.
right
.
left
.
equalTo
(
0
)
}
let
ti
=
UILabel
()
ti
.
text
=
"替 换"
ti
.
textColor
=
UIColor
.
white
ti
.
textAlignment
=
.
center
ti
.
font
=
UIFont
.
systemFont
(
ofSize
:
15
)
img
.
addSubview
(
ti
)
ti
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
bottom
.
right
.
left
.
equalTo
(
0
)
}
let
delImg
=
UIImageView
()
img
.
addSubview
(
delImg
)
...
...
@@ -109,8 +131,12 @@ class AddImgCell: UITableViewCell {
delBtn
.
addTarget
(
self
,
action
:
#selector(
delAction(sender:)
)
,
for
:
.
touchUpInside
)
}
}
@objc
func
changeAction
(
sender
:
UIButton
){
delegate
?
.
ChangeCellBtnClick
(
sender
:
sender
,
cell
:
self
)
}
@objc
func
delAction
(
sender
:
UIButton
){
delegate
?
.
DelImgCellBtnClick
?(
sender
:
sender
,
cell
:
self
)
delegate
?
.
DelImgCellBtnClick
(
sender
:
sender
,
cell
:
self
)
}
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
...
...
GeliBusinessPlatform/View/Cell/YuShouWeiKuanFaHuoCell.swift
View file @
9f3a4b1f
...
...
@@ -7,19 +7,25 @@
//
import
UIKit
protocol
YuShouWeiKuanFaHuoCellDelegate
{
func
YuShouWeiKuanFaHuoCellString
(
str
:
String
)
}
class
YuShouWeiKuanFaHuoCell
:
UITableViewCell
{
var
delegate
:
YuShouWeiKuanFaHuoCellDelegate
?
@IBOutlet
weak
var
textTF
:
UITextField
!
@IBOutlet
weak
var
nameLbl
:
UILabel
!
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
self
.
selectionStyle
=
.
none
textTF
.
addTarget
(
self
,
action
:
#selector(
textChange(tf:)
)
,
for
:
.
allEditingEvents
)
// Initialization code
}
@objc
func
textChange
(
tf
:
UITextField
){
if
tf
.
text
!=
nil
{
delegate
?
.
YuShouWeiKuanFaHuoCellString
(
str
:
tf
.
text
!
)
}
}
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
super
.
setSelected
(
selected
,
animated
:
animated
)
...
...
GeliBusinessPlatform/ViewController/商品详情/EditProductViewController.swift
View file @
9f3a4b1f
////
//// ProductDetailViewController.swift
//// GeliBusinessPlatform
////
//// Created by junye lu on 2020/4/23.
//// Copyright © 2020 junye lu. All rights reserved.
////
//
// ProductDetailViewController.swift
// GeliBusinessPlatform
//
// Created by junye lu on 2020/4/23.
// Copyright © 2020 junye lu. All rights reserved.
//
import
UIKit
import
LGButton
import
Photos
class
EditProductViewController
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
CommendCellDelegate
,
TitleAndBtnCellDelegate
,
GLAlertSelectViewDelegate
,
GoodsClassViewControllerDelegate
,
PinPaiListViewControllerDelegate
,
AddImgCellDelegate
,
AddGuiGeCellDelegate
,
CreatNewSpecsViewControllerDelegate
,
ShangPinGguiGeCellDelegate
,
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
,
TitleAndSwitchCellDelegate
{
var
isEdit
:
Bool
=
false
//是否编辑状态
var
selectIdx
:
IndexPath
?
var
layout
=
UICollectionViewFlowLayout
()
var
glSelectView
:
GLAlertSelectView
?
let
titleArr
=
[
"商品信息"
,
"商品图片"
,
"商品规格"
,
"预售设置"
,
"其它信息"
,
"商品详情"
]
let
spxxArr
=
[
"商品名称"
,
"商品类型"
,
"商品分类"
,
"品牌"
,
"起卖数量"
,
"是否清真"
,
"是否询价"
]
let
tishixxArr
:
NSMutableArray
=
[
"请输入商品名称"
,
"请选择商品类型"
,
"请选择商品分类"
,
"请选择品牌"
,
"请输入起卖数量"
]
let
tishixxArr1
:
NSMutableArray
=
[
"请输入关键字"
,
"请输入物流费用"
,
"请选择国家"
,
"请选择商品状态"
,
"请选择运输方式"
]
let
sptpArr
=
[
"商品封面图(限一张)"
,
"商品主图(限五张)"
]
let
qtxxArr
=
[
"关键字"
,
"物流费用"
,
"国家"
,
"商品状态"
,
"运输方式"
]
let
ysszArr
=
[
"用户付款是否需要审核"
,
"预设预付定金时间段"
,
"预设预付尾款时间段"
,
"预设预付尾款发货时间"
]
let
ysszHolder
=
[
"0"
,
"请选择时段"
,
"请选择时段"
,
"0"
]
var
itemTypeArr
=
NSMutableArray
()
var
shangPinStatus
:
Int
?
var
shangPinStatusArr
=
[
"热销"
,
"爆款"
,
"新品"
,
"促销"
,
"外采"
,
"团购"
]
var
yunShuType
:
Int
?
var
yunShuTypeArr
=
[
"冷链"
,
"常温"
,
"热链"
]
//MARK:--保存按钮
@IBOutlet
weak
var
bottomView
:
UIView
!
@IBOutlet
weak
var
listTbv
:
UITableView
!
var
cellHeight
=
18.5
var
contentStr
:
String
=
""
var
guiGeArr
:
NSMutableArray
=
[]
//根据规格资料数量控制右上角新增按钮是否显示
var
isYuShouShangPin
:
Bool
?
let
btmTitleArr
=
[
"编辑"
,
"入库"
,
"下架"
,
"删除"
]
@objc
func
bottomBtnClick
(
sender
:
UIButton
){
switch
sender
.
titleLabel
?
.
text
{
case
"编辑"
:
isEdit
=
true
sender
.
setTitle
(
"保存"
,
for
:
.
normal
)
firstLbl
!.
text
=
"保存"
listTbv
.
reloadData
()
break
case
"保存"
:
isEdit
=
false
sender
.
setTitle
(
"编辑"
,
for
:
.
normal
)
firstLbl
!.
text
=
"编辑"
listTbv
.
reloadData
()
break
default
:
break
}
}
var
firstLbl
:
UILabel
?
=
nil
var
generalInfoModel
:
GeneralInfoModel
?
=
nil
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
//MARK:--获取新增商品的基本信息(品牌和分类等)
HUD
.
flash
(
.
progress
)
let
UserToken
=
UserDefaults
.
standard
.
value
(
forKey
:
"user_token"
)
GeneralInfo
([
"user_token"
:
UserToken
as
Any
],
success
:
{
(
data
)
in
HUD
.
hide
(
animated
:
true
)
self
.
generalInfoModel
=
data
as!
GeneralInfoModel
})
{
(
error
)
in
}
isYuShouShangPin
=
true
navbar
.
title
=
"商品详情"
self
.
view
.
addSubview
(
navbar
)
listTbv
.
separatorStyle
=
.
none
listTbv
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalTo
(
NavCGRect
.
height
)
make
.
left
.
right
.
equalTo
(
0
)
make
.
bottom
.
equalTo
(
bottomView
.
snp_top
)
}
listTbv
.
register
(
UINib
(
nibName
:
"TitleAndTFCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"TitleAndTF"
)
listTbv
.
register
(
UINib
(
nibName
:
"TitleAndSwitchCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"TitleAndSwitch"
)
listTbv
.
register
(
UINib
(
nibName
:
"TitleAndBtnCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"TitleAndBtn"
)
listTbv
.
register
(
UINib
(
nibName
:
"AddImgCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"AddImg"
)
listTbv
.
register
(
UINib
(
nibName
:
"AddGuiGeCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"AddGuiGe"
)
listTbv
.
register
(
UINib
(
nibName
:
"CommendCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"Commend"
)
listTbv
.
register
(
UINib
(
nibName
:
"YuShouWeiKuanFaHuoCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"YuShouWeiKuanFaHuoCell"
)
listTbv
.
register
(
UINib
(
nibName
:
"ShangPinGguiGeCell"
,
bundle
:
nil
),
forCellReuseIdentifier
:
"ShangPinGguiGeCell"
)
// Do any additional setup after loading the view.
let
w
=
fullScreenWidth
/
CGFloat
(
btmTitleArr
.
count
)
for
i
in
0
..<
btmTitleArr
.
count
{
let
btn
=
UIButton
(
frame
:
CGRect
(
x
:
CGFloat
(
i
)
*
w
,
y
:
0
,
width
:
w
,
height
:
bottomView
.
bounds
.
size
.
height
))
btn
.
tag
=
i
btn
.
setTitle
(
btmTitleArr
[
i
],
for
:
.
normal
)
btn
.
titleLabel
?
.
textColor
=
UIColor
.
clear
btn
.
addTarget
(
self
,
action
:
#selector(
bottomBtnClick(sender:)
)
,
for
:
.
touchUpInside
)
let
lbl
=
UILabel
(
frame
:
CGRect
(
x
:
CGFloat
(
i
)
*
w
,
y
:
0
,
width
:
w
,
height
:
49*
glscale
))
lbl
.
textAlignment
=
.
center
lbl
.
text
=
btmTitleArr
[
i
]
lbl
.
font
=
UIFont
.
systemFont
(
ofSize
:
13
)
lbl
.
textColor
=
UIColor
(
named
:
"蓝色字体颜色"
)
if
i
==
0
{
firstLbl
=
lbl
}
bottomView
.
addSubview
(
btn
)
bottomView
.
addSubview
(
lbl
)
}
}
//MARK: - cell delegate
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
6
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
switch
section
{
case
0
:
return
7
case
1
:
return
2
case
2
:
return
1
case
3
:
return
4
case
4
:
return
5
default
:
return
2
}
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
switch
indexPath
.
section
{
case
0
:
if
indexPath
.
row
==
0
||
indexPath
.
row
==
4
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
spxxArr
[
indexPath
.
row
]
cell
.
textTF
.
placeholder
=
tishixxArr
[
indexPath
.
row
]
as!
String
cell
.
textTF
.
isUserInteractionEnabled
=
isEdit
return
cell
}
if
indexPath
.
row
>
4
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
delegate
=
self
cell
.
namelbl
.
text
=
spxxArr
[
indexPath
.
row
]
cell
.
infoSw
.
isUserInteractionEnabled
=
isEdit
return
cell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
nameLbl
.
text
=
spxxArr
[
indexPath
.
row
]
cell
.
contentLbl
.
text
=
tishixxArr
[
indexPath
.
row
]
as!
String
cell
.
tag
=
indexPath
.
row
cell
.
btn
.
isUserInteractionEnabled
=
isEdit
cell
.
delegate
=
self
return
cell
case
1
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AddImg"
)
as!
AddImgCell
cell
.
nameLbl
.
text
=
sptpArr
[
indexPath
.
row
]
if
indexPath
.
row
==
0
{
cell
.
isSingle
=
true
cell
.
imgs
=
singleImgArr
}
else
{
cell
.
isSingle
=
false
cell
.
imgs
=
maxFiveImgsArr
}
cell
.
delegate
=
self
cell
.
addBtn
.
tag
=
indexPath
.
row
cell
.
isEdit
=
isEdit
return
cell
case
2
:
if
guiGeArr
.
count
>
0
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ShangPinGguiGeCell"
)
as!
ShangPinGguiGeCell
cell
.
delegate
=
self
var
dict
:
NSDictionary
!
if
selectIdx
!=
nil
{
dict
=
guiGeArr
[
selectIdx
!.
item
]
as!
NSDictionary
}
else
{
dict
=
guiGeArr
.
firstObject
as!
NSDictionary
}
cell
.
tempLbl
.
text
=
"冷藏:
\(
String
(
describing
:
dict
[
"wenDu"
]
!
)
)
℃"
cell
.
weightLbl
.
text
=
"重量(kg):
\(
String
(
describing
:
dict
[
"weight"
]
!
)
)
kg"
cell
.
guiGeLbl
.
text
=
"规格:
\(
String
(
describing
:
dict
[
"guiGe"
]
!
)
)
kg/件"
cell
.
danWeiLbl
.
text
=
"单位:
\(
String
(
describing
:
dict
[
"danWei"
]
!
)
)
"
cell
.
sellPriceLbl
.
text
=
"售价:¥
\(
dict
[
"price"
]
!
)
"
if
isEdit
{
cell
.
btn
.
setTitle
(
"编辑详情"
,
for
:
.
normal
)
}
else
{
cell
.
btn
.
setTitle
(
"查看详情"
,
for
:
.
normal
)
}
return
cell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AddGuiGe"
)
as!
AddGuiGeCell
cell
.
imgBtn
.
addTarget
(
self
,
action
:
#selector(
addGuiGe
)
,
for
:
.
touchUpInside
)
cell
.
imgBtn
.
setImage
(
UIImage
(
named
:
"xinzeng"
),
for
:
.
normal
)
cell
.
imgBtn
.
isUserInteractionEnabled
=
isEdit
return
cell
case
3
:
if
indexPath
.
row
==
0
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
namelbl
.
text
=
ysszArr
[
indexPath
.
row
]
cell
.
delegate
=
self
cell
.
infoSw
.
isUserInteractionEnabled
=
isEdit
return
cell
}
if
indexPath
.
row
==
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"YuShouWeiKuanFaHuoCell"
)
as!
YuShouWeiKuanFaHuoCell
cell
.
nameLbl
.
text
=
ysszArr
[
indexPath
.
row
]
cell
.
textTF
.
keyboardType
=
.
numberPad
cell
.
textTF
.
isUserInteractionEnabled
=
isEdit
return
cell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
nameLbl
.
text
=
ysszArr
[
indexPath
.
row
]
cell
.
delegate
=
self
cell
.
contentLbl
.
text
=
ysszHolder
[
indexPath
.
row
]
cell
.
btn
.
isUserInteractionEnabled
=
isEdit
return
cell
case
4
:
if
indexPath
.
row
<
2
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
qtxxArr
[
indexPath
.
row
]
cell
.
textTF
.
placeholder
=
tishixxArr1
[
indexPath
.
row
]
as!
String
cell
.
tag
=
indexPath
.
row
cell
.
textTF
.
isUserInteractionEnabled
=
isEdit
return
cell
}
else
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
nameLbl
.
text
=
qtxxArr
[
indexPath
.
row
]
cell
.
tag
=
indexPath
.
row
cell
.
contentLbl
.
text
=
tishixxArr1
[
indexPath
.
row
]
as!
String
cell
.
btn
.
isUserInteractionEnabled
=
isEdit
cell
.
delegate
=
self
return
cell
}
default
:
if
indexPath
.
row
==
0
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Commend"
)
as!
CommendCell
cell
.
delegate
=
self
cell
.
autoTf
?
.
isUserInteractionEnabled
=
isEdit
return
cell
}
else
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AddGuiGe"
)
as!
AddGuiGeCell
cell
.
imgBtn
.
setImage
(
UIImage
(
named
:
"tupian"
),
for
:
.
normal
)
cell
.
delegate
=
self
cell
.
imgBtn
.
tag
=
indexPath
.
row
cell
.
imgBtn
.
isUserInteractionEnabled
=
isEdit
return
cell
}
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
switch
indexPath
.
section
{
case
0
:
return
49
case
1
:
return
148.5
case
2
:
if
guiGeArr
.
count
>
0
{
return
146
}
return
123.5
case
3
:
if
isYuShouShangPin
==
false
{
return
0.01
}
else
{
return
49
}
case
4
:
return
49
default
:
if
indexPath
.
row
==
0
{
return
CGFloat
(
cellHeight
)
+
27.5
}
else
{
return
155.5
}
}
}
//header
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
if
section
==
3
{
if
isYuShouShangPin
==
false
{
return
UIView
()
}
}
let
view
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
39
))
let
lbl
=
UILabel
(
frame
:
CGRect
(
x
:
15
,
y
:
15
,
width
:
fullScreenWidth
,
height
:
21
))
lbl
.
text
=
titleArr
[
section
]
lbl
.
textColor
=
UIColor
(
named
:
"标题字颜色"
)
lbl
.
font
=
UIFont
.
boldSystemFont
(
ofSize
:
15
)
view
.
addSubview
(
lbl
)
if
section
==
2
&&
guiGeArr
.
count
>
0
{
let
btn
=
UIButton
()
btn
.
setTitle
(
" 新增"
,
for
:
.
normal
)
btn
.
titleLabel
?
.
font
=
UIFont
.
systemFont
(
ofSize
:
13
)
btn
.
setTitleColor
(
UIColor
(
named
:
"蓝色字体颜色"
),
for
:
.
normal
)
btn
.
setImage
(
UIImage
(
named
:
"jiahaoXG"
),
for
:
.
normal
)
view
.
addSubview
(
btn
)
btn
.
sizeToFit
()
btn
.
snp
.
makeConstraints
{
(
make
)
in
make
.
centerY
.
equalTo
(
lbl
.
snp_centerY
)
make
.
right
.
equalTo
(
-
15
)
make
.
height
.
equalTo
(
btn
.
frame
.
size
.
height
)
make
.
width
.
equalTo
(
btn
.
frame
.
size
.
width
)
}
let
btn2
=
UIButton
()
view
.
addSubview
(
btn2
)
btn2
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
right
.
bottom
.
equalTo
(
0
)
make
.
width
.
equalTo
(
80
)
}
btn2
.
addTarget
(
self
,
action
:
#selector(
addGuiGe
)
,
for
:
.
touchUpInside
)
if
guiGeArr
.
count
>
1
{
view
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
80
)
let
collectionView
=
UICollectionView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
0
,
height
:
0
),
collectionViewLayout
:
layout
)
collectionView
.
backgroundColor
=
UIColor
.
white
collectionView
.
delegate
=
self
collectionView
.
dataSource
=
self
view
.
addSubview
(
collectionView
)
collectionView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
bottom
.
left
.
right
.
equalTo
(
0
)
make
.
height
.
equalTo
(
41
)
}
collectionView
.
showsHorizontalScrollIndicator
=
false
collectionView
.
isPagingEnabled
=
true
layout
.
itemSize
=
CGSize
(
width
:
fullScreenWidth
*
0.5
,
height
:
41
)
layout
.
scrollDirection
=
.
horizontal
collectionView
.
collectionViewLayout
=
layout
collectionView
.
register
(
UINib
(
nibName
:
"ItemCell"
,
bundle
:
nil
),
forCellWithReuseIdentifier
:
"ItemCell"
)
collectionView
.
selectItem
(
at
:
selectIdx
,
animated
:
false
,
scrollPosition
:
.
left
)
}
}
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
if
section
==
3
{
if
isYuShouShangPin
==
false
{
return
0.001
}
}
if
section
==
2
{
if
guiGeArr
.
count
>
1
{
return
80
}
}
return
39
}
//footer
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
10
))
view
.
backgroundColor
=
UIColor
(
named
:
"app底色"
)
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
if
section
==
3
{
if
isYuShouShangPin
==
false
{
return
0.001
}
}
return
10
}
//MARK: - 自定义delegate
func
CommendCellSendH
(
height
:
CGFloat
)
{
cellHeight
=
Double
(
height
)
listTbv
.
beginUpdates
()
listTbv
.
endUpdates
()
}
func
CommendCellSendStr
(
content
:
String
)
{
print
(
"CommendCellSendStr"
)
}
override
func
backAction
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
//MARK: -- 选择填或跳转
func
btnClick
(
content
:
String
,
cell
:
TitleAndBtnCell
)
{
if
cell
.
nameLbl
.
text
==
"商品类型"
{
if
glSelectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
isMultipleS
=
true
view
.
titleLbl
.
text
=
"请选择商品类型"
view
.
delegate
=
self
view
.
dataArr
=
[
"预售"
,
"普通"
,
"期货"
,
"团购"
]
if
itemTypeArr
.
count
==
0
{
for
_
in
view
.
dataArr
{
itemTypeArr
.
add
(
"99"
)
}
}
view
.
selectArray
=
itemTypeArr
self
.
view
.
addSubview
(
view
)
glSelectView
=
view
}
}
if
cell
.
nameLbl
.
text
==
"商品分类"
{
let
vc
=
GoodsClassViewController
()
vc
.
delegate
=
self
vc
.
dataModelArray
=
generalInfoModel
?
.
data
?
.
cats
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
if
cell
.
nameLbl
.
text
==
"品牌"
{
let
vc
=
PinPaiListViewController
()
vc
.
isSelectData
=
true
vc
.
delegate
=
self
vc
.
dataModelArray
=
generalInfoModel
?
.
data
?
.
brand
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
if
cell
.
nameLbl
.
text
==
"国家"
{
}
if
cell
.
nameLbl
.
text
==
"商品状态"
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择商品类型"
view
.
delegate
=
self
view
.
dataArr
=
shangPinStatusArr
view
.
selectNum
=
shangPinStatus
!
self
.
view
.
addSubview
(
view
)
glSelectView
=
view
}
if
cell
.
nameLbl
.
text
==
"运输方式"
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择运输方式"
view
.
delegate
=
self
view
.
dataArr
=
yunShuTypeArr
view
.
selectNum
=
yunShuType
!
self
.
view
.
addSubview
(
view
)
glSelectView
=
view
}
if
cell
.
nameLbl
.
text
==
"预设预付定金时间段"
{
}
if
cell
.
nameLbl
.
text
==
"预设预付尾款时间段"
{
}
print
(
cell
.
nameLbl
.
text
)
}
//MARK:---选择商品分类返回数据
func
blackGoodsClass
(
sender
:
GoodsClassModel
)
{
print
(
"选择商品分类返回数据=
\(
sender
)
"
)
}
//MARK:--选择品牌返回的数据
func
blackSelectPinPaiData
(
sender
:
GeneralInfoBrandModel
)
{
print
(
"选择品牌返回的数据=
\(
sender
)
"
)
}
func
GLAlertSelectViewClick
(
selectNum
:
Int
,
view
:
GLAlertSelectView
)
{
print
(
"单选"
,
selectNum
)
print
(
view
.
titleLbl
.
text
)
switch
view
.
titleLbl
.
text
{
case
"请选择商品类型"
:
shangPinStatus
=
selectNum
tishixxArr1
.
replaceObject
(
at
:
view
.
tag
,
with
:
shangPinStatusArr
[
selectNum
])
break
case
"请选择运输方式"
:
yunShuType
=
selectNum
tishixxArr1
.
replaceObject
(
at
:
view
.
tag
,
with
:
yunShuTypeArr
[
selectNum
])
break
default
:
break
}
glSelectView
?
.
removeFromSuperview
()
glSelectView
=
nil
listTbv
.
reloadData
()
}
var
isYuShou
:
Bool
=
false
func
GLAlertMoreSelectViewClick
(
sender
:
NSArray
,
view
:
UIView
)
{
print
(
"多选"
,
sender
)
itemTypeArr
=
sender
as!
NSMutableArray
let
str
=
"
\(
sender
.
firstObject
!
)
"
as!
NSString
if
str
!=
"99"
{
isYuShou
=
true
}
else
{
isYuShou
=
false
}
let
contentArr
=
[
"预售"
,
"普通"
,
"期货"
,
"团购"
]
let
titles
=
NSMutableArray
()
titles
.
removeAllObjects
()
for
num
in
itemTypeArr
{
let
str
=
"
\(
num
)
"
as!
NSString
if
str
!=
"99"
{
titles
.
add
(
contentArr
[
str
.
integerValue
])
}
}
tishixxArr
.
replaceObject
(
at
:
view
.
tag
,
with
:
titles
.
componentsJoined
(
by
:
","
))
if
itemTypeArr
.
componentsJoined
(
by
:
"_"
)
==
"99_99_99_99"
{
tishixxArr
.
replaceObject
(
at
:
view
.
tag
,
with
:
"请选择商品类型"
)
}
glSelectView
?
.
removeFromSuperview
()
glSelectView
=
nil
listTbv
.
reloadData
()
}
func
GLAlertSelectViewClose
(
sender
:
UIButton
)
{
glSelectView
?
.
removeFromSuperview
()
glSelectView
=
nil
}
var
maxFiveImgsArr
=
NSMutableArray
()
var
singleImgArr
=
NSMutableArray
()
func
DelImgCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
{
if
cell
.
isSingle
==
true
{
singleImgArr
.
removeObject
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
else
{
maxFiveImgsArr
.
removeObject
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
}
func
AddImgCellBtnClick
(
cell
:
AddImgCell
)
{
if
cell
.
addBtn
.
tag
==
0
{
//仅一张
_
=
self
.
presentHGImagePicker
(
maxSelected
:
1
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
let
option
=
PHImageRequestOptions
()
option
.
isSynchronous
=
true
option
.
isNetworkAccessAllowed
=
true
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
singleImgArr
.
add
(
image
)
})
}
cell
.
imgs
=
self
.
singleImgArr
}
}
else
{
//可多张
_
=
self
.
presentHGImagePicker
(
maxSelected
:
5
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
let
option
=
PHImageRequestOptions
()
option
.
isSynchronous
=
true
option
.
isNetworkAccessAllowed
=
true
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
maxFiveImgsArr
.
add
(
image
)
})
}
cell
.
imgs
=
self
.
maxFiveImgsArr
}
}
}
func
ShangPinGguiGeCellEditAction
(
cell
:
ShangPinGguiGeCell
)
{
let
vc
=
CreatNewSpecsViewController
()
vc
.
barTitle
=
"编辑规格"
vc
.
datasArr
=
guiGeArr
let
dataDict
:
NSDictionary
!
if
selectIdx
?
.
item
!=
nil
{
dataDict
=
guiGeArr
[
selectIdx
!.
item
]
as!
NSDictionary
}
else
{
dataDict
=
guiGeArr
.
firstObject
as!
NSDictionary
}
vc
.
price
=
dataDict
[
"price"
]
as!
String
vc
.
guiGe
=
dataDict
[
"guiGe"
]
as!
String
vc
.
weight
=
dataDict
[
"weight"
]
as!
String
vc
.
wenDu
=
dataDict
[
"wenDu"
]
as!
String
vc
.
danWei
=
dataDict
[
"danWei"
]
as!
String
let
arr
=
dataDict
[
"jieTiArr"
]
as!
NSMutableArray
let
arr2
=
dataDict
[
"specalArr"
]
as!
NSMutableArray
vc
.
isNonYuShou
=
dataDict
[
"isNonYuShou"
]
as!
Bool
vc
.
isYuShouSetting
=
dataDict
[
"isYuShouSetting"
]
as!
Bool
vc
.
yuShouPrice
=
dataDict
[
"yuShouPrice"
]
as!
String
vc
.
specalArr
=
arr2
vc
.
jieTiArr
=
arr
if
selectIdx
==
nil
{
vc
.
selectIdx
=
IndexPath
(
item
:
0
,
section
:
0
)
}
else
{
vc
.
selectIdx
=
selectIdx
}
print
(
vc
.
selectIdx
?
.
item
)
vc
.
delegate
=
self
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
func
CreatNewSpecsViewControllerDeleteAction
()
{
print
(
"删除数据"
)
}
func
AddGuiGeCellClick
(
cell
:
AddGuiGeCell
)
{
//
print
(
"商品详情添加图片"
)
}
@objc
func
addGuiGe
(){
print
(
"新增规格"
)
let
vc
=
CreatNewSpecsViewController
()
vc
.
barTitle
=
"新增规格"
vc
.
delegate
=
self
print
(
"abc == "
,
isYuShou
)
vc
.
isYuShouSetting
=
isYuShou
vc
.
isNonYuShou
=
isYuShou
vc
.
datasArr
=
guiGeArr
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
@objc
func
addImageAction
(
sender
:
UIButton
){
print
(
sender
.
tag
)
}
func
CreatNewSpecsViewControllerSaveAction
(
datas
:
NSMutableArray
)
{
guiGeArr
=
datas
listTbv
.
reloadData
()
}
//MARK: - COLLECTIONVIEW DELEGATE
func
collectionView
(
_
collectionView
:
UICollectionView
,
layout
collectionViewLayout
:
UICollectionViewLayout
,
minimumLineSpacingForSectionAt
section
:
Int
)
->
CGFloat
{
return
0
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
return
guiGeArr
.
count
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"ItemCell"
,
for
:
indexPath
)
as!
ItemCell
cell
.
tag
=
indexPath
.
row
if
selectIdx
==
nil
{
selectIdx
=
IndexPath
(
item
:
0
,
section
:
0
)
}
if
indexPath
==
selectIdx
{
cell
.
nameLbl
.
textColor
=
UIColor
(
named
:
"蓝色字体颜色"
)
cell
.
lineView
.
isHidden
=
false
}
else
{
cell
.
nameLbl
.
textColor
=
UIColor
(
named
:
"标题字颜色"
)
cell
.
lineView
.
isHidden
=
true
}
return
cell
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
didSelectItemAt
indexPath
:
IndexPath
)
{
selectIdx
=
indexPath
//刷新cell
print
(
"selectItem"
,
selectIdx
?
.
item
)
listTbv
.
reloadData
()
collectionView
.
reloadData
()
}
}
//import UIKit
//import LGButton
//import Photos
//
//class EditProductViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,CommendCellDelegate,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate,GoodsClassViewControllerDelegate,PinPaiListViewControllerDelegate,AddImgCellDelegate,AddGuiGeCellDelegate,CreatNewSpecsViewControllerDelegate,ShangPinGguiGeCellDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,TitleAndSwitchCellDelegate{
//
// var isEdit:Bool = false//是否编辑状态
//
// var selectIdx:IndexPath?
// var layout = UICollectionViewFlowLayout()
// var glSelectView:GLAlertSelectView?
// let titleArr = ["商品信息","商品图片","商品规格","预售设置","其它信息","商品详情"]
// let spxxArr = ["商品名称","商品类型","商品分类","品牌","起卖数量","是否清真","是否询价"]
//
// let tishixxArr:NSMutableArray = ["请输入商品名称","请选择商品类型","请选择商品分类","请选择品牌","请输入起卖数量"]
// let tishixxArr1:NSMutableArray = ["请输入关键字","请输入物流费用","请选择国家","请选择商品状态","请选择运输方式"]
//
// let sptpArr = ["商品封面图(限一张)","商品主图(限五张)"]
// let qtxxArr = ["关键字","物流费用","国家","商品状态","运输方式"]
// let ysszArr = ["用户付款是否需要审核","预设预付定金时间段","预设预付尾款时间段","预设预付尾款发货时间"]
// let ysszHolder = ["0","请选择时段","请选择时段","0"]
//
//
// var itemTypeArr = NSMutableArray()
//
// var shangPinStatus:Int?
// var shangPinStatusArr = ["热销","爆款","新品","促销","外采","团购"]
//
// var yunShuType:Int?
// var yunShuTypeArr = ["冷链","常温","热链"]
// //MARK:--保存按钮
// @IBOutlet weak var bottomView: UIView!
//
// @IBOutlet weak var listTbv: UITableView!
// var cellHeight = 18.5
// var contentStr:String = ""
//
// var guiGeArr:NSMutableArray = []//根据规格资料数量控制右上角新增按钮是否显示
//
//
//
// var isYuShouShangPin:Bool?
//
// let btmTitleArr = ["编辑","入库","下架","删除"]
// @objc func bottomBtnClick(sender:UIButton){
//
// switch sender.titleLabel?.text {
// case "编辑":
// isEdit = true
// sender.setTitle("保存", for: .normal)
// firstLbl!.text = "保存"
// listTbv.reloadData()
// break
// case "保存":
// isEdit = false
// sender.setTitle("编辑", for: .normal)
// firstLbl!.text = "编辑"
// listTbv.reloadData()
// break
// default:
// break
// }
// }
//
// var firstLbl:UILabel? = nil
// var generalInfoModel : GeneralInfoModel? = nil
// override func viewDidLoad() {
// super.viewDidLoad()
// //MARK:--获取新增商品的基本信息(品牌和分类等)
// HUD.flash(.progress)
// let UserToken = UserDefaults.standard.value(forKey: "user_token")
// GeneralInfo(["user_token":UserToken as Any], success: { (data) in
// HUD.hide(animated: true)
// self.generalInfoModel = data as! GeneralInfoModel
//
// }) { (error) in
//
// }
// isYuShouShangPin = true
//
// navbar.title = "商品详情"
// self.view.addSubview(navbar)
// listTbv.separatorStyle = .none
// listTbv.snp.makeConstraints { (make) in
// make.top.equalTo(NavCGRect.height)
// make.left.right.equalTo(0)
// make.bottom.equalTo(bottomView.snp_top)
// }
//
// listTbv.register(UINib(nibName: "TitleAndTFCell", bundle: nil), forCellReuseIdentifier: "TitleAndTF")
// listTbv.register(UINib(nibName: "TitleAndSwitchCell", bundle: nil), forCellReuseIdentifier: "TitleAndSwitch")
// listTbv.register(UINib(nibName: "TitleAndBtnCell", bundle: nil), forCellReuseIdentifier: "TitleAndBtn")
// listTbv.register(UINib(nibName: "AddImgCell", bundle: nil), forCellReuseIdentifier: "AddImg")
// listTbv.register(UINib(nibName: "AddGuiGeCell", bundle: nil), forCellReuseIdentifier: "AddGuiGe")
// listTbv.register(UINib(nibName: "CommendCell", bundle: nil), forCellReuseIdentifier: "Commend")
// listTbv.register(UINib(nibName: "YuShouWeiKuanFaHuoCell", bundle: nil), forCellReuseIdentifier: "YuShouWeiKuanFaHuoCell")
// listTbv.register(UINib(nibName: "ShangPinGguiGeCell", bundle: nil), forCellReuseIdentifier: "ShangPinGguiGeCell")
// // Do any additional setup after loading the view.
// let w = fullScreenWidth / CGFloat(btmTitleArr.count)
// for i in 0 ..< btmTitleArr.count{
// let btn = UIButton(frame: CGRect(x: CGFloat(i) * w, y: 0, width: w, height: bottomView.bounds.size.height))
// btn.tag = i
// btn.setTitle(btmTitleArr[i], for: .normal)
// btn.titleLabel?.textColor = UIColor.clear
// btn.addTarget(self, action: #selector(bottomBtnClick(sender:)), for: .touchUpInside)
// let lbl = UILabel(frame: CGRect(x: CGFloat(i) * w, y: 0, width: w, height: 49*glscale))
// lbl.textAlignment = .center
// lbl.text = btmTitleArr[i]
// lbl.font = UIFont.systemFont(ofSize: 13)
// lbl.textColor = UIColor(named: "蓝色字体颜色")
// if i == 0 {
// firstLbl = lbl
// }
// bottomView.addSubview(btn)
// bottomView.addSubview(lbl)
// }
// }
// //MARK: - cell delegate
// func numberOfSections(in tableView: UITableView) -> Int {
// return 6
// }
// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// switch section {
// case 0: return 7
// case 1:return 2
// case 2:return 1
// case 3:return 4
// case 4:return 5
// default:return 2
// }
// }
//
// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// switch indexPath.section {
// case 0:
// if indexPath.row == 0 || indexPath.row == 4 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
// cell.nameLbl.text = spxxArr[indexPath.row]
//
// cell.textTF.placeholder = tishixxArr[indexPath.row] as! String
// cell.textTF.isUserInteractionEnabled = isEdit
// return cell
// }
// if indexPath.row > 4{
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
// cell.delegate = self
// cell.namelbl.text = spxxArr[indexPath.row]
// cell.infoSw.isUserInteractionEnabled = isEdit
// return cell
// }
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
// cell.nameLbl.text = spxxArr[indexPath.row]
// cell.contentLbl.text = tishixxArr[indexPath.row] as! String
// cell.tag = indexPath.row
// cell.btn.isUserInteractionEnabled = isEdit
// cell.delegate = self
// return cell
// case 1:
// let cell = tableView.dequeueReusableCell(withIdentifier: "AddImg") as! AddImgCell
// cell.nameLbl.text = sptpArr[indexPath.row]
// if indexPath.row == 0 {
// cell.isSingle = true
// cell.imgs = singleImgArr
// }else{
// cell.isSingle = false
// cell.imgs = maxFiveImgsArr
// }
// cell.delegate = self
// cell.addBtn.tag = indexPath.row
// cell.isEdit = isEdit
// return cell
// case 2:
// if guiGeArr.count > 0 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "ShangPinGguiGeCell") as! ShangPinGguiGeCell
// cell.delegate = self
// var dict:NSDictionary!
// if selectIdx != nil{
// dict = guiGeArr[selectIdx!.item] as! NSDictionary
// }else{
// dict = guiGeArr.firstObject as! NSDictionary
// }
// cell.tempLbl.text = "冷藏:\(String(describing: dict["wenDu"]!))℃"
// cell.weightLbl.text = "重量(kg):\(String(describing: dict["weight"]!))kg"
// cell.guiGeLbl.text = "规格:\(String(describing: dict["guiGe"]!))kg/件"
// cell.danWeiLbl.text = "单位:\(String(describing: dict["danWei"]!))"
// cell.sellPriceLbl.text = "售价:¥\(dict["price"]!)"
// if isEdit{
// cell.btn.setTitle("编辑详情", for: .normal)
// }else{
// cell.btn.setTitle("查看详情", for: .normal)
// }
// return cell
// }
// let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
// cell.imgBtn.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
// cell.imgBtn.setImage(UIImage(named: "xinzeng"), for: .normal)
// cell.imgBtn.isUserInteractionEnabled = isEdit
// return cell
// case 3:
// if indexPath.row == 0 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
// cell.namelbl.text = ysszArr[indexPath.row]
// cell.delegate = self
// cell.infoSw.isUserInteractionEnabled = isEdit
// return cell
// }
// if indexPath.row == 3 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "YuShouWeiKuanFaHuoCell") as! YuShouWeiKuanFaHuoCell
// cell.nameLbl.text = ysszArr[indexPath.row]
// cell.textTF.keyboardType = .numberPad
// cell.textTF.isUserInteractionEnabled = isEdit
// return cell
// }
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
// cell.nameLbl.text = ysszArr[indexPath.row]
// cell.delegate = self
// cell.contentLbl.text = ysszHolder[indexPath.row]
// cell.btn.isUserInteractionEnabled = isEdit
// return cell
// case 4:
// if indexPath.row < 2 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
// cell.nameLbl.text = qtxxArr[indexPath.row]
// cell.textTF.placeholder = tishixxArr1[indexPath.row] as! String
// cell.tag = indexPath.row
// cell.textTF.isUserInteractionEnabled = isEdit
// return cell
// }else{
// let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
// cell.nameLbl.text = qtxxArr[indexPath.row]
// cell.tag = indexPath.row
// cell.contentLbl.text = tishixxArr1[indexPath.row] as! String
// cell.btn.isUserInteractionEnabled = isEdit
// cell.delegate = self
// return cell
// }
// default:
// if indexPath.row == 0 {
// let cell = tableView.dequeueReusableCell(withIdentifier: "Commend") as! CommendCell
// cell.delegate = self
// cell.autoTf?.isUserInteractionEnabled = isEdit
// return cell
// }else{
// let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
// cell.imgBtn.setImage(UIImage(named: "tupian"), for: .normal)
// cell.delegate = self
// cell.imgBtn.tag = indexPath.row
// cell.imgBtn.isUserInteractionEnabled = isEdit
// return cell
// }
// }
// }
//
// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//
// }
// func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// switch indexPath.section {
// case 0: return 49
// case 1:return 148.5
// case 2:
// if guiGeArr.count > 0 {
// return 146
// }
// return 123.5
// case 3:
// if isYuShouShangPin == false {
// return 0.01
// }else{
// return 49
// }
// case 4:return 49
// default:
// if indexPath.row == 0 {
// return CGFloat(cellHeight)+27.5
// }else{
// return 155.5
// }
// }
// }
// //header
// func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// if section == 3 {
// if isYuShouShangPin == false {
// return UIView()
// }
// }
// let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39))
// let lbl = UILabel(frame: CGRect(x: 15, y: 15, width: fullScreenWidth, height: 21))
// lbl.text = titleArr[section]
// lbl.textColor = UIColor(named: "标题字颜色")
// lbl.font = UIFont.boldSystemFont(ofSize: 15)
// view.addSubview(lbl)
// if section == 2 && guiGeArr.count > 0{
// let btn = UIButton()
// btn.setTitle(" 新增", for: .normal)
// btn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
// btn.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
// btn.setImage(UIImage(named: "jiahaoXG"), for: .normal)
// view.addSubview(btn)
// btn.sizeToFit()
// btn.snp.makeConstraints { (make) in
// make.centerY.equalTo(lbl.snp_centerY)
// make.right.equalTo(-15)
// make.height.equalTo(btn.frame.size.height)
// make.width.equalTo(btn.frame.size.width)
// }
// let btn2 = UIButton()
// view.addSubview(btn2)
// btn2.snp.makeConstraints { (make) in
// make.top.right.bottom.equalTo(0)
// make.width.equalTo(80)
// }
// btn2.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
// if guiGeArr.count > 1 {
// view.frame = CGRect(x: 0, y: 0, width: fullScreenWidth, height: 80)
// let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: layout)
// collectionView.backgroundColor = UIColor.white
// collectionView.delegate = self
// collectionView.dataSource = self
// view.addSubview(collectionView)
// collectionView.snp.makeConstraints { (make) in
// make.bottom.left.right.equalTo(0)
// make.height.equalTo(41)
// }
// collectionView.showsHorizontalScrollIndicator = false
// collectionView.isPagingEnabled = true
// layout.itemSize = CGSize(width: fullScreenWidth*0.5, height: 41)
// layout.scrollDirection = .horizontal
// collectionView.collectionViewLayout = layout
// collectionView.register(UINib(nibName: "ItemCell", bundle: nil), forCellWithReuseIdentifier: "ItemCell")
// collectionView.selectItem(at:selectIdx, animated: false, scrollPosition: .left)
// }
// }
// return view
// }
// func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
// if section == 3 {
// if isYuShouShangPin == false {
// return 0.001
// }
// }
// if section == 2 {
// if guiGeArr.count > 1 {
// return 80
// }
// }
// return 39
// }
// //footer
// func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 10))
// view.backgroundColor = UIColor(named: "app底色")
// return view
// }
// func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// if section == 3 {
// if isYuShouShangPin == false {
// return 0.001
// }
// }
// return 10
// }
// //MARK: - 自定义delegate
// func CommendCellSendH(height: CGFloat) {
// cellHeight = Double(height)
// listTbv.beginUpdates()
// listTbv.endUpdates()
// }
// func CommendCellSendStr(content: String) {
// print("CommendCellSendStr")
// }
// override func backAction() {
// self.navigationController?.popViewController(animated: true)
// }
// //MARK: -- 选择填或跳转
//
//
//
// func btnClick(content: String, cell: TitleAndBtnCell) {
// if cell.nameLbl.text == "商品类型" {
// if glSelectView == nil {
// let view = GLAlertSelectView(frame: self.view.bounds)
// view.tag = cell.tag
// view.isMultipleS = true
// view.titleLbl.text = "请选择商品类型"
// view.delegate = self
// view.dataArr = ["预售","普通","期货","团购"]
// if itemTypeArr.count == 0 {
// for _ in view.dataArr {
// itemTypeArr.add("99")
// }
// }
// view.selectArray = itemTypeArr
// self.view.addSubview(view)
// glSelectView = view
// }
// }
// if cell.nameLbl.text == "商品分类" {
// let vc = GoodsClassViewController()
// vc.delegate = self
// vc.dataModelArray = generalInfoModel?.data?.cats
// self.navigationController?.pushViewController(vc, animated: true)
// }
// if cell.nameLbl.text == "品牌" {
// let vc = PinPaiListViewController()
// vc.isSelectData = true
// vc.delegate = self
// vc.dataModelArray = generalInfoModel?.data?.brand
// self.navigationController?.pushViewController(vc, animated: true)
// }
// if cell.nameLbl.text == "国家" {
//
// }
// if cell.nameLbl.text == "商品状态" {
// let view = GLAlertSelectView(frame: self.view.bounds)
// view.tag = cell.tag
// view.titleLbl.text = "请选择商品类型"
// view.delegate = self
// view.dataArr = shangPinStatusArr
// view.selectNum = shangPinStatus!
// self.view.addSubview(view)
// glSelectView = view
// }
// if cell.nameLbl.text == "运输方式" {
// let view = GLAlertSelectView(frame: self.view.bounds)
// view.tag = cell.tag
// view.titleLbl.text = "请选择运输方式"
// view.delegate = self
// view.dataArr = yunShuTypeArr
// view.selectNum = yunShuType!
// self.view.addSubview(view)
// glSelectView = view
// }
// if cell.nameLbl.text == "预设预付定金时间段" {
//
// }
// if cell.nameLbl.text == "预设预付尾款时间段" {
//
// }
// print(cell.nameLbl.text)
// }
// //MARK:---选择商品分类返回数据
// func blackGoodsClass(sender: GoodsClassModel) {
// print("选择商品分类返回数据=\(sender)")
// }
// //MARK:--选择品牌返回的数据
// func blackSelectPinPaiData(sender: GeneralInfoBrandModel) {
// print("选择品牌返回的数据=\(sender)")
//
// }
//
// func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) {
// print("单选",selectNum)
// print(view.titleLbl.text)
// switch view.titleLbl.text {
// case "请选择商品类型":
// shangPinStatus = selectNum
// tishixxArr1.replaceObject(at: view.tag, with: shangPinStatusArr[selectNum])
// break
// case "请选择运输方式":
// yunShuType = selectNum
// tishixxArr1.replaceObject(at: view.tag, with: yunShuTypeArr[selectNum])
// break
// default:
// break
// }
// glSelectView?.removeFromSuperview()
// glSelectView = nil
// listTbv.reloadData()
// }
// var isYuShou:Bool = false
//
// func GLAlertMoreSelectViewClick(sender: NSArray, view:UIView) {
// print("多选",sender)
// itemTypeArr = sender as! NSMutableArray
// let str = "\(sender.firstObject!)" as! NSString
// if str != "99" {
// isYuShou = true
// }else{
// isYuShou = false
// }
// let contentArr = ["预售","普通","期货","团购"]
// let titles = NSMutableArray()
// titles.removeAllObjects()
// for num in itemTypeArr {
// let str = "\(num)" as! NSString
// if str != "99"{
// titles.add(contentArr[str.integerValue])
// }
// }
// tishixxArr.replaceObject(at: view.tag, with: titles.componentsJoined(by: ","))
//
// if itemTypeArr.componentsJoined(by: "_") == "99_99_99_99" {
// tishixxArr.replaceObject(at: view.tag, with:"请选择商品类型")
// }
//
// glSelectView?.removeFromSuperview()
// glSelectView = nil
// listTbv.reloadData()
// }
// func GLAlertSelectViewClose(sender: UIButton) {
// glSelectView?.removeFromSuperview()
// glSelectView = nil
// }
// var maxFiveImgsArr = NSMutableArray()
// var singleImgArr = NSMutableArray()
// func DelImgCellBtnClick(sender: UIButton, cell: AddImgCell) {
// if cell.isSingle == true {
// singleImgArr.removeObject(at: sender.tag)
// listTbv.reloadData()
// }else{
// maxFiveImgsArr.removeObject(at: sender.tag)
// listTbv.reloadData()
// }
//
// }
// func AddImgCellBtnClick(cell: AddImgCell) {
// if cell.addBtn.tag == 0 {//仅一张
// _ = self.presentHGImagePicker(maxSelected:1) { (assets) in
// //结果处理
// print("共选择了\(assets.count)张图片,分别如下:")
// let option = PHImageRequestOptions()
// option.isSynchronous = true
// option.isNetworkAccessAllowed = true
// for asset in assets {
// PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize , contentMode: .default , options: option, resultHandler: { (image, _: [AnyHashable : Any]?) in
// // print("上传图片==\(image)")
// self.singleImgArr.add(image)
// })
// }
// cell.imgs = self.singleImgArr
// }
// }else{//可多张
// _ = self.presentHGImagePicker(maxSelected:5) { (assets) in
// //结果处理
// print("共选择了\(assets.count)张图片,分别如下:")
// let option = PHImageRequestOptions()
// option.isSynchronous = true
// option.isNetworkAccessAllowed = true
// for asset in assets {
// PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize , contentMode: .default , options: option, resultHandler: { (image, _: [AnyHashable : Any]?) in
// // print("上传图片==\(image)")
// self.maxFiveImgsArr.add(image)
// })
// }
// cell.imgs = self.maxFiveImgsArr
// }
// }
// }
// func ShangPinGguiGeCellEditAction(cell: ShangPinGguiGeCell) {
// let vc = CreatNewSpecsViewController()
// vc.barTitle = "编辑规格"
// vc.datasArr = guiGeArr
// let dataDict:NSDictionary!
// if selectIdx?.item != nil {
// dataDict = guiGeArr[selectIdx!.item] as! NSDictionary
// }else{
// dataDict = guiGeArr.firstObject as! NSDictionary
// }
//
// vc.price = dataDict["price"] as! String
// vc.guiGe = dataDict["guiGe"] as! String
// vc.weight = dataDict["weight"] as! String
// vc.wenDu = dataDict["wenDu"] as! String
// vc.danWei = dataDict["danWei"] as! String
// let arr = dataDict["jieTiArr"] as! NSMutableArray
// let arr2 = dataDict["specalArr"] as! NSMutableArray
// vc.isNonYuShou = dataDict["isNonYuShou"] as! Bool
// vc.isYuShouSetting = dataDict["isYuShouSetting"] as! Bool
// vc.yuShouPrice = dataDict["yuShouPrice"] as! String
// vc.specalArr = arr2
// vc.jieTiArr = arr
// if selectIdx == nil {
// vc.selectIdx = IndexPath(item: 0, section: 0)
// }else{
// vc.selectIdx = selectIdx
// }
// print(vc.selectIdx?.item)
// vc.delegate = self
// self.navigationController?.pushViewController(vc, animated: true)
// }
//
// func CreatNewSpecsViewControllerDeleteAction() {
// print("删除数据")
// }
// func AddGuiGeCellClick(cell: AddGuiGeCell) {
// //
// print("商品详情添加图片")
// }
// @objc func addGuiGe(){
// print("新增规格")
// let vc = CreatNewSpecsViewController()
// vc.barTitle = "新增规格"
// vc.delegate = self
// print("abc == ",isYuShou)
// vc.isYuShouSetting = isYuShou
// vc.isNonYuShou = isYuShou
// vc.datasArr = guiGeArr
// self.navigationController?.pushViewController(vc, animated: true)
// }
// @objc func addImageAction(sender:UIButton){
// print(sender.tag)
// }
//
// func CreatNewSpecsViewControllerSaveAction(datas: NSMutableArray) {
// guiGeArr = datas
// listTbv.reloadData()
// }
//
// //MARK: - COLLECTIONVIEW DELEGATE
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
// return 0
// }
// func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// return guiGeArr.count
// }
//
// func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath)
// as! ItemCell
// cell.tag = indexPath.row
// if selectIdx == nil {
// selectIdx = IndexPath(item: 0, section: 0)
// }
// if indexPath == selectIdx {
// cell.nameLbl.textColor = UIColor(named: "蓝色字体颜色")
// cell.lineView.isHidden = false
// }else{
// cell.nameLbl.textColor = UIColor(named: "标题字颜色")
// cell.lineView.isHidden = true
// }
// return cell
//
// }
// func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// selectIdx = indexPath
// //刷新cell
// print("selectItem",selectIdx?.item)
// listTbv.reloadData()
// collectionView.reloadData()
// }
//}
GeliBusinessPlatform/ViewController/商品详情/ProductDetailViewController.swift
View file @
9f3a4b1f
...
...
@@ -10,8 +10,7 @@ import UIKit
import
LGButton
import
Photos
class
ProductDetailViewController
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
TitleAndBtnCellDelegate
,
GLAlertSelectViewDelegate
,
GoodsClassViewControllerDelegate
,
PinPaiListViewControllerDelegate
,
AddImgCellDelegate
,
AddGuiGeCellDelegate
,
CreatNewSpecsViewControllerDelegate
,
ShangPinGguiGeCellDelegate
,
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
,
TitleAndSwitchCellDelegate
,
TitleAndTFCellDelegate
{
class
ProductDetailViewController
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
TitleAndBtnCellDelegate
,
GLAlertSelectViewDelegate
,
GoodsClassViewControllerDelegate
,
PinPaiListViewControllerDelegate
,
AddImgCellDelegate
,
AddGuiGeCellDelegate
,
CreatNewSpecsViewControllerDelegate
,
ShangPinGguiGeCellDelegate
,
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
,
TitleAndSwitchCellDelegate
,
TitleAndTFCellDelegate
,
YuShouWeiKuanFaHuoCellDelegate
{
let
titleArr
=
[
"商品信息"
,
"商品图片"
,
"商品规格"
,
"预售设置"
,
"其它信息"
,
"商品详情"
]
let
spxxArr
=
[
"商品名称"
,
"商品类型"
,
"商品分类"
,
"品牌"
,
"起卖数量"
,
"是否清真"
,
"是否询价"
]
...
...
@@ -23,7 +22,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let
ysszHolder
=
[
"0"
,
"请选择时段"
,
"请选择时段"
,
"0"
]
var
shangPinStatusArr
=
[
"热销"
,
"爆款"
,
"新品"
,
"促销"
,
"外采"
,
"团购"
]
var
yunShuTypeArr
=
[
"冷链"
,
"常温"
,
"热链"
]
var
countryArr
=
[
"中国"
]
var
layout
=
UICollectionViewFlowLayout
()
var
glSelectView
:
GLAlertSelectView
?
...
...
@@ -35,31 +34,34 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
var
isYuShou
:
Bool
=
false
//是否预售
var
shangPinStatus
:
Int
?
//商品状态
var
yunShuType
:
Int
?
//运输类型
var
maxFiveImgsArr
=
NSMutableArray
()
//多图
var
singleImgArr
=
NSMutableArray
()
//单张图
var
maxFiveImgsArr
:
Array
<
UIImage
>
=
[]
//多图
var
singleImgArr
:
Array
<
UIImage
>
=
[]
//单张图
var
itemName
=
""
//商品名称
var
qiMaiShuLiang
=
""
//起卖数量
var
shiFouQZ
=
false
//是否清真
var
shiFouXJ
=
false
//是否询价
var
keyWord
=
""
//关键字
var
wuLiuPrice
=
""
//物流费用
var
guiGeArr
:
NSMutableArray
=
[]
//规格数组,根据规格资料数量控制右上角新增按钮是否显示
var
countrySelect
:
Int
?
//选择国家
var
guiGeArr
:
Array
<
GuiGeModel
>
=
[]
//规格数组,根据规格资料数量控制右上角新增按钮是否显示
var
shiFouSH
=
false
//是否审核
var
faHuoTime
=
""
//发货时间
//MARK:--保存按钮
@IBAction
func
submitAction
(
_
sender
:
Any
)
{
print
(
"保存按钮submitAction"
)
print
(
itemName
)
//商品名称
print
(
itemTypeArr
)
//商品类型
print
(
qiMaiShuLiang
)
//起卖数量
print
(
shiFouQZ
)
//是否清真
print
(
shiFouXJ
)
//是否询价
print
(
singleImgArr
.
firstObject
)
//商品封面图
print
(
maxFiveImgsArr
)
//商品主图
print
(
guiGeArr
)
//商品规格
print
(
keyWord
)
//关键字
print
(
wuLiuPrice
)
//物流费用
print
(
shangPinStatusArr
[
shangPinStatus
!
])
//商品状态
print
(
yunShuTypeArr
[
yunShuType
!
])
//运输方式
//
print(itemName)//商品名称
//
print(itemTypeArr)//商品类型
//
print(qiMaiShuLiang)//起卖数量
//
print(shiFouQZ)//是否清真
//
print(shiFouXJ)//是否询价
// print(singleImgArr[0]
)//商品封面图
//
print(maxFiveImgsArr)//商品主图
//
print(guiGeArr)//商品规格
//
print(keyWord)//关键字
//
print(wuLiuPrice)//物流费用
//
print(shangPinStatusArr[shangPinStatus!])//商品状态
//
print(yunShuTypeArr[yunShuType!])//运输方式
// print(countryArr[countrySelect!])//选择国家
}
@IBOutlet
weak
var
submitBtn
:
LGButton
!
@IBOutlet
weak
var
listTbv
:
UITableView
!
...
...
@@ -80,7 +82,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}
//是否为预售商品
isYuShouShangPin
=
fals
e
isYuShouShangPin
=
tru
e
navbar
.
title
=
"商品详情"
self
.
view
.
addSubview
(
navbar
)
...
...
@@ -107,22 +109,42 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
if
indexPath
.
row
==
0
||
indexPath
.
row
==
4
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
spxxArr
[
indexPath
.
row
]
//商家名称
switch
cell
.
nameLbl
.
text
{
case
"商家名称"
:
cell
.
textTF
.
text
=
itemName
break
case
"起卖数量"
:
cell
.
textTF
.
text
=
qiMaiShuLiang
break
default
:
break
}
cell
.
textTF
.
placeholder
=
tishixxArr
[
indexPath
.
row
]
as!
String
cell
.
delegate
=
self
return
cell
}
if
indexPath
.
row
>
4
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
delegate
=
self
cell
.
namelbl
.
text
=
spxxArr
[
indexPath
.
row
]
cell
.
delegate
=
self
switch
cell
.
namelbl
.
text
{
case
"是否清真"
:
cell
.
infoSw
.
isOn
=
shiFouQZ
break
case
"是否询价"
:
cell
.
infoSw
.
isOn
=
shiFouXJ
break
default
:
break
}
return
cell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
nameLbl
.
text
=
spxxArr
[
indexPath
.
row
]
cell
.
contentLbl
.
text
=
tishixxArr
[
indexPath
.
row
]
as!
String
cell
.
tag
=
indexPath
.
row
cell
.
delegate
=
self
return
cell
case
1
:
...
...
@@ -130,10 +152,21 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
cell
.
nameLbl
.
text
=
sptpArr
[
indexPath
.
row
]
if
indexPath
.
row
==
0
{
cell
.
isSingle
=
true
if
singleImgArr
.
count
>
0
{
cell
.
imgs
=
singleImgArr
cell
.
addBtn
.
isHidden
=
true
}
else
{
cell
.
scrollView
?
.
isHidden
=
true
cell
.
addBtn
.
isHidden
=
false
}
}
else
{
cell
.
isSingle
=
false
if
maxFiveImgsArr
.
count
>
0
{
cell
.
imgs
=
maxFiveImgsArr
}
else
{
cell
.
scrollView
?
.
isHidden
=
true
cell
.
addBtnX
.
constant
=
15
}
}
cell
.
delegate
=
self
cell
.
addBtn
.
tag
=
indexPath
.
row
...
...
@@ -143,18 +176,19 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
if
guiGeArr
.
count
>
0
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ShangPinGguiGeCell"
)
as!
ShangPinGguiGeCell
cell
.
delegate
=
self
var
dict
:
NSDictionary
!
var
dict
:
GuiGeModel
!
if
selectIdx
!=
nil
{
dict
=
guiGeArr
[
selectIdx
!.
item
]
as!
NSDictionary
dict
=
guiGeArr
[
selectIdx
!.
item
]
as!
GuiGeModel
}
else
{
dict
=
guiGeArr
.
firstObject
as!
NSDictionary
dict
=
guiGeArr
.
first
as!
GuiGeModel
}
cell
.
tempLbl
.
text
=
"冷藏:
\(
String
(
describing
:
dict
[
"wenDu"
]
!
)
)
℃"
cell
.
weightLbl
.
text
=
"重量(kg):
\(
String
(
describing
:
dict
[
"weight"
]
!
)
)
kg"
cell
.
guiGeLbl
.
text
=
"规格:
\(
String
(
describing
:
dict
[
"guiGe"
]
!
)
)
kg/件"
cell
.
danWeiLbl
.
text
=
"单位:
\(
String
(
describing
:
dict
[
"danWei"
]
!
)
)
"
cell
.
sellPriceLbl
.
text
=
"售价:¥
\(
dict
[
"price"
]
!
)
"
cell
.
tempLbl
.
text
=
"冷藏:
\(
dict
.
wenDu
)
℃"
cell
.
weightLbl
.
text
=
"重量(kg):
\(
dict
.
weight
)
kg"
cell
.
guiGeLbl
.
text
=
"规格:
\(
dict
.
guiGe
)
kg/件"
cell
.
danWeiLbl
.
text
=
"单位:
\(
dict
.
danWei
)
"
cell
.
sellPriceLbl
.
text
=
"售价:¥
\(
dict
.
price
)
"
return
cell
}
...
...
@@ -168,13 +202,15 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
namelbl
.
text
=
ysszArr
[
indexPath
.
row
]
cell
.
delegate
=
self
cell
.
infoSw
.
isOn
=
shiFouSH
return
cell
}
if
indexPath
.
row
==
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"YuShouWeiKuanFaHuoCell"
)
as!
YuShouWeiKuanFaHuoCell
cell
.
nameLbl
.
text
=
ysszArr
[
indexPath
.
row
]
cell
.
textTF
.
keyboardType
=
.
numberPad
cell
.
delegate
=
self
cell
.
textTF
.
text
=
faHuoTime
return
cell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
...
...
@@ -186,6 +222,16 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
if
indexPath
.
row
<
2
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
qtxxArr
[
indexPath
.
row
]
switch
cell
.
nameLbl
.
text
{
case
"关键字"
:
cell
.
textTF
.
text
=
keyWord
break
case
"物流费用"
:
cell
.
textTF
.
text
=
wuLiuPrice
break
default
:
break
}
cell
.
textTF
.
placeholder
=
tishixxArr1
[
indexPath
.
row
]
as!
String
cell
.
tag
=
indexPath
.
row
cell
.
delegate
=
self
...
...
@@ -250,7 +296,18 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
if
cell
.
nameLbl
.
text
==
"国家"
{
print
(
"选择国家"
)
if
glSelectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择国家"
view
.
delegate
=
self
view
.
dataArr
=
countryArr
if
countrySelect
!=
nil
{
view
.
selectNum
=
countrySelect
!
}
self
.
view
.
addSubview
(
view
)
glSelectView
=
view
}
}
if
cell
.
nameLbl
.
text
==
"商品状态"
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
...
...
@@ -304,13 +361,51 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
singleImgArr
.
add
(
image
)
self
.
singleImgArr
.
append
(
image
!
)
})
}
self
.
listTbv
.
reloadData
()
}
}
else
{
//可多张
let
num
=
5
-
maxFiveImgsArr
.
count
_
=
self
.
presentHGImagePicker
(
maxSelected
:
num
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
let
option
=
PHImageRequestOptions
()
option
.
isSynchronous
=
true
option
.
isNetworkAccessAllowed
=
true
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
maxFiveImgsArr
.
append
(
image
!
)
})
}
self
.
listTbv
.
reloadData
()
}
}
}
//MARK: - 修改图片
func
ChangeCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
{
print
(
sender
.
tag
)
if
cell
.
addBtn
.
tag
==
0
{
//仅一张
_
=
self
.
presentHGImagePicker
(
maxSelected
:
1
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
let
option
=
PHImageRequestOptions
()
option
.
isSynchronous
=
true
option
.
isNetworkAccessAllowed
=
true
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
singleImgArr
.
removeAll
()
self
.
singleImgArr
.
append
(
image
!
)
})
}
cell
.
imgs
=
self
.
singleImgArr
self
.
listTbv
.
reloadData
()
}
}
else
{
//可多张
_
=
self
.
presentHGImagePicker
(
maxSelected
:
5
)
{
(
assets
)
in
let
num
=
5
-
maxFiveImgsArr
.
count
_
=
self
.
presentHGImagePicker
(
maxSelected
:
num
)
{
(
assets
)
in
//结果处理
print
(
"共选择了
\(
assets
.
count
)
张图片,分别如下:"
)
let
option
=
PHImageRequestOptions
()
...
...
@@ -319,20 +414,21 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
for
asset
in
assets
{
PHImageManager
.
default
()
.
requestImage
(
for
:
asset
,
targetSize
:
PHImageManagerMaximumSize
,
contentMode
:
.
default
,
options
:
option
,
resultHandler
:
{
(
image
,
_
:
[
AnyHashable
:
Any
]?)
in
// print("上传图片==\(image)")
self
.
maxFiveImgsArr
.
add
(
image
)
self
.
maxFiveImgsArr
.
insert
(
image
!
,
at
:
sender
.
tag
)
self
.
maxFiveImgsArr
.
remove
(
at
:
sender
.
tag
+
1
)
})
}
cell
.
imgs
=
self
.
maxFiveImgsArr
self
.
listTbv
.
reloadData
()
}
}
}
//MARK: - 删除图片处理
func
DelImgCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
{
func
DelImgCellBtnClick
(
sender
:
UIButton
,
cell
:
AddImgCell
)
{
if
cell
.
isSingle
==
true
{
singleImgArr
.
remove
Object
(
at
:
sender
.
tag
)
singleImgArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
else
{
maxFiveImgsArr
.
remove
Object
(
at
:
sender
.
tag
)
maxFiveImgsArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
}
...
...
@@ -413,25 +509,23 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let
vc
=
CreatNewSpecsViewController
()
vc
.
barTitle
=
"编辑规格"
vc
.
datasArr
=
guiGeArr
let
dataDict
:
NSDictionary
!
let
dataDict
:
GuiGeModel
!
if
selectIdx
?
.
item
!=
nil
{
dataDict
=
guiGeArr
[
selectIdx
!.
item
]
as!
NSDictionary
dataDict
=
guiGeArr
[
selectIdx
!.
item
]
}
else
{
dataDict
=
guiGeArr
.
firstObject
as!
NSDictionary
}
vc
.
price
=
dataDict
[
"price"
]
as!
String
vc
.
guiGe
=
dataDict
[
"guiGe"
]
as!
String
vc
.
weight
=
dataDict
[
"weight"
]
as!
String
vc
.
wenDu
=
dataDict
[
"wenDu"
]
as!
String
vc
.
danWei
=
dataDict
[
"danWei"
]
as!
String
let
arr
=
dataDict
[
"jieTiArr"
]
as!
NSMutableArray
let
arr2
=
dataDict
[
"specalArr"
]
as!
NSMutableArray
vc
.
isNonYuShou
=
dataDict
[
"isNonYuShou"
]
as!
Bool
vc
.
isYuShouSetting
=
dataDict
[
"isYuShouSetting"
]
as!
Bool
vc
.
yuShouPrice
=
dataDict
[
"yuShouPrice"
]
as!
String
vc
.
specalArr
=
arr2
vc
.
jieTiArr
=
arr
dataDict
=
guiGeArr
.
first
}
vc
.
price
=
dataDict
.
price
vc
.
guiGe
=
dataDict
.
guiGe
vc
.
weight
=
dataDict
.
weight
vc
.
wenDu
=
dataDict
.
wenDu
vc
.
danWei
=
dataDict
.
danWei
vc
.
isNonYuShou
=
dataDict
.
isNonYuShou
vc
.
isYuShouSetting
=
dataDict
.
isYuShouSetting
vc
.
yuShouPrice
=
dataDict
.
yuShouPrice
vc
.
specalArr
=
dataDict
.
specalArr
vc
.
jieTiArr
=
dataDict
.
jieTiArr
if
selectIdx
==
nil
{
vc
.
selectIdx
=
IndexPath
(
item
:
0
,
section
:
0
)
}
else
{
...
...
@@ -459,7 +553,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}
//MARK: - 新增、编辑规格
func
CreatNewSpecsViewControllerSaveAction
(
datas
:
NSMutableArray
)
{
func
CreatNewSpecsViewControllerSaveAction
(
datas
:
Array
<
GuiGeModel
>
)
{
guiGeArr
=
datas
listTbv
.
reloadData
()
}
...
...
@@ -503,6 +597,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
case
"是否询价"
:
shiFouXJ
=
content
.
isOn
break
case
"用户付款是否需要审核"
:
shiFouSH
=
content
.
isOn
break
default
:
break
}
...
...
@@ -624,6 +721,10 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}
}
func
YuShouWeiKuanFaHuoCellString
(
str
:
String
)
{
faHuoTime
=
str
print
(
faHuoTime
)
}
override
func
backAction
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
...
...
GeliBusinessPlatform/ViewController/新增规格/CreatNewSpecsViewController.swift
View file @
9f3a4b1f
...
...
@@ -9,7 +9,7 @@
import
UIKit
import
LGButton
protocol
CreatNewSpecsViewControllerDelegate
{
func
CreatNewSpecsViewControllerSaveAction
(
datas
:
NSMutableArray
)
func
CreatNewSpecsViewControllerSaveAction
(
datas
:
Array
<
GuiGeModel
>
)
func
CreatNewSpecsViewControllerDeleteAction
()
}
class
CreatNewSpecsViewController
:
BaseViewController
,
UITableViewDelegate
,
UITableViewDataSource
,
TitleAndTFCellDelegate
,
TitleAndBtnCellDelegate
,
TitleAndSwitchCellDelegate
,
TitleAndSwitchHeaderViewDelegate
,
NewCreateHeaderDelegate
,
NewCreateFooterDelegate
,
YuShouCellDelegate
,
GLAlertSelectViewDelegate
,
PuTongJieTiCellDelegate
,
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
{
...
...
@@ -19,9 +19,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
var
delegate
:
CreatNewSpecsViewControllerDelegate
?
var
collectView
:
UICollectionView
?
var
datasArr
:
NSMutableArray
=
[]
var
dataDict
:
NSDictionary
?
var
datasArr
:
Array
<
GuiGeModel
>
=
[]
var
dataModel
=
GuiGeModel
()
let
titleArray
=
[
"售价:"
,
"规格:"
,
"重量:"
,
"温藏:"
,
"单位:"
]
let
pliceHolderArr
=
[
"请输入商品售价"
,
"请输入商品规格"
,
"请输入商品重量"
,
"请选择商品温藏"
,
"请选择商品单位"
]
@IBOutlet
weak
var
bottomBtn
:
LGButton
!
...
...
@@ -68,16 +67,16 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
danWei
=
newValue
}
}
//规格
var
specalArr
:
NSMutableArray
=
[]{
var
specalArr
:
Array
<
Any
>
=
[]{
willSet
{
specalArr
.
removeAll
Objects
()
specalArr
.
removeAll
()
specalArr
=
newValue
}
}
//预售
var
jieTiArr
:
NSMutableArray
=
[]{
var
jieTiArr
:
Array
<
Any
>
=
[]{
willSet
{
jieTiArr
.
removeAll
Objects
()
jieTiArr
.
removeAll
()
jieTiArr
=
newValue
}
...
...
@@ -186,24 +185,26 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
// }
// }
let
dict
=
NSMutableDictionary
()
dict
[
"price"
]
=
price
dict
[
"guiGe"
]
=
guiGe
dict
[
"weight"
]
=
weight
dict
[
"wenDu"
]
=
wenDu
dict
[
"danWei"
]
=
danWei
dict
[
"jieTiArr"
]
=
jieTiArr
dict
[
"specalArr"
]
=
specalArr
dict
[
"itemIdx"
]
=
datasArr
.
count
dict
[
"isNonYuShou"
]
=
isNonYuShou
dict
[
"isYuShouSetting"
]
=
isYuShouSetting
dict
[
"yuShouPrice"
]
=
yuShouPrice
// let dict = NSMutableDictionary()
dataModel
.
price
=
price
dataModel
.
guiGe
=
guiGe
dataModel
.
weight
=
weight
dataModel
.
wenDu
=
wenDu
dataModel
.
danWei
=
danWei
dataModel
.
jieTiArr
=
jieTiArr
as!
Array
<
Any
>
dataModel
.
specalArr
=
specalArr
as!
Array
<
Any
>
dataModel
.
isNonYuShou
=
isNonYuShou
dataModel
.
isYuShouSetting
=
isYuShouSetting
dataModel
.
yuShouPrice
=
yuShouPrice
if
barTitle
?
.
contains
(
"编辑"
)
==
true
{
datasArr
.
replaceObject
(
at
:
selectIdx
!.
item
,
with
:
dict
)
// datasArr.replaceObject(at: selectIdx!.item, with: dict)
datasArr
.
insert
(
dataModel
,
at
:
selectIdx
!.
item
)
datasArr
.
remove
(
at
:
selectIdx
!.
item
+
1
)
}
else
{
datasArr
.
a
dd
(
dict
)
datasArr
.
a
ppend
(
dataModel
)
}
delegate
?
.
CreatNewSpecsViewControllerSaveAction
(
datas
:
datasArr
)
delegate
?
.
CreatNewSpecsViewControllerSaveAction
(
datas
:
datasArr
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
//MARK: - cell delegate
...
...
@@ -529,29 +530,33 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
func
footerClickAction
()
{
print
(
jieTiArr
)
if
selectYuShou
{
//预售
specalArr
.
a
d
d
(
""
)
specalArr
.
a
ppen
d
(
""
)
}
else
{
//非预售
jieTiArr
.
a
d
d
(
""
)
jieTiArr
.
a
ppen
d
(
""
)
}
listTbv
.
reloadData
()
}
func
YuShouCellSwitchStatus
(
sender
:
UISwitch
)
{
//控制
print
(
"status3 =
\(
isYuShouSetting
)
,
\(
isJieTiJiaSetting
)
"
)
isYuShouSetting
=
sender
.
isOn
listTbv
.
reloadData
()
}
func
PuTongJieTiDelAction
(
sender
:
UIButton
)
{
jieTiArr
.
remove
Object
(
at
:
sender
.
tag
)
print
(
jieTiArr
)
func
PuTongJieTiDelAction
(
sender
:
PuTongJieTiCell
)
{
jieTiArr
.
remove
(
at
:
sender
.
tag
)
print
(
jieTiArr
,
sender
.
tag
)
listTbv
.
reloadData
()
}
func
PuTongJieTiContent
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
{
if
selectYuShou
{
specalArr
.
replaceObject
(
at
:
cell
.
tag
,
with
:
"
\(
price
)
_
\(
count
)
"
)
specalArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
print
(
specalArr
)
specalArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
else
{
jieTiArr
.
replaceObject
(
at
:
cell
.
tag
,
with
:
"
\(
price
)
_
\(
count
)
"
)
jieTiArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
print
(
jieTiArr
)
jieTiArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
}
...
...
@@ -589,19 +594,17 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func
collectionView
(
_
collectionView
:
UICollectionView
,
didSelectItemAt
indexPath
:
IndexPath
)
{
selectIdx
=
indexPath
//刷新cell
let
dataDict
=
datasArr
[
selectIdx
!.
item
]
as!
NSDictionary
price
=
dataDict
[
"price"
]
as!
String
guiGe
=
dataDict
[
"guiGe"
]
as!
String
weight
=
dataDict
[
"weight"
]
as!
String
wenDu
=
dataDict
[
"wenDu"
]
as!
String
danWei
=
dataDict
[
"danWei"
]
as!
String
let
arr
=
dataDict
[
"jieTiArr"
]
as!
NSMutableArray
let
arr2
=
dataDict
[
"specalArr"
]
as!
NSMutableArray
isNonYuShou
=
dataDict
[
"isNonYuShou"
]
as!
Bool
isYuShouSetting
=
dataDict
[
"isYuShouSetting"
]
as!
Bool
yuShouPrice
=
dataDict
[
"yuShouPrice"
]
as!
String
specalArr
=
arr2
jieTiArr
=
arr
let
dataDict
=
datasArr
[
selectIdx
!.
item
]
price
=
dataDict
.
price
guiGe
=
dataDict
.
guiGe
weight
=
dataDict
.
weight
wenDu
=
dataDict
.
wenDu
danWei
=
dataDict
.
danWei
isNonYuShou
=
dataDict
.
isNonYuShou
isYuShouSetting
=
dataDict
.
isYuShouSetting
yuShouPrice
=
dataDict
.
yuShouPrice
specalArr
=
dataDict
.
specalArr
jieTiArr
=
dataDict
.
jieTiArr
listTbv
.
reloadData
()
collectionView
.
reloadData
()
}
...
...
GeliBusinessPlatform/ViewController/新增规格/GuiGeModel.swift
0 → 100644
View file @
9f3a4b1f
//
// GuiGeModel.swift
// GeliBusinessPlatform
//
// Created by junye lu on 2020/5/15.
// Copyright © 2020 junye lu. All rights reserved.
//
import
Foundation
class
GuiGeModel
:
NSObject
{
///售价
var
price
:
String
=
""
///规格
var
guiGe
:
String
=
""
///重量
var
weight
:
String
=
""
///温度
var
wenDu
:
String
=
""
///单位
var
danWei
:
String
=
""
///是否预售
var
isNonYuShou
:
Bool
=
false
///是否打开预售设置
var
isYuShouSetting
:
Bool
=
false
///预售价格
var
yuShouPrice
:
String
=
""
///普通阶梯价
var
jieTiArr
:
Array
<
Any
>
=
[]
///预售阶梯价
var
specalArr
:
Array
<
Any
>
=
[]
}
GeliBusinessPlatform/ViewController/新增规格/PuTongJieTiCell.swift
View file @
9f3a4b1f
...
...
@@ -8,16 +8,15 @@
import
UIKit
@objc
protocol
PuTongJieTiCellDelegate
{
@objc
optional
func
PuTongJieTiDelAction
(
sender
:
UIButton
)
@objc
optional
func
PuTongJieTiDelAction
(
sender
:
PuTongJieTiCell
)
@objc
optional
func
PuTongJieTiContent
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
}
class
PuTongJieTiCell
:
UITableViewCell
{
var
delegate
:
PuTongJieTiCellDelegate
?
@IBAction
func
delAction
(
_
sender
:
UIButton
)
{
delegate
?
.
PuTongJieTiDelAction
?(
sender
:
se
nder
)
delegate
?
.
PuTongJieTiDelAction
?(
sender
:
se
lf
)
}
@IBOutlet
weak
var
priceTF
:
UITextField
!
@IBOutlet
weak
var
countTF
:
UITextField
!
@IBOutlet
weak
var
titleLbl
:
UILabel
!
...
...
GeliBusinessPlatform/ViewController/新增规格/YuShouCell.xib
View file @
9f3a4b1f
...
...
@@ -156,7 +156,7 @@
<color
red=
"0.18000000715255737"
green=
"0.18000000715255737"
blue=
"0.18000000715255737"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
</namedColor>
<namedColor
name=
"标题字颜色"
>
<color
red=
"0.180
3921568627451"
green=
"0.1803921568627451"
blue=
"0.1803921568627451
"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<color
red=
"0.180
00000715255737"
green=
"0.18000000715255737"
blue=
"0.18000000715255737
"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
</namedColor>
<namedColor
name=
"灰色分界线"
>
<color
red=
"0.92941176470588238"
green=
"0.92941176470588238"
blue=
"0.92941176470588238"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
...
...
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