an_xiao/police_uniapp/utils/share.js

52 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default {
data() {
return {
//设置默认的分享参数
//如果页面不设置share就触发这个默认的分享
share: {
title: "芙蓉安校",
path: `/pages/index/index`, //默认跳转首页
imageUrl: '', //可设置默认分享图不设置默认截取头部5:4
}
}
},
onShareAppMessage(res) { //发送给朋友
return {
title: this.share.title,
path: this.share.path,
imageUrl: this.share.imageUrl,
success(res) {
uni.showToast({
title: '分享成功'
})
},
fail(res) {
uni.showToast({
title: '分享失败',
icon: 'none'
})
}
}
},
// onShareTimeline(res) { //分享到朋友圈
// return {
// title: this.share.title,
// path: this.share.path,
// imageUrl: this.share.imageUrl,
// success(res) {
// console.log('success(res)==', res);
// uni.showToast({
// title: '分享成功'
// })
// },
// fail(res) {
// console.log('fail(res)==', res);
// uni.showToast({
// title: '分享失败',
// icon: 'none'
// })
// }
// }
// },
}