index.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { defineComponent, reactive, ref } from "vue";
  2. import styles from "./index.module.less";
  3. import iconClose from "../icons/close2.svg";
  4. import { Button, Cell, Field, Tab, Tabs, showToast } from "vant";
  5. import { sysSuggestionAdd } from "/src/page-colexiu/api";
  6. export default defineComponent({
  7. name: "recommendation",
  8. emits: ["close"],
  9. setup(props, { emit }) {
  10. const tags = ["识别不准", "无法评测", "不出评测结果", "曲谱不一致", "指法错误", "其他"];
  11. const recommenData = reactive({
  12. loading: false,
  13. active: "识别不准",
  14. message: "",
  15. });
  16. /** 提交意见反馈 */
  17. const handleSubmit = async () => {
  18. if (!recommenData.message) {
  19. showToast({
  20. message: "请先填写意见反馈",
  21. position: "top",
  22. });
  23. return;
  24. }
  25. recommenData.loading = true;
  26. try {
  27. await sysSuggestionAdd({
  28. content: recommenData.message + "#" + recommenData.active,
  29. type: "SMART_PRACTICE",
  30. });
  31. showToast({
  32. message: "意见反馈已提交",
  33. position: "top",
  34. });
  35. emit('close')
  36. } catch (error) {}
  37. recommenData.loading = false;
  38. };
  39. return () => (
  40. <>
  41. <div class={styles.closeBtn} onClick={() => emit("close")}>
  42. <img src={iconClose} />
  43. </div>
  44. <div class={styles.content}>
  45. <Tabs lineHeight={0} color="#1A1A1A">
  46. <Tab title="意见反馈">
  47. <Cell border={false} title="请选择问题类型" />
  48. <div class={styles.tags}>
  49. {tags.map((text) => (
  50. <span class={[styles.tag, recommenData.active === text && styles.active]} onClick={() => (recommenData.active = text)}>
  51. {text}
  52. </span>
  53. ))}
  54. </div>
  55. <Field
  56. v-model={recommenData.message}
  57. rows="3"
  58. autosize={{ maxHeight: 128 }}
  59. border={false}
  60. type="textarea"
  61. maxlength={200}
  62. placeholder="请详细描述您遇到的问题,以便我们尽快为您解决!"
  63. show-word-limit
  64. />
  65. <Cell>
  66. <Button loading={recommenData.loading} class={styles.btn} block round type="primary" onClick={handleSubmit}>
  67. 提交反馈
  68. </Button>
  69. </Cell>
  70. </Tab>
  71. </Tabs>
  72. </div>
  73. </>
  74. );
  75. },
  76. });