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
acf4003d
Commit
acf4003d
authored
Apr 29, 2020
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录
parent
10311673
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
178 deletions
+119
-178
src/components/ml/index.js
+83
-0
src/components/ml/pythomDes/index.js
+36
-99
src/components/ml/pythonStudy/index.js
+0
-79
No files found.
src/components/ml/index.js
View file @
acf4003d
...
@@ -6,6 +6,7 @@ import {connect} from "react-redux"
...
@@ -6,6 +6,7 @@ import {connect} from "react-redux"
import
{
addDays
}
from
"date-fns"
import
{
addDays
}
from
"date-fns"
import
cookie
from
"js-cookie"
import
cookie
from
"js-cookie"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
import
{
Toast
}
from
"antd-mobile"
@
connect
(
state
=>
({
@
connect
(
state
=>
({
...
@@ -32,6 +33,88 @@ class ML extends Component {
...
@@ -32,6 +33,88 @@ class ML extends Component {
window
[
'loginInfo'
]
=
result
=>
{
window
[
'loginInfo'
]
=
result
=>
{
_this
.
loginInfo
(
result
)
_this
.
loginInfo
(
result
)
}
}
if
(
browser
.
isWeixin
)
{
this
.
isweixinPay
()
}
if
(
getParam
(
'weixinpay'
))
{
this
.
payCallback
()
}
}
// 微信内部支付回调
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
weixin_code
=
getParam
(
'code'
);
if
(
weixin_code
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
return
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
let
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_wcpsys/order_status/ay_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
;
location
.
reload
()
}
})
},
1000
)
}
else
{
Toast
.
info
(
'支付失败'
,
2
);
}
}
)
}
if
(
typeof
WeixinJSBridge
==
"undefined"
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
);
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
}
}
else
{
onBridgeReady
();
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
}
}
// 支付完成之后获取状态
payCallback
=
()
=>
{
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
;
location
.
reload
()
}
})
},
1000
)
}
}
// 获取app登录数据
// 获取app登录数据
...
...
src/components/ml/pythomDes/index.js
View file @
acf4003d
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
'./index.scss'
import
'./index.scss'
import
Description
from
'./Description/index.js'
import
Description
from
'./Description/index.js'
import
Study
from
'./Study/index.js'
import
Study
from
'./Study/index.js'
...
@@ -9,10 +9,10 @@ import Selection from './Selection'
...
@@ -9,10 +9,10 @@ import Selection from './Selection'
import
Mask
from
'./../poup/index.js'
import
Mask
from
'./../poup/index.js'
import
InAction
from
"./InAction"
import
InAction
from
"./InAction"
import
ShareRank
from
"@components/detail/shareRank"
import
ShareRank
from
"@components/detail/shareRank"
import
{
http
,
getParam
,
SendMessageToApp
,
browser
}
from
'@/utils'
import
{
http
,
getParam
,
SendMessageToApp
,
browser
}
from
'@/utils'
import
{
connect
}
from
'react-redux'
import
{
connect
}
from
'react-redux'
import
{
Toast
}
from
"antd-mobile"
import
{
Toast
}
from
"antd-mobile"
import
{
CallApp
}
from
"@common/index"
import
{
CallApp
}
from
"@common/index"
@
connect
(
state
=>
({
@
connect
(
state
=>
({
user
:
state
.
user
user
:
state
.
user
...
@@ -30,7 +30,7 @@ class PythonDes extends Component {
...
@@ -30,7 +30,7 @@ class PythonDes extends Component {
isOnline
:
true
,
//课程是否上架
isOnline
:
true
,
//课程是否上架
courseInfo
:
{},
courseInfo
:
{},
isShowChannel
:
window
.
sessionStorage
.
getItem
(
'isShowSiteWindowByChannel'
),
isShowChannel
:
window
.
sessionStorage
.
getItem
(
'isShowSiteWindowByChannel'
),
orderId
:
''
orderId
:
''
}
}
}
}
...
@@ -55,7 +55,7 @@ class PythonDes extends Component {
...
@@ -55,7 +55,7 @@ class PythonDes extends Component {
this
.
toLogin
()
this
.
toLogin
()
}
}
}
}
creatOid
=
()
=>
{
creatOid
=
()
=>
{
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/trial_create`
,
{
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/trial_create`
,
{
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
const
{
errno
,
data
,
msg
}
=
res
.
data
const
{
errno
,
data
,
msg
}
=
res
.
data
if
(
errno
===
200
)
{
if
(
errno
===
200
)
{
...
@@ -72,94 +72,21 @@ class PythonDes extends Component {
...
@@ -72,94 +72,21 @@ class PythonDes extends Component {
weixinPay
=
(
orderId
)
=>
{
weixinPay
=
(
orderId
)
=>
{
// 微信内部-支付
// 微信内部-支付
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
)
{
window
.
location
.
href
=
"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri="
+
encodeURIComponent
(
window
.
location
.
href
+
"&aa=bb&oid="
+
orderId
).
toLowerCase
()
+
"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
;
window
.
location
.
href
=
"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri="
+
encodeURIComponent
(
window
.
location
.
href
+
"&aa=bb&oid="
+
orderId
).
toLowerCase
()
+
"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
}
else
{
}
else
{
// 微信外部-支付
// 微信外部-支付
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/wap_charge/oid/
${
orderId
}
`
).
then
((
res
)
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/wap_charge/oid/
${
orderId
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
if
(
res
.
data
.
errno
===
0
)
{
window
.
location
.
href
=
res
.
data
.
data
.
url
+
"&redirect_url="
+
encodeURIComponent
(
window
.
location
.
href
+
"&weixinpay=1&oid="
+
orderId
).
toLowerCase
();
window
.
location
.
href
=
res
.
data
.
data
.
url
+
"&redirect_url="
+
encodeURIComponent
(
window
.
location
.
href
+
"&weixinpay=1&oid="
+
orderId
).
toLowerCase
()
}
else
{
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
}
})
})
}
}
}
}
// 微信支付
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
weixin_code
=
getParam
(
'code'
);
if
(
weixin_code
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
return
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
let
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_wcpsys/order_status/ay_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
;
location
.
reload
()
}
})
},
1000
)
}
else
{
Toast
.
info
(
'支付失败'
,
2
);
}
}
)
}
if
(
typeof
WeixinJSBridge
==
"undefined"
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
);
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
}
}
else
{
onBridgeReady
();
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
}
}
// 支付完成之后获取状态
payCallback
=
()
=>
{
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
;
location
.
reload
()
}
})
},
1000
)
}
toLearn
=
()
=>
{
toLearn
=
()
=>
{
const
{
backwardVersion
}
=
this
.
props
;
const
{
backwardVersion
}
=
this
.
props
http
.
post
(
`
${
API
[
'home'
]}
/m/it/user/trialCourse`
,
{
course_id
:
getParam
(
'id'
)}).
then
((
res
)
=>
{
http
.
post
(
`
${
API
[
'home'
]}
/m/it/user/trialCourse`
,
{
course_id
:
getParam
(
'id'
)}).
then
((
res
)
=>
{
const
{
code
,
msg
}
=
res
.
data
const
{
code
,
msg
}
=
res
.
data
if
(
code
==
200
)
{
if
(
code
==
200
)
{
...
@@ -187,7 +114,7 @@ class PythonDes extends Component {
...
@@ -187,7 +114,7 @@ class PythonDes extends Component {
}
}
toDetail
=
()
=>
{
toDetail
=
()
=>
{
const
{
backwardVersion
}
=
this
.
props
;
const
{
backwardVersion
}
=
this
.
props
const
id
=
getParam
(
'id'
)
const
id
=
getParam
(
'id'
)
if
(
!
getParam
(
'version'
))
{
// H5
if
(
!
getParam
(
'version'
))
{
// H5
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/[
${
id
}
]`
).
then
((
res
)
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/cart/addtopreorder/[
${
id
}
]`
).
then
((
res
)
=>
{
...
@@ -199,12 +126,12 @@ class PythonDes extends Component {
...
@@ -199,12 +126,12 @@ class PythonDes extends Component {
})
})
}
else
{
// APP
}
else
{
// APP
if
(
backwardVersion
)
{
if
(
backwardVersion
)
{
Toast
.
info
(
'当前版本不支持该课程模式,请升级到最新版本或前往PC端购买'
,
2
);
Toast
.
info
(
'当前版本不支持该课程模式,请升级到最新版本或前往PC端购买'
,
2
)
let
onlyoneUse
=
setTimeout
(()
=>
{
let
onlyoneUse
=
setTimeout
(()
=>
{
clearTimeout
(
onlyoneUse
);
clearTimeout
(
onlyoneUse
)
onlyoneUse
=
null
;
onlyoneUse
=
null
SendMessageToApp
(
'toPay'
,
id
)
SendMessageToApp
(
'toPay'
,
id
)
},
2000
);
},
2000
)
}
else
{
}
else
{
SendMessageToApp
(
'toPay'
,
id
)
SendMessageToApp
(
'toPay'
,
id
)
}
}
...
@@ -213,11 +140,27 @@ class PythonDes extends Component {
...
@@ -213,11 +140,27 @@ class PythonDes extends Component {
toLogin
=
()
=>
{
toLogin
=
()
=>
{
if
(
!
getParam
(
'version'
))
{
// H5
if
(
!
getParam
(
'version'
))
{
// H5
this
.
props
.
history
.
push
(
'/passport'
)
this
.
changeLoginType
(
)
}
else
{
// APP
}
else
{
// APP
SendMessageToApp
(
"toLogin"
)
SendMessageToApp
(
"toLogin"
)
}
}
}
}
// 点击登录 提示微信登录还是账号登录,微信授权登录不需要绑定手机号
changeLoginType
=
()
=>
{
// 微信登录
if
(
browser
.
isWeixin
)
{
// tool.setCookie('redirect_url', window.location.href);
let
url
=
window
.
location
.
href
if
(
url
.
includes
(
'code='
)
&&
url
.
includes
(
'state=STATE'
))
{
let
index
=
url
.
lastIndexOf
(
'code='
)
url
=
url
.
substr
(
0
,
index
-
1
)
}
window
.
location
.
href
=
"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri="
+
encodeURIComponent
(
url
).
toLowerCase
()
+
"&aa=bb&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
;
}
else
{
// 账号登录
this
.
props
.
history
.
push
(
'/passport'
)
}
}
showAll
=
(
key
)
=>
{
showAll
=
(
key
)
=>
{
if
(
key
===
1
)
{
if
(
key
===
1
)
{
...
@@ -268,16 +211,9 @@ class PythonDes extends Component {
...
@@ -268,16 +211,9 @@ class PythonDes extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
getStatus
()
this
.
getStatus
()
const
{
backwardVersion
,
isPay
}
=
this
.
props
;
const
{
backwardVersion
,
isPay
}
=
this
.
props
if
(
backwardVersion
&&
isPay
===
1
)
{
if
(
backwardVersion
&&
isPay
===
1
)
{
Toast
.
info
(
'当前版本不支持该课程模式,请升级到最新版本或前往PC端学习'
,
2
);
Toast
.
info
(
'当前版本不支持该课程模式,请升级到最新版本或前往PC端学习'
,
2
)
}
if
(
browser
.
isWeixin
)
{
this
.
isweixinPay
()
}
if
(
getParam
(
'weixinpay'
))
{
this
.
payCallback
()
}
}
}
}
...
@@ -326,7 +262,8 @@ class PythonDes extends Component {
...
@@ -326,7 +262,8 @@ class PythonDes extends Component {
<
div
className
=
{
'btn__group'
}
>
<
div
className
=
{
'btn__group'
}
>
<
div
className
=
{
'try__study'
}
onClick
=
{()
=>
{
<
div
className
=
{
'try__study'
}
onClick
=
{()
=>
{
this
.
tryLearn
(
3
)
this
.
tryLearn
(
3
)
}}
>
立即报名
<
/div
>
}}
>
立即报名
<
/div
>
<
div
className
=
{
'sign__now'
}
onClick
=
{()
=>
{
<
div
className
=
{
'sign__now'
}
onClick
=
{()
=>
{
this
.
tryLearn
(
2
)
this
.
tryLearn
(
2
)
}}
>
9.9
特价试学
}}
>
9.9
特价试学
...
...
src/components/ml/pythonStudy/index.js
View file @
acf4003d
...
@@ -23,13 +23,6 @@ class PythonStudy extends Component {
...
@@ -23,13 +23,6 @@ class PythonStudy extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
fetchCourseDetail
()
this
.
fetchCourseDetail
()
if
(
browser
.
isWeixin
)
{
this
.
isweixinPay
()
}
if
(
getParam
(
'weixinpay'
))
{
this
.
payCallback
()
}
}
}
fetchCourseDetail
=
()
=>
{
fetchCourseDetail
=
()
=>
{
...
@@ -119,79 +112,7 @@ class PythonStudy extends Component {
...
@@ -119,79 +112,7 @@ class PythonStudy extends Component {
})
})
}
}
}
}
// 微信支付
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
weixin_code
=
getParam
(
'code'
);
if
(
weixin_code
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
return
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
let
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_wcpsys/order_status/ay_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
;
location
.
reload
()
}
})
},
1000
)
}
else
{
Toast
.
info
(
'支付失败'
,
2
);
}
}
)
}
if
(
typeof
WeixinJSBridge
==
"undefined"
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
);
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
}
}
else
{
onBridgeReady
();
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
}
}
// 支付完成之后获取状态
payCallback
=
()
=>
{
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
;
location
.
reload
()
}
})
},
1000
)
}
render
()
{
render
()
{
const
{
user
}
=
this
.
props
const
{
user
}
=
this
.
props
...
...
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