feat:173版本
This commit is contained in:
+68
-25
@@ -1,15 +1,17 @@
|
||||
<template>
|
||||
<view class="sort_warp" :class="platformType ? '' : 'iosplatformType'">
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<TopSafe bgColor="#F2EBFF"></TopSafe>
|
||||
<TopSafe v-if="!isMP" bgColor="#F2EBFF"></TopSafe>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 顶部固定区域:搜索 + 分类区域 -->
|
||||
<view class="top_fixed_header" :class="{ is_expanded: showAllCategories }" :style="mpHeaderStyle">
|
||||
<!-- 搜索框 -->
|
||||
<view class="search_bar" @click="jumpSearch">
|
||||
<u-icon name="search" size="18" color="#999"></u-icon>
|
||||
<text class="search_placeholder">搜索</text>
|
||||
<view class="top_fixed_header" :class="{ is_expanded: showAllCategories }">
|
||||
<!-- 搜索框容器 -->
|
||||
<view class="search_bar_container" :style="mpHeaderStyle">
|
||||
<view class="search_bar" :style="mpSearchStyle" @click="jumpSearch">
|
||||
<u-icon name="search" size="18" color="#999"></u-icon>
|
||||
<text class="search_placeholder">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 1. 未展开时:顶部分类横向滚动条 -->
|
||||
@@ -171,6 +173,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
platformType: true,
|
||||
isMP: false,
|
||||
mpHeaderStyle: {},
|
||||
mpSearchStyle: {},
|
||||
categoryList: [], // 一级分类列表 (parentId = 0)
|
||||
currentCategoryIndex: 0, // 当前选中的一级分类索引
|
||||
subCategoryList: [], // 二级分类列表 (parentId = 一级ID)
|
||||
@@ -179,7 +184,6 @@ export default {
|
||||
showAllCategories: false,
|
||||
sortBy: 'relevance', // 'relevance' | 'sales' | 'price'
|
||||
sortOrder: 'asc', // 'asc' | 'desc'
|
||||
capsuleTop: 0,
|
||||
defaultIcon: 'https://static.tbmall.xin/static/new-home/xinren.png',
|
||||
defaultProductImg: 'https://static.tbmall.xin/static/new-home/nangua.png',
|
||||
isFromSortShop: false,
|
||||
@@ -191,15 +195,6 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
mpHeaderStyle() {
|
||||
/*#ifdef MP-WEIXIN*/
|
||||
if (this.capsuleTop) {
|
||||
return { paddingTop: this.capsuleTop + 'px' };
|
||||
}
|
||||
return { paddingTop: '80rpx' };
|
||||
/*#endif*/
|
||||
return {};
|
||||
},
|
||||
currentCategory() {
|
||||
return this.categoryList[this.currentCategoryIndex] || null;
|
||||
},
|
||||
@@ -207,6 +202,12 @@ export default {
|
||||
return this.subCategoryList[this.currentSubCategoryIndex] || null;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// #ifdef MP-WEIXIN || MP
|
||||
this.isMP = true;
|
||||
this.initMPHeader();
|
||||
// #endif
|
||||
},
|
||||
onShow() {
|
||||
/*#ifdef APP-PLUS*/
|
||||
uni.hideTabBar({ animation: false });
|
||||
@@ -214,14 +215,10 @@ export default {
|
||||
this.platformType = appUpdate == "android" ? "ANDROID" : "IOS";
|
||||
/*#endif*/
|
||||
|
||||
/*#ifdef MP-WEIXIN*/
|
||||
try {
|
||||
const menu = uni.getMenuButtonBoundingClientRect();
|
||||
if (menu && menu.bottom) {
|
||||
this.capsuleTop = menu.bottom + 6;
|
||||
}
|
||||
} catch (e) { }
|
||||
/*#endif*/
|
||||
// #ifdef MP-WEIXIN || MP
|
||||
this.isMP = true;
|
||||
this.initMPHeader();
|
||||
// #endif
|
||||
|
||||
const isBackFromSortShop = this.isFromSortShop;
|
||||
this.isFromSortShop = false;
|
||||
@@ -229,6 +226,42 @@ export default {
|
||||
this.fetchCategories(isBackFromSortShop);
|
||||
},
|
||||
methods: {
|
||||
initMPHeader() {
|
||||
// #ifdef MP-WEIXIN || MP
|
||||
try {
|
||||
const menuButton = uni.getMenuButtonBoundingClientRect();
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
|
||||
if (menuButton && menuButton.top && menuButton.top > 0) {
|
||||
const menuButtonHeight = menuButton.height || 32;
|
||||
const menuButtonTop = menuButton.top;
|
||||
const menuButtonLeft = menuButton.left;
|
||||
const windowWidth = systemInfo.windowWidth;
|
||||
|
||||
const rightPadding = windowWidth - menuButtonLeft + 12;
|
||||
|
||||
this.mpHeaderStyle = {
|
||||
paddingTop: `${menuButtonTop}px`,
|
||||
paddingRight: `${rightPadding}px`,
|
||||
paddingLeft: '12px',
|
||||
paddingBottom: '8px',
|
||||
height: `${menuButtonTop + menuButtonHeight + 8}px`,
|
||||
boxSizing: 'border-box',
|
||||
display: 'flex',
|
||||
alignItems: 'center'
|
||||
};
|
||||
|
||||
this.mpSearchStyle = {
|
||||
height: `${menuButtonHeight}px`,
|
||||
borderRadius: `${menuButtonHeight / 2}px`,
|
||||
boxSizing: 'border-box'
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("initMPHeader error:", e);
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
getSellingPointTags(sellingPoint) {
|
||||
if (!sellingPoint || typeof sellingPoint !== 'string') return [];
|
||||
return sellingPoint
|
||||
@@ -492,15 +525,25 @@ page {
|
||||
}
|
||||
}
|
||||
|
||||
/* 搜索框容器 */
|
||||
.search_bar_container {
|
||||
width: 100%;
|
||||
padding: 16rpx 24rpx 12rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 搜索框 */
|
||||
.search_bar {
|
||||
margin: 16rpx 24rpx 12rpx;
|
||||
width: 100%;
|
||||
height: 72rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 36rpx;
|
||||
padding: 0 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
|
||||
.search_placeholder {
|
||||
font-size: 28rpx;
|
||||
|
||||
Reference in New Issue
Block a user