index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <v-form
  3. class="mx-auto"
  4. width="900"
  5. ref="form"
  6. lazy-validation
  7. @submit.prevent="createAdsItem"
  8. >
  9. <v-checkbox
  10. max-width="600"
  11. v-model="adsItem.visibility"
  12. label="Показывать рекламу"
  13. ></v-checkbox>
  14. <v-combobox
  15. v-model="adsItem.advertising_section_id"
  16. label="Секция показа рекламы:"
  17. required
  18. :items="sectionsList"
  19. item-text="display_name"
  20. item-value="section_code"
  21. outlined
  22. >
  23. </v-combobox>
  24. <v-text-field
  25. v-model="adsItem.display_title"
  26. label="Название рекламного блока:"
  27. required
  28. outlined
  29. ></v-text-field>
  30. <v-text-field
  31. v-model="adsItem.div_id"
  32. label="ID рекламного блока:"
  33. required
  34. outlined
  35. ></v-text-field>
  36. <v-textarea
  37. label="Вставка кода:"
  38. v-model="adsItem.code"
  39. auto-grow
  40. outlined
  41. rows="10"
  42. row-height="20"
  43. ></v-textarea>
  44. <v-btn type="submit"> Принять </v-btn>
  45. </v-form>
  46. </template>
  47. <script>
  48. export default {
  49. layout: "admin",
  50. data() {
  51. return {
  52. adsItem: {
  53. display_title: "",
  54. visibility: true,
  55. advertising_section_id: "",
  56. div_id: "",
  57. code: ""
  58. },
  59. };
  60. },
  61. methods: {
  62. async createAdsItem({ $axios }) {
  63. let response = await this.$axios.$post(
  64. "/authorized/admin/advertising/create",
  65. {
  66. begin_showing_time: this.date,
  67. end_showing_time: 1661651787,
  68. display_title: this.adsItem.display_title,
  69. visibility: true,
  70. advertising_section_id: this.adsItem.advertising_section_id.id,
  71. script: this.adsItem.code,
  72. ad_click_url: this.adsItem.div_id
  73. }
  74. );
  75. },
  76. },
  77. async asyncData({ $axios }) {
  78. const sectionsList = await $axios
  79. .$get("/advertising/sections/all")
  80. .then((res) => {
  81. console.log(res.data);
  82. return res.data;
  83. });
  84. return { sectionsList };
  85. },
  86. computed: {
  87. date() {
  88. return Math.floor(Date.now() / 1000)
  89. }
  90. }
  91. };
  92. </script>
  93. <style scope lang="less">
  94. form {
  95. width: 90%;
  96. }
  97. </style>