diff --git a/src/components/utils/list.js b/src/components/utils/list.js new file mode 100644 index 0000000..196e1d0 --- /dev/null +++ b/src/components/utils/list.js @@ -0,0 +1,36 @@ +import http from "./http"; + +class List { + constructor(action) { + this.action = action + this.current = 1 + this.total = 0 + this.list = [] + } + + getData(params) { + const {action} = this + return http.post(action, null, {params}) + } + + init(params) { + this.getData({...params, current: 1}).then(res => { + if (res?.data) { + this.list = res.data.records + this.total = res.data.total + } + }) + } + + loadMore(params) { + if (this.list.length < this.total) { + this.getData({...params, current: ++this.current}).then(res => { + if (res?.data) { + this.list = [...this.list, ...res.data.records] + } + }) + } + } +} + +export default List diff --git a/src/mods/publicity/AppAgProducts/AppAgProducts.vue b/src/mods/publicity/AppAgProducts/AppAgProducts.vue index 5c07453..c81864f 100644 --- a/src/mods/publicity/AppAgProducts/AppAgProducts.vue +++ b/src/mods/publicity/AppAgProducts/AppAgProducts.vue @@ -22,11 +22,11 @@
- 共{{ total }}个农产品 + 共{{ list.total }}个农产品
-
-
+
+
{{ item.title }}
@@ -47,7 +47,7 @@
- +
我要发布
@@ -57,6 +57,8 @@ @@ -299,7 +276,6 @@ export default { box-sizing: border-box; display: flex; align-items: center; - box-sizing: border-box; padding: 32px; & > img { diff --git a/src/utils/config.js b/src/utils/config.js index f686029..f1a0528 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -16,7 +16,7 @@ const configs = { dev: { areaId: '341021104000', areaName: '郑村镇', - baseUrl: 'http://192.168.1.87:59998' + baseUrl: 'http://192.168.1.87:9000' } } // 当前选中配置