address.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/shopping/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
  32. })
  33. },
  34. selectAddress(event){
  35. console.log(event.currentTarget.dataset.addressId);
  36. try {
  37. wx.setStorageSync('addressId', event.currentTarget.dataset.addressId);
  38. } catch (e) {
  39. }
  40. //选择该收货地址
  41. wx.redirectTo({
  42. url: '/pages/shopping/checkout/checkout'
  43. })
  44. },
  45. onHide: function () {
  46. // 页面隐藏
  47. },
  48. onUnload: function () {
  49. // 页面关闭
  50. }
  51. })