jinghaibing 2689ecca8e
Some checks are pending
Actions / Litemall-all (11) (push) Waiting to run
Actions / Litemall-all (11.0.3) (push) Waiting to run
Actions / Litemall-all (8) (push) Waiting to run
Actions / Litemall-all (8.0.192) (push) Waiting to run
Actions / Litemall-admin (10.x) (push) Waiting to run
Actions / Litemall-admin (12.x) (push) Waiting to run
Actions / Litemall-admin (14.x) (push) Waiting to run
Actions / Litemall-vue (10.x) (push) Waiting to run
Actions / Litemall-vue (12.x) (push) Waiting to run
Actions / Litemall-vue (14.x) (push) Waiting to run
Initial commit
2025-04-14 14:25:41 +08:00

93 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = getApp();
Page({
data: {
addressList: [],
total: 0
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
this.getAddressList();
},
getAddressList() {
let that = this;
util.request(api.AddressList).then(function(res) {
if (res.errno === 0) {
that.setData({
addressList: res.data.list,
total: res.data.total
});
}
});
},
addressAddOrUpdate(event) {
console.log(event)
//返回之前先取出上一页对象并设置addressId
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2];
if (prevPage.route == "pages/checkout/checkout") {
try {
wx.setStorageSync('addressId', event.currentTarget.dataset.addressId);
} catch (e) {
}
let addressId = event.currentTarget.dataset.addressId;
if (addressId && addressId != 0) {
wx.navigateBack();
} else {
wx.navigateTo({
url: '/pages/ucenter/addressAdd/addressAdd?id=' + addressId
})
}
} else {
wx.navigateTo({
url: '/pages/ucenter/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
})
}
},
deleteAddress(event) {
console.log(event.target)
let that = this;
wx.showModal({
title: '',
content: '确定要删除地址?',
success: function(res) {
if (res.confirm) {
let addressId = event.target.dataset.addressId;
util.request(api.AddressDelete, {
id: addressId
}, 'POST').then(function(res) {
if (res.errno === 0) {
that.getAddressList();
wx.removeStorage({
key: 'addressId',
success: function(res) {},
})
}
});
console.log('用户点击确定')
}
}
})
return false;
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
}
})