"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
|
|
const _sfc_main = {
|
|
mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
|
|
data() {
|
|
return {
|
|
formData: {
|
|
name: "",
|
|
phone: "",
|
|
address: ""
|
|
}
|
|
};
|
|
},
|
|
onLoad(options) {
|
|
if (options.mode === "edit") {
|
|
this.formData = {
|
|
name: decodeURIComponent(options.name || ""),
|
|
phone: options.phone || "",
|
|
address: decodeURIComponent(options.address || "")
|
|
};
|
|
}
|
|
},
|
|
methods: {
|
|
async onRefresh() {
|
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
this.stopPullRefresh();
|
|
},
|
|
goBack() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
confirmEdit() {
|
|
if (!this.formData.name.trim()) {
|
|
return common_vendor.index.showToast({
|
|
title: "请输入姓名",
|
|
icon: "none"
|
|
});
|
|
}
|
|
if (!/^1\d{10}$/.test(this.formData.phone)) {
|
|
return common_vendor.index.showToast({
|
|
title: "请输入正确的手机号",
|
|
icon: "none"
|
|
});
|
|
}
|
|
if (!this.formData.address.trim()) {
|
|
return common_vendor.index.showToast({
|
|
title: "请输入地址",
|
|
icon: "none"
|
|
});
|
|
}
|
|
const pages = getCurrentPages();
|
|
const prevPage = pages[pages.length - 2];
|
|
if (prevPage) {
|
|
const addressList = prevPage.$vm.addressList;
|
|
const index = addressList.findIndex(
|
|
(item) => item.phone === this.formData.phone && item.address === this.formData.address
|
|
);
|
|
if (index > -1) {
|
|
addressList[index] = { ...this.formData };
|
|
}
|
|
}
|
|
common_vendor.index.navigateBack();
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
_easycom_uni_icons2();
|
|
}
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
if (!Math) {
|
|
_easycom_uni_icons();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.p({
|
|
type: "left",
|
|
size: "20"
|
|
}),
|
|
b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
|
|
c: $data.formData.name,
|
|
d: common_vendor.o(($event) => $data.formData.name = $event.detail.value),
|
|
e: $data.formData.phone,
|
|
f: common_vendor.o(($event) => $data.formData.phone = $event.detail.value),
|
|
g: $data.formData.address,
|
|
h: common_vendor.o(($event) => $data.formData.address = $event.detail.value),
|
|
i: common_vendor.o((...args) => $options.confirmEdit && $options.confirmEdit(...args))
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-94b33c72"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/edit.js.map
|