瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.4 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. function query(self, queryParams){
  2. // return (self.beforeGetData && self.beforeGetData()) ||
  3. // queryParams || self.queryParams
  4. // 深度合并对象
  5. return self.$utils.deepMergeObject(
  6. self.$utils.deepMergeObject(self.queryParams,
  7. (self.beforeGetData && self.beforeGetData()) || {}),
  8. queryParams)
  9. }
  10. export default {
  11. data() {
  12. return {
  13. queryParams: {
  14. pageNo: 1,
  15. pageSize: 10,
  16. },
  17. total : 0,
  18. list : [],
  19. onShowData : true,
  20. }
  21. },
  22. onPullDownRefresh() {
  23. this.getData()
  24. },
  25. onReachBottom() {
  26. this.loadMoreData()
  27. },
  28. onShow() {
  29. if(this.onShowData){
  30. this.getData()
  31. }
  32. },
  33. methods: {
  34. getData(queryParams){
  35. return new Promise((success, error) => {
  36. if(!this.mixinsListApi){
  37. return console.error('mixinsListApi 缺失');
  38. }
  39. this.$api(this.mixinsListApi,
  40. query(this, queryParams), res => {
  41. uni.stopPullDownRefresh()
  42. if(res.code == 200){
  43. this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result)
  44. success(res.result)
  45. this[this.mixinsListKey || 'list'] = res.result.records
  46. this.total = res.result.total
  47. }
  48. })
  49. })
  50. },
  51. loadMoreData(){
  52. console.log('loadMoreData----', this.queryParams.pageSize < this.total);
  53. if(this.queryParams.pageSize < this.total){
  54. this.queryParams.pageSize += 10
  55. this.getData()
  56. }
  57. },
  58. }
  59. }