<template>
  <view class="del_user">
    <u-textarea
      v-model="text"
      placeholder="请填写注销理由"
      class="area"
      height="150"
      count
    ></u-textarea>
    <u-button
      type="error"
      text="提交申请"
      class="btn"
      @click="handleDelUser"
    ></u-button>
  </view>
</template>

<script>
import { DelUser } from "@/api/shop.js";

export default {
  data() {
    return {
      text: "",
    };
  },
  methods: {
    async handleDelUser() {
      if (!this.text) {
        uni.showToast({
          title: `请填写理由`,
        });
        return false;
      }

      await DelUser({
        cancelReason: this.text,
      });

      uni.showToast({
        title: `注销成功`,
      });

      setTimeout(() => {
        this.$store.dispatch("user/LoginOut", true);
      }, 2000);
    },
  },
};
</script>

<style lang="scss" scoped>
.del_user {
  background: #fff;
  margin: 20rpx;
  padding: 20rpx;
  .area {
    border-bottom: 1px solid rgb(238, 238, 238, 0.5);
  }
  .btn {
    margin-top: 40rpx;
    margin-bottom: 12rpx;
  }
}
</style>
