<template>
  <div id="detail">
    <admin-frame :usePage="false" topType="2" :rightArrow="false" @back="back" :useNav="false">
      <template v-slot:info>
        <form-1 :form="form" @onSubmit="onSubmit"></form-1>
      </template>
    </admin-frame>
  </div>
</template>

<script>
import form1 from '@/layout/question/form-1.vue';
import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: problem_service } = createNamespacedHelpers('problem_service');
export default {
  name: 'detail',
  props: {},
  components: {
    adminFrame,
    form1,
  },
  data: function () {
    return {
      form: {},
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...problem_service(['fetch', 'create', 'update']),
    search() {
      this.$set(this, `form`, { ask_id: this.user.id, ask_name: this.user.phone });
    },
    async onSubmit({ data }) {
      data.status = '0';
      let res = await this.create(data);
      if (this.$checkRes(res)) {
        this.$toast({ type: `success`, message: `操作成功` });
        this.back();
      }
    },
    back() {
      this.$router.push({ path: '/patent/user/chat/index' });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped></style>
