Merge pull request 'chenxuelian' (#45) from chenxuelian into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/45
This commit is contained in:
1171906056
2023-01-06 12:53:20 +00:00
2 changed files with 13 additions and 8 deletions

View File

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

View File

@@ -13,7 +13,7 @@
<!-- 分类模块 --> <!-- 分类模块 -->
<view class="classify"> <view class="classify">
<u-grid :border="false" col="5"> <u-grid :border="false" col="5">
<u-grid-item v-for="(listItem,listIndex) in classifyList" :key="listIndex" @click="toClassify()"> <u-grid-item v-for="(listItem,listIndex) in classifyList" :key="listIndex" @click="toClassify(listItem.id)">
<u--image :src="imgUrl+listItem.icon" width="86rpx" height="86rpx" :lazy-load="true"> <u--image :src="imgUrl+listItem.icon" width="86rpx" height="86rpx" :lazy-load="true">
</u--image> </u--image>
<!-- <u-icon size="86rpx" :name="listItem.icon"></u-icon> --> <!-- <u-icon size="86rpx" :name="listItem.icon"></u-icon> -->
@@ -173,9 +173,9 @@
}) })
}, },
//点击一级分类跳转到分类页 //点击一级分类跳转到分类页
toClassify() { toClassify(id) {
uni.navigateTo({ uni.navigateTo({
url: '../../packageSearch/goods-category-search/category-index' url: '../../packageSearch/goods-category-search/category-index?categoryId=' + id
}) })
}, },
getImgUrl() { getImgUrl() {