| | |
| | | "use strict"; |
| | | const common_vendor = require("../../common/vendor.js"); |
| | | const _sfc_main = {}; |
| | | const common_assets = require("../../common/assets.js"); |
| | | const api_index = require("../../api/index.js"); |
| | | if (!Array) { |
| | | const _easycom_navbar2 = common_vendor.resolveComponent("navbar"); |
| | | _easycom_navbar2(); |
| | |
| | | if (!Math) { |
| | | _easycom_navbar(); |
| | | } |
| | | function _sfc_render(_ctx, _cache) { |
| | | return { |
| | | a: common_vendor.p({ |
| | | title: "地址管理" |
| | | }) |
| | | }; |
| | | } |
| | | const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); |
| | | wx.createPage(MiniProgramPage); |
| | | const _sfc_main = { |
| | | __name: "index", |
| | | setup(__props) { |
| | | const addressList = common_vendor.ref([]); |
| | | async function getAddressList() { |
| | | await api_index.searchAddress({ limit: 100, page: 1 }).then((res) => { |
| | | if (res.code == 200) { |
| | | res.data.list.forEach((item) => { |
| | | res.data.list.forEach((item2) => { |
| | | item2.isDefault = item2.isDefault == 1 ? true : false; |
| | | item2.addressWhole = item2.regionName.replace(/[,#]/g, " ") + item2.address; |
| | | }); |
| | | }); |
| | | addressList.value = res.data.list; |
| | | } |
| | | }); |
| | | } |
| | | async function setDefault(isDefault, id, index1) { |
| | | if (isDefault == true) { |
| | | console.log("true"); |
| | | } else { |
| | | console.log("false"); |
| | | await api_index.setAddressDefaultApi(id).then((res) => { |
| | | if (res.code == 200) { |
| | | getAddressList(); |
| | | } else { |
| | | common_vendor.index.showToast({ |
| | | title: "设置失败", |
| | | image: "../../static/images/other/success.svg", |
| | | duration: 500 |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | async function deleteAddress(id) { |
| | | await api_index.deleteAddressApi(id).then((res) => { |
| | | if (res.code == 200) { |
| | | common_vendor.index.showToast({ |
| | | title: "删除成功", |
| | | image: "../../static/images/other/success.svg", |
| | | duration: 500 |
| | | }); |
| | | getAddressList(); |
| | | } |
| | | }); |
| | | } |
| | | function navToModify(id) { |
| | | common_vendor.index.navigateTo({ |
| | | url: `/pages/addressAdd/index?id=${id}` |
| | | }); |
| | | } |
| | | function navToAdd() { |
| | | let id = ""; |
| | | common_vendor.index.navigateTo({ |
| | | url: `/pages/addressAdd/index?id=${id}` |
| | | }); |
| | | } |
| | | common_vendor.onShow(async () => { |
| | | getAddressList(); |
| | | }); |
| | | return (_ctx, _cache) => { |
| | | return { |
| | | a: common_vendor.p({ |
| | | title: "地址管理" |
| | | }), |
| | | b: common_vendor.f(addressList.value, (item, index, i0) => { |
| | | return { |
| | | a: common_vendor.t(item.userName), |
| | | b: common_vendor.t(item.userPhone), |
| | | c: common_vendor.t(item.addressWhole), |
| | | d: item.id, |
| | | e: item.isDefault, |
| | | f: common_vendor.o(($event) => setDefault(item.isDefault, item.id)), |
| | | g: common_vendor.o(($event) => navToModify(item.id)), |
| | | h: common_vendor.o(($event) => deleteAddress(item.id)) |
| | | }; |
| | | }), |
| | | c: common_assets._imports_0$8, |
| | | d: common_assets._imports_1$5, |
| | | e: common_vendor.o(($event) => navToAdd()) |
| | | }; |
| | | }; |
| | | } |
| | | }; |
| | | wx.createPage(_sfc_main); |