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
4d506145
Commit
4d506145
authored
Apr 29, 2020
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ml小课优化
parent
acf4003d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
48 deletions
+132
-48
src/common/WxLogin/index.js
+40
-0
src/common/WxLogin/index.scss
+40
-0
src/common/index.js
+1
-0
src/components/ml/index.js
+36
-26
src/components/ml/pythomDes/index.js
+14
-20
src/components/ml/pythonStudy/index.js
+1
-2
No files found.
src/common/WxLogin/index.js
0 → 100755
View file @
4d506145
import
React
,
{
Component
}
from
'react'
import
'./index.scss'
class
WxLogin
extends
Component
{
constructor
(
props
)
{
super
(
props
)
}
// 提示微信登录还是账号登录,微信授权登录不需要绑定手机号
wxLogin
=
()
=>
{
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
+
"&aa=bb"
).
toLowerCase
()
+
"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
}
zhLogin
=
()
=>
{
this
.
props
.
history
.
push
(
'/passport'
)
}
render
()
{
return
(
<
div
className
=
"change-login-type"
>
<
div
className
=
"login-type-content"
>
<
div
className
=
"wx-login"
onClick
=
{
this
.
wxLogin
}
>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/mlCourse/m/wx-icon.png"
alt
=
""
/>
<
span
>
微信登录
<
/span
>
<
/div
>
<
div
className
=
"zh-login"
onClick
=
{
this
.
zhLogin
}
>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/mlCourse/m/zh-icon.png"
alt
=
""
/>
<
span
>
账号登录
<
/span
>
<
/div
>
<
/div
>
<
/div
>
)
}
}
export
default
WxLogin
src/common/WxLogin/index.scss
0 → 100755
View file @
4d506145
.change-login-type
{
background
:
rgba
(
0
,
0
,
0
,
.5
);
position
:
fixed
;
left
:
0
;
top
:
0
;
right
:
0
;
bottom
:
0
;
z-index
:
100
;
.login-type-content
{
width
:
290px
;
height
:
138px
;
background-color
:
#fff
;
border-radius
:
8px
;
position
:
relative
;
left
:
50%
;
top
:
50%
;
margin-left
:
-145px
;
margin-top
:
-69px
;
padding
:
40px
70px
;
display
:
flex
;
justify-content
:
space-between
;
}
.wx-login
,
.zh-login
{
text-align
:
center
;
img
{
width
:
34px
;
height
:
34px
;
}
span
{
display
:
block
;
color
:
#525C65
;
font-size
:
14px
;
margin-top
:
3px
;
}
}
}
\ No newline at end of file
src/common/index.js
View file @
4d506145
...
@@ -9,5 +9,6 @@ export { default as ClearableInput } from "./ClearableInput"
...
@@ -9,5 +9,6 @@ export { default as ClearableInput } from "./ClearableInput"
export
{
default
as
Loading
}
from
'./Loading'
export
{
default
as
Loading
}
from
'./Loading'
export
{
default
as
RenderTabBar
}
from
'./renderTabBar'
export
{
default
as
RenderTabBar
}
from
'./renderTabBar'
export
{
default
as
Popup
}
from
'./closable-popup'
export
{
default
as
Popup
}
from
'./closable-popup'
export
{
default
as
WxLogin
}
from
'./WxLogin'
src/components/ml/index.js
View file @
4d506145
...
@@ -7,6 +7,7 @@ import {addDays} from "date-fns"
...
@@ -7,6 +7,7 @@ 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"
import
{
Toast
}
from
"antd-mobile"
import
{
WxLogin
}
from
"@common/index"
@
connect
(
state
=>
({
@
connect
(
state
=>
({
...
@@ -22,6 +23,7 @@ class ML extends Component {
...
@@ -22,6 +23,7 @@ class ML extends Component {
userInfoList
:
[],
userInfoList
:
[],
isAppUpdate
:
false
,
isAppUpdate
:
false
,
backwardVersion
:
false
,
// 默认是新版本
backwardVersion
:
false
,
// 默认是新版本
isWxlogin
:
false
}
}
}
}
...
@@ -35,7 +37,7 @@ class ML extends Component {
...
@@ -35,7 +37,7 @@ class ML extends Component {
}
}
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
&&
getParam
(
'oid'
)
)
{
this
.
isweixinPay
()
this
.
isweixinPay
()
}
}
if
(
getParam
(
'weixinpay'
))
{
if
(
getParam
(
'weixinpay'
))
{
...
@@ -45,15 +47,15 @@ class ML extends Component {
...
@@ -45,15 +47,15 @@ class ML extends Component {
// 微信内部支付回调
// 微信内部支付回调
isweixinPay
=
()
=>
{
isweixinPay
=
()
=>
{
let
_this
=
this
;
let
_this
=
this
let
weixin_code
=
getParam
(
'code'
)
;
let
weixin_code
=
getParam
(
'code'
)
if
(
weixin_code
)
{
if
(
weixin_code
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
if
(
getParam
(
'oid'
)
===
undefined
)
{
return
return
}
else
{
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/pay/wxpay/pub_charge/oid/
${
getParam
(
'oid'
)}
/code/
${
weixin_code
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
0
)
{
if
(
res
.
data
.
errno
===
0
)
{
let
data
=
res
.
data
.
data
;
let
data
=
res
.
data
.
data
function
onBridgeReady
()
{
function
onBridgeReady
()
{
WeixinJSBridge
.
invoke
(
WeixinJSBridge
.
invoke
(
...
@@ -67,18 +69,18 @@ class ML extends Component {
...
@@ -67,18 +69,18 @@ class ML extends Component {
},
},
function
(
res
)
{
function
(
res
)
{
if
(
res
.
err_msg
==
"get_brand_wcpsys/order_status/ay_request:ok"
)
{
if
(
res
.
err_msg
==
"get_brand_wcpsys/order_status/ay_request:ok"
)
{
Toast
.
info
(
'支付成功'
,
2
)
;
Toast
.
info
(
'支付成功'
,
2
)
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
)
;
clearInterval
(
_this
.
intervalPayStatus
)
_this
.
intervalPayStatus
=
null
;
_this
.
intervalPayStatus
=
null
location
.
reload
()
location
.
reload
()
}
}
})
})
},
1000
)
},
1000
)
}
else
{
}
else
{
Toast
.
info
(
'支付失败'
,
2
)
;
Toast
.
info
(
'支付失败'
,
2
)
}
}
}
}
)
)
...
@@ -88,14 +90,12 @@ class ML extends Component {
...
@@ -88,14 +90,12 @@ class ML extends Component {
if
(
document
.
addEventListener
)
{
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
document
.
addEventListener
(
'WeixinJSBridgeReady'
,
onBridgeReady
,
false
)
}
else
if
(
document
.
attachEvent
)
{
}
else
if
(
document
.
attachEvent
)
{
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
)
;
document
.
attachEvent
(
'WeixinJSBridgeReady'
,
onBridgeReady
)
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
document
.
attachEvent
(
'onWeixinJSBridgeReady'
,
onBridgeReady
)
}
}
}
else
{
}
else
{
onBridgeReady
()
;
onBridgeReady
()
}
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
}
})
})
}
}
...
@@ -103,20 +103,23 @@ class ML extends Component {
...
@@ -103,20 +103,23 @@ class ML extends Component {
}
}
// 支付完成之后获取状态
// 支付完成之后获取状态
payCallback
=
()
=>
{
payCallback
=
()
=>
{
const
_this
=
this
;
const
_this
=
this
// 支付回调
// 支付回调
// 定时器轮训获取订单状态
// 定时器轮训获取订单状态
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
_this
.
intervalPayStatus
=
setInterval
(
function
()
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/orderState/oid/
${
getParam
(
'oid'
)}
`
).
then
(
res
=>
{
if
(
res
.
data
.
errno
===
401
)
{
if
(
res
.
data
.
errno
===
401
)
{
clearInterval
(
_this
.
intervalPayStatus
)
;
clearInterval
(
_this
.
intervalPayStatus
)
_this
.
intervalPayStatus
=
null
;
_this
.
intervalPayStatus
=
null
location
.
reload
()
location
.
reload
()
}
}
})
})
},
1000
)
},
1000
)
}
}
isWxloginFun
=
(
val
)
=>
{
this
.
setState
({
isWxlogin
:
val
})
}
// 获取app登录数据
// 获取app登录数据
loginInfo
=
(
result
)
=>
{
loginInfo
=
(
result
)
=>
{
this
.
setState
({
this
.
setState
({
...
@@ -145,10 +148,10 @@ class ML extends Component {
...
@@ -145,10 +148,10 @@ class ML extends Component {
this
.
setState
({
this
.
setState
({
isAppUpdate
:
true
isAppUpdate
:
true
})
})
this
.
fetchCourseInfo
()
;
this
.
fetchCourseInfo
()
}
}
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
;
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
}
}
transformUser
=
res
=>
{
transformUser
=
res
=>
{
...
@@ -177,22 +180,22 @@ class ML extends Component {
...
@@ -177,22 +180,22 @@ class ML extends Component {
const
{
data
,
code
}
=
res
.
data
const
{
data
,
code
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
let
version
=
getParam
(
'version'
)
let
version
=
getParam
(
'version'
)
if
(
version
)
{
if
(
version
)
{
version
=
version
.
replace
(
/
\.
/g
,
''
).
slice
(
0
,
3
)
version
=
version
.
replace
(
/
\.
/g
,
''
).
slice
(
0
,
3
)
if
(
browser
.
isAndroidApp
&&
version
<
453
)
{
// 安卓的低版本
if
(
browser
.
isAndroidApp
&&
version
<
453
)
{
// 安卓的低版本
this
.
setState
({
this
.
setState
({
backwardVersion
:
true
,
backwardVersion
:
true
,
isPay
:
0
,
isPay
:
0
,
})
})
}
else
if
(
browser
.
isIOSApp
&&
version
<
380
)
{
// ISO的低版本
}
else
if
(
browser
.
isIOSApp
&&
version
<
380
)
{
// ISO的低版本
this
.
setState
({
this
.
setState
({
backwardVersion
:
true
,
backwardVersion
:
true
,
isPay
:
0
,
isPay
:
0
,
})
})
}
else
{
// 安卓/IOS 的高版本
}
else
{
// 安卓/IOS 的高版本
if
(
data
.
course_info
.
is_pay
===
1
)
{
// 在APP内未登录-去登陆-登录后还显示此页;如果是已购买的用户 就需要跳转到 APP已购买的原生页面
if
(
data
.
course_info
.
is_pay
===
1
)
{
// 在APP内未登录-去登陆-登录后还显示此页;如果是已购买的用户 就需要跳转到 APP已购买的原生页面
SendMessageToApp
(
'toSyllabusChapter'
,
id
)
;
// 跳转到APP的已购买详情页 id 是课程ID
SendMessageToApp
(
'toSyllabusChapter'
,
id
)
// 跳转到APP的已购买详情页 id 是课程ID
return
;
return
}
}
this
.
setState
({
this
.
setState
({
backwardVersion
:
false
,
backwardVersion
:
false
,
...
@@ -210,7 +213,7 @@ class ML extends Component {
...
@@ -210,7 +213,7 @@ class ML extends Component {
}
}
render
()
{
render
()
{
const
{
isPay
,
isAppUpdate
,
backwardVersion
}
=
this
.
state
;
const
{
isPay
,
isAppUpdate
,
backwardVersion
,
isWxlogin
}
=
this
.
state
// 旧版本 无论购买未购买 都跳转到 未购买的详情页; 如果是已购买就提示更新APP
// 旧版本 无论购买未购买 都跳转到 未购买的详情页; 如果是已购买就提示更新APP
return
(
return
(
<
div
>
<
div
>
...
@@ -218,6 +221,7 @@ class ML extends Component {
...
@@ -218,6 +221,7 @@ class ML extends Component {
isPay
===
0
&&
(
isPay
===
0
&&
(
<
PythonDes
<
PythonDes
backwardVersion
=
{
backwardVersion
}
backwardVersion
=
{
backwardVersion
}
isWxloginFun
=
{
this
.
isWxloginFun
.
bind
(
this
)}
history
=
{
this
.
props
.
history
}
history
=
{
this
.
props
.
history
}
isAppUpdate
=
{
isAppUpdate
}
isAppUpdate
=
{
isAppUpdate
}
isPay
=
{
isPay
}
isPay
=
{
isPay
}
...
@@ -225,8 +229,14 @@ class ML extends Component {
...
@@ -225,8 +229,14 @@ class ML extends Component {
)
)
}
}
{
{
(
isPay
===
1
&&
!
getParam
(
'version'
))
&&
<
PythonStudy
isAppUpdate
=
{
isAppUpdate
}
/
>
(
isPay
===
1
&&
!
getParam
(
'version'
))
&&
<
PythonStudy
isAppUpdate
=
{
isAppUpdate
}
/
>
}
}
{
isWxlogin
&&
<
WxLogin
history
=
{
this
.
props
.
history
}
/
>
}
<
/div
>
<
/div
>
)
)
}
}
...
...
src/components/ml/pythomDes/index.js
View file @
4d506145
...
@@ -45,18 +45,24 @@ class PythonDes extends Component {
...
@@ -45,18 +45,24 @@ class PythonDes extends Component {
// }
// }
// }
// }
// 立即体验
、免费试学
// 立即体验
type=1、立即报名type=3、9.9特价试学type=2
tryLearn
=
type
=>
{
tryLearn
=
type
=>
{
this
.
statistics
(
type
)
this
.
statistics
(
type
)
// 已登录
// 已登录
if
(
!
this
.
props
.
user
.
hasError
)
{
if
(
!
this
.
props
.
user
.
hasError
)
{
this
.
creatOid
()
this
.
creatOid
(
type
)
}
else
{
// 未登录
}
else
{
// 未登录
this
.
toLogin
()
this
.
toLogin
()
}
}
}
}
creatOid
=
()
=>
{
creatOid
=
(
type
)
=>
{
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/trial_create`
,
{
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
let
url
=
''
if
(
type
==
3
)
{
url
=
`
${
API
[
'base-api'
]}
/sys/it_baoming/create`
}
else
{
url
=
`
${
API
[
'base-api'
]}
/sys/trial_create`
}
http
.
post
(
url
,
{
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
const
{
errno
,
data
,
msg
}
=
res
.
data
const
{
errno
,
data
,
msg
}
=
res
.
data
if
(
errno
===
200
)
{
if
(
errno
===
200
)
{
this
.
setState
({
this
.
setState
({
...
@@ -140,26 +146,14 @@ class PythonDes extends Component {
...
@@ -140,26 +146,14 @@ class PythonDes extends Component {
toLogin
=
()
=>
{
toLogin
=
()
=>
{
if
(
!
getParam
(
'version'
))
{
// H5
if
(
!
getParam
(
'version'
))
{
// H5
this
.
changeLoginType
()
}
else
{
// APP
SendMessageToApp
(
"toLogin"
)
}
}
// 点击登录 提示微信登录还是账号登录,微信授权登录不需要绑定手机号
changeLoginType
=
()
=>
{
// 微信登录
if
(
browser
.
isWeixin
)
{
if
(
browser
.
isWeixin
)
{
// tool.setCookie('redirect_url', window.location.href);
this
.
props
.
isWxloginFun
(
true
);
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
{
}
else
{
// 账号登录
this
.
props
.
history
.
push
(
'/passport'
)
this
.
props
.
history
.
push
(
'/passport'
)
}
}
}
else
{
// APP
SendMessageToApp
(
"toLogin"
)
}
}
}
showAll
=
(
key
)
=>
{
showAll
=
(
key
)
=>
{
...
...
src/components/ml/pythonStudy/index.js
View file @
4d506145
...
@@ -17,7 +17,6 @@ class PythonStudy extends Component {
...
@@ -17,7 +17,6 @@ class PythonStudy extends Component {
syllabus
:
''
,
syllabus
:
''
,
learning
:
''
,
learning
:
''
,
isShowChannel
:
window
.
sessionStorage
.
getItem
(
'isShowSiteWindowByChannel'
)
isShowChannel
:
window
.
sessionStorage
.
getItem
(
'isShowSiteWindowByChannel'
)
}
}
}
}
...
@@ -84,7 +83,7 @@ class PythonStudy extends Component {
...
@@ -84,7 +83,7 @@ class PythonStudy extends Component {
}
}
creatOid
=
()
=>
{
creatOid
=
()
=>
{
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/
trial_
create`
,
{
course_id
:
getParam
(
'id'
)}).
then
(
res
=>
{
http
.
post
(
`
${
API
[
'base-api'
]}
/sys/
it_baoming/
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
)
{
this
.
setState
({
this
.
setState
({
...
...
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