address.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. addressList: [],
  7. },
  8. onLoad: function (options) {
  9. // 页面初始化 options为页面跳转所带来的参数
  10. this.getAddressList();
  11. },
  12. onReady: function () {
  13. // 页面渲染完成
  14. },
  15. onShow: function () {
  16. // 页面显示
  17. },
  18. getAddressList (){
  19. let that = this;
  20. util.request(api.AddressList).then(function (res) {
  21. if (res.errno === 0) {
  22. that.setData({
  23. addressList: res.data
  24. });
  25. }
  26. });
  27. },
  28. addressAddOrUpdate (event) {
  29. console.log(event)
  30. wx.navigateTo({
  31. url: '/pages/ucenter/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
  32. })
  33. },
  34. deleteAddress(event){
  35. console.log(event.target)
  36. let that = this;
  37. wx.showModal({
  38. title: '',
  39. content: '确定要删除地址?',
  40. success: function (res) {
  41. if (res.confirm) {
  42. let addressId = event.target.dataset.addressId;
  43. util.request(api.AddressDelete, { id: addressId }, 'POST').then(function (res) {
  44. if (res.errno === 0) {
  45. that.getAddressList();
  46. }
  47. });
  48. console.log('用户点击确定')
  49. }
  50. }
  51. })
  52. return false;
  53. },
  54. onHide: function () {
  55. // 页面隐藏
  56. },
  57. onUnload: function () {
  58. // 页面关闭
  59. }
  60. })