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
bd87e46b
Commit
bd87e46b
authored
Aug 22, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单集购买微信支付
parent
408c6f1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
36 deletions
+109
-36
src/components/detail/outline/index.js
+11
-3
src/components/detail/single/index.js
+98
-33
No files found.
src/components/detail/outline/index.js
View file @
bd87e46b
...
...
@@ -15,9 +15,17 @@ class OutLine extends Component {
}
htmlDecode
=
(
content
)
=>
{
let
e
=
document
.
createElement
(
'div'
);
e
.
innerHTML
=
content
;
return
e
.
childNodes
.
length
===
0
?
""
:
e
.
innerHTML
;
// let e = document.createElement('div');
// e.innerHTML = content;
// return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
if
(
content
)
{
content
=
content
.
replace
(
/</g
,
'<'
);
content
=
content
.
replace
(
/>/g
,
'>'
);
content
=
content
.
replace
(
/&gt;/g
,
''
);
content
=
content
.
replace
(
/"/g
,
'"'
);
content
=
content
.
replace
(
/&nbsp;/g
,
''
);
}
return
content
;
}
tabchange
=
(
tab
,
index
)
=>
{
...
...
src/components/detail/single/index.js
View file @
bd87e46b
...
...
@@ -101,6 +101,7 @@ class Single extends Component {
}
// 微信内部支付
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
weixin_code
=
getParam
(
'code'
)
if
(
weixin_code
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
...
...
@@ -108,17 +109,71 @@ class Single extends Component {
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
const
data
=
res
.
data
.
data
this
.
onBridgeReady
(
data
)
const
data
=
res
.
data
.
data
;
function
onBridgeReady
()
{
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
{
"appId"
:
data
.
appId
,
//公众号名称,由商户传入
"timeStamp"
:
data
.
timeStamp
,
//时间戳,自1970年以来的秒数
"nonceStr"
:
data
.
nonceStr
,
//随机串
"package"
:
data
.
package
,
"signType"
:
data
.
signType
,
//微信签名方式:
"paySign"
:
data
.
paySign
//微信签名
},
function
(
res
)
{
if
(
res
.
err_msg
==
"get_brand_wcpay_request:ok"
)
{
Toast
.
info
(
'支付成功'
,
2
);
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
);
_this
.
intervalPayStatus
=
null
;
// 获取课程类型
http
.
get
(
`
${
API
.
home
}
/sys/orderStatus/
${
getParam
(
'oid'
)}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
data
.
errno
==
'200'
)
{
// 正常购买单集成功
this
.
setState
({
status
:
6
})
}
else
if
(
res
.
data
.
data
.
errno
==
'201'
)
{
// 0元参团
this
.
setState
({
status
:
4
})
}
else
if
(
res
.
data
.
data
.
errno
==
'202'
)
{
// 0元购
this
.
setState
({
status
:
3
})
}
else
if
(
res
.
data
.
data
.
errno
==
'203'
)
{
// 三天内特价
this
.
setState
({
nowPrice
:
res
.
data
.
data
.
data
.
now_price
,
laterPrice
:
res
.
data
.
data
.
data
.
three_day_later_price
,
status
:
2
})
}
else
{
Toast
.
info
(
res
.
data
.
data
.
msg
,
2
)
}
})
}
})
},
1000
)
}
else
{
alert
(
'支付失败'
)
}
}
)
}
if
(
typeof
WeixinJSBridge
==
"undefined"
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
this
.
onBridgeReady
,
false
)
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
this
.
onBridgeReady
)
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
this
.
onBridgeReady
)
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
)
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
}
}
else
{
this
.
onBridgeReady
()
onBridgeReady
()
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
...
...
@@ -130,33 +185,43 @@ class Single extends Component {
// 支付完成之后获取状态
payCallback
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/orderStatus/
${
getParam
(
'oid'
)}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
data
.
errno
==
'200'
)
{
// 正常购买单集成功
this
.
setState
({
status
:
6
})
}
else
if
(
res
.
data
.
data
.
errno
==
'201'
)
{
// 0元参团
this
.
setState
({
status
:
4
})
}
else
if
(
res
.
data
.
data
.
errno
==
'202'
)
{
// 0元购
this
.
setState
({
status
:
3
})
}
else
if
(
res
.
data
.
data
.
errno
==
'203'
)
{
// 三天内特价
this
.
setState
({
nowPrice
:
res
.
data
.
data
.
data
.
now_price
,
laterPrice
:
res
.
data
.
data
.
data
.
three_day_later_price
,
status
:
2
})
}
else
{
Toast
.
info
(
res
.
data
.
data
.
msg
,
2
)
}
})
const
_this
=
this
;
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
);
_this
.
intervalPayStatus
=
null
;
// 获取课程类型
http
.
get
(
`
${
API
.
home
}
/sys/orderStatus/
${
getParam
(
'oid'
)}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
data
.
errno
==
'200'
)
{
// 正常购买单集成功
this
.
setState
({
status
:
6
})
}
else
if
(
res
.
data
.
data
.
errno
==
'201'
)
{
// 0元参团
this
.
setState
({
status
:
4
})
}
else
if
(
res
.
data
.
data
.
errno
==
'202'
)
{
// 0元购
this
.
setState
({
status
:
3
})
}
else
if
(
res
.
data
.
data
.
errno
==
'203'
)
{
// 三天内特价
this
.
setState
({
nowPrice
:
res
.
data
.
data
.
data
.
now_price
,
laterPrice
:
res
.
data
.
data
.
data
.
three_day_later_price
,
status
:
2
})
}
else
{
Toast
.
info
(
res
.
data
.
data
.
msg
,
2
)
}
})
}
})
},
1000
)
}
...
...
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