Commit a0143ecc authored by zhoucong's avatar zhoucong

添加分享功能

parent 68fb5dbf
export default{//微信小程序分享功能
data(){
return {//设置默认的分享参数
share:{
title:'vlog',
path:'/pages/index/index',
imageUrl:'',
desc:'',
content:''
}
}
},
onLoad(){
wx.showShareMenu({
withShareTicket:true,
menus:["shareAppMessage","shareTimeline"]
})
},
onShareAppMessage(res) {//发送给朋友
// 此处的openid为分享者的部分信息,需要传递给其他人
let openid = uni.getStorageSync('openid');
if (openid) {
return {
title: '胖丁旅游',
type: 0,
path: '/pages/index/index?id=' + openid,
summary: "",
imageUrl: "https://58d.oss-cn-hangzhou.aliyuncs.com/goods/ttg_1596073788000.png"
}
}
},
onShareTimeline(res) {//分享到朋友圈
let openid = uni.getStorageSync('openid');
if (openid) {
return {
title: '胖丁旅游',
type: 0,
query: 'id=' + openid,
summary: "",
imageUrl: "https://58d.oss-cn-hangzhou.aliyuncs.com/goods/ttg_1596073788000.png"
}
}
},
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment