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