consumer模块完成度95%,优化安卓端界面和小程序测试3
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
transform: showNavbar ? 'translateY(0)' : 'translateY(-100%)'
|
||||
}"
|
||||
>
|
||||
<view class="search-container">
|
||||
<view class="search-container" :style="{ paddingRight: navBarRight + 'px' }">
|
||||
<view class="search-box" @click="navigateToSearch" :style="{ height: '30px' }">
|
||||
<!-- 模拟输入框 -->
|
||||
<text class="search-placeholder">请输入商品名称、店铺</text>
|
||||
@@ -287,6 +287,20 @@ const activeFilter = ref('recommend')
|
||||
const currentPage = ref(1)
|
||||
const priceAscending = ref(true) // 价格排序方向:true=升序,false=降序
|
||||
|
||||
// 小程序胶囊按钮信息类型
|
||||
type CapsuleButtonInfo = {
|
||||
left: number,
|
||||
top: number,
|
||||
right: number,
|
||||
bottom: number,
|
||||
width: number,
|
||||
height: number
|
||||
}
|
||||
|
||||
// 小程序胶囊按钮信息
|
||||
const capsuleButtonInfo = ref<CapsuleButtonInfo | null>(null)
|
||||
const navBarRight = ref(0) // 导航栏右侧预留空间
|
||||
|
||||
// 数据源
|
||||
const hotProducts = ref<Product[]>([])
|
||||
const recommendedProducts = ref<Product[]>([])
|
||||
@@ -629,6 +643,24 @@ const initPage = () => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight
|
||||
|
||||
// 获取小程序胶囊按钮信息
|
||||
// #ifdef MP-WEIXIN
|
||||
try {
|
||||
capsuleButtonInfo.value = uni.getMenuButtonBoundingClientRect()
|
||||
if (capsuleButtonInfo.value != null) {
|
||||
// 计算导航栏右侧需要预留的空间(胶囊按钮宽度 + 左右边距)
|
||||
navBarRight.value = (systemInfo.screenWidth - capsuleButtonInfo.value.left) + 10
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取胶囊按钮信息失败', e)
|
||||
navBarRight.value = 90 // 默认预留空间
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
navBarRight.value = 0 // 非小程序不需要预留空间
|
||||
// #endif
|
||||
|
||||
// 计算滚动区域高度 - 不再需要手动计算,使用 Flex 布局自动撑开
|
||||
// scrollHeight.value = windowHeight - 50
|
||||
|
||||
@@ -985,7 +1017,7 @@ const navigateToProduct = (product: any) => {
|
||||
const productId = prodObj.getString('productId') ?? prodObj.getString('id') ?? ''
|
||||
const name = prodObj.getString('name') ?? ''
|
||||
// 使用 main_image_url
|
||||
const image = prodObj.getString('main_image_url') ?? prodObj.getString('image') ?? '/static/product1.jpg'
|
||||
const image = prodObj.getString('main_image_url') ?? prodObj.getString('image') ?? '/static/images/default-product.png'
|
||||
const price = (prodObj.getNumber('base_price') ?? prodObj.getNumber('price') ?? 0).toString()
|
||||
const marketPrice = prodObj.getNumber('market_price') ?? prodObj.getNumber('original_price') ?? (parseFloat(price) * 1.2)
|
||||
const originalPrice = marketPrice.toString()
|
||||
|
||||
Reference in New Issue
Block a user