address.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_order = require("../api/order.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. address: []
  9. };
  10. },
  11. onLoad() {
  12. this.getUserAddr();
  13. common_vendor.index.$on("refreshAddress", () => {
  14. this.getUserAddr();
  15. });
  16. },
  17. methods: {
  18. getUserAddr() {
  19. this.userInfo = JSON.parse(common_vendor.index.getStorageSync("userInfo"));
  20. api_order.userAddr(this.userInfo.userId).then((res) => {
  21. if (res.code == 200) {
  22. console.log("\u7528\u6237\u6536\u8D27\u5730\u5740>>>>", res.data);
  23. this.address = res.data;
  24. } else {
  25. common_vendor.index.showToast({
  26. title: res.msg,
  27. icon: "none"
  28. });
  29. }
  30. }, (rej) => {
  31. });
  32. },
  33. selectAddress(item) {
  34. common_vendor.index.$emit("updateAddress", item);
  35. common_vendor.index.navigateBack({
  36. delta: 1
  37. });
  38. },
  39. editAddress(item) {
  40. common_vendor.index.navigateTo({
  41. url: "./addAddress?type=edit&addressId=" + item.addressId
  42. });
  43. },
  44. delAddress(item) {
  45. common_vendor.index.showModal({
  46. title: "\u63D0\u793A",
  47. content: "\u786E\u8BA4\u5220\u9664\u6B64\u5730\u5740\u5417?",
  48. showCancel: true,
  49. cancelText: "\u53D6\u6D88",
  50. confirmText: "\u786E\u5B9A",
  51. success: (res) => {
  52. if (res.confirm) {
  53. var data = {
  54. addressId: item.addressId
  55. };
  56. api_order.delAddress(data).then((res2) => {
  57. if (res2.code == 200) {
  58. common_vendor.index.showToast({
  59. icon: "success",
  60. title: "\u64CD\u4F5C\u6210\u529F"
  61. });
  62. this.getUserAddr();
  63. } else {
  64. common_vendor.index.showToast({
  65. icon: "none",
  66. title: "\u8BF7\u6C42\u5931\u8D25"
  67. });
  68. }
  69. }, (rej) => {
  70. });
  71. }
  72. }
  73. });
  74. },
  75. addAdress() {
  76. common_vendor.index.navigateTo({
  77. url: "./addAddress?type=add"
  78. });
  79. }
  80. }
  81. };
  82. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  83. return common_vendor.e({
  84. a: common_vendor.f($data.address, (item, index, i0) => {
  85. return common_vendor.e({
  86. a: item.isDefault == 1
  87. }, item.isDefault == 1 ? {} : {}, {
  88. b: common_vendor.t(item.province),
  89. c: common_vendor.t(item.city),
  90. d: common_vendor.t(item.district),
  91. e: common_vendor.t(item.detail),
  92. f: common_vendor.t(item.realName),
  93. g: common_vendor.t(_ctx.$parsePhone(item.phone)),
  94. h: common_vendor.o(($event) => $options.selectAddress(item)),
  95. i: common_vendor.o(($event) => $options.delAddress(item)),
  96. j: common_vendor.o(($event) => $options.editAddress(item)),
  97. k: index
  98. });
  99. }),
  100. b: $data.address.length == 0
  101. }, $data.address.length == 0 ? {
  102. c: common_vendor.o(($event) => _ctx.getAddressList())
  103. } : {}, {
  104. d: common_vendor.o((...args) => $options.addAdress && $options.addAdress(...args))
  105. });
  106. }
  107. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_user/address.vue"]]);
  108. wx.createPage(MiniProgramPage);