Skip to content

Commit

Permalink
fix: Wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Apr 1, 2019
1 parent 332d67e commit 9acb7bc
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/Wechat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventBus } from './EventBus'
import { isBoolean } from './isBoolean'
import { promiseSeries } from './promiseSeries'

declare const wx: any

Expand Down Expand Up @@ -165,6 +166,15 @@ export type WechatNonBaseMenuItem = (
'menuItem:share:brand'
)

const shareJsApiList: WechatJsApi[] = [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline',
'onMenuShareQQ',
'onMenuShareQZone',
]

export class Wechat {
private ready: boolean = false

Expand All @@ -190,18 +200,7 @@ export class Wechat {
...params,
jsApiList: [
...(params.jsApiList || []),
...(
sharable
? [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline',
'onMenuShareQQ',
'onMenuShareQZone',
]
: []
) as WechatJsApi[],
...(sharable ? shareJsApiList : []),
],
})
wx.ready(() => {
Expand All @@ -224,13 +223,11 @@ export class Wechat {
...params,
}
this.prevShareParams = params
this.invoke('updateAppMessageShareData', params)
this.invoke('updateTimelineShareData', params)
this.invoke('onMenuShareAppMessage', params)
this.invoke('onMenuShareTimeline', params)
this.invoke('onMenuShareQQ', params)
this.invoke('onMenuShareQZone', params)
return Promise.resolve()
return promiseSeries(
shareJsApiList.map(
jsApi => () => this.invoke(jsApi, params),
),
)
}

chooseImage(params?: WechatChooseImageParams): Promise<string[]> {
Expand Down

0 comments on commit 9acb7bc

Please sign in to comment.