From 4948f5c8ecb960f5d9b342fa8f571dfd60b37c21 Mon Sep 17 00:00:00 2001 From: "jqtmviyu@gmail.com" Date: Thu, 25 Feb 2021 20:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E5=80=9F=E5=8F=A3=E6=8B=BF=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/http.api.js | 9 ++++++++- src/pages/goods_list/goods_list.vue | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/common/http.api.js b/src/common/http.api.js index 3df03fb..4fff77e 100644 --- a/src/common/http.api.js +++ b/src/common/http.api.js @@ -11,6 +11,9 @@ const FLOORDATA_URL = "/home/floordata" // 分类 const CATEGORIES_URL = "/categories" +// 商品页列表搜索 +const GOODS_SEARCH_URL = '/goods/search' + // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作 const install = (Vue, vm) => { @@ -22,8 +25,12 @@ const install = (Vue, vm) => { // 分类页 const getCategories = (params = {}) => vm.$u.get(CATEGORIES_URL, params) + // 商品页 + // 商品列表搜索 + const getGoods = (params = {}) => vm.$u.get(GOODS_SEARCH_URL, params) + // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 - vm.$u.api = { getSwiperdata, getCatitems, getFloordata, getCategories } + vm.$u.api = { getSwiperdata, getCatitems, getFloordata, getCategories, getGoods } } export default { diff --git a/src/pages/goods_list/goods_list.vue b/src/pages/goods_list/goods_list.vue index e274b21..3826d8b 100644 --- a/src/pages/goods_list/goods_list.vue +++ b/src/pages/goods_list/goods_list.vue @@ -29,9 +29,25 @@ export default { tabsCurrent: 0, } }, - onLoad (id){ - console.log(id) + + async onLoad ({ id }){ + console.log(id) + const params = { + // 关键字 + query: "", + // 分类id + cid: id, + // 页码 + pagenum: 1, + // 页容量 一页有几条数据 + pagesize: 10 + } + + // 从接口拿数据 + const {message} = await this.$u.api.getGoods(params) + console.log(message) }, + methods: { onTapsChange(index){ this.tabsCurrent = index