Examples of code I've written in PHP, Javascript, SCSS, etc.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

support.vue 1.8 KiB

il y a 3 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="support-section" id="main">
  3. <h2>Support</h2>
  4. <loading v-if="loading"></loading>
  5. <div v-if="!loading && complete" class="dialog">
  6. <img class="icon" src="../../images/checked2.svg" alt="">
  7. <h3>Ticket sent. An administrator will contact you soon.</h3>
  8. </div>
  9. <div v-if="!loading && !complete" id="support-form">
  10. <label for="">Topic</label>
  11. <select id="support-topic" name="" v-model="topic">
  12. <option value="order">Order</option>
  13. <option value="service">Service</option>
  14. <option value="credits">Credits</option>
  15. <option value="payment">Payment</option>
  16. <option value="other">Other</option>
  17. </select>
  18. <label for="">Details</label>
  19. <textarea id="" name="" cols="30" rows="10" v-model="message"></textarea>
  20. <span class="note-grey">Include any relevant information like the order number,
  21. service name, etc</span>
  22. <button @click="send">Submit</button>
  23. <p class="error-message">{{errorMessage}}</p>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import Loading from '../icons/loading.vue'
  29. function send() {
  30. this.errorMessage = ''
  31. if (!this.topic || !this.message) {
  32. this.errorMessage = 'Topic and details cannot be blank.'
  33. return
  34. }
  35. this.loading = true
  36. fetch("/panel/support", {
  37. method: 'POST',
  38. headers: {'Content-Type': 'application/json',
  39. 'Accept': 'application/json',
  40. 'X-XSRF-TOKEN': this.token},
  41. body: JSON.stringify({'topic': this.topic, 'message': this.message})}).
  42. then(response => {
  43. if (response.ok) {
  44. this.complete = true
  45. } else {
  46. this.complete = false
  47. this.error = true
  48. this.errorMessage = `${response.status}:
  49. ${response.statusText}`
  50. }
  51. this.loading = false
  52. })
  53. }
  54. export default {
  55. components: {Loading},
  56. props: ['user', 'token'],
  57. data() {
  58. return {loading: false, complete: false, error: false, errorMessage:
  59. '', topic: null, message: ''}
  60. },
  61. methods: {send}
  62. }
  63. </script>