"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_api = require("../../utils/api.js"); const _sfc_main = { data() { return { feedbackType: "bug", // bug, suggestion, other description: "", imageList: [], isSubmitting: false }; }, onLoad() { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.id) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); setTimeout(() => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }, 1500); } }, methods: { goBack() { common_vendor.index.navigateBack(); }, selectType(type) { this.feedbackType = type; }, chooseImage() { common_vendor.index.chooseImage({ count: 3 - this.imageList.length, sizeType: ["compressed"], sourceType: ["album", "camera"], success: (res) => { this.imageList = this.imageList.concat(res.tempFilePaths); }, fail: (err) => { common_vendor.index.__f__("error", "at pages/feedback/feedback.vue:141", "选择图片失败:", err); common_vendor.index.showToast({ title: "选择图片失败", icon: "none" }); } }); }, deleteImage(index) { this.imageList.splice(index, 1); }, async submitFeedback() { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.id) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); setTimeout(() => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }, 1500); return; } if (!this.description.trim()) { common_vendor.index.showToast({ title: "请输入详细描述", icon: "none" }); return; } if (this.isSubmitting) { return; } this.isSubmitting = true; common_vendor.index.showLoading({ title: "提交中...", mask: true }); try { const feedbackData = { userId: userInfo.id, type: this.feedbackType, description: this.description.trim(), images: this.imageList // 图片列表,暂时使用临时路径 // 注意:在生产环境中,需要先将图片上传到服务器获取URL // images: uploadedImageUrls }; const res = await utils_api.submitFeedback(feedbackData); common_vendor.index.hideLoading(); this.isSubmitting = false; if (res && res.code === 200) { common_vendor.index.showToast({ title: "提交成功", icon: "success" }); this.description = ""; this.imageList = []; this.feedbackType = "bug"; setTimeout(() => { common_vendor.index.navigateBack(); }, 1500); } else { common_vendor.index.showToast({ title: res.message || "提交失败,请重试", icon: "none" }); } } catch (error) { common_vendor.index.hideLoading(); this.isSubmitting = false; common_vendor.index.__f__("error", "at pages/feedback/feedback.vue:229", "提交反馈失败:", error); common_vendor.index.showToast({ title: error.message || "网络错误,请稍后再试", icon: "none" }); } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)), b: $data.feedbackType === "bug" ? 1 : "", c: common_vendor.o(($event) => $options.selectType("bug")), d: $data.feedbackType === "suggestion" ? 1 : "", e: common_vendor.o(($event) => $options.selectType("suggestion")), f: $data.feedbackType === "other" ? 1 : "", g: common_vendor.o(($event) => $options.selectType("other")), h: $data.description, i: common_vendor.o(($event) => $data.description = $event.detail.value), j: common_vendor.f($data.imageList, (image, index, i0) => { return { a: image, b: common_vendor.o(($event) => $options.deleteImage(index), index), c: index }; }), k: $data.imageList.length < 3 }, $data.imageList.length < 3 ? { l: common_vendor.o((...args) => $options.chooseImage && $options.chooseImage(...args)) } : {}, { m: common_vendor.o((...args) => $options.submitFeedback && $options.submitFeedback(...args)) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a24b82f2"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/feedback/feedback.js.map