uniapp异步方法让同步执行 await async
异步方法让同步执行 awaitasynconShow() {this.grantShare();},methods: {grantShare(){ //授权判断let that = this;return new Promise((resolve, reject) => {$api.ajax({url:"/Share/check_user_relation_id",data:{},metho
·
uniapp异步方法让同步执行 await async
onShow() {
this.grantShare();
},
methods: {
grantShare(){ //授权判断
let that = this;
return new Promise((resolve, reject) => {
$api.ajax({
url:"/Share/check_user_relation_id",
data:{},
method: "POST",
success:(res)=>{
if(res.code == 0){ //已授权
this.grantState = false;
this.layerGrantShow = false;
}else{
// that.grantState = true;
}
resolve('suc');
},
error(msg){
uni.showModal({
title:'提示',
content:"请检查网络或者重新登录"
})
this.grantState = true;
reject('msg');
}
});
})
},
async mountDealCount(){
await this.grantShare();
await $user.userLogin();//执行grantShare成功之后的方法
},
},
beforeMount(){
this.mountDealCount()
}
更多推荐
已为社区贡献1条内容
所有评论(0)