修复:预约作品弹层滚动穿透

This commit is contained in:
2026-10-12 17:37:51 +08:00
parent 2714bd7201
commit fa1fed006e
5 changed files with 84 additions and 37 deletions
@@ -454,6 +454,9 @@ Page({
stopTap() {
},
stopTouchMove() {
},
onProductSearch(event) {
this.setData({ productKeyword: event.detail.value })
this.refreshProductCards()
@@ -79,7 +79,7 @@
<text class="tip-text">{{conflictTip}}</text>
</view>
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal">
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove">
<view class="product-modal" catchtap="stopTap">
<view class="modal-head">
<view>
@@ -88,44 +88,46 @@
<view class="modal-close" bindtap="closeProductModal">×</view>
</view>
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
<scroll-view class="product-list" scroll-y>
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
<view wx:else class="product-cover placeholder">图</view>
<view class="product-info">
<view class="product-title-row">
<text class="product-title">{{item.title}}</text>
<text class="product-price">{{item.priceText}}</text>
</view>
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
<view class="tag-row">
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
<scroll-view class="product-modal-scroll" scroll-y enhanced show-scrollbar="{{false}}">
<view class="product-list">
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
<view wx:else class="product-cover placeholder">图</view>
<view class="product-info">
<view class="product-title-row">
<text class="product-title">{{item.title}}</text>
<text class="product-price">{{item.priceText}}</text>
</view>
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
<view class="tag-row">
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
</view>
</view>
</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</view>
<view class="manual-panel">
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
<view class="manual-grid single">
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
</view>
<view class="manual-image-row">
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
<view wx:else class="manual-image placeholder">图</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</scroll-view>
<view class="manual-panel">
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
<view class="manual-grid single">
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
</view>
<view class="manual-image-row">
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
<view wx:else class="manual-image placeholder">图</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
</view>
</view>
</view>
@@ -208,8 +208,13 @@
}
.product-modal {
display: flex;
box-sizing: border-box;
height: 88vh;
width: 100%;
max-height: 88vh;
flex-direction: column;
overflow: hidden;
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
border-radius: 28rpx 28rpx 0 0;
background: #fffaf4;
@@ -293,9 +298,16 @@
font-size: 26rpx;
}
.product-list {
max-height: 440rpx;
.product-modal-scroll {
flex: 1;
height: 0;
min-height: 0;
margin-top: 20rpx;
padding-right: 2rpx;
}
.product-list {
width: 100%;
}
.product-option {
@@ -0,0 +1,14 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
const pageScript = fs.readFileSync(path.join(__dirname, 'index.js'), 'utf8')
assert.match(wxml, /class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove"/)
assert.match(wxml, /<scroll-view class="product-modal-scroll" scroll-y/)
assert.match(wxml, /<view class="product-list">/)
assert.match(wxss, /\.product-modal\s*\{[^}]*height:\s*88vh;[^}]*flex-direction:\s*column;[^}]*overflow:\s*hidden;/s)
assert.match(wxss, /\.product-modal-scroll\s*\{[^}]*flex:\s*1;[^}]*height:\s*0;[^}]*min-height:\s*0;/s)
assert.match(pageScript, /stopTouchMove\(\)\s*\{\s*\}/)
@@ -0,0 +1,16 @@
# 预约作品弹层滚动修复设计
## 问题
预约作品弹层只有最大高度,内部作品列表没有确定的可滚动高度;遮罩层也未拦截纵向触摸,导致滑动作品弹层时底层预约页面滚动。
## 方案
- 将作品弹层设置为固定视口高度的纵向弹性布局,并隐藏弹层自身溢出。
- 标题和搜索框保持固定,将作品列表及手动新增区域放入同一个纵向 `scroll-view`。
- 遮罩层拦截 `touchmove`,阻止手势穿透到底层页面。
- 保留点击遮罩关闭、作品选择、搜索和手动新增的原有业务行为。
## 验证
增加弹层结构测试,检查滚动容器、固定高度布局和触摸拦截;运行全部小程序测试。当前会话未提供 GitNexus `impact` 与 `detect_changes` 工具,因此使用静态引用检查、结构测试和 Git 差异检查替代。