支付宝小程序分享时 封面图片设置
<button class='share-friend' open-type="share">
<image src='/images/share-icon.png'></image>
<text>分享好友</text>
</button>
/**
* 分享给好友
*/
// 固定方法
onShareAppMessage(res) {
const staffId = this.data.originStaffId;
const packageCode = this.data.packageCode;
const salesPage = true;
if (res.from !== "button") return;
return {
// 转发时顶部title
title: `${this.data.productDetail.packageName}`,
// 转发时描述
desc: '智行未来 出行无忧',
// 需要转发的页面 可拼接参数
path: `/pages/detail/index?staffId=${staffId}&packageCode=${packageCode}&salesPage=${salesPage}`,
// 设置的展示时默认图片
bgImgUrl: 'https://zhonger-file.oss-cn-beijing.aliyuncs.com/zx-car-owner-welfare-api/share-img.jpg'
};
},
bgImgUrl: 默认图片 比例为5:4
当设置的默认图片为接口返回数据时
onShareAppMessage(res) {
let bgImgUrl
const remoteUrl = this.data.productDetail.coverImg
bgImgUrl = remoteUrl
return {
bgImgUrl
}
以上为简单的分享时 默认图片的设置 附上官网 :https://opendocs.alipay.com/mini/framework/page-detail#%E9%A1%B5%E9%9D%A2%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0
哪里不对还望指点!😉