商城类、订单类uniapp模板,多角色
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.

63 lines
1.2 KiB

5 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. }
  20. },
  21. onReachBottom() {
  22. this.loadMoreData()
  23. },
  24. methods: {
  25. getData(queryParams){
  26. return new Promise((success, error) => {
  27. if(!this.mixinsListApi){
  28. return console.error('mixinsListApi 缺失');
  29. }
  30. this.$api(this.mixinsListApi,
  31. query(this, queryParams), res => {
  32. uni.stopPullDownRefresh()
  33. if(res.code == 200){
  34. this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result)
  35. success(res.result)
  36. this[this.mixinsListKey || 'list'] = res.result.records
  37. this.total = res.result.total
  38. }
  39. })
  40. })
  41. },
  42. loadMoreData(){
  43. console.log('loadMoreData----', this.queryParams.pageSize < this.total);
  44. if(this.queryParams.pageSize < this.total){
  45. this.queryParams.pageSize += 10
  46. this.getData()
  47. }
  48. },
  49. }
  50. }