<template>
  <div class="feedback-container">
    <div class="main">
      <div class="title">
        意见反馈
      </div>

      <el-form
          :model="feedbackObj"
          label-width="150px"
        >
          <el-form-item label="描述问题">
            <el-input
              v-model="feedbackObj.describe"
              :rows="6"
              type="textarea"
              style="width: 95%"
            />
          </el-form-item>
          <el-form-item label="上传图片">
            <el-upload
              ref="uploadRef"
              multiple
              :limit="3"
              list-type="picture-card"
              :http-request="uploadSubmit"
              :auto-upload="false"
            >
              <el-icon class="avatar-uploader-icon">
                <Plus />
              </el-icon>
            </el-upload>
          </el-form-item>
          <el-form-item label="您的联系方式">
            <el-input v-model="feedbackObj.contact"  style="width: 95%" />
          </el-form-item>
        </el-form>

      <div class="submit">
        <el-button color="#f34d2c" plain @click="uploadRef.submit()"
          >提交反馈</el-button
        >
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import { Plus } from "@element-plus/icons-vue";
import { uploadFile } from "@/api/upload"; // 引入新的 API 方法

const feedbackObj = reactive({
  describe: "",
  img: "",
  contact: "",
});

const uploadRef = ref();

const uploadSubmit = ({ file }) => {
  const params = {
    // 可以在这里添加其他参数
  };
  uploadFile(file, params)
    .then((response) => {
      console.log(response);
      // 处理上传成功的逻辑
    })
    .catch((error) => {
      console.error(error);
      // 处理上传失败的逻辑
    });
};
</script>

<style lang="scss" scoped>
.feedback-container {
  width: 100%;
  min-height: calc(100vh - 70px - 150px);
  background: #eee;
  padding: 20px;
  .main {
    width: 1200px;
    margin:0 auto;
    background: #fff;
    border-radius: 10px;

    .title{
        font-size: 24px;
        padding: 30px 30px 60px 30px;
    }

    .submit{
        padding: 50px 0;
        text-align: center;
    }
  }
}

@media (max-width: 768px) {
  .feedback-container {
  width: 100%;
  min-height: calc(100vh - 70px - 150px);
  background: #eee;
  padding: 20px;
  .main {
    width: auto;
  }
}
}
</style>
