完善下单逻辑及其ui展示,修复支付倒计时显示错误bug
This commit is contained in:
@@ -195,29 +195,12 @@
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class="recommend-section">
|
||||
<view class="recommend-header">
|
||||
<text class="recommend-title">猜你喜欢</text>
|
||||
<text class="recommend-subtitle">精选推荐,继续逛一逛</text>
|
||||
</view>
|
||||
<view class="recommend-grid">
|
||||
<view v-for="item in recommendProducts" :key="item.id" class="recommend-card" @click="goToRecommendProduct(item)">
|
||||
<image :src="item.image" class="recommend-image" mode="aspectFill" />
|
||||
<view class="recommend-info">
|
||||
<text class="recommend-name">{{ item.name }}</text>
|
||||
<view class="recommend-meta-row">
|
||||
<text class="recommend-price">¥{{ item.price }}</text>
|
||||
<text class="recommend-tag">{{ item.tag }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="recommend-load-more" @click="loadRecommendProducts(false)">
|
||||
<text v-if="recommendLoading" class="recommend-load-text">正在加载更多...</text>
|
||||
<text v-else-if="!recommendHasMore && recommendInitialized" class="recommend-load-text">没有更多了</text>
|
||||
<text v-else class="recommend-load-text">上拉加载更多</text>
|
||||
</view>
|
||||
</view>
|
||||
<GuessYouLike
|
||||
title="猜你喜欢"
|
||||
:pageSize="8"
|
||||
:loadMoreKey="guessLoadMoreKey"
|
||||
@productClick="handleGuessProductClick"
|
||||
/>
|
||||
|
||||
<view class="profile-bottom-safe"></view>
|
||||
</view>
|
||||
@@ -229,6 +212,7 @@
|
||||
import { UserType } from '@/types/mall-types.uts'
|
||||
import supabaseService from '@/utils/supabaseService.uts'
|
||||
import { goToLogin } from '@/utils/utils.uts'
|
||||
import GuessYouLike from '@/components/mall/GuessYouLike/GuessYouLike.uvue'
|
||||
|
||||
type UserStatsType = {
|
||||
points: number
|
||||
@@ -290,6 +274,9 @@ type PendingReceiptGoodsType = {
|
||||
type ModalSuccessResult = { confirm: boolean; cancel: boolean }
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GuessYouLike
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userInfo: {
|
||||
@@ -345,6 +332,7 @@ export default {
|
||||
recommendBottomLocked: false,
|
||||
recommendViewportHeight: 0,
|
||||
pageWindowHeight: 0,
|
||||
guessLoadMoreKey: 0,
|
||||
statusBarHeight: 0,
|
||||
isAndroidApp: false,
|
||||
capsuleTop: 0,
|
||||
@@ -376,7 +364,6 @@ export default {
|
||||
this.initPage()
|
||||
this.loadUserProfile()
|
||||
this.loadOrders()
|
||||
this.loadRecommendProducts(true)
|
||||
|
||||
// 监听订单更新事件
|
||||
uni.$on('orderUpdated', this.handleOrderUpdated)
|
||||
@@ -474,24 +461,6 @@ export default {
|
||||
return result
|
||||
},
|
||||
|
||||
mockRecommendProducts(page: number, pageSize: number): Array<RecommendProductType> {
|
||||
const list: Array<RecommendProductType> = []
|
||||
if (page >= 5) {
|
||||
return list
|
||||
}
|
||||
for (let i: number = 0; i < pageSize; i++) {
|
||||
const index = (page - 1) * pageSize + i + 1
|
||||
list.push({
|
||||
id: 'mock-recommend-' + index,
|
||||
name: '猜你喜欢 推荐商品 ' + index,
|
||||
image: '/static/images/default.png',
|
||||
price: 9.9 + index,
|
||||
tag: '已售' + (100 + index) + '+'
|
||||
} as RecommendProductType)
|
||||
}
|
||||
return list
|
||||
},
|
||||
|
||||
async fetchRecommendProducts(page: number, pageSize: number): Promise<Array<RecommendProductType>> {
|
||||
console.log('[profile推荐] fetchRecommendProducts 请求 page=', page, 'pageSize=', pageSize)
|
||||
const result = await supabaseService.searchProducts('', page, pageSize, 'sales')
|
||||
@@ -578,14 +547,7 @@ export default {
|
||||
this.recommendInitialized = true
|
||||
} catch (e) {
|
||||
console.error('加载推荐商品失败:', e)
|
||||
|
||||
if (reset && this.recommendProducts.length === 0) {
|
||||
const mockList = this.mockRecommendProducts(1, this.recommendPageSize)
|
||||
this.recommendProducts = mockList
|
||||
this.recommendPage = 2
|
||||
this.recommendHasMore = true
|
||||
this.recommendInitialized = true
|
||||
}
|
||||
this.recommendHasMore = false
|
||||
} finally {
|
||||
this.recommendLoading = false
|
||||
if (!reset && this.recommendPendingLoad && this.recommendHasMore) {
|
||||
@@ -597,55 +559,20 @@ export default {
|
||||
},
|
||||
|
||||
onRecommendScrollToLower() {
|
||||
console.log('[profile推荐] scrolltolower 触发')
|
||||
this.recommendBottomLocked = true
|
||||
this.loadRecommendProducts(false)
|
||||
this.guessLoadMoreKey = this.guessLoadMoreKey + 1
|
||||
},
|
||||
|
||||
onRecommendScroll(event: any) {
|
||||
if (this.recommendLoading || !this.recommendHasMore) {
|
||||
return
|
||||
},
|
||||
|
||||
handleGuessProductClick(productId: string) {
|
||||
if (productId == null || productId === '') {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const eventObj = this.toRecommendScrollJson(event)
|
||||
let detailObj: UTSJSONObject | null = null
|
||||
if (eventObj != null) {
|
||||
detailObj = this.toRecommendScrollJson(eventObj.get('detail'))
|
||||
}
|
||||
if (detailObj == null) {
|
||||
return
|
||||
}
|
||||
|
||||
const scrollTop = this.readRecommendScrollMetric(detailObj, 'scrollTop')
|
||||
const scrollHeight = this.readRecommendScrollMetric(detailObj, 'scrollHeight')
|
||||
let clientHeight = this.readRecommendScrollMetric(detailObj, 'clientHeight')
|
||||
|
||||
if (clientHeight <= 0) {
|
||||
clientHeight = this.recommendViewportHeight
|
||||
}
|
||||
|
||||
console.log('[profile推荐] scroll事件 scrollTop=', scrollTop, 'scrollHeight=', scrollHeight, 'clientHeight=', clientHeight)
|
||||
|
||||
if (scrollHeight <= 0 || clientHeight <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const distanceToBottom = scrollHeight - scrollTop - clientHeight
|
||||
if (distanceToBottom > 260) {
|
||||
this.recommendBottomLocked = false
|
||||
}
|
||||
if (distanceToBottom <= 180) {
|
||||
console.log('[profile推荐] scroll 兜底触底 distanceToBottom=', distanceToBottom)
|
||||
if (this.recommendBottomLocked) {
|
||||
this.recommendPendingLoad = true
|
||||
return
|
||||
}
|
||||
this.recommendBottomLocked = true
|
||||
this.loadRecommendProducts(false)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[profile推荐] 处理推荐滚动失败', e)
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/mall/consumer/product-detail?id=${productId}&productId=${productId}`
|
||||
})
|
||||
},
|
||||
|
||||
resetGuestProfileState() {
|
||||
@@ -1045,9 +972,6 @@ export default {
|
||||
const userId = supabaseService.getCurrentUserId()
|
||||
if (userId == null || userId === '') {
|
||||
this.resetGuestProfileState()
|
||||
if (!this.recommendInitialized) {
|
||||
this.loadRecommendProducts(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1055,9 +979,6 @@ export default {
|
||||
this.loadUserProfile()
|
||||
this.loadOrders()
|
||||
this.updateCouponCount() // 更新优惠券数量
|
||||
if (!this.recommendInitialized) {
|
||||
this.loadRecommendProducts(true)
|
||||
}
|
||||
},
|
||||
|
||||
async updateCouponCount() {
|
||||
@@ -1545,13 +1466,14 @@ export default {
|
||||
},
|
||||
|
||||
payOrder(order: OrderItemType) {
|
||||
const paymentAmount = order.actual_amount
|
||||
const userId = supabaseService.getCurrentUserId()
|
||||
if (userId == null || userId === '') {
|
||||
goToLogin(`/pages/mall/consumer/payment?orderId=${order.id}`)
|
||||
goToLogin(`/pages/mall/consumer/payment?orderId=${order.id}&amount=${paymentAmount}`)
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/mall/consumer/payment?orderId=${order.id}`
|
||||
url: `/pages/mall/consumer/payment?orderId=${order.id}&amount=${paymentAmount}`
|
||||
})
|
||||
},
|
||||
|
||||
@@ -2693,4 +2615,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user