推广小程序前端代码
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.

76 lines
1.5 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 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. uvLoadMore : 'loading',
  20. }
  21. },
  22. onPullDownRefresh() {
  23. this.getData()
  24. },
  25. onReachBottom() {
  26. this.loadMoreData()
  27. },
  28. onShow() {
  29. this.getData()
  30. },
  31. methods: {
  32. getData(queryParams){
  33. return new Promise((success, error) => {
  34. if(!this.mixinsListApi){
  35. return console.error('mixinsListApi 缺失');
  36. }
  37. this.$api(this.mixinsListApi,
  38. query(this, queryParams), res => {
  39. uni.stopPullDownRefresh()
  40. if(res.code == 200){
  41. this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result)
  42. success(res.result)
  43. this[this.mixinsListKey || 'list'] = res.result.records || res.result
  44. this.total = res.result.total || res.result.length
  45. if(this.queryParams.pageSize < this.total){
  46. this.uvLoadMore = 'loadmore'
  47. }else{
  48. this.uvLoadMore = 'nomore'
  49. }
  50. }
  51. })
  52. })
  53. },
  54. loadMoreData(){
  55. console.log('loadMoreData----', this.queryParams.pageSize < this.total);
  56. if(this.queryParams.pageSize < this.total){
  57. this.queryParams.pageSize += 10
  58. this.getData()
  59. }
  60. },
  61. }
  62. }