city.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const WXAPI = require('apifm-wxapi')
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. page: 1 // 读取第几页
  8. },
  9. onLoad(e) {
  10. this.data.provinceId = e.provinceId
  11. this.data.cityId = e.cityId
  12. this.fxCityReport()
  13. },
  14. onShow: function () {
  15. },
  16. async fxCityReport() {
  17. const res = await WXAPI.fxCityReport({
  18. token: wx.getStorageSync('token'),
  19. provinceId: this.data.provinceId,
  20. cityId: this.data.cityId,
  21. page: this.data.page
  22. })
  23. if (res.code == 700) {
  24. if (this.data.page == 1) {
  25. this.setData({
  26. members: []
  27. })
  28. } else {
  29. wx.showToast({
  30. title: '没有更多了',
  31. icon: 'none'
  32. })
  33. }
  34. }
  35. if (res.code == 0) {
  36. if (this.data.page == 1) {
  37. this.setData({
  38. members: res.data.result
  39. })
  40. } else {
  41. this.setData({
  42. members: this.data.members.concat(res.data.result)
  43. })
  44. }
  45. }
  46. },
  47. onReachBottom: function() {
  48. this.data.page += 1
  49. this.fxCityReport()
  50. },
  51. onPullDownRefresh: function() {
  52. this.data.page = 1
  53. this.fxCityReport()
  54. wx.stopPullDownRefresh()
  55. },
  56. })