<template>
  <div class="content bind-content">
    <!-- 头部 -->
    <div :class="{ header: true, 'scroll white': isScrollTop, white: true }">
      <div class="back" @click="$router.go(-1)">
        <img src="../../../assets/images/home/expert/back.png" alt="" />
      </div>
      <div class="header-title">意见与反馈</div>
    </div>
    <div class="info-bg pull-content">
      <div class="feedback-msg">
        <textarea v-model="content" rows="" cols="" placeholder="请输入您反馈的内容"></textarea>
      </div>
    </div>
    <div @click="btnFeedback()" class="bind-btn">提交</div>
  </div>
</template>

<script>
export default {
  name: "feedback",
  data() {
    return {
      isScrollTop: false,
      content: "",
    };
  },
  created() {
    this.isScroll = true;
    window.addEventListener("scroll", this.eventScrollTop);
  },
  mounted() {},
  computed: {},
  methods: {
    btnFeedback() {
      if (this.content == "") {
        return;
      }
      this.axios
        .post(
          this.HOME + "/api/consumer/submit-feedback",
          { content: this.content },
        )
        .then(function (res) {
		  window.alert(res.data.msg)
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    // 滚动改变样式
    eventScrollTop() {
      let scrollTop =
        document.body.scrollTop || document.documentElement.scrollTop;
      if (scrollTop >= 5) {
        if (this.isScroll) {
          this.isScroll = false;
          this.isScrollTop = true;
        }
      } else {
        if (!this.isScroll) {
          this.isScroll = true;
          this.isScrollTop = false;
        }
      }
    },
  },
  destroyed() {
    window.removeEventListener("scroll", this.eventScrollTop);
  },
  //keep-alive进入时触发
  activated() {
    this.isScroll = true;
    window.addEventListener("scroll", this.eventScrollTop);
  },
  //keep-alive离开时触发
  deactivated() {
    window.removeEventListener("scroll", this.eventScrollTop);
  },
};
</script>

<style scoped>
</style>