My SMM panel
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

edit-cards.vue 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div v-if="cards && cards.length > 0">
  3. <div class="saved-cards-heading">
  4. <h5>Card</h5> <h5>Default</h5> <h5>Delete</h5>
  5. </div>
  6. <div v-for="(card, index) in cards" :key="card.id" class="saved-card">
  7. <span>{{card.card.brand[0].toUpperCase() + card.card.brand.substring(1)}}
  8. (••••{{card.card.last4}})</span>
  9. <span><input :checked="index === 0" :value="card.id" name="selected-card" type="radio"
  10. @change="change(card.id)"></span>
  11. <span><img @click="remove(card.id)" src="../../images/close-icon-black.svg"/></span>
  12. </div>
  13. <p id="billing-error"></p>
  14. </div>
  15. </template>
  16. <script>
  17. function get() {
  18. fetch('/panel/cards', {
  19. method: 'GET',
  20. headers: {'Content-Type': 'application/json',
  21. 'Accept': 'application/json',
  22. 'X-XSRF-TOKEN': this.token}
  23. }).then((response) => {response.json().then(data => {
  24. this.cards = data.data
  25. })})
  26. }
  27. function change(card) {
  28. fetch('/panel/change-card', {
  29. method: 'POST',
  30. headers: {'Content-Type': 'application/json',
  31. 'Accept': 'application/json',
  32. 'X-XSRF-TOKEN': this.token},
  33. body: JSON.stringify({'card': card})
  34. }).then((response) => {
  35. if (response.ok) {
  36. console.log('ok')
  37. response.json().then((data) => {
  38. this.cards = data
  39. })
  40. } else {
  41. console.log('bad')
  42. document.getElementById("billing-error").textContent =
  43. `${response.status}: ${response.statusText}`
  44. }
  45. response.json().then(data => {
  46. console.log(data)}
  47. )
  48. })
  49. }
  50. function remove(card) {
  51. fetch('/panel/delete-card', {
  52. method: 'POST',
  53. headers: {'Content-Type': 'application/json',
  54. 'Accept': 'application/json',
  55. 'X-XSRF-TOKEN': this.token},
  56. body: JSON.stringify({'card': card})
  57. }).then((response) => {
  58. if (response.ok) {
  59. console.log('ok')
  60. response.json().then((data) => {
  61. this.cards = data
  62. })
  63. } else {
  64. console.log('bad')
  65. document.getElementById("billing-error").textContent =
  66. `${response.status}: ${response.statusText}`
  67. }
  68. response.json().then(data => {
  69. console.log(data)}
  70. )
  71. })
  72. }
  73. export default {
  74. data() {
  75. return {cards: null}
  76. },
  77. methods: {get, change, remove},
  78. created() {
  79. this.get()
  80. },
  81. props: ['token',],
  82. }
  83. </script>