purchase-let/unpackage/dist/dev/mp-weixin/pagesOrder/addressList/addressList.js

105 lines
3.5 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.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_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) => {
if (addressList.value.length <= 1)
return common_vendor.index.$u.toast("最后一个地址无法删除!");
deleteInfo.value = item;
show.value = true;
};
const updateDefault = (item) => {
api_user.addressEditApi({
...item,
is_default: !item.is_default
}).then((res) => {
getAddressLists();
});
};
const deleteAddress = () => {
api_user.addressDeleteApi({
address_id: deleteInfo.value.address_id
}).then((res) => {
getAddressLists();
});
show.value = false;
};
const addressList = common_vendor.ref([]);
const getAddressLists = () => {
api_user.addressListsApi().then((res) => {
addressList.value = res.data.lists;
});
};
common_vendor.onShow(() => {
getAddressLists();
});
return (_ctx, _cache) => {
return {
a: common_vendor.f(addressList.value, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.real_name),
b: common_vendor.t(item.phone),
c: common_vendor.t(item.detail),
d: item.is_default
}, item.is_default ? {
e: common_assets._imports_0
} : {
f: common_assets._imports_1
}, {
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
});
}),
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);