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
346d3d08
Commit
346d3d08
authored
May 27, 2020
by
lujunye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充规格填写售价,重量输入格式错误提醒
parent
680fd596
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
434 additions
and
423 deletions
+434
-423
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
...erdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/View/Cell/TitleAndTFCell.swift
GeliBusinessPlatform/View/Cell/TitleAndTFCell.swift
+1
-3
GeliBusinessPlatform/ViewController/新增规格/CreatNewSpecsViewController.swift
...orm/ViewController/新增规格/CreatNewSpecsViewController.swift
+433
-420
No files found.
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
View file @
346d3d08
No preview for this file type
GeliBusinessPlatform/View/Cell/TitleAndTFCell.swift
View file @
346d3d08
...
...
@@ -22,9 +22,7 @@ class TitleAndTFCell: UITableViewCell {
// Initialization code
}
@objc
func
textEditing
(
sender
:
UITextField
){
// if sender.text!.count > 0 {
delegate
?
.
textFieldContent
?(
content
:
sender
.
text
!
,
cell
:
self
)
// }
delegate
?
.
textFieldContent
?(
content
:
sender
.
text
!
,
cell
:
self
)
}
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
super
.
setSelected
(
selected
,
animated
:
animated
)
...
...
GeliBusinessPlatform/ViewController/新增规格/CreatNewSpecsViewController.swift
View file @
346d3d08
...
...
@@ -237,490 +237,503 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func
textFieldDidEndEditing
(
_
textField
:
UITextField
)
{
switch
textField
.
tag
{
case
0
:
textField
.
text
=
formatShowNumber
(
value
:
textField
.
text
!
)
price
=
textField
.
text
!
if
isPurnNumber
(
str
:
textField
.
text
!
)
{
textField
.
text
=
formatShowNumber
(
value
:
textField
.
text
!
)
price
=
textField
.
text
!
}
else
{
HUD
.
flash
(
.
label
(
"请输入正确的价格"
),
delay
:
1.2
)
textField
.
text
=
""
price
=
textField
.
text
!
}
break
case
2
:
textField
.
text
=
formatShowNumber
(
value
:
textField
.
text
!
)
weight
=
textField
.
text
!
break
default
:
break
}
}
func
textFieldShouldReturn
(
_
textField
:
UITextField
)
->
Bool
{
switch
textField
.
tag
{
case
1
:
guiGe
=
textField
.
text
!
if
isPurnNumber
(
str
:
textField
.
text
!
)
{
textField
.
text
=
formatShowNumber
(
value
:
textField
.
text
!
)
weight
=
textField
.
text
!
}
else
{
HUD
.
flash
(
.
label
(
"请输入正确的重量"
),
delay
:
1.2
)
textField
.
text
=
""
price
=
textField
.
text
!
}
break
default
:
break
}
return
true
}
func
PuTongJieTiClickDone
()
{
IQKeyboardManager
.
shared
.
resignFirstResponder
()
func
textFieldShouldReturn
(
_
textField
:
UITextField
)
->
Bool
{
switch
textField
.
tag
{
case
1
:
guiGe
=
textField
.
text
!
break
default
:
break
}
return
true
}
func
PuTongJieTiClickDone
()
{
IQKeyboardManager
.
shared
.
resignFirstResponder
()
}
//MARK: - cell delegate
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
if
(
navbar
.
title
?
.
contains
(
"编辑"
))
!
{
return
4
}
else
{
return
3
}
//MARK: - cell delegate
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
if
(
navbar
.
title
?
.
contains
(
"编辑"
))
!
{
return
4
}
else
{
return
3
}
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
section
==
0
{
return
titleArray
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
section
==
0
{
return
titleArray
.
count
}
if
section
==
2
{
if
selectYuShou
{
//预售
return
specalArr
.
count
}
else
{
//非预售
return
jieTiArr
.
count
}
if
section
==
2
{
if
selectYuShou
{
//预售
return
specalArr
.
count
}
else
{
//非预售
return
jieTiArr
.
count
}
return
1
}
return
1
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
if
indexPath
.
section
==
0
{
if
indexPath
.
row
<
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
titleArray
[
indexPath
.
row
]
cell
.
textTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
tag
=
indexPath
.
row
cell
.
textTF
.
tag
=
cell
.
tag
//keyboardType
cell
.
textTF
.
returnKeyType
=
.
done
cell
.
textTF
.
delegate
=
self
if
indexPath
.
row
==
0
||
indexPath
.
row
==
2
{
cell
.
textTF
.
keyboardType
=
.
decimalPad
}
let
str
=
NSAttributedString
(
string
:
pliceHolderArr
[
indexPath
.
row
],
attributes
:
[
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
(
named
:
"灰色字体颜色"
)])
cell
.
textTF
.
attributedPlaceholder
=
str
if
datasArr
.
count
>
0
{
switch
indexPath
.
row
{
case
0
:
cell
.
textTF
.
text
=
price
break
case
1
:
cell
.
textTF
.
text
=
guiGe
break
default
:
cell
.
textTF
.
text
=
weight
break
}
}
cell
.
delegate
=
self
return
cell
}
else
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
tag
=
indexPath
.
row
cell
.
btn
.
isUserInteractionEnabled
=
isAllEditing
cell
.
delegate
=
self
cell
.
nameLbl
.
text
=
titleArray
[
indexPath
.
row
]
cell
.
contentLbl
.
text
=
pliceHolderArr
[
indexPath
.
row
]
if
indexPath
.
row
==
3
{
if
tempSelect
!=
nil
{
cell
.
contentLbl
.
text
=
selectListArr
[
tempSelect
!
]
}
if
indexPath
.
section
==
0
{
if
indexPath
.
row
<
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndTF"
)
as!
TitleAndTFCell
cell
.
nameLbl
.
text
=
titleArray
[
indexPath
.
row
]
cell
.
textTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
tag
=
indexPath
.
row
cell
.
textTF
.
tag
=
cell
.
tag
//keyboardType
cell
.
textTF
.
returnKeyType
=
.
done
cell
.
textTF
.
delegate
=
self
if
indexPath
.
row
==
0
||
indexPath
.
row
==
2
{
cell
.
textTF
.
keyboardType
=
.
decimalPad
}
let
str
=
NSAttributedString
(
string
:
pliceHolderArr
[
indexPath
.
row
],
attributes
:
[
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
(
named
:
"灰色字体颜色"
)])
cell
.
textTF
.
attributedPlaceholder
=
str
if
datasArr
.
count
>
0
{
switch
indexPath
.
row
{
case
0
:
cell
.
textTF
.
text
=
price
break
case
1
:
cell
.
textTF
.
text
=
guiGe
break
default
:
cell
.
textTF
.
text
=
weight
break
}
if
indexPath
.
row
==
4
{
if
itemDanWeiSelect
!=
nil
{
cell
.
contentLbl
.
text
=
danWeiArr
!
[
itemDanWeiSelect
!
]
}
}
cell
.
delegate
=
self
return
cell
}
else
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndBtn"
)
as!
TitleAndBtnCell
cell
.
tag
=
indexPath
.
row
cell
.
btn
.
isUserInteractionEnabled
=
isAllEditing
cell
.
delegate
=
self
cell
.
nameLbl
.
text
=
titleArray
[
indexPath
.
row
]
cell
.
contentLbl
.
text
=
pliceHolderArr
[
indexPath
.
row
]
if
indexPath
.
row
==
3
{
if
tempSelect
!=
nil
{
cell
.
contentLbl
.
text
=
selectListArr
[
tempSelect
!
]
}
if
datasArr
.
count
>
0
{
switch
indexPath
.
row
{
case
3
:
cell
.
contentLbl
.
text
=
wenDu
break
case
4
:
cell
.
contentLbl
.
text
=
danWei
break
default
:
break
}
}
if
indexPath
.
row
==
4
{
if
itemDanWeiSelect
!=
nil
{
cell
.
contentLbl
.
text
=
danWeiArr
!
[
itemDanWeiSelect
!
]
}
return
cell
}
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
delegate
=
self
cell
.
namelbl
.
font
=
UIFont
.
boldSystemFont
(
ofSize
:
15
)
cell
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
if
indexPath
.
section
==
1
{
cell
.
namelbl
.
text
=
"预售设置"
if
isYuShouSetting
==
false
{
isOpenYSSetting
=
isYuShouSetting
cell
.
namelbl
.
alpha
=
0.45
cell
.
isUserInteractionEnabled
=
false
}
else
{
cell
.
infoSw
.
isOn
=
isOpenYSSetting
if
datasArr
.
count
>
0
{
switch
indexPath
.
row
{
case
3
:
cell
.
contentLbl
.
text
=
wenDu
break
case
4
:
cell
.
contentLbl
.
text
=
danWei
break
default
:
break
}
}
cell
.
tag
=
5
return
cell
}
if
indexPath
.
section
==
1
{
if
isYuShouSetting
==
true
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"YuShou"
)
as!
YuShouCell
cell
.
inputTF1
.
isUserInteractionEnabled
=
isAllEditing
cell
.
inputTF2
.
isUserInteractionEnabled
=
isAllEditing
cell
.
inputTF2
.
keyboardType
=
.
numberPad
cell
.
inputTF3
.
isUserInteractionEnabled
=
isAllEditing
cell
.
tag
=
indexPath
.
row
cell
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
cell
.
infoSw
.
isOn
=
isOpenYSSetting
cell
.
delegate
=
self
cell
.
inputTF1
.
text
=
yuShouPrice
cell
.
inputTF2
.
text
=
ysKuCun
cell
.
inputTF3
.
text
=
DJBiLi
return
cell
}
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"TitleAndSwitch"
)
as!
TitleAndSwitchCell
cell
.
delegate
=
self
cell
.
namelbl
.
font
=
UIFont
.
boldSystemFont
(
ofSize
:
15
)
cell
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
if
indexPath
.
section
==
1
{
cell
.
namelbl
.
text
=
"预售设置"
if
isYuShouSetting
==
false
{
isOpenYSSetting
=
isYuShouSetting
cell
.
namelbl
.
alpha
=
0.45
cell
.
isUserInteractionEnabled
=
false
}
else
{
cell
.
infoSw
.
isOn
=
isOpenYSSetting
}
cell
.
tag
=
5
if
indexPath
.
section
==
2
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"PuTongJieTi"
)
as!
PuTongJieTiCell
cell
.
btn
.
isUserInteractionEnabled
=
isAllEditing
cell
.
delegate
=
self
cell
.
titleLbl
.
text
=
"
\(
indexPath
.
row
+
1
)
.数量≥"
}
if
indexPath
.
section
==
1
{
if
isYuShouSetting
==
true
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"YuShou"
)
as!
YuShouCell
cell
.
inputTF1
.
isUserInteractionEnabled
=
isAllEditing
cell
.
inputTF2
.
isUserInteractionEnabled
=
isAllEditing
cell
.
inputTF2
.
keyboardType
=
.
numberPad
cell
.
inputTF3
.
isUserInteractionEnabled
=
isAllEditing
cell
.
tag
=
indexPath
.
row
cell
.
countTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
priceTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
isYuShou
=
selectYuShou
cell
.
countTF
.
text
=
""
cell
.
priceTF
.
text
=
""
var
item
:
NSString
=
""
if
selectYuShou
{
item
=
specalArr
[
indexPath
.
row
]
as!
NSString
}
else
{
item
=
jieTiArr
[
indexPath
.
row
]
as!
NSString
}
if
item
!=
""
{
//MARK:--阶梯价格切割
let
arr
=
item
.
components
(
separatedBy
:
"_"
)
cell
.
priceTF
.
text
=
arr
[
0
]
cell
.
countTF
.
text
=
arr
[
1
]
}
cell
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
cell
.
infoSw
.
isOn
=
isOpenYSSetting
cell
.
delegate
=
self
cell
.
inputTF1
.
text
=
yuShouPrice
cell
.
inputTF2
.
text
=
ysKuCun
cell
.
inputTF3
.
text
=
DJBiLi
return
cell
}
if
indexPath
.
section
==
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DelGuiGe"
)
as!
DelGuiGeCell
return
cell
}
if
indexPath
.
section
==
2
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"PuTongJieTi"
)
as!
PuTongJieTiCell
cell
.
btn
.
isUserInteractionEnabled
=
isAllEditing
cell
.
delegate
=
self
cell
.
titleLbl
.
text
=
"
\(
indexPath
.
row
+
1
)
.数量≥"
cell
.
tag
=
indexPath
.
row
cell
.
countTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
priceTF
.
isUserInteractionEnabled
=
isAllEditing
cell
.
isYuShou
=
selectYuShou
cell
.
countTF
.
text
=
""
cell
.
priceTF
.
text
=
""
var
item
:
NSString
=
""
if
selectYuShou
{
item
=
specalArr
[
indexPath
.
row
]
as!
NSString
}
else
{
item
=
jieTiArr
[
indexPath
.
row
]
as!
NSString
}
if
item
!=
""
{
//MARK:--阶梯价格切割
let
arr
=
item
.
components
(
separatedBy
:
"_"
)
cell
.
priceTF
.
text
=
arr
[
0
]
cell
.
countTF
.
text
=
arr
[
1
]
}
return
cell
}
if
indexPath
.
section
==
3
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"DelGuiGe"
)
as!
DelGuiGeCell
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
isAllEditing
==
false
{
return
}
if
indexPath
.
section
==
3
{
//删除
datasArr
.
remove
(
at
:
selectIdx
!.
item
)
var
num
=
0
if
selectIdx
!.
item
>
0
{
num
=
selectIdx
!.
item
-
1
}
let
idx
=
IndexPath
(
item
:
num
,
section
:
0
)
delegate
?
.
CreatNewSpecsViewControllerDeleteAction
(
datas
:
datasArr
,
selectIdx
:
idx
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
isAllEditing
==
false
{
return
}
if
indexPath
.
section
==
3
{
//删除
datasArr
.
remove
(
at
:
selectIdx
!.
item
)
var
num
=
0
if
selectIdx
!.
item
>
0
{
num
=
selectIdx
!.
item
-
1
}
let
idx
=
IndexPath
(
item
:
num
,
section
:
0
)
delegate
?
.
CreatNewSpecsViewControllerDeleteAction
(
datas
:
datasArr
,
selectIdx
:
idx
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
indexPath
.
section
==
1
{
if
isOpenYSSetting
{
return
184.5
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
indexPath
.
section
==
1
{
if
isOpenYSSetting
{
return
184.5
}
if
indexPath
.
section
==
2
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
return
49
}
if
indexPath
.
section
==
2
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
return
49
}
if
isYsJieTiOpen
&&
selectYuShou
{
return
49
}
return
0.001
if
isYsJieTiOpen
&&
selectYuShou
{
return
49
}
return
49
return
0.001
}
//header
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
()
if
section
==
2
{
//阶梯价设置
if
isYuShouSetting
{
//预售阶梯价
let
view
=
TitleAndSwitchHeaderView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
90
))
view
.
infoSW
.
isUserInteractionEnabled
=
isAllEditing
view
.
ysInfoSw
.
isUserInteractionEnabled
=
isAllEditing
view
.
delegate
=
self
view
.
selectYuShou
=
selectYuShou
view
.
infoSW
.
isOn
=
isJieTiOpen
//普通
view
.
ysInfoSw
.
isOn
=
isYsJieTiOpen
//预售
return
view
}
else
{
//普通
let
view
=
NewCreateHeader
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
view
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
view
.
infoSw
.
isOn
=
isJieTiOpen
if
isJieTiOpen
==
false
{
return
view
}
return
49
}
//header
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
()
if
section
==
2
{
//阶梯价设置
if
isYuShouSetting
{
//预售阶梯价
let
view
=
TitleAndSwitchHeaderView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
90
))
view
.
infoSW
.
isUserInteractionEnabled
=
isAllEditing
view
.
ysInfoSw
.
isUserInteractionEnabled
=
isAllEditing
view
.
delegate
=
self
view
.
selectYuShou
=
selectYuShou
view
.
infoSW
.
isOn
=
isJieTiOpen
//普通
view
.
ysInfoSw
.
isOn
=
isYsJieTiOpen
//预售
return
view
}
else
{
//普通
let
view
=
NewCreateHeader
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
view
.
infoSw
.
isUserInteractionEnabled
=
isAllEditing
view
.
infoSw
.
isOn
=
isJieTiOpen
if
isJieTiOpen
==
false
{
return
view
}
return
view
}
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
if
section
!=
0
{
if
section
==
2
{
if
isYuShouSetting
{
return
90
}
return
59
}
return
10
}
return
0.01
}
//footer
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
if
section
!=
0
{
if
section
==
2
{
if
barTitle
?
.
contains
(
"查看"
)
==
false
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
let
view
=
NewCreateFooter
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
return
view
}
if
isYsJieTiOpen
&&
selectYuShou
{
let
view
=
NewCreateFooter
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
return
view
}
if
isYuShouSetting
{
return
90
}
return
59
}
let
view
=
UIView
()
return
view
return
10
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
if
section
==
2
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
return
49
return
0.01
}
//footer
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
if
section
==
2
{
if
barTitle
?
.
contains
(
"查看"
)
==
false
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
let
view
=
NewCreateFooter
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
return
view
}
if
isYsJieTiOpen
&&
selectYuShou
{
return
49
let
view
=
NewCreateFooter
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
fullScreenWidth
,
height
:
49
))
view
.
delegate
=
self
return
view
}
}
return
0.01
}
//MARK: - NEW CELL DELEGATE
func
YuShouCellTFContent
(
Price
:
NSString
)
{
let
arr
=
Price
.
components
(
separatedBy
:
"_"
)
yuShouPrice
=
arr
[
0
]
ysKuCun
=
arr
[
1
]
DJBiLi
=
arr
[
2
]
}
func
textFieldContent
(
content
:
String
,
cell
:
TitleAndTFCell
)
{
switch
cell
.
tag
{
case
0
:
price
=
content
break
case
1
:
guiGe
=
content
break
default
:
weight
=
content
break
let
view
=
UIView
()
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
if
section
==
2
{
if
isJieTiOpen
&&
selectYuShou
==
false
{
return
49
}
}
func
GLAlertSelectViewClick
(
selectNum
:
Int
,
view
:
GLAlertSelectView
)
{
let
cell
=
listTbv
.
cellForRow
(
at
:
IndexPath
(
row
:
view
.
tag
,
section
:
0
))
as!
TitleAndBtnCell
if
view
.
tag
==
3
{
tempSelect
=
selectNum
wenDu
=
selectListArr
[
selectNum
]
cell
.
contentLbl
.
text
=
selectListArr
[
selectNum
]
}
else
{
itemDanWeiSelect
=
selectNum
cell
.
contentLbl
.
text
=
danWeiArr
!
[
selectNum
]
danWei
=
danWeiArr
!
[
selectNum
]
if
isYsJieTiOpen
&&
selectYuShou
{
return
49
}
selectView
?
.
removeFromSuperview
()
selectView
=
nil
}
return
0.01
}
//MARK: - NEW CELL DELEGATE
func
YuShouCellTFContent
(
Price
:
NSString
)
{
let
arr
=
Price
.
components
(
separatedBy
:
"_"
)
yuShouPrice
=
arr
[
0
]
ysKuCun
=
arr
[
1
]
DJBiLi
=
arr
[
2
]
}
func
textFieldContent
(
content
:
String
,
cell
:
TitleAndTFCell
)
{
switch
cell
.
tag
{
case
0
:
price
=
content
break
case
1
:
guiGe
=
content
break
default
:
weight
=
content
break
}
}
func
GLAlertSelectViewClick
(
selectNum
:
Int
,
view
:
GLAlertSelectView
)
{
let
cell
=
listTbv
.
cellForRow
(
at
:
IndexPath
(
row
:
view
.
tag
,
section
:
0
))
as!
TitleAndBtnCell
if
view
.
tag
==
3
{
tempSelect
=
selectNum
wenDu
=
selectListArr
[
selectNum
]
cell
.
contentLbl
.
text
=
selectListArr
[
selectNum
]
}
else
{
itemDanWeiSelect
=
selectNum
cell
.
contentLbl
.
text
=
danWeiArr
!
[
selectNum
]
danWei
=
danWeiArr
!
[
selectNum
]
}
var
tempSelect
:
Int
?
var
itemDanWeiSelect
:
Int
?
func
btnClick
(
content
:
String
,
cell
:
TitleAndBtnCell
)
{
if
cell
.
tag
==
3
{
if
selectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择商品温藏"
view
.
delegate
=
self
view
.
dataArr
=
selectListArr
if
tempSelect
!=
nil
{
view
.
selectNum
=
tempSelect
!
view
.
tempNum
=
view
.
selectNum
}
self
.
view
.
addSubview
(
view
)
selectView
=
view
selectView
?
.
removeFromSuperview
()
selectView
=
nil
}
var
tempSelect
:
Int
?
var
itemDanWeiSelect
:
Int
?
func
btnClick
(
content
:
String
,
cell
:
TitleAndBtnCell
)
{
if
cell
.
tag
==
3
{
if
selectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择商品温藏"
view
.
delegate
=
self
view
.
dataArr
=
selectListArr
if
tempSelect
!=
nil
{
view
.
selectNum
=
tempSelect
!
view
.
tempNum
=
view
.
selectNum
}
}
else
{
if
selectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择商品单位"
view
.
delegate
=
self
if
itemDanWeiSelect
!=
nil
{
view
.
selectNum
=
itemDanWeiSelect
!
}
if
danWeiArr
!=
nil
{
view
.
dataArr
=
danWeiArr
!
}
self
.
view
.
addSubview
(
view
)
selectView
=
view
self
.
view
.
addSubview
(
view
)
selectView
=
view
}
}
else
{
if
selectView
==
nil
{
let
view
=
GLAlertSelectView
(
frame
:
self
.
view
.
bounds
)
view
.
tag
=
cell
.
tag
view
.
titleLbl
.
text
=
"请选择商品单位"
view
.
delegate
=
self
if
itemDanWeiSelect
!=
nil
{
view
.
selectNum
=
itemDanWeiSelect
!
}
}
}
func
switchStatus
(
sender
:
UISwitch
)
{
//阶梯价设置
if
sender
.
tag
==
99
{
isYsJieTiOpen
=
sender
.
isOn
}
else
{
isJieTiOpen
=
sender
.
isOn
}
listTbv
.
reloadData
()
}
func
switchClick
(
content
:
UISwitch
,
cell
:
TitleAndSwitchCell
)
{
//控制
if
cell
.
tag
==
5
{
let
idxPath
=
IndexPath
(
row
:
0
,
section
:
1
)
if
isYuShouSetting
&&
isOpenYSSetting
{
//单独点击预售设置
listTbv
.
reloadData
()
}
else
{
//单独打开预售设置
listTbv
.
reloadRows
(
at
:
[
idxPath
],
with
:
.
none
)
if
danWeiArr
!=
nil
{
view
.
dataArr
=
danWeiArr
!
}
self
.
view
.
addSubview
(
view
)
selectView
=
view
}
}
func
newCreateSwitchStatus
(
sender
:
UISwitch
)
{
//打开switch 阶梯价设置
// isJieTiJiaSetting = sender.isOn
isJieTiOpen
=
sender
.
isOn
listTbv
.
reloadData
()
}
func
footerClickAction
()
{
if
isAllEditing
==
false
{
return
}
print
(
jieTiArr
)
if
selectYuShou
{
//预售
specalArr
.
append
(
""
)
}
else
{
//非预售
jieTiArr
.
append
(
""
)
}
listTbv
.
reloadData
()
}
func
YuShouCellSwitchStatus
(
sender
:
UISwitch
)
{
//控制
// isYuShouSetting = sender.isOn
isOpenYSSetting
=
sender
.
isOn
listTbv
.
reloadData
()
}
func
switchStatus
(
sender
:
UISwitch
)
{
//阶梯价设置
if
sender
.
tag
==
99
{
isYsJieTiOpen
=
sender
.
isOn
}
else
{
isJieTiOpen
=
sender
.
isOn
}
func
PuTongJieTiDelAction
(
sender
:
PuTongJieTiCell
)
{
if
selectYuShou
{
specalArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
else
{
jieTiArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
func
switchClick
(
content
:
UISwitch
,
cell
:
TitleAndSwitchCell
)
{
//控制
if
cell
.
tag
==
5
{
let
idxPath
=
IndexPath
(
row
:
0
,
section
:
1
)
if
isYuShouSetting
&&
isOpenYSSetting
{
//单独点击预售设置
listTbv
.
reloadData
()
}
else
{
//单独打开预售设置
listTbv
.
reloadRows
(
at
:
[
idxPath
],
with
:
.
none
)
}
}
func
PuTongJieTiContentSp
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
{
specalArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
specalArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
func
PuTongJieTiContent
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
{
jieTiArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
jieTiArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
func
selectYuShou
(
sender
:
UIButton
)
{
if
sender
.
tag
==
0
{
selectYuShou
=
false
}
else
{
selectYuShou
=
true
}
listTbv
.
reloadData
()
}
func
newCreateSwitchStatus
(
sender
:
UISwitch
)
{
//打开switch 阶梯价设置
// isJieTiJiaSetting = sender.isOn
isJieTiOpen
=
sender
.
isOn
listTbv
.
reloadData
()
}
func
footerClickAction
()
{
if
isAllEditing
==
false
{
return
}
//MARK: - COLLECTIONVIEW DELEGATE
func
collectionView
(
_
collectionView
:
UICollectionView
,
layout
collectionViewLayout
:
UICollectionViewLayout
,
minimumLineSpacingForSectionAt
section
:
Int
)
->
CGFloat
{
return
0
print
(
jieTiArr
)
if
selectYuShou
{
//预售
specalArr
.
append
(
""
)
}
else
{
//非预售
jieTiArr
.
append
(
""
)
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
return
datasArr
.
count
listTbv
.
reloadData
()
}
func
YuShouCellSwitchStatus
(
sender
:
UISwitch
)
{
//控制
// isYuShouSetting = sender.isOn
isOpenYSSetting
=
sender
.
isOn
listTbv
.
reloadData
()
}
func
PuTongJieTiDelAction
(
sender
:
PuTongJieTiCell
)
{
if
selectYuShou
{
specalArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
else
{
jieTiArr
.
remove
(
at
:
sender
.
tag
)
listTbv
.
reloadData
()
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"ItemCell"
,
for
:
indexPath
)
as!
ItemCell
cell
.
tag
=
indexPath
.
item
cell
.
nameLbl
.
text
=
"规格"
+
"
\(
indexPath
.
item
+
1
)
"
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
let
dataDict
=
datasArr
[
selectIdx
!.
item
]
price
=
dataDict
.
price
guiGe
=
dataDict
.
guiGe
weight
=
dataDict
.
weight
wenDu
=
dataDict
.
wenDu
danWei
=
dataDict
.
danWei
yuShouPrice
=
dataDict
.
yuShouPrice
specalArr
=
dataDict
.
specalArr
jieTiArr
=
dataDict
.
jieTiArr
isJieTiOpen
=
dataDict
.
isJieTiOpen
isOpenYSSetting
=
dataDict
.
isOpenYSSetting
DJBiLi
=
dataDict
.
DJBiLi
isYsJieTiOpen
=
dataDict
.
isYsJieTiOpen
ysKuCun
=
dataDict
.
ysKuCun
selectYuShou
=
dataDict
.
selectYuShou
listTbv
.
reloadData
()
collectionView
.
reloadData
()
}
func
PuTongJieTiContentSp
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
{
specalArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
specalArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
func
PuTongJieTiContent
(
price
:
String
,
count
:
String
,
cell
:
PuTongJieTiCell
)
{
jieTiArr
.
insert
(
"
\(
price
)
_
\(
count
)
"
,
at
:
cell
.
tag
)
jieTiArr
.
remove
(
at
:
cell
.
tag
+
1
)
}
func
selectYuShou
(
sender
:
UIButton
)
{
if
sender
.
tag
==
0
{
selectYuShou
=
false
}
else
{
selectYuShou
=
true
}
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
datasArr
.
count
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"ItemCell"
,
for
:
indexPath
)
as!
ItemCell
cell
.
tag
=
indexPath
.
item
cell
.
nameLbl
.
text
=
"规格"
+
"
\(
indexPath
.
item
+
1
)
"
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
let
dataDict
=
datasArr
[
selectIdx
!.
item
]
price
=
dataDict
.
price
guiGe
=
dataDict
.
guiGe
weight
=
dataDict
.
weight
wenDu
=
dataDict
.
wenDu
danWei
=
dataDict
.
danWei
yuShouPrice
=
dataDict
.
yuShouPrice
specalArr
=
dataDict
.
specalArr
jieTiArr
=
dataDict
.
jieTiArr
isJieTiOpen
=
dataDict
.
isJieTiOpen
isOpenYSSetting
=
dataDict
.
isOpenYSSetting
DJBiLi
=
dataDict
.
DJBiLi
isYsJieTiOpen
=
dataDict
.
isYsJieTiOpen
ysKuCun
=
dataDict
.
ysKuCun
selectYuShou
=
dataDict
.
selectYuShou
listTbv
.
reloadData
()
collectionView
.
reloadData
()
}
}
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