replenish.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // pages/stock/replenish.js
  2. const util = require('../../utils/util.js');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. searchParams:{
  10. pageNo:1,
  11. pageSize:10,
  12. storeName:'',
  13. },
  14. storeList:[],
  15. loadding: false,
  16. pullUpOn: true,
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.bindStoreList()
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面隐藏
  36. */
  37. onHide: function () {
  38. },
  39. onUnload: function () {
  40. },
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh: function () {
  45. this.setData({
  46. ["searchParams.pageNo"]: 1,
  47. pullUpOn: true,
  48. loadding: false,
  49. storeList: []
  50. })
  51. this.bindStoreList()
  52. setTimeout(() => {
  53. wx.stopPullDownRefresh()
  54. }, 300);
  55. },
  56. /**
  57. * 页面上拉触底事件的处理函数
  58. */
  59. onReachBottom: function () {
  60. var that = this
  61. //只是测试效果,逻辑以实际数据为准
  62. this.setData({
  63. loadding: true,
  64. pullUpOn: true
  65. })
  66. this.setData({
  67. ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
  68. })
  69. this.bindStoreList()
  70. },
  71. onPageScroll(e) {
  72. this.setData({
  73. scrollTop: e.scrollTop
  74. })
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage: function () {
  80. },
  81. toDetail(e){
  82. wx.navigateTo({
  83. url: '/pages/stock/replenishDetail?storeId='+e.currentTarget.dataset.id,
  84. })
  85. },
  86. bindStoreList(){
  87. var that = this
  88. util.request(util.api.storeListPage, that.data.searchParams, "GET", false, true,app.globalData.token).then((res)=>{
  89. if (res.code == 200) {
  90. if (res.result.records.length > 0) {
  91. if (that.data.storeList.length > 0) {
  92. let list = that.data.productList
  93. var records = res.result.records
  94. records.forEach(record => {
  95. list.push(record)
  96. });
  97. that.setData({
  98. storeList: list
  99. })
  100. } else {
  101. that.setData({
  102. storeList: res.result.records
  103. })
  104. }
  105. } else {
  106. that.setData({
  107. loadding: false,
  108. pullUpOn: false,
  109. ["searchParams.pageNo"]:that.data.searchParams.pageNo-1
  110. })
  111. }
  112. }
  113. }).catch((res) => {})
  114. },
  115. })