store.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // pages/store/store.js
  2. const util = require('../../utils/util.js');
  3. const api = require('../../config/api.js');
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. type: 21,
  11. storeList: [],
  12. hasData: true,
  13. fetcherData: {
  14. type: 21,
  15. address: '',
  16. page: 1,
  17. size: 20,
  18. name: ''
  19. }
  20. },
  21. gotoWV: function (event) {
  22. let id = event.detail
  23. wx.navigateTo({
  24. url: `/pages/webview/index?id=${id}`,
  25. })
  26. },
  27. toSearch(e) {
  28. var type = e.currentTarget.dataset.type
  29. console.log(type)
  30. wx.navigateTo({
  31. url: `/pages/searchRoom/searchRoom?type=` + type
  32. })
  33. },
  34. getStoreList() {
  35. if (this.data.hasData) {
  36. util.request(api.BrandList, this.data.fetcherData).then((res) => {
  37. console.log(res)
  38. if (res.errno === 0) {
  39. if (res.data.data.length != 0) {
  40. this.setData({
  41. storeList: this.data.storeList.concat(res.data.data),
  42. 'fetcherData.page': this.data.fetcherData.page + 1
  43. })
  44. } else {
  45. this.setData({
  46. hasData: false
  47. })
  48. }
  49. }
  50. });
  51. } else {
  52. console.log('没有更多数据')
  53. }
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad: function (options) {
  59. getApp().checkNetStatu();
  60. this.getStoreList()
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh() {
  86. this.setData({
  87. storeList: [],
  88. 'fetcherData.page': 1,
  89. hasData: true
  90. });
  91. this.getStoreList()
  92. app.onPullDownRefresh()
  93. },
  94. onReachBottom: function () {
  95. this.getStoreList()
  96. console.log('onReachBottom')
  97. },
  98. /**
  99. * 用户点击右上角分享
  100. */
  101. onShareAppMessage: function () {
  102. }
  103. })