My SMM panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

services.vue 5.3 KiB

3 jaren geleden
3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div>
  3. <div class="sliding-menu">
  4. <a href="#new-order" :class="{selected: page == 'new-order'}">Services</a>
  5. <a href="#credits" :class="{selected: page == 'credits'}">Credits</a>
  6. <div :class="page" class="menu-slider"><div></div></div>
  7. </div>
  8. <h4 class="credits-display"><img class="icon" src="../../images/coin-stack.svg" alt=""><span> {{credits.toLocaleString('en')}}</span></h4>
  9. <template v-if="page == 'new-order'">
  10. <div class="services-legend">
  11. <h5>Name</h5><h5>Credits per 1000</h5><h5>Min Qt.</h5><h5>Max Qt.</h5>
  12. </div>
  13. <ServicePane :site="'youtube'" :services="services"
  14. @select="select"></ServicePane> <ServicePane :site="'instagram'"
  15. :services="services" @select="select"></ServicePane> <ServicePane
  16. :site="'twitter'" :services="services" @select="select"></ServicePane>
  17. <ServicePane :site="'tiktok'" :services="services"
  18. @select="select"></ServicePane>
  19. <div id="overlay" v-if="selected">
  20. <div v-if="!completed" class="overlay-item">
  21. <img @click="completed = false; selected = null" class="cancel icon"
  22. src="../../images/cancel-icon2.svg" alt=""/>
  23. <img v-if="selected.site == 'youtube'" class="icon"
  24. src="../../images/youtube-icon.svg" alt=""/>
  25. <img v-if="selected.site == 'instagram'" class="icon"
  26. src="../../images/instagram-icon.svg" alt=""/>
  27. <img v-if="selected.site == 'twitter'" class="icon"
  28. src="../../images/twitter.svg" alt=""/>
  29. <img v-if="selected.site == 'tiktok'" class="icon"
  30. src="../../images/tik-tok.svg" alt=""/>
  31. <h3>{{selected.name}}</h3>
  32. <h4>Cost: {{cost.toLocaleString('en')}}</h4>
  33. <h4>Quantity</h4>
  34. <div><input required :min="selected.minimum" :max="selected.maximum"
  35. type="number" v-model="amount" id="selQty"><span> /
  36. {{selected.maximum.toLocaleString('en')}}</span></div>
  37. <template v-if="selected.modifier == 'location'">
  38. <h4>Location</h4>
  39. <div><select required id="country" name="">
  40. <option value="usa">USA</option>
  41. <option value="canada">Canada</option>
  42. <option value="uk">United Kingdom</option>
  43. <option value="germany">Germany</option>
  44. <option value="france">France</option>
  45. </select>
  46. </div>
  47. </template>
  48. <template v-if="selected.modifier == 'language'">
  49. <h4>Location</h4>
  50. <div><select required id="language" name="">
  51. <option value="english">English</option>
  52. <option value="french">French</option>
  53. <option value="spanish">Spanish</option>
  54. <option value="german">German</option>
  55. </select>
  56. </div>
  57. </template>
  58. <h4>URL</h4>
  59. <div><input required type="url" id="url" v-model="url"></div>
  60. <button @click="buyService" :disabled="paying">Submit<loading
  61. v-if="paying"></loading></button>
  62. <p id="overlay-error"></p>
  63. </div>
  64. <div class="overlay-item" v-else-if="completed">
  65. <img @click="completed = false; selected = null" class="cancel icon"
  66. src="../../images/cancel-icon2.svg" alt=""/>
  67. <img class="icon" src="../../images/checked2.svg" alt=""/>
  68. <h3>Success!</h3>
  69. </div>
  70. </div>
  71. </template>
  72. <credits @purchase-complete="$emit('updateUser')" :token="token" v-if="page == 'credits'"></credits>
  73. </div>
  74. </template>
  75. <script>
  76. import ServicePane from './service-pane.vue'
  77. import Credits from './credits.vue'
  78. import Loading from '../icons/loading.vue'
  79. function select(service) {
  80. this.completed = false
  81. this.selected = service
  82. }
  83. function cost() {
  84. return Math.ceil(this.selected.price * this.amount / 1000)
  85. }
  86. function buyService() {
  87. if (!this.url) {
  88. document.getElementById('overlay-error').textContent = "You must provide a URL."
  89. return
  90. } else if (Math.ceil(this.cost > this.credits)) {
  91. document.getElementById('overlay-error').textContent =
  92. 'Insuficient Credits'
  93. return
  94. }
  95. this.paying = true
  96. let note = ''
  97. let country = document.getElementById('country')
  98. let language = document.getElementById('language')
  99. if (country) {
  100. note = JSON.stringify({'location': country.value})
  101. } else if (language) {
  102. note = JSON.stringify({'language': language.value})
  103. }
  104. fetch('/panel/orders', {
  105. method: 'POST',
  106. headers: {'Content-Type': 'application/json',
  107. 'Accept': 'application/json',
  108. 'X-XSRF-TOKEN': this.token},
  109. body: JSON.stringify({'service': this.selected.id,
  110. 'quantity': this.amount, 'url': this.url, 'note': note}), }).then(
  111. response => {
  112. if (response.ok) {
  113. document.getElementById('overlay-error').textContent = `Success!`
  114. this.completed = true
  115. this.$emit('updateUser')
  116. this.$emit('updateOrders')
  117. } else if (response.status == 520) {
  118. document.getElementById('overlay-error').textContent =
  119. 'Insuficient Credits'
  120. } else {
  121. document.getElementById('overlay-error').textContent = `Error
  122. ${response.status}: ${response.statusText}`
  123. }
  124. this.paying = false
  125. }
  126. )
  127. }
  128. function page() {
  129. switch (this.active) {
  130. case '#new-order':
  131. return 'new-order'
  132. case '#credits':
  133. return 'credits'
  134. }
  135. }
  136. export default {
  137. data() {
  138. return {servicePane: true, services: null, selected: null, amount: 0,
  139. paying: false, url: '', completed: false}
  140. },
  141. components: {ServicePane, Loading, Credits},
  142. props: ['token', 'credits', 'active'],
  143. created() {
  144. fetch("/panel/services", {
  145. method: 'GET',
  146. headers: {'Content-Type': 'application/json',
  147. 'Accept': 'application/json',
  148. 'X-XSRF-TOKEN': this.token}
  149. }).then(response => {
  150. response.json().then(data => {this.services = data})
  151. })
  152. },
  153. methods: {select, buyService},
  154. computed: {cost, page},
  155. emits: ['updateUser', 'updateOrders']
  156. }
  157. </script>