index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // import Vue from 'vue'
  2. import Charge from './charge.vue'
  3. import i18n from '@/util/lang/lang'
  4. Charge.install = function (Vue, store) {
  5. const ChargeConstructor = Vue.extend(Charge)
  6. let instance
  7. Vue.prototype.$showCharge = (amount = null) => {
  8. if (instance) {
  9. document.body.removeChild(instance.$el)
  10. instance = null
  11. }
  12. instance = new ChargeConstructor({
  13. el: document.createElement('div'),
  14. computed: {
  15. $store () { return store }
  16. },
  17. data () {
  18. return {
  19. showCharge: true,
  20. amount
  21. }
  22. },
  23. i18n
  24. })
  25. document.body.appendChild(instance.$el)
  26. }
  27. Vue.prototype.$showWallet = () => {
  28. if (instance) {
  29. document.body.removeChild(instance.$el)
  30. instance = null
  31. }
  32. instance = new ChargeConstructor({
  33. el: document.createElement('div'),
  34. computed: {
  35. $store () { return store }
  36. },
  37. data () {
  38. return {
  39. showWallet: true
  40. }
  41. },
  42. i18n
  43. })
  44. document.body.appendChild(instance.$el)
  45. }
  46. // Vue.prototype.hide = () =>{
  47. // if(instance) {
  48. // instance.showWallet = false;
  49. // instance.showCharge = false;
  50. // }
  51. // }
  52. }
  53. export default Charge