首页与分类页参数传递

This commit is contained in:
”chenxuelian“
2023-01-06 20:44:35 +08:00
parent ce9d241d05
commit bc9b2b8e9c
2 changed files with 13 additions and 8 deletions

View File

@@ -199,14 +199,15 @@
isAllData: false
}
},
onLoad() {
onLoad(options) {
console.log(options)
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
this.searchBarTop = menuButtonInfo.top;
this.searchBarHeight = menuButtonInfo.height;
this.imgUrl = uni.getStorageSync('img_url')
this.goodsList = []
this.isAllData = false
this.getCategoryList()
this.getCategoryList(options.categoryId)
},
onReady() {
let that = this;
@@ -303,13 +304,17 @@
url: '../search/search'
})
},
getCategoryList() {
getCategoryList(selectedCategoryId) {
this.$apiServe.getCategories().then(res => {
this.categoryList = res.data.data.map((item, index) => {
item.icon = this.imgUrl + item.icon
if (this.selectedCategory && this.selectedCategory === index) {
if(selectedCategoryId && selectedCategoryId === item.id) {
item.active = true
} else if (!this.selectedCategory && !index) {
this.selectedCategory = index
} else if (selectedCategoryId === null && this.selectedCategory && this.selectedCategory === index) {
item.active = true
active = true
} else if (selectedCategoryId === null && !this.selectedCategory && !index) {
item.active = true
} else {
item.active = false