mineAddress.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // pages/mineAddress/mineAddress.js
  2. var app = getApp();
  3. const request = require("../../utils/request.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ad_list: [],
  10. from: 0,//0:我的页面进入,1:下单页修改进入
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad(options) {
  16. this.setData({
  17. from: options.from
  18. })
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady() {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow() {
  29. this.getAddressList();
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide() {
  35. },
  36. /**
  37. * 生命周期函数--监听页面卸载
  38. */
  39. onUnload() {
  40. },
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh() {
  45. },
  46. /**
  47. * 页面上拉触底事件的处理函数
  48. */
  49. onReachBottom() {
  50. },
  51. /**
  52. * 用户点击右上角分享
  53. */
  54. onShareAppMessage() {
  55. },
  56. selectFun(event) {
  57. // app.globalData.adress_select = event.currentTarget.dataset.ad;
  58. if(this.data.from != 0){
  59. const eventChannel = this.getOpenerEventChannel()
  60. eventChannel.emit('getSelectAd', event.currentTarget.dataset.ad);
  61. wx.navigateBack({
  62. delta: 1
  63. })
  64. }
  65. },
  66. editFun(event) {
  67. let userAddressId = event.currentTarget.dataset.adid;
  68. wx.navigateTo({
  69. url: '../editAddress/editAddress?userAddressId=' + userAddressId,
  70. })
  71. },
  72. getAddressList() {
  73. let that = this;
  74. request.getData(
  75. 'app/user/address/list',{},
  76. res => {
  77. that.setData({
  78. ad_list: res.data.data
  79. })
  80. }
  81. )
  82. },
  83. toNewEdit() {
  84. wx.navigateTo({
  85. url: '../editAddress/editAddress',
  86. })
  87. },
  88. })