"use strict";
const common_vendor = require("../../common/vendor.js");
const config_user = require("../../config/user.js");
const _sfc_main = {
  __name: "index",
  setup(__props) {
    const types = common_vendor.ref(["设备故障", "收费问题", "使用建议", "其他"]);
    const selectedType = common_vendor.ref(-1);
    const paramsType = common_vendor.ref("");
    const description = common_vendor.ref("");
    common_vendor.ref([]);
    const contact = common_vendor.ref("");
    const selectType = (index) => {
      selectedType.value = index;
    };
    const submitFeedback = async () => {
      if (selectedType.value === -1) {
        common_vendor.index.showToast({
          title: "请选择问题类型",
          icon: "none"
        });
        return;
      }
      if (!description.value.trim()) {
        common_vendor.index.showToast({
          title: "请描述您的问题",
          icon: "none"
        });
        return;
      }
      if (!contact.value) {
        common_vendor.index.showToast({
          title: "请留下联系方式",
          icon: "none"
        });
        return;
      }
      if (types.value[selectedType.value] == "设备故障" || types.value[selectedType.value] == "收费问题") {
        paramsType.value = "complain";
      } else {
        paramsType.value = "suggestion";
      }
      const feedbackData = {
        type: paramsType.value,
        content: description.value,
        phone: contact.value
        // images: images.value
      };
      const res = await config_user.addUserFeedback(feedbackData);
      if (res.code == 200) {
        common_vendor.index.showToast({
          title: "反馈成功",
          icon: "success"
        });
      } else {
        common_vendor.index.showToast({
          title: "反馈失败",
          icon: "none"
        });
      }
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(types.value, (type, index, i0) => {
          return {
            a: common_vendor.t(type),
            b: index,
            c: selectedType.value === index ? 1 : "",
            d: common_vendor.o(($event) => selectType(index), index)
          };
        }),
        b: description.value,
        c: common_vendor.o(($event) => description.value = $event.detail.value),
        d: common_vendor.t(description.value.length),
        e: contact.value,
        f: common_vendor.o(($event) => contact.value = $event.detail.value),
        g: common_vendor.o(submitFeedback)
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2aa7bac2"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/feedback/index.js.map
