From cf21392f70bce3fce5e545e3ffdbe5fbd8fd33be Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 10 Jan 2023 15:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E4=B8=80=E7=9A=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=A4=84=E7=90=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/utils/list.js | 36 +++++++++++++ .../publicity/AppAgProducts/AppAgProducts.vue | 52 +++++-------------- src/utils/config.js | 2 +- 3 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 src/components/utils/list.js 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' } } // 当前选中配置