jiangchengfeiyi-xiaochengxu/unpackage/dist/dev/mp-weixin/pages/order/component/addressComponent.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

2024-11-03 23:34:53 +00:00
"use strict";
const common_vendor = require("../../../common/vendor.js");
const pages_utils_emitter = require("../../utils/emitter.js");
const api_request = require("../../../api/request.js");
2024-11-06 12:46:53 +00:00
require("../../../store/userStore.js");
2024-11-03 23:34:53 +00:00
const _sfc_main = {
__name: "addressComponent",
setup(__props) {
common_vendor.ref([null, null]);
const addressList = common_vendor.ref([]);
2024-11-06 12:46:53 +00:00
const userInfo = common_vendor.wx$1.getStorageSync("userInfo");
common_vendor.onShow(() => {
2024-11-03 23:34:53 +00:00
getAddressList();
});
const getAddressList = async () => {
const res = await common_vendor.index.request({
2024-11-06 12:46:53 +00:00
url: api_request.baseUrl + "/address/list",
2024-11-03 23:34:53 +00:00
method: "POST",
data: {
2024-11-06 12:46:53 +00:00
id: userInfo.id
2024-11-03 23:34:53 +00:00
}
});
addressList.value = res.data.data;
};
const close = () => {
pages_utils_emitter.emitter.emit("close");
};
const radioChange = (event) => {
const index = event.detail.value;
const temp = addressList.value[index];
pages_utils_emitter.emitter.emit("addressInfo", temp);
pages_utils_emitter.emitter.emit("close");
};
2024-11-06 12:46:53 +00:00
const toNewAddress = () => {
common_vendor.index.navigateTo({
url: "/pages/Shopping-cart/newaddress_Info/newaddress_Info"
});
};
2024-11-03 23:34:53 +00:00
return (_ctx, _cache) => {
return {
a: common_vendor.o(close),
b: common_vendor.f(addressList.value, (item, index, i0) => {
return {
a: index,
b: index === _ctx.current,
c: common_vendor.t(item.name),
d: common_vendor.t(item.phone),
e: common_vendor.t(item.detailAddress),
f: index
};
}),
2024-11-06 12:46:53 +00:00
c: common_vendor.o(radioChange),
d: common_vendor.o(toNewAddress)
2024-11-03 23:34:53 +00:00
};
};
}
};
2024-11-06 12:46:53 +00:00
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c20b9e4d"]]);
2024-11-03 23:34:53 +00:00
wx.createComponent(Component);