爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. formData: {
  9. name: "",
  10. phone: "",
  11. address: ""
  12. }
  13. };
  14. },
  15. onLoad(options) {
  16. if (options.mode === "edit") {
  17. this.formData = {
  18. name: decodeURIComponent(options.name || ""),
  19. phone: options.phone || "",
  20. address: decodeURIComponent(options.address || "")
  21. };
  22. }
  23. },
  24. methods: {
  25. async onRefresh() {
  26. await new Promise((resolve) => setTimeout(resolve, 1e3));
  27. this.stopPullRefresh();
  28. },
  29. goBack() {
  30. common_vendor.index.navigateBack();
  31. },
  32. confirmEdit() {
  33. if (!this.formData.name.trim()) {
  34. return common_vendor.index.showToast({
  35. title: "请输入姓名",
  36. icon: "none"
  37. });
  38. }
  39. if (!/^1\d{10}$/.test(this.formData.phone)) {
  40. return common_vendor.index.showToast({
  41. title: "请输入正确的手机号",
  42. icon: "none"
  43. });
  44. }
  45. if (!this.formData.address.trim()) {
  46. return common_vendor.index.showToast({
  47. title: "请输入地址",
  48. icon: "none"
  49. });
  50. }
  51. const pages = getCurrentPages();
  52. const prevPage = pages[pages.length - 2];
  53. if (prevPage) {
  54. const addressList = prevPage.$vm.addressList;
  55. const index = addressList.findIndex(
  56. (item) => item.phone === this.formData.phone && item.address === this.formData.address
  57. );
  58. if (index > -1) {
  59. addressList[index] = { ...this.formData };
  60. }
  61. }
  62. common_vendor.index.navigateBack();
  63. }
  64. }
  65. };
  66. if (!Array) {
  67. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  68. _easycom_uni_icons2();
  69. }
  70. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  71. if (!Math) {
  72. _easycom_uni_icons();
  73. }
  74. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  75. return {
  76. a: common_vendor.p({
  77. type: "left",
  78. size: "20"
  79. }),
  80. b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  81. c: $data.formData.name,
  82. d: common_vendor.o(($event) => $data.formData.name = $event.detail.value),
  83. e: $data.formData.phone,
  84. f: common_vendor.o(($event) => $data.formData.phone = $event.detail.value),
  85. g: $data.formData.address,
  86. h: common_vendor.o(($event) => $data.formData.address = $event.detail.value),
  87. i: common_vendor.o((...args) => $options.confirmEdit && $options.confirmEdit(...args))
  88. };
  89. }
  90. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-94b33c72"]]);
  91. wx.createPage(MiniProgramPage);
  92. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/edit.js.map