Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
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
baiguangyao
mr-julyedu
Commits
6420830c
Commit
6420830c
authored
Sep 23, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
国际手机号
parent
cb2f3a7d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
107 deletions
+101
-107
src/components/country/index.js
+99
-106
src/components/country/index.scss
+2
-1
No files found.
src/components/country/index.js
View file @
6420830c
...
...
@@ -13,65 +13,8 @@ class Country extends Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
navs
:
[
'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'
],
currentNav
:
'A'
}
}
componentDidMount
()
{
// document.body.scrollIntoView();
document
.
addEventListener
(
'scroll'
,
this
.
judgeCurrentPosition
)
}
componentWillUnmount
()
{
document
.
removeEventListener
(
'scroll'
,
this
.
judgeCurrentPosition
)
}
judgeCurrentPosition
=
()
=>
{
const
{
navs
}
=
this
.
state
;
let
top
=
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
;
const
lens
=
navs
.
map
(
item
=>
{
let
el
=
document
.
querySelector
(
`[data-type="
${
item
}
"]`
);
if
(
el
)
{
return
el
.
offsetTop
;
}
return
''
;
});
lens
.
map
((
item
,
index
)
=>
{
if
(
item
&&
(
top
+
200
)
>
item
)
{
this
.
setState
({
currentNav
:
navs
[
index
]
})
}
});
}
toParentPage
=
(
e
,
num
)
=>
{
// console.log(this.props);
const
{
history
,
addCountryNum
}
=
this
.
props
;
addCountryNum
({
num
,
code
:
getParam
(
'share_code'
)
});
// history.push(`/detail?id=${getParam('id')}`);
history
.
go
(
-
1
)
e
.
preventDefault
();
}
scrollTo
=
(
param
)
=>
{
const
el
=
document
.
querySelector
(
`[data-type="
${
param
}
"]`
)
if
(
el
)
{
this
.
setState
({
currentNav
:
param
});
el
.
scrollIntoView
({
behavior
:
'smooth'
});
}
}
render
()
{
const
data
=
[
currentNav
:
'A'
,
data
:
[
{
type
:
'0'
,
list
:
[
...
...
@@ -80,17 +23,41 @@ class Country extends Component {
num
:
'86'
},
{
name
:
'中国澳门'
,
num
:
'853'
name
:
'美国'
,
num
:
'1'
},
{
name
:
'日本'
,
num
:
'81'
},
{
name
:
'中国香港'
,
num
:
'852'
},
{
name
:
'中国澳门'
,
num
:
'853'
},
{
name
:
'中国台湾'
,
num
:
'886'
}
},
{
name
:
'澳大利亚'
,
num
:
'61'
},
{
name
:
'加拿大'
,
num
:
'1'
},
{
name
:
'英国'
,
num
:
'44'
},
{
name
:
'新西兰'
,
num
:
'64'
},
]
},
{
...
...
@@ -163,14 +130,6 @@ class Country extends Component {
{
name
:
'爱沙尼亚'
,
num
:
'372'
},
{
name
:
'爱沙尼亚'
,
num
:
'372'
},
{
name
:
'爱沙尼亚'
,
num
:
'372'
}
]
},
...
...
@@ -736,26 +695,6 @@ class Country extends Component {
{
name
:
'奥地利'
,
num
:
'43'
},
{
name
:
'澳大利亚'
,
num
:
'61'
},
{
name
:
'澳大利亚'
,
num
:
'61'
},
{
name
:
'澳大利亚'
,
num
:
'61'
},
{
name
:
'澳大利亚'
,
num
:
'61'
},
{
name
:
'澳大利亚'
,
num
:
'61'
}
]
},
...
...
@@ -885,7 +824,6 @@ class Country extends Component {
{
type
:
'T'
,
list
:
[
,
{
name
:
'塔吉克斯坦'
,
num
:
'992'
...
...
@@ -1004,31 +942,31 @@ class Country extends Component {
{
name
:
'印度'
,
num
:
'91'
},
,
}
,
{
name
:
'印度尼西亚'
,
num
:
'62'
},
,
}
,
{
name
:
'伊朗'
,
num
:
'98'
},
,
}
,
{
name
:
'伊拉克'
,
num
:
'964'
},
,
}
,
{
name
:
'以色列'
,
num
:
'972'
},
,
}
,
{
name
:
'意大利'
,
num
:
'39'
},
,
}
,
{
name
:
'牙买加'
,
num
:
'1876'
},
,
}
,
{
name
:
'约旦'
,
num
:
'962'
...
...
@@ -1088,19 +1026,74 @@ class Country extends Component {
}
]
}
];
const
{
currentNav
,
navs
}
=
this
.
state
;
]
}
}
componentDidMount
()
{
// document.body.scrollIntoView();
document
.
addEventListener
(
'scroll'
,
this
.
judgeCurrentPosition
)
}
componentWillUnmount
()
{
document
.
removeEventListener
(
'scroll'
,
this
.
judgeCurrentPosition
)
}
judgeCurrentPosition
=
()
=>
{
const
{
data
}
=
this
.
state
;
let
top
=
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
;
const
lens
=
data
.
map
(
item
=>
{
let
el
=
document
.
querySelector
(
`[data-type="
${
item
[
'type'
]}
"]`
);
if
(
el
)
{
return
el
.
offsetTop
;
}
return
''
;
});
lens
.
map
((
item
,
index
)
=>
{
if
(
item
&&
(
top
+
200
)
>
item
)
{
this
.
setState
({
currentNav
:
data
[
index
][
'type'
]
})
}
});
}
toParentPage
=
(
e
,
num
)
=>
{
const
{
history
,
addCountryNum
}
=
this
.
props
;
addCountryNum
({
num
,
code
:
getParam
(
'share_code'
)
});
// history.push(`/detail?id=${getParam('id')}`);
history
.
go
(
-
1
)
e
.
preventDefault
();
}
scrollTo
=
(
param
)
=>
{
const
el
=
document
.
querySelector
(
`[data-type="
${
param
}
"]`
)
if
(
el
)
{
this
.
setState
({
currentNav
:
param
});
el
.
scrollIntoView
({
behavior
:
'smooth'
});
}
}
render
()
{
const
{
currentNav
,
data
}
=
this
.
state
;
return
(
<>
<
HeaderBar
title
=
"选择国家和地区"
/>
<
HeaderBar
title
=
"选择国家和地区"
arrow
=
{
true
}
/
>
<
ul
className
=
"letter-nav"
>
{
navs
.
map
((
item
,
index
)
=>
{
{
data
.
map
(
item
=>
{
return
(
<
li
key
=
{
`nav-
${
i
ndex
}
`
}
className
=
{
classnames
(
"letter-nav__item"
,
{
"letter-nav__item--active"
:
currentNav
===
item
})}
onClick
=
{()
=>
this
.
scrollTo
(
item
)}
>
{
item
}
<
/li
>
key
=
{
`nav-
${
i
tem
[
'type'
]
}
`
}
className
=
{
classnames
(
"letter-nav__item"
,
{
"letter-nav__item--active"
:
currentNav
===
item
[
'type'
]
})}
onClick
=
{()
=>
this
.
scrollTo
(
item
[
'type'
]
)}
>
{
item
[
'type'
]
===
'0'
?
'常'
:
item
[
'type'
]
}
<
/li
>
)
})}
<
/ul
>
...
...
src/components/country/index.scss
View file @
6420830c
...
...
@@ -33,7 +33,8 @@ body {
}
.country-item
{
margin
:
0
12px
;
margin-left
:
12px
;
padding-right
:
22px
;
}
.country-item__link
{
...
...
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