myAddress.js 3.4 KB
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  const _component_test = common_vendor.resolveComponent("test");
  (_easycom_u_navbar2 + _component_test)();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
  _easycom_u_navbar();
}
const _sfc_main = {
  setup(__props) {
    const addressList = common_vendor.ref([]);
    common_vendor.onShow(() => {
      addressList.value.splice(0);
      getAdressLists();
    });
    common_vendor.onLoad((e) => {
      isCheck.value = e.isCheck;
    });
    const newAdd = (type, id) => {
      console.log(type, id, "type id\u662F\u4EC0\u4E48");
      common_vendor.index.navigateTo({
        url: `/pages/mine/newAddress?id=${type == 0 ? id : ""}`
      });
    };
    let isCheck = common_vendor.ref(0);
    const checkAddress = (item) => {
      if (isCheck.value == 1) {
        const pop = getCurrentPages().pop();
        pop.$vm.getOpenerEventChannel().emit("steBack", item);
        common_vendor.index.navigateBack();
      }
    };
    const del = (id) => {
      common_vendor.index.showModal({
        title: "\u63D0\u793A",
        content: "\u786E\u8BA4\u5220\u9664\u6B64\u5730\u5740\u5417",
        success: function(res) {
          if (res.confirm) {
            getDelAdress(id);
          }
        }
      });
    };
    const getDelAdress = async (ids) => {
      try {
        const res = await api_index.getDelAdres(ids);
        common_vendor.index.showToast({ title: "\u5220\u9664\u6210\u529F\uFF01", icon: "none" });
        getAdressLists();
        console.log("getDelAdres", res);
      } catch (err) {
        console.log("getDelAdres", err);
      }
    };
    const getAdressLists = async () => {
      try {
        const res = await api_index.getAdressList();
        addressList.value = res;
        let defaultAdres = res.find((item) => item.is_default == 1);
        common_vendor.index.setStorageSync("defaultAdres", defaultAdres);
        console.log("getAdressList", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getAdressList", err);
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          placeholder: true,
          title: "\u6211\u7684\u5730\u5740",
          bgColor: "#fff",
          autoBack: true
        }),
        b: common_vendor.f(addressList.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.t(item.mobile),
            c: common_vendor.o(($event) => del(item.id)),
            d: common_vendor.o(($event) => newAdd(0, item.id)),
            e: common_vendor.t(item.diqu),
            f: common_vendor.t(item.address),
            g: "03a0db18-1-" + i0,
            h: item.id,
            i: common_vendor.o(($event) => checkAddress(item), item.id)
          };
        }),
        c: !addressList.value
      }, !addressList.value ? {} : {}, {
        d: common_vendor.o(($event) => newAdd(1))
      });
    };
  }
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/mine/myAddress.vue"]]);
wx.createPage(MiniProgramPage);