Examples of code I've written in PHP, Javascript, SCSS, etc.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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>
  15. <ServicePane :site="'instagram'" :services="services"
  16. @select="select"></ServicePane>
  17. <ServicePane :site="'twitter'" :services="services"
  18. @select="select"></ServicePane>
  19. <ServicePane :site="'tiktok'" :services="services"
  20. @select="select"></ServicePane>
  21. <div id="overlay" v-if="selected">
  22. <div v-if="!completed" class="overlay-item">
  23. <img @click="completed = false; selected = null" class="cancel icon"
  24. src="../../images/cancel-icon2.svg" alt=""/>
  25. <img v-if="selected.site == 'youtube'" class="icon"
  26. src="../../images/youtube-icon.svg" alt=""/>
  27. <img v-if="selected.site == 'instagram'" class="icon"
  28. src="../../images/instagram-icon.svg" alt=""/>
  29. <img v-if="selected.site == 'twitter'" class="icon"
  30. src="../../images/twitter.svg" alt=""/>
  31. <img v-if="selected.site == 'tiktok'" class="icon"
  32. src="../../images/tik-tok.svg" alt=""/>
  33. <h3>{{selected.name}}</h3>
  34. <h4>Cost: {{(cost).toLocaleString('en')}}</h4>
  35. <h4>Quantity</h4>
  36. <div><input required :min="selected.minimum" :max="selected.maximum"
  37. type="number" v-model="amount" id="selQty"><span> /
  38. {{selected.maximum.toLocaleString('en')}}</span></div>
  39. <template v-if="selected.modifier == 'location'">
  40. <h4>Location</h4>
  41. <div><select required id="country" name="">
  42. <option value="usa">USA</option>
  43. <option value="canada">Canada</option>
  44. <option value="uk">United Kingdom</option>
  45. <option value="germany">Germany</option>
  46. <option value="france">France</option>
  47. </select>
  48. </div>
  49. </template>
  50. <template v-if="selected.modifier == 'language'">
  51. <h4>Location</h4>
  52. <div><select required id="language" name="">
  53. <option value="english">English</option>
  54. <option value="french">French</option>
  55. <option value="spanish">Spanish</option>
  56. <option value="german">German</option>
  57. <option value="arabic">Arabic</option>
  58. </select>
  59. </div>
  60. </template>
  61. <h4>URL</h4>
  62. <div><input required type="url" id="url" v-model="url"></div>
  63. <button @click="buyService" :disabled="paying">Submit<loading
  64. v-if="paying"></loading></button>
  65. <p id="overlay-error">{{errorText}}</p>
  66. </div>
  67. <div class="overlay-item" v-else-if="completed">
  68. <img @click="completed = false; selected = null" class="cancel icon"
  69. src="../../images/cancel-icon2.svg" alt=""/>
  70. <img class="icon" src="../../images/checked2.svg" alt=""/>
  71. <h3>Success!</h3>
  72. </div>
  73. </div>
  74. </template>
  75. <credits @purchase-complete="$emit('updateUser')" :preferred="preferred" :token="token" v-if="page == 'credits'"></credits>
  76. </div>
  77. </template>
  78. <script>
  79. import ServicePane from './service-pane.vue'
  80. import Credits from './credits.vue'
  81. import Loading from '../icons/loading.vue'
  82. function select(service) {
  83. this.completed = false
  84. if (this.amount < service.minimum){
  85. this.amount = service.minimum;
  86. }
  87. if (this.amount > service.maximum){
  88. this.amount = service.maximum;
  89. }
  90. this.selected = service
  91. this.errorText = ''
  92. }
  93. function cost() {
  94. return (this.selected.price * this.amount / 100000).toFixed(2)
  95. }
  96. function buyService() {
  97. if (!this.url) {
  98. this.errorText = "You must provide a URL."
  99. return
  100. } else if (Math.ceil(this.cost > this.credits)) {
  101. this.errorText = 'Insuficient Credits'
  102. return
  103. } else if (this.amount < this.selected.minimum || this.amount > this.selected.maximum) {
  104. this.errorText = '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. this.errorText = `Success!`
  126. this.completed = true
  127. this.$emit('updateUser')
  128. this.$emit('updateOrders')
  129. } else if (response.status == 520) {
  130. this.errorText = 'Insuficient Credits'
  131. } else {
  132. this.errorText = `Error ${response.status}:
  133. ${response.statusText}`
  134. }
  135. this.paying = false
  136. }
  137. )
  138. }
  139. function page() {
  140. switch (this.active) {
  141. case '#new-order':
  142. return 'new-order'
  143. case '#credits':
  144. return 'credits'
  145. }
  146. }
  147. export default {
  148. data() {
  149. return {servicePane: true, services: null, selected: null, amount: 0,
  150. paying: false, url: '', completed: false, errorText: ''}
  151. },
  152. components: {ServicePane, Loading, Credits},
  153. props: ['token', 'credits', 'active', 'preferred'],
  154. created() {
  155. fetch("/panel/services", {
  156. method: 'GET',
  157. headers: {'Content-Type': 'application/json',
  158. 'Accept': 'application/json',
  159. 'X-XSRF-TOKEN': this.token}
  160. }).then(response => {
  161. response.json().then(data => {this.services = data})
  162. })
  163. },
  164. methods: {select, buyService},
  165. computed: {cost, page},
  166. emits: ['updateUser', 'updateOrders']
  167. }
  168. </script>