| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- "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
|