-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.tsx
58 lines (49 loc) · 1.29 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { ComponentClass } from 'react'
import Taro from '@tarojs/taro'
// import { connect } from '@tarojs/redux';
import defaultShareImg from '@/assets/images/share.png'
type Options = {
title?: string
imageUrl?: string
path?: string
}
const defalutOptions = {
title: '你能听懂我说啥么?最近很火的反转录音来啦~',
imageUrl: defaultShareImg,
path: 'pages/index/index',
}
function withShare() {
return function demoComponent(Component: ComponentClass) {
// @connect(({ user }) => ({
// userInfo: user.userInfo
// }))
class WithShare extends Component {
$shareOptions?: Options
async componentWillMount() {
Taro.showShareMenu({
withShareTicket: true,
})
if (super.componentWillMount) {
super.componentWillMount()
}
}
// 点击分享的那一刻会进行调用
onShareAppMessage() {
// const sharePath = `${path}&shareFromUser=${userInfo.shareId}`
let options = defalutOptions
if (this.$shareOptions) {
options = {
...defalutOptions,
...this.$shareOptions,
}
}
return options
}
render() {
return super.render()
}
}
return WithShare
}
}
export default withShare