"use strict"; const common_vendor = require("../../common/vendor.js"); const api_user = require("../../api/user.js"); require("../../utils/request.js"); require("../../config/app.js"); require("../../store/user.js"); if (!Array) { const _easycom_up_input2 = common_vendor.resolveComponent("up-input"); const _easycom_up_form_item2 = common_vendor.resolveComponent("up-form-item"); const _easycom_up_form2 = common_vendor.resolveComponent("up-form"); const _easycom_up_switch2 = common_vendor.resolveComponent("up-switch"); const _easycom_up_button2 = common_vendor.resolveComponent("up-button"); (_easycom_up_input2 + _easycom_up_form_item2 + _easycom_up_form2 + _easycom_up_switch2 + _easycom_up_button2)(); } const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js"; const _easycom_up_form_item = () => "../../uni_modules/uview-plus/components/u-form-item/u-form-item.js"; const _easycom_up_form = () => "../../uni_modules/uview-plus/components/u-form/u-form.js"; const _easycom_up_switch = () => "../../uni_modules/uview-plus/components/u-switch/u-switch.js"; const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js"; if (!Math) { (_easycom_up_input + _easycom_up_form_item + _easycom_up_form + _easycom_up_switch + _easycom_up_button)(); } const _sfc_main = { __name: "addressEdit", setup(__props) { const mode = common_vendor.ref("add"); const formData = common_vendor.ref({ real_name: "", phone: "", detail: "", is_default: 0 }); const rules = common_vendor.ref({ real_name: [{ required: true, message: "请输入姓名", trigger: ["blur"] }], phone: [{ required: true, message: "请输入手机号", trigger: ["blur"] }], detail: [{ required: true, message: "请输入地址", trigger: ["blur"] }] }); const uForm = common_vendor.ref(null); const submit = () => { uForm.value.validate().then(() => { console.log("验证通过"); if (mode.value == "add") { api_user.addressCreateApi(formData.value).then((res) => { common_vendor.index.$u.toast(res.msg); common_vendor.index.$u.sleep(800).then((res2) => { common_vendor.index.navigateBack(); }); }); } else { api_user.addressEditApi(formData.value).then((res) => { common_vendor.index.$u.toast(res.msg); common_vendor.index.$u.sleep(800).then((res2) => { common_vendor.index.navigateBack(); }); }); } }).catch(() => { console.log("验证失败"); }); }; const getAddressDetil = (address_id) => { api_user.addressDetailApi({ address_id }).then((res) => { formData.value = res.data; }); }; common_vendor.onLoad((options) => { if (options.mode == "edit" && options.address_id) { mode.value = "edit"; common_vendor.index.setNavigationBarTitle({ title: "编辑地址" }); getAddressDetil(options.address_id); } else common_vendor.index.setNavigationBarTitle({ title: "新增地址" }); }); return (_ctx, _cache) => { return { a: common_vendor.o(($event) => formData.value.real_name = $event), b: common_vendor.p({ disabledColor: "#ffffff", border: "none", placeholder: "请填写收货人姓名", modelValue: formData.value.real_name }), c: common_vendor.p({ label: "收货人", prop: "real_name", borderBottom: true }), d: common_vendor.o(($event) => formData.value.phone = $event), e: common_vendor.p({ disabledColor: "#ffffff", type: "number", placeholder: "请填写联系电话", border: "none", modelValue: formData.value.phone }), f: common_vendor.p({ label: "联系电话", prop: "phone", borderBottom: true }), g: common_vendor.o(($event) => formData.value.detail = $event), h: common_vendor.p({ disabledColor: "#ffffff", placeholder: "请填写详细地址", border: "none", modelValue: formData.value.detail }), i: common_vendor.p({ label: "详细地址", prop: "detail", borderBottom: true }), j: common_vendor.sr(uForm, "663ade36-0", { "k": "uForm" }), k: common_vendor.p({ labelPosition: "left", model: formData.value, rules: rules.value, labelWidth: "100" }), l: common_vendor.o(($event) => formData.value.is_default = $event), m: common_vendor.p({ activeValue: 1, inactiveValue: 0, activeColor: "#20B128", modelValue: formData.value.is_default }), n: common_vendor.o(submit), o: common_vendor.p({ color: "#20B128", shape: "circle" }) }; }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pagesOrder/addressEdit/addressEdit.vue"]]); wx.createPage(MiniProgramPage);