address.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // pages/my/address/address.js
  2. const app =getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. addressList:[],
  9. pageindex: 1
  10. },
  11. onLoad:function(){
  12. this.address()
  13. },
  14. /**
  15. * 页面上拉触底事件的处理函数
  16. */
  17. onReachBottom: function () {
  18. this.setData({pageindex:this.data.pageindex+=1})
  19. this.address()
  20. },
  21. addSite(e){
  22. let {parmise} = e.currentTarget.dataset
  23. console.log(parmise);
  24. wx.navigateTo({
  25. url: './addSite/addSite?parmise='+parmise,
  26. })
  27. },
  28. editSite(e){
  29. let {parmise} = e.currentTarget.dataset
  30. console.log(parmise);
  31. wx.navigateTo({
  32. url: './addSite/addSite?parmise='+JSON.stringify(parmise),
  33. })
  34. },
  35. //获取地址列表
  36. address(){
  37. var that=this;
  38. app.api.useApi(app.globalData.baseAppUrl + "api/address/index", {
  39. network_id: 1,
  40. page: that.data.pageindex
  41. }, "get").then(function (res) {
  42. if (res.original.code != 200) {
  43. wx.showLoading({
  44. title:res.original.message.msg,
  45. })
  46. that.setData({pageindex: that.data.pageindex -= 1})
  47. } else {
  48. if (that.data.pageindex == 1) {
  49. that.setData({addressList: []})
  50. }
  51. if (res.original.message.data.data.length > 0) {
  52. that.setData({addressList: that.data.addressList.concat(res.original.message.data.data)})
  53. } else {
  54. that.setData({pageindex: that.data.pageindex -= 1})
  55. }
  56. }
  57. setTimeout(function () {
  58. wx.hideLoading({
  59. success: (res) => {},
  60. })
  61. }, 2000);
  62. }).catch(function (err) {
  63. console.log(222);
  64. })
  65. }
  66. })