从借口拿商品数据

This commit is contained in:
jqtmviyu@gmail.com 2021-02-25 20:42:26 +08:00
parent c149973199
commit 4948f5c8ec
2 changed files with 26 additions and 3 deletions

View File

@ -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 {

View File

@ -29,9 +29,25 @@ export default {
tabsCurrent: 0,
}
},
onLoad (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