"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
  data() {
    return {
      statusBarHeight: 20,
      types: [
        { label: "系统投诉", value: "complaint" },
        { label: "改进建议", value: "suggestion" },
        { label: "其他反馈", value: "other" }
      ],
      formData: {
        type: "complaint",
        content: "",
        images: []
      }
    };
  },
  computed: {
    isFormValid() {
      return this.formData.content && this.formData.content.trim().length >= 5;
    }
  },
  onLoad() {
    try {
      const info = common_vendor.index.getSystemInfoSync();
      this.statusBarHeight = info.statusBarHeight || 20;
    } catch (e) {
      this.statusBarHeight = 20;
    }
  },
  methods: {
    goBack() {
      common_vendor.index.navigateBack();
    },
    chooseImage() {
      const count = 6 - this.formData.images.length;
      common_vendor.index.chooseImage({
        count,
        sizeType: ["compressed"],
        success: (res) => {
          this.formData.images = [...this.formData.images, ...res.tempFilePaths];
        }
      });
    },
    removeImage(index) {
      this.formData.images.splice(index, 1);
    },
    previewImage(index) {
      common_vendor.index.previewImage({
        urls: this.formData.images,
        current: index
      });
    },
    handleSubmit() {
      common_vendor.index.showLoading({ title: "提交中" });
      setTimeout(() => {
        common_vendor.index.hideLoading();
        common_vendor.index.showToast({ title: "反馈成功" });
        setTimeout(() => {
          common_vendor.index.navigateBack();
        }, 1500);
      }, 1e3);
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args), "46"),
    b: $data.statusBarHeight + "px",
    c: common_vendor.f($data.types, (item, k0, i0) => {
      return {
        a: common_vendor.t(item.label),
        b: item.value,
        c: $data.formData.type === item.value ? 1 : "",
        d: common_vendor.o(($event) => $data.formData.type = item.value, item.value)
      };
    }),
    d: $data.formData.content,
    e: common_vendor.o(($event) => $data.formData.content = $event.detail.value, "f6"),
    f: common_vendor.t($data.formData.content.length),
    g: common_vendor.f($data.formData.images, (img, index, i0) => {
      return {
        a: img,
        b: common_vendor.o(($event) => $options.previewImage(index), index),
        c: common_vendor.o(($event) => $options.removeImage(index), index),
        d: index
      };
    }),
    h: $data.formData.images.length < 6
  }, $data.formData.images.length < 6 ? {
    i: common_vendor.o((...args) => $options.chooseImage && $options.chooseImage(...args), "55")
  } : {}, {
    j: !$options.isFormValid,
    k: common_vendor.o((...args) => $options.handleSubmit && $options.handleSubmit(...args), "d6")
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b5530f64"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/complaint.js.map
