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
73bfcd95
Commit
73bfcd95
authored
Jul 06, 2020
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
强制拼团
parent
f4ccf1de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
45 deletions
+66
-45
src/components/detail/group/index.js
+9
-0
src/components/detail/group/togroup.js
+55
-44
src/components/detail/index.js
+2
-1
No files found.
src/components/detail/group/index.js
View file @
73bfcd95
...
@@ -106,15 +106,24 @@ class Group extends Component {
...
@@ -106,15 +106,24 @@ class Group extends Component {
formatTimeByMillisecond
=
(
millisecond
)
=>
{
formatTimeByMillisecond
=
(
millisecond
)
=>
{
let
date
=
millisecond
*
1000
,
let
date
=
millisecond
*
1000
,
day
=
0
,
hours
=
0
,
hours
=
0
,
minutes
=
0
,
minutes
=
0
,
seconds
=
0
;
seconds
=
0
;
date
-=
1000
;
date
-=
1000
;
if
(
millisecond
>
86400
)
{
day
=
`
${
parseInt
(
date
/
(
3600000
*
24
))}
`
.
padStart
(
2
,
0
)
hours
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
)
/
3600000
)}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
return
`
${
day
}
:
${
hours
}
:
${
minutes
}
`
;
}
else
{
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
);
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
);
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
);
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
);
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
);
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
);
return
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
;
return
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
;
}
}
}
render
()
{
render
()
{
const
{
courseInfo
}
=
this
.
props
;
const
{
courseInfo
}
=
this
.
props
;
...
...
src/components/detail/group/togroup.js
View file @
73bfcd95
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
'./togroup.scss'
import
'./togroup.scss'
import
{
HeaderBar
,
VList
}
from
'../../../common'
import
{
HeaderBar
,
VList
}
from
'../../../common'
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
;
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
connect
}
from
"react-redux"
import
{
connect
}
from
"react-redux"
import
{
Link
}
from
"react-router-dom"
import
{
Link
}
from
"react-router-dom"
import
{
WingBlank
,
WhiteSpace
,
Flex
,
Toast
,
Modal
}
from
'antd-mobile'
import
{
WingBlank
,
WhiteSpace
,
Flex
,
Toast
,
Modal
}
from
'antd-mobile'
@
connect
(
state
=>
({
user
:
state
.
user
}))
@
connect
(
state
=>
({
user
:
state
.
user
}))
...
@@ -21,34 +21,34 @@ class ToGroup extends Component {
...
@@ -21,34 +21,34 @@ class ToGroup extends Component {
number
:
0
,
// 差几人成团
number
:
0
,
// 差几人成团
isBuy
:
false
,
isBuy
:
false
,
modal
:
false
,
modal
:
false
,
pddOrderId
:
''
pddOrderId
:
''
}
}
}
}
invitedFriends
=
()
=>
{
invitedFriends
=
()
=>
{
const
{
pdd_price
,
number
,
data
}
=
this
.
state
;
const
{
pdd_price
,
number
,
data
}
=
this
.
state
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
)
{
let
share
=
this
.
state
.
share
;
let
share
=
this
.
state
.
share
this
.
setState
({
this
.
setState
({
share
:
!
share
,
share
:
!
share
,
})
;
})
wxShare
({
wxShare
({
title
:
`【仅剩
${
number
}
个名额】我
${
pdd_price
}
元拼了《
${
data
.
course_title
}
》`
,
title
:
`【仅剩
${
number
}
个名额】我
${
pdd_price
}
元拼了《
${
data
.
course_title
}
》`
,
desc
:
data
.
course_title
,
desc
:
data
.
course_title
,
link
:
location
.
href
+
'&is_originator=1'
,
link
:
location
.
href
+
'&is_originator=1'
,
imgUrl
:
data
.
image_name
,
imgUrl
:
data
.
image_name
,
})
;
})
}
else
{
}
else
{
Toast
.
info
(
'请在微信中使用分享功能!'
,
2
)
;
Toast
.
info
(
'请在微信中使用分享功能!'
,
2
)
}
}
}
}
componentDidMount
()
{
componentDidMount
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pdd/info/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pdd/info/
${
getParam
(
'id'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
!==
0
)
{
if
(
res
.
data
.
errno
!==
0
)
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
;
Toast
.
info
(
res
.
data
.
msg
,
2
)
return
;
return
}
}
this
.
setState
({
this
.
setState
({
data
:
res
.
data
.
data
.
course_info
,
data
:
res
.
data
.
data
.
course_info
,
...
@@ -61,41 +61,51 @@ class ToGroup extends Component {
...
@@ -61,41 +61,51 @@ class ToGroup extends Component {
pddOrderId
:
res
.
data
.
data
.
pdd_order_id
,
pddOrderId
:
res
.
data
.
data
.
pdd_order_id
,
countdown
:
''
,
countdown
:
''
,
isBuy
:
res
.
data
.
data
.
is_buy
isBuy
:
res
.
data
.
data
.
is_buy
})
;
})
if
(
res
.
data
.
data
.
is_success
===
0
)
{
if
(
res
.
data
.
data
.
is_success
===
0
)
{
let
date
=
res
.
data
.
data
.
end_time
*
1000
,
let
date
=
res
.
data
.
data
.
end_time
*
1000
,
day
=
0
,
hours
=
0
,
hours
=
0
,
minutes
=
0
,
minutes
=
0
,
seconds
=
0
;
seconds
=
0
setInterval
(()
=>
{
setInterval
(()
=>
{
date
-=
1000
date
-=
1000
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
);
if
(
res
.
data
.
data
.
end_time
>
86400
)
{
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
);
day
=
`
${
parseInt
(
date
/
(
3600000
*
24
))}
`
.
padStart
(
2
,
0
)
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
);
hours
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
)
/
3600000
)}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
this
.
setState
({
countdown
:
`
${
day
}
:
${
hours
}
:
${
minutes
}
`
})
}
else
{
hours
=
`
${
parseInt
(
date
/
(
60
*
60
*
1000
))}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
seconds
=
`
${
parseInt
((
date
-
hours
*
3600000
-
minutes
*
60000
)
/
1000
)}
`
.
padStart
(
2
,
0
)
this
.
setState
({
this
.
setState
({
countdown
:
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
countdown
:
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
});
})
}
},
1000
)
},
1000
)
}
}
})
;
})
}
}
toCourseDetail
=
(
id
)
=>
{
toCourseDetail
=
(
id
)
=>
{
const
{
history
}
=
this
.
props
;
const
{
history
}
=
this
.
props
history
.
push
(
`/detail?id=
${
id
}
`
,
{
href
:
'/classify'
})
;
history
.
push
(
`/detail?id=
${
id
}
`
,
{
href
:
'/classify'
})
return
false
;
return
false
}
}
handleToGroup
=
()
=>
{
handleToGroup
=
()
=>
{
const
{
isBuy
=
false
,
data
=
{}}
=
this
.
state
;
const
{
isBuy
=
false
,
data
=
{}}
=
this
.
state
const
{
user
,
history
,
location
}
=
this
.
props
;
const
{
user
,
history
,
location
}
=
this
.
props
if
(
user
.
hasError
)
{
if
(
user
.
hasError
)
{
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
)
{
let
redirectURI
=
window
.
location
.
href
let
redirectURI
=
window
.
location
.
href
if
(
redirectURI
.
includes
(
'code='
)
&&
redirectURI
.
includes
(
'state=STATE'
))
{
if
(
redirectURI
.
includes
(
'code='
)
&&
redirectURI
.
includes
(
'state=STATE'
))
{
let
index
=
redirectURI
.
lastIndexOf
(
'code='
)
;
let
index
=
redirectURI
.
lastIndexOf
(
'code='
)
redirectURI
=
redirectURI
.
substr
(
0
,
index
-
1
)
;
redirectURI
=
redirectURI
.
substr
(
0
,
index
-
1
)
}
}
window
.
location
.
assign
(
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=
${
encodeURIComponent
(
redirectURI
)}
&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
)
window
.
location
.
assign
(
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=
${
encodeURIComponent
(
redirectURI
)}
&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
)
}
else
{
}
else
{
...
@@ -110,7 +120,7 @@ class ToGroup extends Component {
...
@@ -110,7 +120,7 @@ class ToGroup extends Component {
`/order?id=
${
data
.
course_id
}
`
,
`/order?id=
${
data
.
course_id
}
`
,
{
{
group
:
1
,
group
:
1
,
pdd_order_id
:
this
.
state
.
pddOrderId
pdd_order_id
:
this
.
state
.
pddOrderId
}
}
)
)
}
else
{
}
else
{
...
@@ -121,7 +131,7 @@ class ToGroup extends Component {
...
@@ -121,7 +131,7 @@ class ToGroup extends Component {
}
}
render
()
{
render
()
{
const
{
data
:
{
course_id
,
course_title
,
simpledescription
,
price0
,
price1
},
pdd_price
,
is_success
,
person_num
,
groupon_member
,
course_list
}
=
this
.
state
;
const
{
data
:
{
course_id
,
course_title
,
simpledescription
,
price0
,
price1
},
pdd_price
,
is_success
,
person_num
,
groupon_member
,
course_list
}
=
this
.
state
const
Info
=
(
const
Info
=
(
<
div
className
=
"info"
>
<
div
className
=
"info"
>
<
p
className
=
'title'
onClick
=
{()
=>
this
.
toCourseDetail
(
course_id
)}
>
<
p
className
=
'title'
onClick
=
{()
=>
this
.
toCourseDetail
(
course_id
)}
>
...
@@ -151,8 +161,8 @@ class ToGroup extends Component {
...
@@ -151,8 +161,8 @@ class ToGroup extends Component {
onPress
:
()
=>
{
onPress
:
()
=>
{
this
.
setState
({
this
.
setState
({
modal
:
false
modal
:
false
})
;
})
this
.
props
.
history
.
push
(
'/'
)
;
this
.
props
.
history
.
push
(
'/'
)
}
}
}
}
]}
]}
...
@@ -203,7 +213,7 @@ class ToGroup extends Component {
...
@@ -203,7 +213,7 @@ class ToGroup extends Component {
return
(
return
(
<
VList
<
VList
img
=
{
item
.
image_name
}
img
=
{
item
.
image_name
}
key
=
{
item
.
u
id
}
key
=
{
item
.
course_
id
}
id
=
{
item
.
course_id
}
id
=
{
item
.
course_id
}
info
=
{
weekInfo
}
info
=
{
weekInfo
}
toDetail
=
{
this
.
toCourseDetail
}
toDetail
=
{
this
.
toCourseDetail
}
...
@@ -219,13 +229,14 @@ class ToGroup extends Component {
...
@@ -219,13 +229,14 @@ class ToGroup extends Component {
}
}
function
GorupContent
(
props
)
{
function
GorupContent
(
props
)
{
let
tip
,
btn
,
dec
,
groupTip
,
shareTip
,
groupSuccessMbc
;
let
tip
,
btn
,
dec
,
groupTip
,
shareTip
,
groupSuccessMbc
const
{
pdd_price
,
data
,
groupon_member
,
is_success
,
person_num
,
share
,
number
,
countdown
}
=
props
.
data
;
const
{
pdd_price
,
data
,
groupon_member
,
is_success
,
person_num
,
share
,
number
,
countdown
}
=
props
.
data
const
{
userInfo
}
=
props
const
{
userInfo
}
=
props
let
ary
=
[],
num
=
number
;
let
ary
=
[],
num
=
number
while
(
num
!=
0
)
{
while
(
num
!=
0
)
{
ary
.
push
(
num
)
;
ary
.
push
(
num
)
num
--
;
num
--
}
}
groupTip
=
(
<
div
className
=
'group-user-list'
>
groupTip
=
(
<
div
className
=
'group-user-list'
>
<
Flex
justify
=
'center'
className
=
'imgList'
>
<
Flex
justify
=
'center'
className
=
'imgList'
>
...
@@ -241,7 +252,7 @@ function GorupContent(props) {
...
@@ -241,7 +252,7 @@ function GorupContent(props) {
<
/div
>
<
/div
>
)
:
null
)
:
null
}
}
<
/div>
)
;
<
/div>
)
})
})
}
}
{
{
...
@@ -254,14 +265,14 @@ function GorupContent(props) {
...
@@ -254,14 +265,14 @@ function GorupContent(props) {
})
})
}
}
<
/Flex
>
<
/Flex
>
<
/div>
)
;
<
/div>
)
if
(
groupon_member
&&
groupon_member
.
length
>
0
)
{
if
(
groupon_member
&&
groupon_member
.
length
>
0
)
{
let
flag
=
false
;
let
flag
=
false
!
userInfo
.
hasError
&&
groupon_member
.
map
(
item
=>
{
!
userInfo
.
hasError
&&
groupon_member
.
map
(
item
=>
{
if
(
item
.
uid
==
userInfo
.
data
.
uid
)
{
if
(
item
.
uid
==
userInfo
.
data
.
uid
)
{
flag
=
true
flag
=
true
return
;
return
}
}
})
})
if
(
flag
)
{
if
(
flag
)
{
...
@@ -269,7 +280,7 @@ function GorupContent(props) {
...
@@ -269,7 +280,7 @@ function GorupContent(props) {
btn
=
<
span
className
=
'group-btn'
onClick
=
{
props
.
invitedFriends
}
>
邀请好友参团
{
countdown
}
后结束
<
/span
>
btn
=
<
span
className
=
'group-btn'
onClick
=
{
props
.
invitedFriends
}
>
邀请好友参团
{
countdown
}
后结束
<
/span
>
dec
=
<
p
className
=
'dec'
>
分享到
3
个群后,成团率高达
98
%<
/p
>
dec
=
<
p
className
=
'dec'
>
分享到
3
个群后,成团率高达
98
%<
/p
>
}
else
{
}
else
{
if
(
getParam
(
'is_originator'
)
==
1
)
{
if
(
getParam
(
'is_originator'
)
==
1
)
{
tip
=
<
p
className
=
'tip'
>
{
`拼团省¥
${
data
.
price1
-
pdd_price
}
元`
}
<
/p
>
tip
=
<
p
className
=
'tip'
>
{
`拼团省¥
${
data
.
price1
-
pdd_price
}
元`
}
<
/p
>
btn
=
<
a
href
=
"javascript:;"
className
=
'group-btn'
onClick
=
{
props
.
handleToGroup
}
>
一键参团
<
/a
>
btn
=
<
a
href
=
"javascript:;"
className
=
'group-btn'
onClick
=
{
props
.
handleToGroup
}
>
一键参团
<
/a
>
}
else
{
}
else
{
...
...
src/components/detail/index.js
View file @
73bfcd95
...
@@ -419,11 +419,12 @@ class Detail extends Component {
...
@@ -419,11 +419,12 @@ class Detail extends Component {
seconds
=
0
seconds
=
0
setInterval
(()
=>
{
setInterval
(()
=>
{
date
-=
1000
date
-=
1000
console
.
log
(
endTime
)
if
(
endTime
>
86400
)
{
if
(
endTime
>
86400
)
{
day
=
`
${
parseInt
(
date
/
(
3600000
*
24
))}
`
.
padStart
(
2
,
0
)
day
=
`
${
parseInt
(
date
/
(
3600000
*
24
))}
`
.
padStart
(
2
,
0
)
hours
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
)
/
3600000
)}
`
.
padStart
(
2
,
0
)
hours
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
)
/
3600000
)}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
minutes
=
`
${
parseInt
((
date
-
day
*
3600000
*
24
-
hours
*
3600000
)
/
60000
)}
`
.
padStart
(
2
,
0
)
// seconds = `${parseInt((date - day * 3600000 * 24 - hours * 3600000 - minutes * 60000) / 1000)}`.padStart(2, 0);
this
.
setState
({
this
.
setState
({
countdown
:
`
${
day
}
:
${
hours
}
:
${
minutes
}
`
countdown
:
`
${
day
}
:
${
hours
}
:
${
minutes
}
`
})
})
...
...
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