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
b4eb724e
Commit
b4eb724e
authored
Jan 06, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信分享
parent
6ae12cdc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
43 deletions
+42
-43
src/utils/wechat/base.js
+42
-43
No files found.
src/utils/wechat/base.js
View file @
b4eb724e
...
@@ -3,54 +3,54 @@ import { http, browser } from "@/utils"
...
@@ -3,54 +3,54 @@ import { http, browser } from "@/utils"
const
url
=
`https://res.wx.qq.com/open/js/jweixin-1.4.0.js`
const
url
=
`https://res.wx.qq.com/open/js/jweixin-1.4.0.js`
const
appId
=
'wx23dac6775ac82877'
const
appId
=
'wx23dac6775ac82877'
const
jsApiList
=
[
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareAppMessage'
,
'onMenuShareTimeline'
]
const
jsApiList
=
[
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
'onMenuShareAppMessage'
,
'onMenuShareTimeline'
]
export
const
getSignature
=
async
(
config
=
{})
=>
{
export
const
getSignature
=
async
(
config
=
{})
=>
{
let
res
=
await
http
.
post
(
`
${
API
[
'base-api'
]}
/m/sale/signature`
,
{
let
res
=
await
http
.
post
(
`
${
API
[
'base-api'
]}
/m/sale/signature`
,
{
url
:
browser
.
isWeixin
&&
browser
.
isIOS
?
sessionStorage
.
getItem
(
'enter_url'
)
:
window
.
location
.
href
.
split
(
'#'
)[
0
],
url
:
encodeURIComponent
(
browser
.
isWeixin
&&
browser
.
isIOS
?
sessionStorage
.
getItem
(
'enter_url'
)
:
window
.
location
.
href
.
split
(
'#'
)[
0
],)
})
})
return
wx
.
config
({
return
wx
.
config
({
debug
:
false
,
// 开启调试模式,
debug
:
false
,
// 开启调试模式,
appId
,
// 必填,公众号的唯一标识
appId
,
// 必填,公众号的唯一标识
timestamp
:
res
.
data
.
timestamp
,
// 必填,生成签名的时间戳
timestamp
:
res
.
data
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
res
.
data
.
nonce_str
,
// 必填,生成签名的随机串
nonceStr
:
res
.
data
.
nonce_str
,
// 必填,生成签名的随机串
signature
:
res
.
data
.
signature
,
// 必填,签名,见附录1
signature
:
res
.
data
.
signature
,
// 必填,签名,见附录1
jsApiList
,
jsApiList
,
...
config
...
config
})
})
}
}
export
const
getWXObject
=
()
=>
{
export
const
getWXObject
=
()
=>
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
if
(
!
window
.
wx
)
{
if
(
!
window
.
wx
)
{
return
loadScript
(
url
).
then
(()
=>
resolve
())
return
loadScript
(
url
).
then
(()
=>
resolve
())
}
}
resolve
()
resolve
()
})
})
}
}
function
loadScript
(
url
)
{
function
loadScript
(
url
)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
var
head
=
document
.
head
||
document
.
getElementsByTagName
(
'head'
)[
0
]
var
head
=
document
.
head
||
document
.
getElementsByTagName
(
'head'
)[
0
]
var
script
=
document
.
createElement
(
'script'
)
var
script
=
document
.
createElement
(
'script'
)
script
.
type
=
'text/javascript'
script
.
type
=
'text/javascript'
script
.
src
=
url
script
.
src
=
url
if
(
!
(
'onload'
in
script
))
{
if
(
!
(
'onload'
in
script
))
{
script
.
onreadystatechange
=
function
()
{
script
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
!==
'complete'
&&
this
.
readyState
!==
'loaded'
)
return
if
(
this
.
readyState
!==
'complete'
&&
this
.
readyState
!==
'loaded'
)
return
this
.
onreadystatechange
=
null
this
.
onreadystatechange
=
null
resolve
()
resolve
()
}
}
}
}
script
.
onload
=
function
()
{
script
.
onload
=
function
()
{
this
.
onload
=
null
this
.
onload
=
null
resolve
()
resolve
()
}
}
head
.
appendChild
(
script
)
head
.
appendChild
(
script
)
})
})
}
}
\ No newline at end of file
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