Browse Source

修复点击top无法回到顶部、评论内容不换行、评论区布局问题

pull/19/head
徐飞洋 2 months ago
parent
commit
5d22f09e92
  1. 14
      pages/goods-detail/goods-detail.wxss
  2. 19
      pages/index/index.js
  3. 14
      pages/index/index.wxml
  4. 4
      utils/api.js

14
pages/goods-detail/goods-detail.wxss

@ -1052,7 +1052,7 @@ video.slider-media .wx-video-volume-icon {
.comments-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
align-items: center;
margin-bottom: 20px;
padding-bottom: 12px;
border-bottom: 1px solid #f0f0f0;
@ -1170,6 +1170,9 @@ video.slider-media .wx-video-volume-icon {
font-size: 14px;
line-height: 1.6;
color: #595959;
word-break: break-all;
word-wrap: break-word;
white-space: normal;
}
.comment-footer {
@ -1354,12 +1357,13 @@ video.slider-media .wx-video-volume-icon {
background-color: #1890ff;
color: #ffffff;
border: none;
border-radius: 12rpx;
padding: 24rpx 64rpx;
font-size: 32rpx;
border-radius: 8rpx;
padding: 16rpx 48rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.3);
box-shadow: 0 2rpx 8rpx rgba(24, 144, 255, 0.3);
transition: all 0.3s ease;
white-space: nowrap;
}
.comment-button:active {

19
pages/index/index.js

@ -2503,11 +2503,30 @@ Page({
// 回到顶部
scrollToTop: function () {
// 使用数据绑定的方式回到顶部,这是小程序中最可靠的方式
this.setData({
scrollTop: 0,
searchSectionVisible: true,
showBackToTop: false
});
// 作为备选方案,确保滚动到顶部
const scrollView = this.selectComponent('#goodsScrollView');
if (scrollView) {
// 添加微小延迟确保数据绑定生效后再调用scrollTo
setTimeout(() => {
scrollView.scrollTo({
scrollTop: 0,
duration: 300
});
}, 50);
}
},
// 图片加载完成事件
onImageLoad(e) {
console.log('图片加载完成:', e);
// 可以在这里添加图片加载完成后的处理逻辑,比如统计加载时间、显示动画等
},
// 上拉加载更多

14
pages/index/index.wxml

@ -160,6 +160,7 @@
bindscrolltolower="onReachBottom"
bindscroll="onScroll"
scroll-y="true"
scroll-top="{{scrollTop}}"
refresher-enabled="{{true}}"
refresher-triggered="{{isRefreshing}}"
refresher-default-style="black"
@ -172,7 +173,7 @@
<view class="function-buttons">
<view class="function-btn" bindtap="navigateToSettlement">
<text class="function-btn-icon">🏠</text>
<text class="function-btn-text">入驻</text>
<text class="function-btn-text">我要卖蛋</text>
</view>
<view class="function-btn" bindtap="navigateToCooperation">
<text class="function-btn-icon">📣</text>
@ -182,6 +183,10 @@
<text class="function-btn-icon">🚻</text>
<text class="function-btn-text">我们</text>
</view>
<view class="function-btn" bindtap="navigateToCooperation">
<text class="function-btn-icon">🚻</text>
<text class="function-btn-text">添加桌面</text>
</view>
</view>
<!-- 广告走马灯轮播图 -->
@ -291,5 +296,12 @@
</view>
</view>
</scroll-view>
<!-- 回到顶部按钮 -->
<view
class="back-to-top-btn {{showBackToTop ? 'visible' : ''}}"
bindtap="scrollToTop"
>
<text class="back-to-top-text">top</text>
</view>
</view>
</view>

4
utils/api.js

@ -39,9 +39,9 @@ function isRealDevice() {
// 尝试通过系统信息判断环境 - 增强版
try {
const systemInfo = wx.getSystemInfoSync();
const deviceInfo = wx.getDeviceInfo();
// 明确识别开发者工具环境
if (systemInfo && (systemInfo.platform === 'devtools' || systemInfo.environment === 'devtools')) {
if (deviceInfo && (deviceInfo.platform === 'devtools' || deviceInfo.environment === 'devtools')) {
return false;
}
// 其他平台都认为是真机

Loading…
Cancel
Save