text-edit.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. key: "bio",
  7. text: "",
  8. placeholder: "请输入内容",
  9. title: ""
  10. };
  11. },
  12. onLoad(options) {
  13. this.key = options.key || "bio";
  14. const value = options.value || "";
  15. this.text = value ? decodeURIComponent(value) : "";
  16. this.placeholder = options.placeholder ? decodeURIComponent(options.placeholder) : "请输入内容";
  17. this.title = options.title ? decodeURIComponent(options.title) : "编辑文本";
  18. },
  19. methods: {
  20. cancel() {
  21. common_vendor.index.navigateBack();
  22. },
  23. save() {
  24. const trimmedText = this.text.trim();
  25. common_vendor.index.setStorageSync(`temp_text_${this.key}`, trimmedText);
  26. common_vendor.index.showToast({
  27. title: "已保存",
  28. icon: "success",
  29. duration: 1e3
  30. });
  31. setTimeout(() => {
  32. common_vendor.index.navigateBack();
  33. }, 500);
  34. }
  35. }
  36. };
  37. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  38. return common_vendor.e({
  39. a: $data.title
  40. }, $data.title ? {
  41. b: common_vendor.t($data.title)
  42. } : {}, {
  43. c: $data.placeholder,
  44. d: $data.text,
  45. e: common_vendor.o(($event) => $data.text = $event.detail.value),
  46. f: common_vendor.o((...args) => $options.cancel && $options.cancel(...args)),
  47. g: common_vendor.o((...args) => $options.save && $options.save(...args))
  48. });
  49. }
  50. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-58cb064e"]]);
  51. wx.createPage(MiniProgramPage);
  52. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/text-edit/text-edit.js.map