My SMM panel
 
 
 
 
 
 

120 lines
4.0 KiB

  1. <template>
  2. <div>
  3. <div class="services-menu">
  4. <button class="selected">Services</button>
  5. <button>Credits</button>
  6. <div class="menu-slider"><div></div></div>
  7. </div>
  8. <h4 class="credits-display">Credits: {{credits}}</h4>
  9. <div class="services-legend"><h5>Name</h5>
  10. <h5>Credits per 1000</h5><h5>Min Qt.</h5><h5>Max Qt.</h5></div>
  11. <ServicePane :site="'youtube'" :services="services" @select="select"></ServicePane>
  12. <ServicePane :site="'instagram'" :services="services" @select="select"></ServicePane>
  13. <ServicePane :site="'twitter'" :services="services" @select="select"></ServicePane>
  14. <ServicePane :site="'tiktok'" :services="services" @select="select"></ServicePane>
  15. <div id="overlay" v-if="selected">
  16. <div v-if="!completed" class="overlay-item">
  17. <img @click="completed = false; selected = null" class="cancel icon" src="../../images/cancel-icon2.svg" alt=""/>
  18. <img v-if="selected.site == 'youtube'" class="icon" src="../../images/youtube-icon.svg" alt="">
  19. <img v-if="selected.site == 'instagram'" class="icon" src="../../images/instagram-icon.svg" alt="">
  20. <img v-if="selected.site == 'twitter'" class="icon" src="../../images/twitter.svg" alt="">
  21. <img v-if="selected.site == 'tiktok'" class="icon" src="../../images/tik-tok.svg" alt="">
  22. <h3>{{selected.name}}</h3>
  23. <h4>Cost: {{cost.toLocaleString('en')}}</h4>
  24. <h4>Quantity</h4>
  25. <div><input required :min="selected.minimum" :max="selected.maximum" type="number" v-model="amount" id="selQty"><span> / {{selected.maximum.toLocaleString('en')}}</span></div>
  26. <template v-if="selected.modifier == 'location'">
  27. <h4>Location</h4>
  28. <div><select required id="country" name="">
  29. <option value="usa">USA</option>
  30. <option value="canada">Canada</option>
  31. <option value="uk">United Kingdom</option>
  32. <option value="germany">Germany</option>
  33. <option value="france">France</option>
  34. </select></div>
  35. </template>
  36. <h4>URL</h4>
  37. <div><input required type="url" id="url" v-model="url"></div>
  38. <button @click="buyService" :disabled="paying">Submit<loading v-if="paying"></loading></button>
  39. <p id="overlay-error"></p>
  40. </div>
  41. <div class="overlay-item" v-else-if="completed">
  42. <img @click="completed = false; selected = null" class="cancel icon" src="../../images/cancel-icon2.svg" alt=""/>
  43. <img class="icon" src="../../images/checked2.svg" alt="">
  44. <h3>Success!</h3>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import ServicePane from './service-pane.vue'
  51. import Loading from '../icons/loading.vue'
  52. function select(service) {
  53. this.completed = false
  54. this.selected = service
  55. }
  56. function cost() {
  57. return Math.ceil(this.selected.price * this.amount / 1000)
  58. }
  59. function buyService() {
  60. if (!this.url) {
  61. document.getElementById('overlay-error').textContent = "You must provide a URL."
  62. return
  63. }
  64. this.paying = true
  65. let note = ''
  66. let country = document.getElementById('country')
  67. if (country) {
  68. note = JSON.stringify({'location': country.value})
  69. }
  70. fetch('/panel/orders', {
  71. method: 'POST',
  72. headers: {'Content-Type': 'application/json',
  73. 'Accept': 'application/json',
  74. 'X-XSRF-TOKEN': this.token},
  75. body: JSON.stringify({'service': this.selected.id,
  76. 'quantity': this.amount, 'url': this.url, 'note': note}), }).then(
  77. response => {
  78. if (response.ok) {
  79. document.getElementById('overlay-error').textContent = `Success!`
  80. this.completed = true
  81. this.$emit('updateUser')
  82. } else {
  83. document.getElementById('overlay-error').textContent = `Error
  84. ${response.status}: ${response.statusText}`
  85. }
  86. this.paying = false
  87. }
  88. )
  89. }
  90. export default {
  91. data() {
  92. return {servicePane: true, services: null, selected: null, amount: 0,
  93. paying: false, url: '', completed: false}
  94. },
  95. components: {ServicePane, Loading},
  96. props: ['token', 'credits'],
  97. created() {
  98. fetch("/panel/services", {
  99. method: 'GET',
  100. headers: {'Content-Type': 'application/json',
  101. 'Accept': 'application/json',
  102. 'X-XSRF-TOKEN': this.token}
  103. }).then(response => {
  104. response.json().then(data => {this.services = data})
  105. })
  106. },
  107. methods: {select, buyService},
  108. computed: {cost},
  109. emits: ['updateUser']
  110. }
  111. </script>