Skip to content

分享

分享小程序

js
onShareAppMessage(res) {
    return {
        title: '点餐小程序',
        path: '/pages/main/main'
    }
}

分享功能组件

js
export default {
    data() {
        return {

        }
    },
    onLoad: function() {
        wx.showShareMenu({
            withShareTicket: true,
            menus: ["shareAppMessage", "shareTimeline"]
        })
    },
    onShareAppMessage(res) {
        let that = this;
        let imageUrl = that.shareUrl || '';
        if (res.from === 'button') {
        //这块需要传参,不然链接地址进去获取不到数据
            let path = `/` + that.$scope.route + `?item=` + that.$scope.options.item;
            return {
                title: '商品分享~',
                path: path,
                imageUrl: imageUrl
            };
        }
        if (res.from === 'menu') {
            return {
                title: 'IT技术进阶',
                path: '/pages/index/index',
                imageUrl: imageUrl
            };
        }
    },
    // 分享到朋友圈
    onShareTimeline() {
        return {
            title: 'IT技术进阶',
            path: '/pages/index/index',
            imageUrl: 'https://diyai.cn/noteImgs/qrcode_for_gh_f26b126934b4_3442.jpg'
        };
    },
    methods: {

    }
}