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.

services.vue 5.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/100).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. <option value="arabic">Arabic</option>
  56. </select>
  57. </div>
  58. </template>
  59. <h4>URL</h4>
  60. <div><input required type="url" id="url" v-model="url"></div>
  61. <button @click="buyService" :disabled="paying">Submit<loading
  62. v-if="paying"></loading></button>
  63. <p id="overlay-error"></p>
  64. </div>
  65. <div class="overlay-item" v-else-if="completed">
  66. <img @click="completed = false; selected = null" class="cancel icon"
  67. src="../../images/cancel-icon2.svg" alt=""/>
  68. <img class="icon" src="../../images/checked2.svg" alt=""/>
  69. <h3>Success!</h3>
  70. </div>
  71. </div>
  72. </template>
  73. <credits @purchase-complete="$emit('updateUser')" :preferred="preferred" :token="token" v-if="page == 'credits'"></credits>
  74. </div>
  75. </template>
  76. <script>
  77. import ServicePane from './service-pane.vue'
  78. import Credits from './credits.vue'
  79. import Loading from '../icons/loading.vue'
  80. function select(service) {
  81. this.completed = false
  82. if (this.amount < service.minimum){
  83. this.amount = service.minimum;
  84. }
  85. if (this.amount > service.maximum){
  86. this.amount = service.maximum;
  87. }
  88. this.selected = service
  89. document.getElementById('overlay-error').textContent = ''
  90. }
  91. function cost() {
  92. return (this.selected.price * this.amount / 100000).toFixed(2)
  93. }
  94. function buyService() {
  95. if (!this.url) {
  96. document.getElementById('overlay-error').textContent = "You must provide a URL."
  97. return
  98. } else if (Math.ceil(this.cost > this.credits)) {
  99. document.getElementById('overlay-error').textContent =
  100. 'Insuficient Credits'
  101. return
  102. } else if (this.amount < this.selected.minimum || this.amount > this.selected.maximum) {
  103. document.getElementById('overlay-error').textContent =
  104. 'Invalid amount'
  105. return
  106. }
  107. this.paying = true
  108. let note = ''
  109. let country = document.getElementById('country')
  110. let language = document.getElementById('language')
  111. if (country) {
  112. note = JSON.stringify({'location': country.value})
  113. } else if (language) {
  114. note = JSON.stringify({'language': language.value})
  115. }
  116. fetch('/panel/orders', {
  117. method: 'POST',
  118. headers: {'Content-Type': 'application/json',
  119. 'Accept': 'application/json',
  120. 'X-XSRF-TOKEN': this.token},
  121. body: JSON.stringify({'service': this.selected.id,
  122. 'quantity': this.amount, 'url': this.url, 'note': note}), }).then(
  123. response => {
  124. if (response.ok) {
  125. document.getElementById('overlay-error').textContent = `Success!`
  126. this.completed = true
  127. this.$emit('updateUser')
  128. this.$emit('updateOrders')
  129. } else if (response.status == 520) {
  130. document.getElementById('overlay-error').textContent =
  131. 'Insuficient Credits'
  132. } else {
  133. document.getElementById('overlay-error').textContent = `Error
  134. ${response.status}: ${response.statusText}`
  135. }
  136. this.paying = false
  137. }
  138. )
  139. }
  140. function page() {
  141. switch (this.active) {
  142. case '#new-order':
  143. return 'new-order'
  144. case '#credits':
  145. return 'credits'
  146. }
  147. }
  148. export default {
  149. data() {
  150. return {servicePane: true, services: null, selected: null, amount: 0,
  151. paying: false, url: '', completed: false}
  152. },
  153. components: {ServicePane, Loading, Credits},
  154. props: ['token', 'credits', 'active', 'preferred'],
  155. created() {
  156. fetch("/panel/services", {
  157. method: 'GET',
  158. headers: {'Content-Type': 'application/json',
  159. 'Accept': 'application/json',
  160. 'X-XSRF-TOKEN': this.token}
  161. }).then(response => {
  162. response.json().then(data => {this.services = data})
  163. })
  164. },
  165. methods: {select, buyService},
  166. computed: {cost, page},
  167. emits: ['updateUser', 'updateOrders']
  168. }
  169. </script>