<view @tap="beforeShare">
<button :open-type="isshare">分享</button>
</view>
<script>
export default{
data(){
isshare:''
},
methods:{
beforeShare(){
if(!this.$store.getters.loginStatus){ //loginStatus登录状态
uni.showToast({
icon:'none',
title:'请先登录'
})
setTimeout(()=>{
uni.navigateTo({url:'/pages/auth/auth'})
},2000)
}else{
this.isshare = 'share'
}
}
}
}
</script>
右上角的分享可以在App.vue的onLaunch中先用uni.hideShareMenu()隐藏,然后登录成功时uni.showShareMenu()