非常奇怪的page页数据问题?
首先我在onload函数中获取openid并setdata到页面data中,此时打印data,存在openid
wx.cloud.callFunction({
name:'getOpenidtest',
success:res =>{
console.log(res,'11111111111');
//console.log(res.result.openid);
this.setData({
openid:res.result.openid
})
console.log(this.data);
},
fail:res =>{
console.log(res,'11111111111');
}
})
然后在onshow里调用openapi,他却消失了,打印data,openapi存在
onShow:function(){
const { goods_id,countDownTxt} = this.data;
const openid = this.data.openid
if(countDownTxt == null){
wx.cloud.callFunction({
name:'sendMessagetest',
data:{
goods_id,
openid
},
success:res =>{
console.log(this.data);
console.log(res,'sendMessage正在被执行',openid,goods_id);
},
fail:res =>{
console.log(res,'fail');
}
})
}
//获取openid
}
大致就是这种情况,求解答