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
fc0bbae8
Commit
fc0bbae8
authored
Sep 10, 2019
by
FE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug and country tel modity
parent
62c9455f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
71 deletions
+138
-71
src/components/country/countryRedux.js
+31
-0
src/components/country/index.js
+39
-49
src/components/country/index.scss
+6
-2
src/components/detail/index.js
+3
-1
src/components/detail/redPacket/index.js
+55
-18
src/store/index.js
+4
-1
No files found.
src/components/country/countryRedux.js
0 → 100644
View file @
fc0bbae8
const
ADD_COUNTRY_NUM
=
'ADD_COUNTRY_NUM'
;
const
DEL_COUNTRY_NUM
=
'DEL_COUNTRY_NUM'
;
export
const
addCountryNum
=
(
payload
)
=>
({
type
:
'ADD_COUNTRY_NUM'
,
payload
});
export
const
delCountryNum
=
()
=>
({
type
:
'DEL_COUNTRY_NUM'
});
export
default
(
state
=
{},
action
)
=>
{
const
{
type
,
payload
}
=
action
;
switch
(
type
)
{
case
ADD_COUNTRY_NUM
:
return
{
...
state
,
...
payload
};
case
DEL_COUNTRY_NUM
:
return
{
...
state
,
num
:
''
,
code
:
''
};
default
:
return
state
;
}
}
\ No newline at end of file
src/components/country/index.js
View file @
fc0bbae8
import
React
,
{
Component
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
{
bindActionCreators
}
from
'redux'
;
import
{
getParam
}
from
'@/utils'
;
import
{
addCountryNum
}
from
'./countryRedux'
;
import
{
HeaderBar
}
from
'@/common'
import
'./index.scss'
;
class
Country
extends
Component
{
toParentPage
=
(
e
,
num
)
=>
{
// console.log(this.props);
const
{
history
,
addCountryNum
}
=
this
.
props
;
addCountryNum
({
num
,
code
:
getParam
(
'share_code'
)
});
history
.
push
(
`/detail?id=
${
getParam
(
'id'
)}
`
);
e
.
preventDefault
();
}
render
()
{
const
data
=
[
{
...
...
@@ -384,15 +400,6 @@ class Country extends Component {
]
},
{
type
:
'I'
,
list
:
[
{
name
:
''
,
num
:
''
}
]
},
{
type
:
'J'
,
list
:
[
{
...
...
@@ -716,15 +723,6 @@ class Country extends Component {
]
},
{
type
:
'Q'
,
list
:
[
{
name
:
''
,
num
:
''
}
]
},
{
type
:
'R'
,
list
:
[
{
...
...
@@ -877,24 +875,6 @@ class Country extends Component {
]
},
{
type
:
'U'
,
list
:
[
{
name
:
''
,
num
:
''
}
]
},
{
type
:
'V'
,
list
:
[
{
name
:
''
,
num
:
''
}
]
},
{
type
:
'W'
,
list
:
[
{
...
...
@@ -1061,9 +1041,8 @@ class Country extends Component {
];
return
(
<>
<
HeaderBar
title
=
"选择国家和地区"
arrow
=
{
true
}
><
/HeaderBar
>
<
div
className
=
"letter-nav"
>
<
ul
>
<
HeaderBar
title
=
"选择国家和地区"
/>
<
ul
className
=
"letter-nav"
>
<
li
className
=
"letter-nav__item"
>
A
<
/li
>
<
li
className
=
"letter-nav__item letter-nav__item--active"
>
B
<
/li
>
<
li
className
=
"letter-nav__item"
>
C
<
/li
>
...
...
@@ -1091,17 +1070,16 @@ class Country extends Component {
<
li
className
=
"letter-nav__item"
>
Y
<
/li
>
<
li
className
=
"letter-nav__item"
>
Z
<
/li
>
<
/ul
>
<
/div
>
<
div
className
=
"page-body"
>
{
data
.
map
((
itme
,
index
)
=>
{
{
data
.
map
((
{
type
,
list
}
,
index
)
=>
{
return
(
<>
<
h2
className
=
"country-header"
>
{
itme
.
type
}
<
/h2
>
<
div
key
=
{
index
}
>
<
h2
className
=
"country-header"
>
{
type
}
<
/h2
>
<
ul
className
=
"country-list"
>
{
itme
.
list
.
map
((
val
,
key
)
=>
{
{
list
.
map
((
val
,
key
)
=>
{
return
(
<
li
className
=
"country-item"
key
=
{
index
}
>
<
a
className
=
"country-item__link"
href
=
"
"
>
<
li
className
=
"country-item"
key
=
{
`
${
index
}
-
${
key
}
`
}
>
<
a
className
=
"country-item__link"
href
=
"
#"
onClick
=
{(
e
)
=>
this
.
toParentPage
(
e
,
val
.
num
)}
>
<
span
className
=
"country-name"
>
{
val
.
name
}
<
/span
>
<
span
className
=
"country-num"
>+
{
val
.
num
}
<
/span
>
<
/a
>
...
...
@@ -1110,7 +1088,7 @@ class Country extends Component {
})}
<
/ul
>
<
/
>
<
/
div
>
)
})}
<
/div
>
...
...
@@ -1119,4 +1097,16 @@ class Country extends Component {
}
}
export
default
Country
;
\ No newline at end of file
export
default
connect
(
({
country
})
=>
({
country
}),
(
dispatch
)
=>
{
return
bindActionCreators
(
{
addCountryNum
},
dispatch
);
}
)(
Country
);
\ No newline at end of file
src/components/country/index.scss
View file @
fc0bbae8
...
...
@@ -58,9 +58,12 @@ body {
// NAV
.letter-nav
{
position
:
fixed
;
top
:
0
;
top
:
44px
;
bottom
:
0
;
right
:
2px
;
height
:
468px
;
margin
:
auto
;
z-index
:
999
;
}
.letter-nav__item
{
...
...
@@ -72,6 +75,7 @@ body {
color
:
#0099FF
;
text-align
:
center
;
line-height
:
12px
;
cursor
:
pointer
;
}
.letter-nav__item--active
{
...
...
src/components/detail/index.js
View file @
fc0bbae8
...
...
@@ -571,6 +571,7 @@ class Detail extends Component {
isRedPacket
&&
<
RedPacket
history
=
{
this
.
props
.
history
}
country
=
{
this
.
props
.
country
}
/
>
}
...
...
@@ -650,7 +651,8 @@ const mapStateToProps = (state) => {
// courseInfo: state.courseInfo,
user
:
{
...
state
.
user
}
},
country
:
state
.
country
}
}
...
...
src/components/detail/redPacket/index.js
View file @
fc0bbae8
...
...
@@ -42,15 +42,46 @@ class RedPacket extends PureComponent {
countdownTimer
:
null
,
countdown
:
'00分00秒'
,
// 绑定时间
accountInfo
:
{},
bindInfo
:
{}
bindInfo
:
{},
country
:
{
num
:
'86'
}
}
}
componentDidMount
()
{
// 分享链接进入
console
.
log
(
this
.
props
);
const
share_code
=
getParam
(
'share_code'
);
const
{
country
}
=
this
.
props
;
if
(
country
.
code
)
{
this
.
setState
({
country
});
// 检查收否领取过
http
.
post
(
`
${
API
.
home
}
/sys/redPacket/split`
,
{
action
:
'check'
,
share_code
:
country
.
code
}
).
then
(
res
=>
{
console
.
log
(
res
);
const
{
code
,
data
}
=
res
.
data
;
if
(
code
===
200
)
{
// is_receive 是否领取过 0-否 1-是
if
(
data
.
is_receive
)
{
this
.
judgeReceiveStatus
(
data
,
8
);
}
else
{
this
.
setState
({
type
:
3
});
}
}
})
}
// 分享链接进入
const
{
shareInfo
}
=
this
.
state
;
if
(
share_code
)
{
this
.
setState
({
shareInfo
:
{
...
...
@@ -97,10 +128,7 @@ class RedPacket extends PureComponent {
}
// 判断领取状态--领取后
judgeReceiveStatus
=
(
data
)
=>
{
// receive_status 领取状态 1-已领取 2-已领取未绑定 3-已失效
if
(
data
.
receive_status
===
1
)
{
judgeReceiveStatus
=
(
data
,
bindType
=
4
)
=>
{
let
txt
=
''
;
let
desc
=
''
;
...
...
@@ -113,6 +141,9 @@ class RedPacket extends PureComponent {
txt
=
data
.
red_packet_type
===
1
?
`您已经领过该红包
${
data
.
amount
}
元现金!`
:
`您已经领过该红包
${
data
.
amount
}
元代金券碎片!`
;
desc
=
'每天只能帮好友领取一次哦~'
;
}
// receive_status 领取状态 1-已领取 2-已领取未绑定 3-已失效
if
(
data
.
receive_status
===
1
)
{
this
.
setState
({
type
:
9
,
doneInfo
:
{
...
...
@@ -123,7 +154,7 @@ class RedPacket extends PureComponent {
});
}
else
if
(
data
.
receive_status
===
2
)
{
this
.
setState
({
type
:
4
,
type
:
bindType
,
money
:
data
.
amount
,
endTime
:
data
.
end_time
});
...
...
@@ -336,7 +367,7 @@ class RedPacket extends PureComponent {
}
handleToSend
=
({
tel
,
code
})
=>
{
let
{
validate
,
seconds
,
isFirst
,
isTimer
,
captchaInstance
}
=
this
.
state
;
let
{
validate
,
seconds
,
isFirst
,
isTimer
,
captchaInstance
,
country
:
{
num
=
'0086'
}
}
=
this
.
state
;
if
(
validate
)
{
if
(
!
isFirst
)
{
Toast
.
info
(
'请重新进行滑块验证'
,
2
,
null
,
false
);
...
...
@@ -349,7 +380,8 @@ class RedPacket extends PureComponent {
if
(
!
isTimer
)
{
if
(
!
tel
)
{
Toast
.
info
(
'手机号码不能为空'
,
2
,
null
,
false
);
}
else
if
(
!
validateTel
(
tel
))
{
}
else
if
(
!
/^
\d
+$/
.
test
(
tel
))
{
// }else if (!validateTel(tel)) {
Toast
.
info
(
'请输入正确格式的手机号码'
,
2
,
null
,
false
);
}
else
{
...
...
@@ -357,7 +389,7 @@ class RedPacket extends PureComponent {
http
.
post
(
`
${
API
[
'passport-api'
]}
/m/personal/bindPhoneSendCode`
,
{
area_code
:
'0086'
,
area_code
:
num
.
padStart
(
4
,
'0'
)
,
phone_num
:
tel
}
).
then
(
res
=>
{
...
...
@@ -438,12 +470,12 @@ class RedPacket extends PureComponent {
// 绑定手机
toContinueBind
=
(
isValid
=
1
)
=>
{
const
{
accountInfo
:
{
tel
,
code
}
}
=
this
.
state
;
const
{
accountInfo
:
{
tel
,
code
}
,
country
:
{
num
=
'0086'
}
}
=
this
.
state
;
// is_valid 是否验证 1:验证(默认),0不验证
http
.
post
(
`
${
API
[
'passport-api'
]}
/m/personal/bindPhone`
,
{
area_code
:
'0086'
,
area_code
:
num
.
padStart
(
4
,
'0'
)
,
phone_num
:
tel
,
code
:
code
,
type
:
1
,
...
...
@@ -480,13 +512,15 @@ class RedPacket extends PureComponent {
isTimer
,
seconds
,
shareInfo
:
{
command
=
''
command
=
''
,
share_code
=
''
},
money
,
doneInfo
,
countdown
,
endTime
,
bindInfo
bindInfo
,
country
}
=
this
.
state
;
const
cls
=
classnames
(
'popup-mask'
,{
'popup-mask--no'
:
type
!==
2
...
...
@@ -657,7 +691,8 @@ class RedPacket extends PureComponent {
validate
=
{({
tel
,
code
})
=>
{
const
errors
=
{};
if
(
!
validateTel
(
tel
))
{
// if (!validateTel(tel)) {
if
(
!
/^
\d
+$/
.
test
(
tel
))
{
errors
.
tel
=
'请填写正确格式的手机号'
;
}
if
(
!
/
[
0-9
]{6}
/
.
test
(
code
))
{
...
...
@@ -678,8 +713,10 @@ class RedPacket extends PureComponent {
<
Form
className
=
"popup-form__content"
>
<
h4
className
=
"popup-form__title"
>
绑定手机号
<
/h4
>
<
div
className
=
"popup-form__item"
>
<
a
className
=
"popup-form__button--num"
>
+
86
<
a
className
=
"popup-form__button--num"
href
=
{
`/country?id=
${
getParam
(
'id'
)}
&share_code=
${
share_code
}
`
}
>
+
{
country
.
num
}
<
i
className
=
"iconfont iconiconfront-69"
><
/i
>
<
/a
>
<
Field
...
...
src/store/index.js
View file @
fc0bbae8
...
...
@@ -2,12 +2,14 @@ import { combineReducers } from 'redux';
import
myCourses
from
'@/components/study/myCourses/reducers'
import
courseInfo
from
'@/components/detail/reducers'
import
user
from
'./userReducer'
import
country
from
'@/components/country/countryRedux'
const
reducer
=
combineReducers
({
myCourses
,
courseInfo
,
user
user
,
country
});
export
default
reducer
;
\ No newline at end of file
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