小程序页面如果不实现接口onShareTimeline,则默认分享到朋友圈是灰色的:
需要实现该接口:
// 分享朋友圈
onShareTimeline() {
let userInfo = util.hasLogin();
let query = 'id=' + this.data.brand.id;
if (userInfo) {
query = query + '&shareUserId=' + userInfo.userId
}
console.log('onShareTimeline:' + query);
return {
title: this.data.brand.name,
query: query, // 参数不是path
imageUrl: this.data.brand.picUrl
}
},
注意query不是路径,和onShareAppMessage path不同 ,参考官网文档解释。
实现接口后,分享到朋友圈 就变亮了。
实际效果是这样的:
有图片和名称,比短链接效果好点。