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
8c012e06
Commit
8c012e06
authored
May 11, 2020
by
刘俊宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成商品分类数据对接(缺确定按钮)
parent
d7a7aff6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
32 deletions
+60
-32
GeliBusinessPlatform.xcworkspace/xcuserdata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
...ata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/ViewController/商品分类/GoodsClassModel.swift
...usinessPlatform/ViewController/商品分类/GoodsClassModel.swift
+6
-3
GeliBusinessPlatform/ViewController/商品分类/GoodsClassViewController.swift
...atform/ViewController/商品分类/GoodsClassViewController.swift
+54
-29
No files found.
GeliBusinessPlatform.xcworkspace/xcuserdata/liujunhong.xcuserdatad/UserInterfaceState.xcuserstate
View file @
8c012e06
No preview for this file type
GeliBusinessPlatform/ViewController/商品分类/GoodsClassModel.swift
View file @
8c012e06
...
@@ -14,9 +14,12 @@ class GoodsClassModel: NSObject {
...
@@ -14,9 +14,12 @@ class GoodsClassModel: NSObject {
var
isSelect
:
Bool
?
=
false
var
isSelect
:
Bool
?
=
false
var
isCanExpand
:
Bool
?
=
false
var
isCanExpand
:
Bool
?
=
false
var
isCanSelect
:
Bool
?
=
false
var
isCanSelect
:
Bool
?
=
false
var
Level_Type
:
Int
?
var
cat_id
:
Int
?
//分类id
var
name
:
String
?
var
cat_name
:
String
?
//分类名
var
parent_id
:
Int
?
//分类上一级id,其值为 上一层级分类的"cat_id"
var
parents_id
:
Int
?
var
sort_order
:
Int
?
var
level
:
Int
?
//分类层级,0为第一级
var
modelS
:
Array
<
GoodsClassModel
>
?
=
[]
var
modelS
:
Array
<
GoodsClassModel
>
?
=
[]
var
modelId
:
Int
?
}
}
GeliBusinessPlatform/ViewController/商品分类/GoodsClassViewController.swift
View file @
8c012e06
...
@@ -18,57 +18,82 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -18,57 +18,82 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
print
(
"商品分类数据==
\(
dataModelArray
)
"
)
print
(
"商品分类数据==
\(
dataModelArray
)
"
)
self
.
view
.
addSubview
(
navbar
)
self
.
view
.
addSubview
(
navbar
)
//先分级
for
i
in
0
..<
5
{
var
levelArr_0
:
Array
<
GeneralInfoCatsModel
>
?
=
[]
var
levelArr_1
:
Array
<
GeneralInfoCatsModel
>
?
=
[]
var
levelArr_2
:
Array
<
GeneralInfoCatsModel
>
?
=
[]
dataModelArray
?
.
forEach
({
(
model
)
in
if
model
.
level
==
0
{
levelArr_0
?
.
append
(
model
)
}
else
if
model
.
level
==
1
{
levelArr_1
?
.
append
(
model
)
}
else
if
model
.
level
==
2
{
levelArr_2
?
.
append
(
model
)
}
})
for
i
in
0
..<
levelArr_0
!.
count
{
let
dataModel_1
=
levelArr_0
!
[
i
]
//model_1
let
model_1
=
GoodsClassModel
()
let
model_1
=
GoodsClassModel
()
model_1
.
name
=
"第一级商品=
\(
i
)
"
model_1
.
cat_name
=
dataModel_1
.
cat_name
model_1
.
isExpand
=
false
model_1
.
isExpand
=
false
model_1
.
isCanExpand
=
false
model_1
.
isCanExpand
=
false
model_1
.
isCanSelect
=
false
model_1
.
isCanSelect
=
false
model_1
.
isSelect
=
false
model_1
.
isSelect
=
false
model_1
.
Level_Type
=
0
model_1
.
level
=
dataModel_1
.
level
model_1
.
modelId
=
i
model_1
.
cat_id
=
dataModel_1
.
cat_id
if
i
!=
1
{
model_1
.
isCanExpand
=
true
levelArr_1
?
.
forEach
({
(
dataModel_2
)
in
for
j
in
0
..<
3
{
if
dataModel_2
.
parent_id
==
model_1
.
cat_id
{
model_1
.
isCanExpand
=
true
//model_2
let
model_2
=
GoodsClassModel
()
let
model_2
=
GoodsClassModel
()
model_2
.
name
=
"第二级商品=
\(
j
)
"
model_2
.
cat_name
=
dataModel_2
.
cat_name
model_2
.
isExpand
=
false
model_2
.
isExpand
=
false
model_2
.
isCanExpand
=
false
model_2
.
isCanExpand
=
false
model_2
.
isCanSelect
=
false
model_2
.
isCanSelect
=
false
model_2
.
isSelect
=
false
model_2
.
isSelect
=
false
model_2
.
Level_Type
=
1
model_2
.
level
=
dataModel_2
.
level
model_2
.
modelId
=
j
model_2
.
cat_id
=
dataModel_2
.
cat_id
if
j
!=
2
{
levelArr_2
?
.
forEach
({
(
dataModel_3
)
in
model_2
.
isCanExpand
=
true
for
k
in
0
..<
2
{
if
dataModel_3
.
parent_id
==
model_2
.
cat_id
{
model_2
.
isCanExpand
=
true
//model_3
let
model_3
=
GoodsClassModel
()
let
model_3
=
GoodsClassModel
()
model_3
.
name
=
"第三级商品=
\(
k
)
"
model_3
.
cat_name
=
dataModel_3
.
cat_name
model_3
.
isExpand
=
false
model_3
.
isExpand
=
false
model_3
.
isCanExpand
=
false
model_3
.
isCanExpand
=
false
model_3
.
isCanSelect
=
true
model_3
.
isCanSelect
=
true
model_3
.
isSelect
=
false
model_3
.
isSelect
=
false
model_3
.
Level_Type
=
2
model_3
.
level
=
dataModel_3
.
level
model_3
.
modelId
=
k
model_3
.
cat_id
=
dataModel_3
.
cat_id
//添加
model_2
.
modelS
?
.
append
(
model_3
)
model_2
.
modelS
?
.
append
(
model_3
)
}
}
}
else
{
})
if
!
model_2
.
isCanExpand
!
{
model_2
.
isCanSelect
=
true
model_2
.
isCanSelect
=
true
}
}
model_1
.
modelS
?
.
append
(
model_2
)
model_1
.
modelS
?
.
append
(
model_2
)
}
}
else
{
}
})
if
!
model_1
.
isCanExpand
!
{
model_1
.
isCanSelect
=
true
model_1
.
isCanSelect
=
true
}
}
var
arrs
:
Array
<
Any
>
=
[]
var
arrs
:
Array
<
Any
>
=
[]
arrs
.
append
(
model_1
)
arrs
.
append
(
model_1
)
dataArr
.
append
(
arrs
)
dataArr
.
append
(
arrs
)
}
}
setTabv
()
setTabv
()
}
}
...
@@ -105,9 +130,9 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -105,9 +130,9 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
let
arrs
=
dataArr
[
indexPath
.
section
]
as!
Array
<
Any
>
let
arrs
=
dataArr
[
indexPath
.
section
]
as!
Array
<
Any
>
let
rowModel
=
arrs
[
indexPath
.
row
]
as!
GoodsClassModel
let
rowModel
=
arrs
[
indexPath
.
row
]
as!
GoodsClassModel
if
rowModel
.
Level_Type
==
1
{
if
rowModel
.
level
==
1
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"SecondCell"
)
as!
SecondCell
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"SecondCell"
)
as!
SecondCell
cell
.
nameLbl
.
text
=
rowModel
.
name
cell
.
nameLbl
.
text
=
rowModel
.
cat_
name
if
rowModel
.
isCanExpand
!
{
if
rowModel
.
isCanExpand
!
{
if
rowModel
.
isExpand
!
{
if
rowModel
.
isExpand
!
{
cell
.
imgView
.
image
=
UIImage
.
init
(
named
:
"2"
)
cell
.
imgView
.
image
=
UIImage
.
init
(
named
:
"2"
)
...
@@ -127,9 +152,9 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -127,9 +152,9 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
}
}
return
cell
return
cell
}
}
if
rowModel
.
Level_Type
==
2
{
if
rowModel
.
level
==
2
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ThirdCell"
)
as!
ThirdCell
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ThirdCell"
)
as!
ThirdCell
cell
.
nameLbl
.
text
=
rowModel
.
name
cell
.
nameLbl
.
text
=
rowModel
.
cat_
name
if
rowModel
.
isSelect
!
{
if
rowModel
.
isSelect
!
{
cell
.
imgView
.
image
=
UIImage
.
init
(
named
:
"yuxuan"
)
cell
.
imgView
.
image
=
UIImage
.
init
(
named
:
"yuxuan"
)
cell
.
nameLbl
.
textColor
=
UIColor
.
init
(
named
:
"蓝色字体颜色"
)
cell
.
nameLbl
.
textColor
=
UIColor
.
init
(
named
:
"蓝色字体颜色"
)
...
@@ -157,17 +182,16 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -157,17 +182,16 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
cell
.
nameLbl
.
textColor
=
UIColor
.
init
(
named
:
"标题字颜色"
)
cell
.
nameLbl
.
textColor
=
UIColor
.
init
(
named
:
"标题字颜色"
)
}
}
}
}
cell
.
nameLbl
.
text
=
rowModel
.
name
cell
.
nameLbl
.
text
=
rowModel
.
cat_
name
return
cell
return
cell
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
print
(
indexPath
)
let
arrs
=
dataArr
[
indexPath
.
section
]
as!
Array
<
Any
>
let
arrs
=
dataArr
[
indexPath
.
section
]
as!
Array
<
Any
>
let
rowModel
=
arrs
[
indexPath
.
row
]
as!
GoodsClassModel
let
rowModel
=
arrs
[
indexPath
.
row
]
as!
GoodsClassModel
if
rowModel
.
Level_Type
!=
2
&&
rowModel
.
isCanExpand
!
if
rowModel
.
level
!=
2
&&
rowModel
.
isCanExpand
!
{
{
rowModel
.
isExpand
=
!
rowModel
.
isExpand
!
rowModel
.
isExpand
=
!
rowModel
.
isExpand
!
...
@@ -177,6 +201,7 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -177,6 +201,7 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
let
reloadSet
=
IndexSet
.
init
(
arrayLiteral
:
indexPath
.
section
)
let
reloadSet
=
IndexSet
.
init
(
arrayLiteral
:
indexPath
.
section
)
tableV
.
reloadSections
(
reloadSet
,
with
:
.
automatic
)
tableV
.
reloadSections
(
reloadSet
,
with
:
.
automatic
)
}
}
}
}
//MARK:--展开或收起(利用数据)
//MARK:--展开或收起(利用数据)
...
@@ -193,7 +218,7 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
...
@@ -193,7 +218,7 @@ class GoodsClassViewController: BaseViewController , UITableViewDelegate, UITabl
dataArr
.
insert
(
arrs
,
at
:
section
)
dataArr
.
insert
(
arrs
,
at
:
section
)
}
else
{
}
else
{
let
lenght
=
((
model
.
Level_Type
==
0
)
?
(
arrs
.
count
-
1
):
model
.
modelS
?
.
count
)
!
let
lenght
=
((
model
.
level
==
0
)
?
(
arrs
.
count
-
1
):
model
.
modelS
?
.
count
)
!
let
startIndex
=
index
!
+
1
let
startIndex
=
index
!
+
1
let
lastIndex
=
startIndex
+
lenght
let
lastIndex
=
startIndex
+
lenght
for
i
in
(
startIndex
..<
lastIndex
)
.
reversed
()
{
for
i
in
(
startIndex
..<
lastIndex
)
.
reversed
()
{
...
...
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