index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const app = getApp()
  2. Page({
  3. data: {
  4. tableData: [],
  5. keyword:'',
  6. from: 0,
  7. size: 10
  8. },
  9. onLoad: function(options) {
  10. this.setData({
  11. spinShow: true
  12. });
  13. this.search(true)
  14. },
  15. onPullDownRefresh() {
  16. this.setData({ spinShow: true });
  17. if (!this.loading) {
  18. this.setData({ from:0,tableData:[]});
  19. this.search(true)
  20. }
  21. },
  22. onReachBottom() {
  23. if (!this.loading && this.data.from > -1) {
  24. this.search(false)
  25. }
  26. },
  27. gotoDetail( e ){
  28. let {id,out} = e.currentTarget.dataset;
  29. if( out ){
  30. wx.navigateTo({
  31. url: `/pages/detail/out/index?id=${id}`,
  32. })
  33. }else{
  34. wx.navigateTo({
  35. url: `/pages/detail/visit/index?id=${id}`,
  36. })
  37. }
  38. },
  39. onInputEvent(e){
  40. let {value} = e.detail;
  41. if( this.data.keyword == value) return;
  42. this.setData({keyword: value, from:0})
  43. this.search( )
  44. },
  45. search: function() {
  46. let {from, size, keyword, tableData} = this.data;
  47. let _this = this
  48. let param = {from, size, keyword}
  49. app.formPost('User.search', param ).then(res => {
  50. _this.setData({spinShow: false});
  51. wx.stopPullDownRefresh()
  52. if (res.code === 200) {
  53. const re = res.data
  54. if( from== 0) tableData = [];
  55. _this.setData({
  56. from: re.from,
  57. tableData: tableData.concat(re.list)
  58. });
  59. }
  60. })
  61. }
  62. })