index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. statusBarHeight: 20,
  7. types: [
  8. { label: "系统投诉", value: "complaint" },
  9. { label: "改进建议", value: "suggestion" },
  10. { label: "其他反馈", value: "other" }
  11. ],
  12. formData: {
  13. type: "complaint",
  14. content: "",
  15. images: []
  16. }
  17. };
  18. },
  19. computed: {
  20. isFormValid() {
  21. return this.formData.content && this.formData.content.trim().length >= 5;
  22. }
  23. },
  24. onLoad() {
  25. try {
  26. const info = common_vendor.index.getSystemInfoSync();
  27. this.statusBarHeight = info.statusBarHeight || 20;
  28. } catch (e) {
  29. this.statusBarHeight = 20;
  30. }
  31. },
  32. methods: {
  33. goBack() {
  34. common_vendor.index.navigateBack();
  35. },
  36. chooseImage() {
  37. const count = 6 - this.formData.images.length;
  38. common_vendor.index.chooseImage({
  39. count,
  40. sizeType: ["compressed"],
  41. success: (res) => {
  42. this.formData.images = [...this.formData.images, ...res.tempFilePaths];
  43. }
  44. });
  45. },
  46. removeImage(index) {
  47. this.formData.images.splice(index, 1);
  48. },
  49. previewImage(index) {
  50. common_vendor.index.previewImage({
  51. urls: this.formData.images,
  52. current: index
  53. });
  54. },
  55. handleSubmit() {
  56. common_vendor.index.showLoading({ title: "提交中" });
  57. setTimeout(() => {
  58. common_vendor.index.hideLoading();
  59. common_vendor.index.showToast({ title: "反馈成功" });
  60. setTimeout(() => {
  61. common_vendor.index.navigateBack();
  62. }, 1500);
  63. }, 1e3);
  64. }
  65. }
  66. };
  67. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  68. return common_vendor.e({
  69. a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args), "46"),
  70. b: $data.statusBarHeight + "px",
  71. c: common_vendor.f($data.types, (item, k0, i0) => {
  72. return {
  73. a: common_vendor.t(item.label),
  74. b: item.value,
  75. c: $data.formData.type === item.value ? 1 : "",
  76. d: common_vendor.o(($event) => $data.formData.type = item.value, item.value)
  77. };
  78. }),
  79. d: $data.formData.content,
  80. e: common_vendor.o(($event) => $data.formData.content = $event.detail.value, "f6"),
  81. f: common_vendor.t($data.formData.content.length),
  82. g: common_vendor.f($data.formData.images, (img, index, i0) => {
  83. return {
  84. a: img,
  85. b: common_vendor.o(($event) => $options.previewImage(index), index),
  86. c: common_vendor.o(($event) => $options.removeImage(index), index),
  87. d: index
  88. };
  89. }),
  90. h: $data.formData.images.length < 6
  91. }, $data.formData.images.length < 6 ? {
  92. i: common_vendor.o((...args) => $options.chooseImage && $options.chooseImage(...args), "55")
  93. } : {}, {
  94. j: !$options.isFormValid,
  95. k: common_vendor.o((...args) => $options.handleSubmit && $options.handleSubmit(...args), "d6")
  96. });
  97. }
  98. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6497fc4f"]]);
  99. wx.createPage(MiniProgramPage);
  100. //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/mine/complaint/index.js.map