异步数据设置为小程序分享内容
发布时间: 2022-04-14 15:20:37
作者: 王乐园 浏览次数:
487
场景 一个列表 点击不同数据设置 小程序分享不同内容,内容都是点击之后异步获取/生成的
1.同步监听异步数据是否处理完成
async getTicketImg(){
let that = this;
await new Promise((resolve,reject)=>{
that.time = setInterval(()=>{
if(that.ticket.imageUrl){
resolve();
clearInterval(that.time)
}
},100)
});
return that.ticket;
},
2.阻塞 onShareAppMessage 分享周期
async onShareAppMessage(){
let that = this;
clearInterval(that.time)
let ticket = await this.getTicketImg();
let uid = '';
try {
const res = uni.getStorageSync('member');
uid = res.id;
} catch (e) {
}
return {
title: '送你一张优惠券,快来领取 吧~',
path: 'pagesMine/couponReceive/couponReceive?id='+ticket.id+"&uid="+uid,
imageUrl:ticket.imageUrl
}
},
上一篇:(转载)追忆过往青春
下一篇:(转载)时光悠悠 岁月无言