index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //import * as WxJsApi from '@/utils/wxJsApi.js'
  2. import * as API from '@/apis/common.js'
  3. export default {
  4. data() {
  5. return {
  6. isReady:false,
  7. page:{
  8. classifyId:0,
  9. pageIndex:1,
  10. pageSize:10,
  11. },
  12. result:[],
  13. recordsTotal:0,
  14. }
  15. },
  16. components: {
  17. },
  18. // onPullDownRefresh() {
  19. // if(this.result.length<this.recordsTotal){
  20. // this.myLoadmore();
  21. // }
  22. // },
  23. onReachBottom() {
  24. if(this.result.length<this.recordsTotal){
  25. this.myLoadmore();
  26. }
  27. },
  28. onLoad(op){
  29. this.page.classifyId=op.id;
  30. },
  31. methods: {
  32. myLoadmore(){
  33. this.page.pageIndex++;
  34. this.getList();
  35. },
  36. getList(){
  37. uni.showLoading({
  38. title:"加载中",mask:true,
  39. })
  40. API.messageList(this.page).then((response) => {
  41. this.result=[
  42. ...this.result,
  43. ...response.data.data,
  44. ];
  45. this.recordsTotal=response.data.recordsTotal
  46. uni.stopPullDownRefresh();
  47. uni.hideLoading()
  48. }).catch(error => {
  49. uni.showToast({
  50. title:error
  51. })
  52. })
  53. },
  54. },onReady(){
  55. this.getList();
  56. this.isReady=true;
  57. },onShow(){
  58. if(this.isReady){
  59. }
  60. },
  61. }