"use strict"; var common_vendor = require("../common/vendor.js"); var api_order = require("../api/order.js"); require("../common/request.js"); const EvanSwitch = () => "../components/evan-switch/evan-switch.js"; const _sfc_main = { components: { EvanSwitch }, data() { return { content: null, type: null, addressId: null, isDefault: false, addressList: [[], [], []], multiIndex: [0, 0, 0], address: [], form: { realName: null, phone: null, detail: null, address: null, isDefault: 0 } }; }, onLoad(option) { console.log("option", option); this.type = option.type; if (this.type == "edit") { common_vendor.index.setNavigationBarTitle({ title: "\u4FEE\u6539\u6536\u8D27\u5730\u5740" }); this.addressId = option.addressId; } else { common_vendor.index.setNavigationBarTitle({ title: "\u65B0\u589E\u6536\u8D27\u5730\u5740" }); } this.getCitys(); }, methods: { submit() { if (this.type == "add") { this.addAddress(); } else if (this.type == "edit") { this.editAddress(); } }, editAddress() { this.form.isDefault = this.isDefault ? 1 : 0; api_order.editAddress(this.form).then((res) => { if (res.code == 200) { common_vendor.index.showToast({ icon: "success", title: "\u64CD\u4F5C\u6210\u529F" }); setTimeout(function() { common_vendor.index.$emit("refreshAddress"); common_vendor.index.navigateBack({ delta: 1 }); }, 500); } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }, (rej) => { }); }, addAddress() { this.form.isDefault = this.isDefault ? 1 : 0; api_order.addAddress(this.form).then((res) => { if (res.code == 200) { common_vendor.index.showToast({ icon: "success", title: "\u64CD\u4F5C\u6210\u529F" }); setTimeout(function() { common_vendor.index.$emit("refreshAddress"); common_vendor.index.navigateBack({ delta: 1 }); }, 500); } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }, (rej) => { }); }, pickerChange(e) { this.multiIndex = e.detail.value; this.form.address = this.addressList[0][this.multiIndex[0]].n + this.addressList[1][this.multiIndex[1]].n + this.addressList[2][this.multiIndex[2]].n; this.form.province = this.addressList[0][this.multiIndex[0]].n; this.form.city = this.addressList[1][this.multiIndex[1]].n; this.form.district = this.addressList[2][this.multiIndex[2]].n; this.form.cityId = this.addressList[1][this.multiIndex[1]].v; }, pickerColumnchange(e) { if (e.detail.column === 0) { this.multiIndex[0] = e.detail.value; this.addressList[1] = this.address[this.multiIndex[0]].c; this.addressList[2] = this.address[this.multiIndex[0]].c[0].c; this.multiIndex.splice(1, 1, 0); this.multiIndex.splice(2, 1, 0); } if (e.detail.column === 1) { this.multiIndex[1] = e.detail.value; this.addressList[2] = this.address[this.multiIndex[0]].c[this.multiIndex[1]].c; this.multiIndex.splice(2, 1, 0); } if (e.detail.column === 2) { this.multiIndex[2] = e.detail.value; } }, getCitys() { api_order.getCitys().then((res) => { if (res.code == 200) { this.address = res.data; for (var i = 0; i < this.address.length; i++) { this.addressList[0].push(this.address[i]); } for (var i = 0; i < this.address[0].c.length; i++) { this.addressList[1].push(this.address[0].c[i]); } for (var i = 0; i < this.address[0].c[0].c.length; i++) { this.addressList[2].push(this.address[0].c[0].c[i]); } } else { common_vendor.index.showToast({ icon: "none", title: "\u8BF7\u6C42\u5931\u8D25" }); } }, (rej) => { }); } } }; if (!Array) { const _easycom_evan_switch2 = common_vendor.resolveComponent("evan-switch"); _easycom_evan_switch2(); } const _easycom_evan_switch = () => "../components/evan-switch/evan-switch.js"; if (!Math) { _easycom_evan_switch(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: $data.content, b: common_vendor.o(($event) => $data.content = $event.detail.value), c: common_vendor.o(($event) => _ctx.parseAddress()), d: $data.form.realName, e: common_vendor.o(($event) => $data.form.realName = $event.detail.value), f: $data.form.phone, g: common_vendor.o(($event) => $data.form.phone = $event.detail.value), h: $data.form.address, i: common_vendor.o(($event) => $data.form.address = $event.detail.value), j: $data.multiIndex, k: $data.addressList, l: common_vendor.o((...args) => $options.pickerChange && $options.pickerChange(...args)), m: common_vendor.o((...args) => $options.pickerColumnchange && $options.pickerColumnchange(...args)), n: $data.form.detail, o: common_vendor.o(($event) => $data.form.detail = $event.detail.value), p: common_vendor.o(($event) => $data.isDefault = $event), q: common_vendor.p({ activeColor: "#0bb3f2", inactiveColor: "rgba(0, 0, 0, 0.1)", modelValue: $data.isDefault }), r: common_vendor.o(($event) => $options.submit()) }; } var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_user/addAddress.vue"]]); wx.createPage(MiniProgramPage);