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
34a0cb86
Commit
34a0cb86
authored
Sep 17, 2019
by
FE
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new-share'
parents
18c2e46b
c39b1536
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
70 deletions
+166
-70
src/components/detail/index.js
+1
-0
src/components/detail/redPacket/index.js
+160
-70
yarn.lock
+5
-0
No files found.
src/components/detail/index.js
View file @
34a0cb86
...
@@ -570,6 +570,7 @@ class Detail extends Component {
...
@@ -570,6 +570,7 @@ class Detail extends Component {
history
=
{
this
.
props
.
history
}
history
=
{
this
.
props
.
history
}
country
=
{
this
.
props
.
country
}
country
=
{
this
.
props
.
country
}
delCountryNum
=
{
this
.
props
.
delCountryNum
}
delCountryNum
=
{
this
.
props
.
delCountryNum
}
userInfo
=
{
this
.
props
.
user
.
data
}
/
>
/
>
}
}
...
...
src/components/detail/redPacket/index.js
View file @
34a0cb86
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
CopyToClipboard
from
'react-copy-to-clipboard'
;
import
{
CopyToClipboard
}
from
'react-copy-to-clipboard'
;
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
browser
}
from
'@/utils'
;
import
{
browser
}
from
'@/utils'
;
...
@@ -28,13 +28,11 @@ class RedPacket extends PureComponent {
...
@@ -28,13 +28,11 @@ class RedPacket extends PureComponent {
shareInfo
:
{
shareInfo
:
{
url
:
''
,
url
:
''
,
share_code
:
''
,
share_code
:
''
,
command
:
''
command
:
'
【七月在线送你一个红包】https://www.julyedu.com/
'
},
},
doneInfo
:
{
//领取后的状态,1:领取成功,2:领取超时
doneInfo
:
{
//领取后的状态,1:领取成功,2:领取超时
status
:
2
,
status
:
2
,
txt
:
'手机号绑定超时,红包已失效!'
,
txt
:
'手机号绑定超时,红包已失效!'
,
// txt: '今日已领取5.6元代金券碎片!',
// txt: '今日已领取5.6元现金!',
desc
:
''
desc
:
''
},
},
money
:
''
,
// 红包金额,
money
:
''
,
// 红包金额,
...
@@ -51,49 +49,82 @@ class RedPacket extends PureComponent {
...
@@ -51,49 +49,82 @@ class RedPacket extends PureComponent {
componentDidMount
()
{
componentDidMount
()
{
// console.log(this.props);
// console.log(this.props);
const
share_code
=
getParam
(
'share_code'
);
this
.
judgePopupTypeFromCountry
();
const
{
country
}
=
this
.
props
;
const
{
shareInfo
}
=
this
.
state
;
if
(
country
.
code
)
{
this
.
setState
({
country
,
shareInfo
:
{
...
shareInfo
,
share_code
:
country
.
code
}
});
// 检查收否领取过
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
.
judgePopupType
();
this
.
judgeReceiveStatus
(
data
,
8
);
}
else
{
// 微信进入
this
.
setState
({
const
isWechat
=
getParam
(
'wechat'
);
type
:
3
const
{
userInfo
}
=
this
.
props
;
});
if
(
isWechat
===
'1'
&&
!
browser
.
isWeixin
)
{
}
if
(
userInfo
&&
userInfo
.
uid
)
{
// 清除
const
type
=
window
.
localStorage
.
getItem
(
'redpacket-click'
);
this
.
props
.
delCountryNum
();
if
(
type
===
'split'
)
{
http
.
get
(
`
${
API
.
home
}
/sys/redPacket/shareUrl/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
;
if
(
code
===
200
)
{
// 检查收否领取过
http
.
post
(
`
${
API
.
home
}
/sys/redPacket/split`
,
{
action
:
'check'
,
share_code
:
data
.
share_code
}
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
;
if
(
code
===
200
)
{
window
.
localStorage
.
removeItem
(
'redpacket-click'
);
// is_receive 是否领取过 0-否 1-是
if
(
data
.
is_receive
)
{
this
.
judgeReceiveStatus
(
data
,
8
);
}
else
{
this
.
setState
({
type
:
3
});
}
}
})
}
});
}
else
{
this
.
setState
({
type
:
1
});
window
.
localStorage
.
removeItem
(
'redpacket-click'
);
}
}
})
}
else
{
this
.
setState
({
type
:
1
});
}
}
}
// 分享链接进入
if
(
share_code
)
{
this
.
fetchShareInfo
();
}
// 获取分享信息
fetchShareInfo
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/redPacket/shareUrl/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
;
if
(
code
===
200
)
{
this
.
setState
({
shareInfo
:
data
});
}
});
}
// 分享后进入,链接中带 share_code 字段
judgePopupType
=
()
=>
{
const
share_code
=
getParam
(
'share_code'
);
const
{
shareInfo
}
=
this
.
state
;
if
(
share_code
&&
share_code
!==
'null'
)
{
this
.
setState
({
this
.
setState
({
shareInfo
:
{
shareInfo
:
Object
.
assign
({},
shareInfo
,
{
...
shareInfo
,
share_code
share_code
}
}
)
});
});
// 检查收否领取过
// 检查收否领取过
...
@@ -133,6 +164,47 @@ class RedPacket extends PureComponent {
...
@@ -133,6 +164,47 @@ class RedPacket extends PureComponent {
}
}
}
}
// 选择区号后进入
judgePopupTypeFromCountry
=
()
=>
{
const
{
country
}
=
this
.
props
;
const
{
shareInfo
}
=
this
.
state
;
if
(
country
.
code
)
{
this
.
setState
({
country
,
shareInfo
:
Object
.
assign
({},
shareInfo
,
{
share_code
:
country
.
code
})
});
// 检查收否领取过
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
});
}
// 清除
this
.
props
.
delCountryNum
();
}
})
}
}
// 判断领取状态--领取后
// 判断领取状态--领取后
judgeReceiveStatus
=
(
data
,
bindType
=
4
)
=>
{
judgeReceiveStatus
=
(
data
,
bindType
=
4
)
=>
{
let
txt
=
''
;
let
txt
=
''
;
...
@@ -209,25 +281,21 @@ class RedPacket extends PureComponent {
...
@@ -209,25 +281,21 @@ class RedPacket extends PureComponent {
// 获取分享信息
// 获取分享信息
handleToShare
=
()
=>
{
handleToShare
=
()
=>
{
const
{
history
}
=
this
.
props
;
const
{
history
,
userInfo
}
=
this
.
props
;
http
.
get
(
`
${
API
.
home
}
/sys/redPacket/shareUrl/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
if
(
browser
.
isWeixin
)
{
const
{
code
,
data
}
=
res
.
data
;
this
.
setState
({
if
(
code
===
4030
||
code
===
4040
)
{
type
:
2
if
(
browser
.
isWeixin
)
{
});
this
.
setState
({
history
.
push
(
`/detail?id=
${
getParam
(
'id'
)}
&wechat=1`
);
type
:
2
}
else
{
});
if
(
userInfo
&&
userInfo
.
uid
)
{
}
else
{
history
.
push
(
'/passport/login'
);
}
}
if
(
code
===
200
)
{
this
.
setState
({
this
.
setState
({
shareInfo
:
data
,
type
:
1
type
:
browser
.
isWeixin
?
2
:
1
});
});
}
else
{
history
.
push
(
'/passport/login'
);
}
}
}
);
}
}
}
// 提示关注公众号
// 提示关注公众号
...
@@ -354,13 +422,6 @@ class RedPacket extends PureComponent {
...
@@ -354,13 +422,6 @@ class RedPacket extends PureComponent {
}
}
}
}
// 复制口令
handleToCopy
=
()
=>
{
this
.
setState
({
isCopy
:
true
});
}
getCaptchaInstance
=
instance
=>
{
getCaptchaInstance
=
instance
=>
{
this
.
setState
({
this
.
setState
({
captchaInstance
:
instance
captchaInstance
:
instance
...
@@ -515,7 +576,7 @@ class RedPacket extends PureComponent {
...
@@ -515,7 +576,7 @@ class RedPacket extends PureComponent {
render
()
{
render
()
{
// console.log(this.props);
// console.log(this.props);
const
{
history
}
=
this
.
props
;
const
{
history
,
userInfo
}
=
this
.
props
;
const
{
const
{
type
,
type
,
isCopy
,
isCopy
,
...
@@ -570,10 +631,25 @@ class RedPacket extends PureComponent {
...
@@ -570,10 +631,25 @@ class RedPacket extends PureComponent {
{
command
.
length
>
16
?
`
${
command
.
substr
(
0
,
16
)}
...`
:
command
}
{
command
.
length
>
16
?
`
${
command
.
substr
(
0
,
16
)}
...`
:
command
}
<
/p
>
<
/p
>
{
!
isCopy
{
!
isCopy
?
userInfo
&&
userInfo
.
uid
?
(
?
(
<
CopyToClipboard
text
=
{
command
}
onCopy
=
{
this
.
handleToCopy
}
>
<
CopyToClipboard
<
button
className
=
"popup-password__button--copy"
>
复制口令
<
/button
>
text
=
{
command
}
<
/CopyToClipboard
>
onCopy
=
{()
=>
this
.
setState
({
isCopy
:
true
})}
>
<
button
className
=
"popup-password__button--copy"
>
复制口令
<
/button
>
<
/CopyToClipboard
>
)
:
(
<
button
className
=
"popup-password__button--copy"
onClick
=
{()
=>
{
window
.
localStorage
.
setItem
(
'redpacket-click'
,
'copy'
);
history
.
push
(
'/passport/login'
);
}}
>
复制口令
<
/button
>
)
)
:
<
p
className
=
"popup-password__success"
>
复制成功,快发送给好友吧
~<
/p
>
:
<
p
className
=
"popup-password__success"
>
复制成功,快发送给好友吧
~<
/p
>
}
}
...
@@ -585,7 +661,21 @@ class RedPacket extends PureComponent {
...
@@ -585,7 +661,21 @@ class RedPacket extends PureComponent {
<
/div
>
<
/div
>
<
i
<
i
className
=
"popup-password__button--close iconfont iconiconfront-2"
className
=
"popup-password__button--close iconfont iconiconfront-2"
onClick
=
{()
=>
this
.
handleToClose
(
true
)}
onClick
=
{()
=>
{
if
(
getParam
(
'wechat'
)
===
'1'
)
{
if
(
userInfo
&&
userInfo
.
uid
)
{
this
.
handleToClose
(
true
);
history
.
push
(
`/detail?id=
${
getParam
(
'id'
)}
`
);
}
else
{
this
.
setState
({
type
:
3
});
window
.
localStorage
.
setItem
(
'redpacket-click'
,
'split'
);
}
}
else
{
this
.
handleToClose
(
true
);
}
}}
/
>
/
>
<
/div
>
<
/div
>
}
}
...
...
yarn.lock
View file @
34a0cb86
...
@@ -2772,6 +2772,11 @@ cli-width@^2.0.0:
...
@@ -2772,6 +2772,11 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
clipboard-copy@^3.1.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/clipboard-copy/download/clipboard-copy-3.1.0.tgz#4c59030a43d4988990564a664baeafba99f78ca4"
integrity sha1-TFkDCkPUmImQVkpmS66vupn3jKQ=
cliui@^3.2.0:
cliui@^3.2.0:
version "3.2.0"
version "3.2.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
...
...
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