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
25cb172d
Commit
25cb172d
authored
Aug 26, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信分享
parent
8267a5da
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
114 deletions
+39
-114
src/App.js
+6
-2
src/components/bargainMiddlePage/index.js
+11
-2
src/components/detail/group/togroup.js
+6
-46
src/components/detail/index.js
+11
-59
src/utils/wechat/base.js
+2
-2
src/utils/wechat/share.js
+3
-3
No files found.
src/App.js
View file @
25cb172d
...
...
@@ -5,7 +5,7 @@ import { connect } from "react-redux";
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
;
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
}
from
"@/utils"
;
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
Toast
}
from
"antd-mobile"
;
import
{
addDays
}
from
'date-fns'
...
...
@@ -41,6 +41,10 @@ class App extends Component {
//平台信息
cookie
.
set
(
'plat'
,
'5'
,
{
domain
:
'.julyedu.com'
})
if
(
browser
.
isWeixin
&&
browser
.
isIOS
)
{
sessionStorage
.
setItem
(
'enter_url'
,
window
.
location
.
href
)
}
this
.
props
.
startFetchUser
()
http
.
get
(
`
${
API
.
home
}
/m/user_info`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
res
))
...
...
@@ -51,7 +55,7 @@ class App extends Component {
history
.
listen
(
location
=>
{
const
{
pathname
}
=
location
if
(
pathname
.
startsWith
(
'/passport'
))
{
if
(
routeMatchRule
.
test
(
pathname
))
{
if
(
routeMatchRule
.
test
(
pathname
))
{
return
}
location
.
state
=
{
from
:
this
.
previousLocation
};
...
...
src/components/bargainMiddlePage/index.js
View file @
25cb172d
...
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import
'./bargain-middle-page.scss'
import
{
HeaderBar
,
VList
}
from
'@common'
import
{
Course
}
from
'@common'
import
{
api
,
getParam
,
http
,
browser
}
from
"@/utils"
import
{
api
,
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
import
{
Link
,
withRouter
}
from
"react-router-dom"
import
Ranking
from
'./ranking'
...
...
@@ -43,7 +43,8 @@ class BargainMiddlePage extends Component {
amount
:
''
,
firendBaigainPrice
:
true
,
isshowYindao
:
false
,
isLoaidng
:
true
isLoaidng
:
true
,
imglink
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/'
,
}
}
...
...
@@ -285,6 +286,14 @@ class BargainMiddlePage extends Component {
status
:
7
,
isshowYindao
:
browser
.
isWeixin
?
true
:
false
})
wxShare
({
title
:
`我发现一门好课,快来帮我砍价吧!`
,
desc
:
`我已经砍了
${
this
.
state
.
bargainData
.
bargain_price
}
元,看看你能砍多少`
,
link
:
encodeURI
(
location
.
href
),
imgUrl
:
this
.
state
.
course
.
course_img
,
});
}
// 关闭弹窗
...
...
src/components/detail/group/togroup.js
View file @
25cb172d
...
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import
'./togroup.scss'
import
{
HeaderBar
,
VList
}
from
'../../../common'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
getParam
,
http
,
browser
,
wxShare
}
from
"@/utils"
;
import
{
connect
}
from
"react-redux"
import
{
Link
}
from
"react-router-dom"
import
{
WingBlank
,
WhiteSpace
,
Flex
,
Toast
}
from
'antd-mobile'
...
...
@@ -27,53 +27,13 @@ class ToGroup extends Component {
invitedFriends
=
()
=>
{
const
{
pdd_price
,
number
,
data
}
=
this
.
state
;
if
(
browser
.
isWeixin
)
{
let
share
=
this
.
state
.
share
;
this
.
setState
({
share
:
!
share
,
});
let
shareData
=
{
wxShare
({
title
:
`【仅剩
${
number
}
个名额】我
${
pdd_price
}
元拼了《
${
data
.
course_title
}
》`
,
desc
:
data
.
course_title
,
// 分享描述
// 直接进入课程详情页,isIn: 1
link
:
location
.
origin
+
`/detail?id=
${
data
.
course_id
}
`
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl
:
data
.
image_name
,
// 分享图标
};
http
.
post
(
`
${
API
[
'base-api'
]}
/m/sale/signature`
).
then
(
res
=>
{
const
{
nonce_str
,
signature
,
timestamp
}
=
res
.
data
;
wx
.
config
({
"debug"
:
false
,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
"appId"
:
'wx23dac6775ac82877'
,
// 必填,公众号的唯一标识
"timestamp"
:
timestamp
,
// 必填,生成签名的时间戳
"nonceStr"
:
nonce_str
,
// 必填,生成签名的随机串
"signature"
:
signature
,
// 必填,签名
jsApiList
:
[
'hideMenuItems'
,
'showMenuItems'
,
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareWeibo'
,
'onMenuShareAppMessage'
,
],
// 必填,需要使用的JS接口列表
});
});
wx
.
ready
(
function
()
{
//需在用户可能点击分享按钮前就先调用
wx
.
hideAllNonBaseMenuItem
();
wx
.
showMenuItems
({
menuList
:
[
'menuItem:share:appMessage'
,
'menuItem:share:timeline'
]
// 要显示的菜单项,所有menu项见附录3
});
wx
.
updateAppMessageShareData
({
...
shareData
,
success
:
function
()
{
// 设置成功
}
})
wx
.
updateTimelineShareData
({
...
shareData
,
success
:
function
()
{
// 设置成功
}
})
desc
:
data
.
course_title
,
link
:
location
.
href
,
imgUrl
:
data
.
image_name
,
});
}
else
{
Toast
.
info
(
'请在微信中使用分享功能!'
,
2
);
}
...
...
src/components/detail/index.js
View file @
25cb172d
...
...
@@ -46,13 +46,6 @@ class Detail extends Component {
}
componentDidMount
()
{
wxShare
({
title
:
`课程详情页`
,
desc
:
`课程详情页`
,
link
:
encodeURI
(
location
.
origin
+
'/detail?id='
+
getParam
(
'id'
)),
imgUrl
:
''
});
this
.
fetchCourseInfo
();
const
{
location
:
{
state
=
{}
}
}
=
this
.
props
;
if
(
state
.
oid
)
{
...
...
@@ -242,12 +235,7 @@ class Detail extends Component {
}
})
}
// payCallback = () => {
//
// };
// weixinPay = (weixin_code) => {
//
// }
payCallBack
=
(
singleType
,
nowPrice
,
laterPrice
)
=>
{
// Toast.info(singleType, 2);
const
_this
=
this
;
...
...
@@ -289,9 +277,14 @@ class Detail extends Component {
});
},
1000
)
}
wxShare
({
title
:
course_info
.
course_title
,
desc
:
course_info
.
index_description
,
link
:
encodeURI
(
location
.
origin
+
'/detail?id='
+
getParam
(
'id'
)),
imgUrl
:
course_info
.
image_name
});
}
}
});
}
...
...
@@ -377,52 +370,11 @@ class Detail extends Component {
invitedFriends
=
()
=>
{
const
{
course_title
,
image_name
,
course_id
,
pdd_group_info
,
pdd_group_info
:
{
groupon_member
,
groupon_member
:
{
number
},
price
}}
=
this
.
state
.
course
.
course_info
;
if
(
browser
.
isWeixin
)
{
let
share
=
this
.
state
.
share
;
this
.
setState
({
share
:
!
share
,
});
let
shareData
=
{
wxShare
({
title
:
`【仅剩
${
number
}
个名额】我
${
price
}
元拼了《
${
course_title
}
》`
,
desc
:
course_title
,
// 分享描述
link
:
location
.
origin
+
`/detail??id=
${
course_id
}
`
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl
:
image_name
,
// 分享图标
};
http
.
post
(
`
${
API
[
'base-api'
]}
/m/sale/signature`
).
then
(
res
=>
{
const
{
nonce_str
,
signature
,
timestamp
}
=
res
.
data
;
wx
.
config
({
"debug"
:
false
,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
"appId"
:
'wx23dac6775ac82877'
,
// 必填,公众号的唯一标识
"timestamp"
:
timestamp
,
// 必填,生成签名的时间戳
"nonceStr"
:
nonce_str
,
// 必填,生成签名的随机串
"signature"
:
signature
,
// 必填,签名
jsApiList
:
[
'hideMenuItems'
,
'showMenuItems'
,
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareWeibo'
,
'onMenuShareAppMessage'
,
],
// 必填,需要使用的JS接口列表
});
});
wx
.
ready
(
function
()
{
//需在用户可能点击分享按钮前就先调用
wx
.
hideAllNonBaseMenuItem
();
wx
.
showMenuItems
({
menuList
:
[
'menuItem:share:appMessage'
,
'menuItem:share:timeline'
]
// 要显示的菜单项,所有menu项见附录3
});
wx
.
updateAppMessageShareData
({
...
shareData
,
success
:
function
()
{
// 设置成功
}
})
wx
.
updateTimelineShareData
({
...
shareData
,
success
:
function
()
{
// 设置成功
}
})
desc
:
course_title
,
link
:
location
.
href
,
imgUrl
:
image_name
,
});
}
else
{
Toast
.
info
(
'请在微信中使用分享功能!'
,
2
);
...
...
src/utils/wechat/base.js
View file @
25cb172d
import
{
http
}
from
"@/utils/index
"
import
{
http
,
browser
}
from
"@/utils
"
const
url
=
`https://res.wx.qq.com/open/js/jweixin-1.4.0.js`
...
...
@@ -7,7 +7,7 @@ const jsApiList = ['updateAppMessageShareData','updateTimelineShareData','onMenu
export
const
getSignature
=
async
(
config
=
{})
=>
{
let
res
=
await
http
.
post
(
`
${
API
[
'base-api'
]}
/m/sale/signature`
,
{
url
:
window
.
location
.
href
.
split
(
'#'
)[
0
]
url
:
browser
.
isWeixin
&&
browser
.
isIOS
?
sessionStorage
.
getItem
(
'enter_url'
)
:
window
.
location
.
href
.
split
(
'#'
)[
0
],
})
return
wx
.
config
({
debug
:
false
,
// 开启调试模式,
...
...
src/utils/wechat/share.js
View file @
25cb172d
import
{
getWXObject
,
getSignature
}
from
'./base'
const
shareApiList
=
[
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareAppMessage'
,
'onMenuShareTimeline'
]
const
shareApiList
=
[
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareAppMessage'
,
'onMenuShareTimeline'
]
export
default
async
function
(
data
=
{
title
:
''
,
desc
:
''
,
link
:
''
,
imgUrl
:
''
})
{
export
default
async
function
(
data
=
{
title
:
''
,
desc
:
''
,
link
:
''
,
imgUrl
:
''
},
config
=
{
})
{
await
getWXObject
()
await
getSignature
()
await
getSignature
(
config
)
wx
.
ready
(
function
()
{
console
.
log
(
'ready'
);
...
...
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