"use strict"; const common_vendor = require("../../common/vendor.js"); const api_index = require("../../api/index.js"); if (!Array) { const _easycom_wd_navbar2 = common_vendor.resolveComponent("wd-navbar"); const _easycom_wd_input2 = common_vendor.resolveComponent("wd-input"); const _easycom_wd_switch2 = common_vendor.resolveComponent("wd-switch"); (_easycom_wd_navbar2 + _easycom_wd_input2 + _easycom_wd_switch2)(); } const _easycom_wd_navbar = () => "../../uni_modules/wot-design-uni/components/wd-navbar/wd-navbar.js"; const _easycom_wd_input = () => "../../uni_modules/wot-design-uni/components/wd-input/wd-input.js"; const _easycom_wd_switch = () => "../../uni_modules/wot-design-uni/components/wd-switch/wd-switch.js"; if (!Math) { (_easycom_wd_navbar + _easycom_wd_input + _easycom_wd_switch)(); } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "add", setup(__props) { common_vendor.onLoad((options) => { if (options.id) { api_index.api.addressInfo({ id: options.id }).then((res) => { const resData = res || {}; resData.isDefault = resData.isDefault ? true : false; const formKeys = Object.keys(from.value); const updateData = {}; formKeys.forEach((key) => { if (resData.hasOwnProperty(key)) { updateData[key] = resData[key]; } }); Object.assign(from.value, updateData); }); } }); const from = common_vendor.ref({ receiverName: "", receiverPhone: "", receiverArea: "", receiverAddress: "", isDefault: true, status: 0, id: "" }); const add_Address = () => { let data = JSON.parse(JSON.stringify(from.value)); data.isDefault = data.isDefault ? 1 : 0; if (data.id) { api_index.api.addressUp(data).then((res) => { common_vendor.index.navigateBack(); }); } else { api_index.api.addressAdd(data).then((res) => { common_vendor.index.navigateBack(); }); } }; const back = () => { common_vendor.index.navigateBack(); }; return (_ctx, _cache) => { return { a: common_vendor.o(back), b: common_vendor.p({ title: "新增地址", safeAreaInsetTop: true, ["left-arrow"]: true }), c: common_vendor.o(($event) => from.value.receiverName = $event), d: common_vendor.p({ type: "text", ["no-border"]: true, placeholder: "请输入收货人姓名", modelValue: from.value.receiverName }), e: common_vendor.o(($event) => from.value.receiverPhone = $event), f: common_vendor.p({ type: "number", ["no-border"]: true, placeholder: "请输入手机号", modelValue: from.value.receiverPhone }), g: common_vendor.o(($event) => from.value.receiverArea = $event), h: common_vendor.p({ type: "text", ["no-border"]: true, placeholder: "请输入省市区", modelValue: from.value.receiverArea }), i: common_vendor.o(($event) => from.value.receiverAddress = $event), j: common_vendor.p({ type: "text", ["no-border"]: true, placeholder: "请输入详细地址", modelValue: from.value.receiverAddress }), k: common_vendor.o(($event) => from.value.isDefault = $event), l: common_vendor.p({ size: "20px", modelValue: from.value.isDefault }), m: common_vendor.o(add_Address) }; }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ef9226d4"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/address/add.js.map