feedback.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="main">
  3. <div class="content">
  4. <sub-header />
  5. <div class="left">
  6. <hero-sub-title :type="5" />
  7. <div class="detail">
  8. <div class="back" @click="$router.go(-1)"></div>
  9. <div class="info">
  10. <n-input
  11. v-model:value="feedBackContent"
  12. type="textarea"
  13. autosize
  14. placeholder="请填入内容,5-500字"
  15. style="min-height: 25rem"
  16. />
  17. <n-space align="center" style="padding: 1.25rem" justify="center">
  18. <n-input
  19. v-model:value="nickName"
  20. size="large"
  21. type="text"
  22. placeholder="昵称"
  23. />
  24. <n-input
  25. v-model:value="contact"
  26. size="large"
  27. type="text"
  28. placeholder="联系方式"
  29. />
  30. <n-input
  31. v-model:value="verifyCode"
  32. size="large"
  33. type="text"
  34. placeholder="请填入图形验证码"
  35. />
  36. <img
  37. class="txt-code"
  38. :src="imageCode"
  39. @click="handleCodeReload"
  40. />
  41. </n-space>
  42. <n-space align="center" justify="center" style="padding: 1.25rem">
  43. <n-button
  44. class="submit"
  45. size="large"
  46. :disabled="
  47. feedBackContent.length === 0 ||
  48. nickName.length === 0 ||
  49. contact.length === 0 ||
  50. verifyCode.length === 0
  51. "
  52. type="primary"
  53. @click="submit"
  54. >
  55. 提交
  56. </n-button>
  57. </n-space>
  58. </div>
  59. </div>
  60. </div>
  61. <side-menu />
  62. </div>
  63. </div>
  64. </template>
  65. <script setup>
  66. import { ref } from "vue";
  67. import subHeader from "../components/subHeader";
  68. import sideMenu from "../components/sideMenu";
  69. import heroSubTitle from "../components/heroSubTitle";
  70. import { useFeedBackStore } from "../store/feedback";
  71. import { useRouter } from "vue-router";
  72. import { useMessage } from "naive-ui";
  73. window.$message = useMessage();
  74. const router = useRouter();
  75. const feedBackStore = useFeedBackStore();
  76. const imageCode = ref(
  77. `${import.meta.env.VITE_API_URL}/show/getRandCode?t=` + Date.now()
  78. );
  79. const feedBackContent = ref("");
  80. const nickName = ref("");
  81. const contact = ref("");
  82. const verifyCode = ref("");
  83. const submit = async () => {
  84. try {
  85. const data = {
  86. name: nickName.value,
  87. content: feedBackContent.value,
  88. phone: contact.value,
  89. randCode: verifyCode.value,
  90. };
  91. const res = await feedBackStore.sendFeedback(data);
  92. console.log("res", res);
  93. if (res.isOK) {
  94. window.$message.success("提交成功!");
  95. router.go(-1);
  96. } else {
  97. window.$message.warning(res.msg);
  98. }
  99. } catch (error) {}
  100. };
  101. const handleCodeReload = () => {
  102. const url = imageCode.value.split("?");
  103. imageCode.value = url[0] + "?=" + Date.now();
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. :deep(.n-input) {
  108. font-size: 1rem;
  109. }
  110. .detail {
  111. --main-show-case-background: #ddd5d5;
  112. --main-detail-margin: 30px;
  113. --main-detail-padding: 30px;
  114. // box-shadow: var(--main-box-shadow);
  115. margin: var(--main-detail-margin);
  116. margin-bottom: 0;
  117. flex: 1;
  118. border-radius: 13px;
  119. background-color: transparent;
  120. padding: 32px 48px 64px 48px;
  121. background-image: var(--main-detail-background-img);
  122. background-size: cover;
  123. background-position: top 100%;
  124. background-repeat: no-repeat;
  125. overflow-y: scroll;
  126. &::-webkit-scrollbar {
  127. display: none;
  128. }
  129. .back {
  130. background-image: url("/img/back_arrow.png");
  131. width: 120px;
  132. height: 30px;
  133. background-repeat: no-repeat;
  134. background-size: contain;
  135. margin-bottom: 12px;
  136. }
  137. .info {
  138. max-width: 1069px;
  139. margin: 0 auto;
  140. font-size: 20px;
  141. }
  142. .show-case {
  143. max-width: 1069px;
  144. height: 547px;
  145. background: var(--main-show-case-background);
  146. }
  147. .submit {
  148. font-size: 1.25rem;
  149. padding: 25px 50px;
  150. border-radius: 1.1875rem;
  151. }
  152. .txt-code {
  153. vertical-align: middle;
  154. cursor: pointer;
  155. }
  156. }
  157. :deep(.detail .info .n-input--textarea) {
  158. --n-font-size: 1.25rem !important;
  159. padding: 20px;
  160. border-radius: 19px;
  161. }
  162. </style>