button分享时未登录的时候跳转登录

<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()

猜你喜欢

转载自blog.csdn.net/xiyan_yu/article/details/129688670