Last active
March 21, 2020 13:53
-
-
Save julien51/8d771a84ad5db0be9ad00928cd54e8c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div v-if="unlockState === 'locked'">locked</div> | |
<div v-if="unlockState === 'pending'">pending</div> | |
<div v-if="unlockState === 'unlocked'">unlocked</div> | |
<button @click="checkout()">checkout</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
data: function() { | |
return { | |
unlockHandler: null, | |
unlockState: 'pending' | |
} | |
}, | |
mounted() { | |
this.$nextTick(function() { | |
window.addEventListener('unlockProtocol', this.unlockHandler) | |
}) | |
}, | |
created() { | |
this.unlockHandler = () -> { | |
var state = e.detail | |
this.unlockState = state | |
} | |
}, | |
beforeDestroy() { | |
window.removeEventListener('unlockProtocol', this.unlockHandler) | |
}, | |
methods: { | |
checkout() { | |
window.unlockProtocol && window.unlockProtocol.loadCheckoutModal() | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment