<button open-type="share">分享</button>
export default {
data(){
return{
params:''
}
},
onShareAppMessage() {
return {
title: 'xxx',
imageUrl: '',
path: '/xxx?params=' + this.params
};
},
onShareTimeline() {
return {
title: 'xxx',
imageUrl: '',
query: 'params=' + this.params
};
},
onLoad(data) {
if (data.scene) {
var sceneParams = decodeURIComponent(data.scene);
sceneParams = sceneParams.split('&');
if (sceneParams.length) {
sceneParams.forEach(item => {
if (item.indexOf('params') != -1) this.params= item.split('-')[1];
});
}
}
}
}
<button @click="share">分享</button>
share() {
uni.showLoading({
title: '视频分享中...'
});
wx.downloadFile({
url: url,
success(res) {
uni.hideLoading();
wx.shareVideoMessage({
videoPath: res.tempFilePath,
success() {},
fail: console.error
});
wx.showShareImageMenu({
path: res.tempFilePath,
});
},
fail() {
uni.hideLoading();
console.error;
}
});
}



参考链接:developers.weixin.qq.com/miniprogram…