Browse Source

修复双击确定功能失效问题

pull/1/head
徐飞洋 3 months ago
parent
commit
adc81f8863
  1. 29
      pages/seller/index.js
  2. 4
      pages/seller/index.wxml

29
pages/seller/index.js

@ -2709,7 +2709,9 @@ Page({
const index = e.detail.value
const productName = this.data.productNameOptions[index]
const newSupply = this.data.newSupply
newSupply.name = productName
// 品种和商品名称保持一致
newSupply.name = productName // 更新品种字段
newSupply.productName = productName // 更新商品名称字段
this.setData({ newSupply })
},
@ -3099,8 +3101,10 @@ Page({
})
.then(() => {
// 【关键修复】准备商品数据 - 确保包含地区字段
// 品种和商品名称保持一致,使用商品名称的值
const productName = editSupply.productName || editSupply.name;
const productData = {
productName: editSupply.name,
productName: productName, // 使用统一的商品名称
price: editSupply.price, // 保留原始字符串,不进行数字转换
quantity: Number(editSupply.minOrder),
grossWeight: editSupply.grossWeight !== undefined && editSupply.grossWeight !== null && editSupply.grossWeight !== '' ? editSupply.grossWeight : "",
@ -3566,10 +3570,14 @@ Page({
const specIndex = this.data.specOptions.indexOf(supply.spec) >= 0 ? this.data.specOptions.indexOf(supply.spec) : 0;
// 设置编辑货源数据,显示编辑弹窗
// 确保商品名称和品种字段同步
const productName = supply.productName || supply.name;
const supplyWithFormattedTime = {
...supply,
formattedCreatedAt: this.formatCreateTime(supply.created_at),
region: supply.region || '', // 【新增】确保地区字段存在
name: productName, // 确保品种字段有值
productName: productName, // 确保商品名称字段有值
yolkIndex: yolkIndex,
specIndex: specIndex
};
@ -4373,14 +4381,22 @@ Page({
// 通用双击检测函数
handleDoubleTap: function (e, type, callback) {
// 确保lastTapTime对象存在
if (!this.lastTapTime) {
this.lastTapTime = {};
}
const currentTime = Date.now();
const tapKey = `${type}-${e.currentTarget.dataset.index}`;
const index = e.currentTarget.dataset.index;
const tapKey = `${type}-${index}`;
const lastTap = this.lastTapTime[tapKey] || 0;
const tapInterval = currentTime - lastTap;
if (tapInterval < 300 && tapInterval > 0) {
// 双击事件触发,执行确认选择
callback();
// 清除双击记录
delete this.lastTapTime[tapKey];
} else {
// 单击事件触发,执行选择操作
this.lastTapTime[tapKey] = currentTime;
@ -5161,13 +5177,16 @@ Page({
// 根据当前是编辑还是创建模式,更新对应的对象
if (this.data.showEditModal) {
this.setData({
'editSupply.name': selectedName,
'editSupply.name': selectedName, // 同时更新品种字段
'editSupply.productName': selectedName, // 更新商品名称字段
showNameSelectModal: false,
showTabBar: true // 显示底部tab-bar
});
} else {
const newSupply = this.data.newSupply;
newSupply.name = selectedName;
// 品种和商品名称保持一致
newSupply.name = selectedName; // 更新品种字段
newSupply.productName = selectedName; // 更新商品名称字段
this.setData({
newSupply: newSupply,
showNameSelectModal: false,

4
pages/seller/index.wxml

@ -565,14 +565,12 @@
<view style="font-size: 22rpx; color: #999; margin-top: 16rpx; text-align: center;">最多上传5张图片</view>
</view>
<view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">品种</view>
<input class="input" type="text" placeholder="请输入品种" bindinput="onEditInput" data-field="name" value="{{editSupply.name}}" style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block;" placeholder-style="font-size: 24rpx; color: #999; text-align: left;"></input>
<view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">商品名称</view>
<view
bindtap="openNameSelectModal"
style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block; background: white; position: relative;">
<view style="display: flex; justify-content: space-between; align-items: center;">
<text style="text-align: left;">{{editSupply.productName || editSupply.name || '请选择商品名称'}}</text>
<text style="text-align: left;">{{editSupply.productName || '请选择商品名称'}}</text>
<text style="color: #999;">▼</text>
</view>
</view>

Loading…
Cancel
Save