Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-school-app
Commits
2beebcbc
Commit
2beebcbc
authored
Mar 12, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改校区选择列表按字母排序
parent
77b0a743
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
35 deletions
+71
-35
area.ts
src/api/area.ts
+8
-2
SelectCampus.scss
src/pages/SelectCampus/SelectCampus.scss
+3
-0
SelectCampus.tsx
src/pages/SelectCampus/SelectCampus.tsx
+60
-33
No files found.
src/api/area.ts
View file @
2beebcbc
import
{
baseFetch
}
from
'./index'
;
import
{
baseFetch
,
ResponseDataEntity
}
from
'./index'
;
export
const
fetchAllArea
=
()
=>
export
type
Area
=
{
id
:
number
;
areaName
:
string
;
initial
?:
string
;
};
export
const
fetchAllArea
=
():
Promise
<
ResponseDataEntity
<
Area
[]
>>
=>
baseFetch
({
url
:
'/area/queryAreaList'
,
});
src/pages/SelectCampus/SelectCampus.scss
View file @
2beebcbc
...
...
@@ -88,4 +88,7 @@
border-bottom
:
2px
solid
#ebebeb
;
word-break
:
break-all
;
}
.locationItem
:last-child
{
border-bottom
:
none
;
}
}
src/pages/SelectCampus/SelectCampus.tsx
View file @
2beebcbc
...
...
@@ -5,17 +5,11 @@ import { connect } from '@tarojs/redux';
import
{
View
,
Text
,
Input
,
Image
,
ScrollView
}
from
'@tarojs/components'
;
import
SearchIcon
from
'../../images/login/icon_search@2x.png'
;
import
{
fetchAllArea
}
from
'../../api/area'
;
import
{
fetchAllArea
,
Area
}
from
'../../api/area'
;
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
'./SelectCampus.scss'
;
type
Area
=
{
id
:
number
;
areaName
:
string
;
initial
?:
string
;
};
type
AreaList
=
Array
<
{
firstPin
:
string
;
children
:
Array
<
Area
>
;
...
...
@@ -80,6 +74,34 @@ class SelectCampus extends Component {
fetchAllArea
()
.
then
(
res
=>
{
console
.
log
(
res
);
let
initialList
=
[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
,
];
let
campusIndexArr
:
Array
<
string
>
=
[];
let
campusList
:
AreaList
=
[];
res
.
data
.
map
((
area
:
Area
)
=>
{
...
...
@@ -89,11 +111,12 @@ class SelectCampus extends Component {
if
(
index
>
-
1
)
{
campusList
[
index
].
children
.
push
(
area
);
}
else
{
campusIndexArr
.
push
(
firstPin
);
campusList
.
push
({
let
index
=
initialList
.
indexOf
(
firstPin
);
campusIndexArr
[
index
]
=
firstPin
;
campusList
[
index
]
=
{
firstPin
:
firstPin
,
children
:
[
area
],
}
)
;
};
}
}
});
...
...
@@ -190,14 +213,16 @@ class SelectCampus extends Component {
</
View
>
</
View
>
<
View
className=
'infoBar'
>
{
pinList
.
map
(
item
=>
(
<
View
key=
{
item
}
className=
'infoItem'
onClick=
{
()
=>
this
.
showToastHandle
(
item
)
}
>
{
item
}
</
View
>
))
}
{
pinList
.
map
(
item
=>
item
?
(
<
View
key=
{
item
}
className=
'infoItem'
onClick=
{
()
=>
this
.
showToastHandle
(
item
)
}
>
{
item
}
</
View
>
)
:
null
,
)
}
</
View
>
<
View
className=
{
showToast
?
'show br8 infoToast'
:
'br8 infoToast'
}
>
{
localText
}
...
...
@@ -207,22 +232,24 @@ class SelectCampus extends Component {
className=
'locationList'
scrollIntoView=
{
localText
}
scrollWithAnimation
>
{
filterList
.
map
(
campusItem
=>
(
<
View
key=
{
campusItem
.
firstPin
}
className=
'locationArea'
>
<
View
id=
{
campusItem
.
firstPin
}
className=
'locationTitle'
>
{
campusItem
.
firstPin
}
</
View
>
{
campusItem
.
children
.
map
(
campus
=>
(
<
View
key=
{
campus
.
id
}
className=
'locationItem'
data
-
campus=
{
campus
}
onClick=
{
this
.
bindCampus
}
>
{
campus
.
areaName
}
{
filterList
.
map
(
campusItem
=>
campusItem
?
(
<
View
key=
{
campusItem
.
firstPin
}
className=
'locationArea'
>
<
View
id=
{
campusItem
.
firstPin
}
className=
'locationTitle'
>
{
campusItem
.
firstPin
}
</
View
>
))
}
</
View
>
))
}
{
campusItem
.
children
.
map
(
campus
=>
(
<
View
key=
{
campus
.
id
}
className=
'locationItem'
data
-
campus=
{
campus
}
onClick=
{
this
.
bindCampus
}
>
{
campus
.
areaName
}
</
View
>
))
}
</
View
>
)
:
null
,
)
}
</
ScrollView
>
</
View
>
);
...
...
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