quanyawei
2024-07-04 1e71dd86f6d0c4fc7e5143600d4bc4b50992a2a7
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
export default {
    data() {
        return {
            // 默认的全局分享内容(待测试)
            share: {
                title: '分享',
                path: '/pages/index/index', // 全局分享的路径
                imageUrl: '', // 全局分享的图片(可本地可网络)
            }
        }
    },
    // 定义全局分享
    // 1.发送给朋友
    onShareAppMessage(res) {
        // 获取加载的页面
        let pages = getCurrentPages(),
            // 获取当前页面的对象
            page = pages[pages.length - 1]
        // console.log("获取加载的页面", pages);
        this.share.path = `/${page.route}`
        if (page.options.infor) {
            this.share.path = `/${page.route}?infor=${page.options.infor}&type=share`
        }
        console.log('page.options', page.options)
        return {
            title: this.share.title,
            path: this.share.path,
            imageUrl: this.share.imageUrl,
        }
    },
    // //2.分享到朋友圈
    // onShareTimeline(res) {
    //     return {
    //         title: this.share.title,
    //         path: this.share.path,
    //         imageUrl: this.share.imageUrl,
    //     }
    // },
}