diff --git a/pages/seller/index.js b/pages/seller/index.js index fee921e..3af9e30 100644 --- a/pages/seller/index.js +++ b/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, diff --git a/pages/seller/index.wxml b/pages/seller/index.wxml index f9e0df6..ad48632 100644 --- a/pages/seller/index.wxml +++ b/pages/seller/index.wxml @@ -565,14 +565,12 @@ 最多上传5张图片 - 品种 - 商品名称 - {{editSupply.productName || editSupply.name || '请选择商品名称'}} + {{editSupply.productName || '请选择商品名称'}}