2024-04-27 18:02:43 +08:00
|
|
|
"use strict";
|
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
|
const common_assets = require("../../common/assets.js");
|
2024-04-28 18:08:57 +08:00
|
|
|
const api_user = require("../../api/user.js");
|
|
|
|
require("../../utils/request.js");
|
|
|
|
require("../../config/app.js");
|
|
|
|
require("../../store/user.js");
|
2024-04-27 18:02:43 +08:00
|
|
|
if (!Array) {
|
|
|
|
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
|
|
|
|
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
|
|
|
|
(_easycom_up_icon2 + _easycom_up_button2)();
|
|
|
|
}
|
|
|
|
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
|
|
const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
|
|
|
|
if (!Math) {
|
|
|
|
(_easycom_up_icon + _easycom_up_button + modal)();
|
|
|
|
}
|
|
|
|
const modal = () => "../../components/modal.js";
|
|
|
|
const _sfc_main = {
|
|
|
|
__name: "addressList",
|
|
|
|
setup(__props) {
|
|
|
|
const navTo = (url) => {
|
|
|
|
common_vendor.index.navigateTo({
|
|
|
|
url
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const show = common_vendor.ref(false);
|
|
|
|
const deleteInfo = common_vendor.ref({});
|
|
|
|
const showDelete = (item) => {
|
2024-04-30 18:08:36 +08:00
|
|
|
if (addressList.value.length <= 1)
|
|
|
|
return common_vendor.index.$u.toast("最后一个地址无法删除!");
|
2024-04-27 18:02:43 +08:00
|
|
|
deleteInfo.value = item;
|
|
|
|
show.value = true;
|
|
|
|
};
|
2024-04-29 18:14:58 +08:00
|
|
|
const updateDefault = (item) => {
|
|
|
|
api_user.addressEditApi({
|
|
|
|
...item,
|
|
|
|
is_default: !item.is_default
|
2024-04-30 18:08:36 +08:00
|
|
|
}).then((res) => {
|
|
|
|
getAddressLists();
|
2024-04-29 18:14:58 +08:00
|
|
|
});
|
|
|
|
};
|
2024-04-27 18:02:43 +08:00
|
|
|
const deleteAddress = () => {
|
2024-04-29 18:14:58 +08:00
|
|
|
api_user.addressDeleteApi({
|
|
|
|
address_id: deleteInfo.value.address_id
|
2024-04-30 18:08:36 +08:00
|
|
|
}).then((res) => {
|
|
|
|
getAddressLists();
|
2024-04-29 18:14:58 +08:00
|
|
|
});
|
2024-04-27 18:02:43 +08:00
|
|
|
show.value = false;
|
|
|
|
};
|
2024-04-28 18:08:57 +08:00
|
|
|
const addressList = common_vendor.ref([]);
|
|
|
|
const getAddressLists = () => {
|
|
|
|
api_user.addressListsApi().then((res) => {
|
|
|
|
addressList.value = res.data.lists;
|
|
|
|
});
|
|
|
|
};
|
2024-04-29 10:44:50 +08:00
|
|
|
common_vendor.onShow(() => {
|
|
|
|
getAddressLists();
|
|
|
|
});
|
2024-04-27 18:02:43 +08:00
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return {
|
2024-04-28 18:08:57 +08:00
|
|
|
a: common_vendor.f(addressList.value, (item, index, i0) => {
|
2024-04-27 18:02:43 +08:00
|
|
|
return common_vendor.e({
|
2024-04-28 18:08:57 +08:00
|
|
|
a: common_vendor.t(item.real_name),
|
|
|
|
b: common_vendor.t(item.phone),
|
2024-04-29 18:14:58 +08:00
|
|
|
c: common_vendor.t(item.detail),
|
|
|
|
d: item.is_default
|
|
|
|
}, item.is_default ? {
|
2024-04-30 18:08:36 +08:00
|
|
|
e: common_assets._imports_0
|
2024-04-29 18:14:58 +08:00
|
|
|
} : {
|
2024-04-30 18:08:36 +08:00
|
|
|
f: common_assets._imports_1
|
2024-04-27 18:02:43 +08:00
|
|
|
}, {
|
2024-04-29 18:14:58 +08:00
|
|
|
g: common_vendor.o(($event) => updateDefault(item), index),
|
|
|
|
h: "5e66515e-0-" + i0,
|
|
|
|
i: common_vendor.o(($event) => showDelete(item), index),
|
|
|
|
j: "5e66515e-1-" + i0,
|
|
|
|
k: common_vendor.o(($event) => navTo("/pagesOrder/addressEdit/addressEdit?mode=edit&address_id=" + item.address_id), index),
|
|
|
|
l: index
|
2024-04-27 18:02:43 +08:00
|
|
|
});
|
|
|
|
}),
|
|
|
|
b: common_vendor.p({
|
|
|
|
name: "trash"
|
|
|
|
}),
|
|
|
|
c: common_vendor.p({
|
|
|
|
name: "edit-pen"
|
|
|
|
}),
|
|
|
|
d: common_vendor.o(($event) => navTo("/pagesOrder/addressEdit/addressEdit")),
|
|
|
|
e: common_vendor.p({
|
|
|
|
color: "#20B128",
|
|
|
|
shape: "circle"
|
|
|
|
}),
|
|
|
|
f: common_vendor.o(($event) => show.value = false),
|
|
|
|
g: common_vendor.o(deleteAddress),
|
|
|
|
h: common_vendor.p({
|
|
|
|
show: show.value,
|
|
|
|
title: "确认删除吗",
|
|
|
|
content: "删除后不可恢复"
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pagesOrder/addressList/addressList.vue"]]);
|
|
|
|
wx.createPage(MiniProgramPage);
|