consumer模块完成度95%,优化安卓端界面和小程序测试3
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<view class="cart-page">
|
||||
<!-- 智能顶部导航栏 - 与消息页保持一致 -->
|
||||
<view class="smart-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<view class="nav-container">
|
||||
<view class="nav-container" :style="{ paddingRight: navBarRight + 'px' }">
|
||||
<text class="nav-title">购物车</text>
|
||||
<view class="nav-actions">
|
||||
<view class="action-btn" @click="toggleManageMode">
|
||||
@@ -245,6 +245,20 @@ const statusBarHeight = ref(0)
|
||||
const isManageMode = ref(false)
|
||||
const updatingItems = ref<Set<string>>(new Set()) // Track items being updated to prevent race conditions
|
||||
|
||||
// 小程序胶囊按钮信息类型
|
||||
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 cartGroups = computed<CartGroup[]>(() => {
|
||||
console.log('[cartGroups] 计算购物车分组, cartItems count:', cartItems.value.length)
|
||||
@@ -326,6 +340,27 @@ const toggleManageMode = () => {
|
||||
const initPage = () => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight ?? 0
|
||||
|
||||
// 获取小程序胶囊按钮信息
|
||||
// #ifdef MP-WEIXIN
|
||||
try {
|
||||
const menuButton = uni.getMenuButtonBoundingClientRect()
|
||||
if (menuButton != null) {
|
||||
capsuleButtonInfo.value = {
|
||||
left: menuButton.left,
|
||||
top: menuButton.top,
|
||||
right: menuButton.right,
|
||||
bottom: menuButton.bottom,
|
||||
width: menuButton.width,
|
||||
height: menuButton.height
|
||||
}
|
||||
navBarRight.value = (systemInfo.screenWidth - menuButton.left) + 10
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取胶囊按钮信息失败', e)
|
||||
navBarRight.value = 90
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
@@ -863,7 +898,7 @@ const navigateToProduct = (product: any) => {
|
||||
const name = productJson.getString('name') ?? ''
|
||||
paramsArr.push('name=' + encodeURIComponent(name))
|
||||
|
||||
const image = productJson.getString('image') ?? '/static/product1.jpg'
|
||||
const image = productJson.getString('image') ?? '/static/images/default-product.png'
|
||||
paramsArr.push('image=' + encodeURIComponent(image))
|
||||
|
||||
const url = `/pages/mall/consumer/product-detail?${paramsArr.join('&')}`
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="category-page">
|
||||
<!-- 顶部搜索栏 -->
|
||||
<view class="search-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<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>
|
||||
@@ -139,6 +139,21 @@ type LocalCategory = {
|
||||
// 响应式数据
|
||||
const statusBarHeight = ref(0)
|
||||
const headerHeight = ref(44)
|
||||
|
||||
// 小程序胶囊按钮信息类型
|
||||
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 primaryCategories = ref<LocalCategory[]>([])
|
||||
const subCategories = ref<LocalCategory[]>([]) // 二级分类列表
|
||||
const productList = ref<Product[]>([])
|
||||
@@ -547,6 +562,28 @@ onShow(() => {
|
||||
onLoad((options: any) => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight
|
||||
|
||||
// 获取小程序胶囊按钮信息
|
||||
// #ifdef MP-WEIXIN
|
||||
try {
|
||||
const menuButton = uni.getMenuButtonBoundingClientRect()
|
||||
if (menuButton != null) {
|
||||
capsuleButtonInfo.value = {
|
||||
left: menuButton.left,
|
||||
top: menuButton.top,
|
||||
right: menuButton.right,
|
||||
bottom: menuButton.bottom,
|
||||
width: menuButton.width,
|
||||
height: menuButton.height
|
||||
}
|
||||
navBarRight.value = (systemInfo.screenWidth - menuButton.left) + 10
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取胶囊按钮信息失败', e)
|
||||
navBarRight.value = 90
|
||||
}
|
||||
// #endif
|
||||
|
||||
console.log('=== category页面onLoad被调用 ===')
|
||||
|
||||
let categoryId = ''
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -413,7 +413,7 @@ const loadMessages = async () => {
|
||||
time: formatTime(room.last_message_at ?? ''),
|
||||
read: room.unread_count === 0,
|
||||
type: 'service',
|
||||
avatar: room.shop_logo ?? '/static/icons/shop-default.png',
|
||||
avatar: room.shop_logo ?? '/static/icons/customer-service.png',
|
||||
online: true,
|
||||
unreadCount: room.unread_count,
|
||||
tags: [] as string[],
|
||||
@@ -442,7 +442,7 @@ const loadMessages = async () => {
|
||||
time: '刚刚',
|
||||
read: true,
|
||||
type: 'service',
|
||||
avatar: '/static/icons/service-avatar.png',
|
||||
avatar: '/static/icons/customer-service.png',
|
||||
online: true,
|
||||
unreadCount: 0,
|
||||
tags: ['自动回复'],
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<!-- 基础用户信息:头像和昵称 -->
|
||||
<view class="nav-user-basic" @click="editProfile">
|
||||
<image
|
||||
:src="userInfo.avatar_url != '' ? userInfo.avatar_url : '/static/default-avatar.png'"
|
||||
:src="userInfo.avatar_url != '' ? userInfo.avatar_url : '/static/images/default-product.png'"
|
||||
class="nav-avatar"
|
||||
/>
|
||||
<text class="nav-user-name">{{ userInfo.nickname != '' ? userInfo.nickname : userInfo.phone }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 用户资产横向排列 (积分、余额、优惠券) -->
|
||||
<view class="nav-user-stats">
|
||||
<view class="nav-user-stats" :style="{ marginRight: navBarRight + 'px' }">
|
||||
<view class="nav-stat-item" @click="goToPoints">
|
||||
<text class="nav-stat-label">积分</text>
|
||||
<text class="nav-stat-value">{{ userStats.points }}</text>
|
||||
@@ -371,6 +371,7 @@ export default {
|
||||
save_amount: 0
|
||||
} as ConsumptionStatsType,
|
||||
statusBarHeight: 0,
|
||||
navBarRight: 0, // 导航栏右侧预留空间(小程序胶囊按钮)
|
||||
currentOrderTab: 'all' as string,
|
||||
allOrders: [] as Array<OrderItemType>
|
||||
}
|
||||
@@ -529,6 +530,19 @@ export default {
|
||||
initPage() {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
this.statusBarHeight = systemInfo.statusBarHeight ?? 0
|
||||
|
||||
// 获取小程序胶囊按钮信息
|
||||
// #ifdef MP-WEIXIN
|
||||
try {
|
||||
const menuButton = uni.getMenuButtonBoundingClientRect()
|
||||
if (menuButton != null) {
|
||||
this.navBarRight = (systemInfo.screenWidth - menuButton.left) + 10
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取胶囊按钮信息失败', e)
|
||||
this.navBarRight = 90
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
async loadUserProfile() {
|
||||
try {
|
||||
@@ -570,7 +584,7 @@ export default {
|
||||
phone: uPhone,
|
||||
email: uEmail,
|
||||
nickname: uNickname != '' ? uNickname : '微信用户',
|
||||
avatar_url: uAvatar != '' ? uAvatar : '/static/default-avatar.png',
|
||||
avatar_url: uAvatar != '' ? uAvatar : '/static/images/default-product.png',
|
||||
gender: uGender,
|
||||
user_type: 1,
|
||||
status: 1,
|
||||
@@ -929,20 +943,20 @@ export default {
|
||||
|
||||
getOrderMainImage(order: OrderItemType): string {
|
||||
const itemsRaw = order.ml_order_items
|
||||
if (itemsRaw == null) return '/static/product1.jpg'
|
||||
if (itemsRaw == null) return '/static/images/default-product.png'
|
||||
const items = itemsRaw as any[]
|
||||
if (items.length > 0) {
|
||||
const firstItem = items[0]
|
||||
const itemStr = JSON.stringify(firstItem)
|
||||
const itemParsed = JSON.parse(itemStr)
|
||||
if (itemParsed == null) return '/static/product1.jpg'
|
||||
if (itemParsed == null) return '/static/images/default-product.png'
|
||||
const itemObj = itemParsed as UTSJSONObject
|
||||
const imgUrl = itemObj.getString('image_url')
|
||||
const prodImg = itemObj.getString('product_image')
|
||||
const img = (imgUrl != null && imgUrl !== '') ? imgUrl : prodImg
|
||||
if (img != null && img !== '') return img
|
||||
}
|
||||
return '/static/product1.jpg'
|
||||
return '/static/images/default-product.png'
|
||||
},
|
||||
|
||||
getOrderTitle(order: OrderItemType): string {
|
||||
|
||||
Reference in New Issue
Block a user