123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- "use strict";
- const common_vendor = require("../common/vendor.js");
- const api_order = require("../api/order.js");
- const common_assets = require("../common/assets.js");
- const _sfc_main = {
- data() {
- return {
- address: []
- };
- },
- onLoad() {
- this.getUserAddr();
- common_vendor.index.$on("refreshAddress", () => {
- this.getUserAddr();
- });
- },
- // mounted() {
- // this.getUserAddr()
- // },
- methods: {
- // 获取用户收货地址
- getUserAddr() {
- this.userInfo = JSON.parse(common_vendor.index.getStorageSync("userInfo"));
- api_order.userAddr(this.userInfo.userId).then(
- (res) => {
- if (res.code == 200) {
- console.log("用户收货地址>>>>", res.data);
- this.address = res.data;
- } else {
- common_vendor.index.showToast({
- title: res.msg,
- icon: "none"
- });
- }
- },
- (rej) => {
- }
- );
- },
- // 选地址
- selectAddress(item) {
- common_vendor.index.$emit("updateAddress", item);
- common_vendor.index.navigateBack({
- delta: 1
- });
- },
- // 编辑地址
- editAddress(item) {
- common_vendor.index.navigateTo({
- url: "./addAddress?type=edit&addressId=" + item.addressId
- });
- },
- // 删除所有地址(暂无)
- // delAllAddress(item) {
- // uni.showModal({
- // title: "提示",
- // content: "确认删除所有地址吗?",
- // showCancel: true,
- // cancelText: '取消',
- // confirmText: '确定',
- // success: res => {
- // if (res.confirm) {
- // var data = {}
- // delAllAddress(data).then(
- // res => {
- // if (res.code == 200) {
- // uni.showToast({
- // icon: 'success',
- // title: "操作成功",
- // });
- // this.getAddressList()
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: "请求失败",
- // });
- // }
- // },
- // rej => {}
- // );
- // } else {
- // // 否则点击了取消
- // }
- // }
- // })
- // },
- // 删除地址
- delAddress(item) {
- common_vendor.index.showModal({
- title: "提示",
- content: "确认删除此地址吗?",
- showCancel: true,
- cancelText: "取消",
- confirmText: "确定",
- success: (res) => {
- if (res.confirm) {
- var data = {
- addressId: item.addressId
- };
- api_order.delAddress(data).then(
- (res2) => {
- if (res2.code == 200) {
- common_vendor.index.showToast({
- icon: "success",
- title: "操作成功"
- });
- this.getUserAddr();
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: "请求失败"
- });
- }
- },
- (rej) => {
- }
- );
- }
- }
- });
- },
- // getAddressList(){
- // uni.showLoading({
- // title:"正在加载中"
- // })
- // getAddressList().then(
- // res => {
- // uni.hideLoading()
- // if(res.code==200){
- // this.address=res.data;
- // }else{
- // uni.showToast({
- // icon:'none',
- // title: "请求失败",
- // });
- // }
- // },
- // rej => {}
- // );
- // },
- // 新建收货地址
- addAdress() {
- common_vendor.index.navigateTo({
- url: "./addAddress?type=add"
- });
- }
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: common_vendor.f($data.address, (item, index, i0) => {
- return common_vendor.e({
- a: item.isDefault == 1
- }, item.isDefault == 1 ? {} : {}, {
- b: common_vendor.t(item.province),
- c: common_vendor.t(item.city),
- d: common_vendor.t(item.district),
- e: common_vendor.t(item.detail),
- f: common_vendor.t(item.realName),
- g: common_vendor.t(_ctx.$parsePhone(item.phone)),
- h: common_vendor.o(($event) => $options.selectAddress(item), index),
- i: common_vendor.o(($event) => $options.delAddress(item), index),
- j: common_vendor.o(($event) => $options.editAddress(item), index),
- k: index
- });
- }),
- b: common_assets._imports_0$14,
- c: common_assets._imports_1$8,
- d: $data.address.length == 0
- }, $data.address.length == 0 ? {
- e: common_assets._imports_2$3,
- f: common_vendor.o(($event) => _ctx.getAddressList())
- } : {}, {
- g: common_vendor.o((...args) => $options.addAdress && $options.addAdress(...args))
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
- wx.createPage(MiniProgramPage);
|