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
9efc5cec
Commit
9efc5cec
authored
Sep 06, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
3fd53089
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
5 deletions
+85
-5
src/components/ShareCourse/index.js
+14
-3
src/utils/app.js
+68
-0
src/utils/index.js
+3
-2
No files found.
src/components/ShareCourse/index.js
View file @
9efc5cec
import
React
,
{
Component
}
from
'react'
;
import
'./index.scss'
;
import
{
HeaderBar
,
VList
}
from
'@/common'
;
import
{
http
,
getParam
}
from
'@/utils'
;
import
{
http
,
getParam
,
SendMessageToApp
}
from
'@/utils'
;
import
{
Toast
}
from
'antd-mobile'
;
import
{
Link
}
from
"react-router-dom"
;
import
FollowQRcode
from
"../detail/followQRcode"
;
class
ShareCourse
extends
Component
{
...
...
@@ -25,6 +26,15 @@ class ShareCourse extends Component {
})
}
toCourseDetail
=
(
id
)
=>
{
if
(
!
getParam
(
'from'
))
{
const
{
history
}
=
this
.
props
;
history
.
push
(
`/detail?id=
${
id
}
`
)
}
else
{
SendMessageToApp
(
"toCourse"
,
id
)
}
}
render
()
{
const
{
list
}
=
this
.
state
;
return
(
...
...
@@ -43,12 +53,13 @@ class ShareCourse extends Component {
<
/div
>
)
return
(
<
Link
to
=
{
`/detail?id=
${
item
.
course_id
}
`
}
key
=
{
index
}
>
<
div
key
=
{
index
}
onClick
=
{()
=>
this
.
toCourseDetail
(
item
.
course_id
)
}
>
<
VList
img
=
{
item
.
image_name
}
info
=
{
Info
}
/
>
<
/Link
>
<
/div
>
)
})
}
...
...
src/utils/app.js
0 → 100644
View file @
9efc5cec
export
default
function
SendMessageToApp
()
{
let
messageName
=
'nullName'
let
params
=
''
;
let
callback
;
//app定义的的方法名
if
(
typeof
arguments
[
0
]
==
"string"
)
{
messageName
=
arguments
[
0
]
}
//传递的参数或者回调函数
let
arg1
=
arguments
[
1
];
if
(
typeof
arg1
==
"function"
)
{
callback
=
arg1
}
else
if
(
typeof
arg1
!=
"undefined"
)
{
params
=
arg1
}
//回调函数
if
(
typeof
arguments
[
2
]
==
"function"
)
{
callback
=
arguments
[
2
]
}
if
(
callback
)
{
let
fun_name
=
getFunName
(
callback
)
window
[
fun_name
]
=
callback
}
if
(
window
.
webkit
!=
undefined
)
{
sendToIOS
(
messageName
,
params
)
}
else
{
//貌似安卓传的参数,不能是数组和对象,所以这里json一下
if
(
typeof
params
!=
"string"
)
{
params
=
JSON
.
stringify
(
params
)
}
sendToAndroid
(
messageName
,
params
)
}
}
function
sendToIOS
(
messageName
,
params
)
{
window
.
webkit
.
messageHandlers
[
messageName
].
postMessage
(
params
)
}
function
sendToAndroid
(
messageName
,
params
)
{
try
{
if
(
params
.
length
>
0
)
{
console
.
log
(
"有参"
)
AndroidWebViewBridge
[
messageName
](
params
)
}
else
{
console
.
log
(
"无参"
)
AndroidWebViewBridge
[
messageName
]()
}
}
catch
(
error
)
{
console
.
log
(
error
)
}
}
function
getFunName
(
fn
)
{
let
res
=
fn
.
name
.
split
(
' '
)
if
(
res
.
length
>
1
)
{
return
res
[
1
]
}
else
if
(
res
.
length
>
0
)
{
return
res
[
0
]
}
}
src/utils/index.js
View file @
9efc5cec
...
...
@@ -92,6 +92,7 @@ const isLogin = (function () {
})()
export
{
default
as
http
}
from
'./http'
export
{
default
as
http
}
from
'./http'
export
{
default
as
wxShare
}
from
'./wechat/share'
export
{
html
,
initCaptcha
,
validateTel
,
validateEmail
,
browser
,
isLogin
}
export
{
html
,
initCaptcha
,
validateTel
,
validateEmail
,
browser
,
isLogin
}
export
{
default
as
SendMessageToApp
}
from
'./app'
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