|
|
@ -137,6 +137,16 @@ Page({ |
|
|
filteredSpecOptions: this.data.specOptions, |
|
|
filteredSpecOptions: this.data.specOptions, |
|
|
filteredEditSpecOptions: this.data.specOptions |
|
|
filteredEditSpecOptions: this.data.specOptions |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 尝试从本地存储加载草稿数据
|
|
|
|
|
|
const draftData = wx.getStorageSync('newSupplyDraft'); |
|
|
|
|
|
if (draftData) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
newSupply: draftData |
|
|
|
|
|
}); |
|
|
|
|
|
console.log('从本地存储加载了草稿数据'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console.log('卖家页面onLoad执行完毕'); |
|
|
console.log('卖家页面onLoad执行完毕'); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -1214,11 +1224,14 @@ Page({ |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 从本地存储加载之前保存的货源数据
|
|
|
|
|
|
const savedSupply = wx.getStorageSync('newSupplyDraft') || { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }; |
|
|
|
|
|
|
|
|
// 直接显示创建货源弹窗,无需登录验证
|
|
|
// 直接显示创建货源弹窗,无需登录验证
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
showImagePreview: false, |
|
|
showImagePreview: false, |
|
|
showModal: true, |
|
|
showModal: true, |
|
|
newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } |
|
|
newSupply: savedSupply |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 锁定页面滚动
|
|
|
// 锁定页面滚动
|
|
|
@ -1229,7 +1242,6 @@ Page({ |
|
|
hideModal() { |
|
|
hideModal() { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
showModal: false, |
|
|
showModal: false, |
|
|
newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }, |
|
|
|
|
|
showImagePreview: false // 确保图片预览弹窗关闭
|
|
|
showImagePreview: false // 确保图片预览弹窗关闭
|
|
|
}) |
|
|
}) |
|
|
// 恢复页面滚动
|
|
|
// 恢复页面滚动
|
|
|
@ -1286,6 +1298,9 @@ Page({ |
|
|
const newSupply = this.data.newSupply |
|
|
const newSupply = this.data.newSupply |
|
|
newSupply[field] = value |
|
|
newSupply[field] = value |
|
|
this.setData({ newSupply }) |
|
|
this.setData({ newSupply }) |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 编辑输入处理
|
|
|
// 编辑输入处理
|
|
|
@ -1453,6 +1468,10 @@ Page({ |
|
|
showModal: false, |
|
|
showModal: false, |
|
|
newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } |
|
|
newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 清除本地存储的草稿数据
|
|
|
|
|
|
wx.removeStorageSync('newSupplyDraft'); |
|
|
|
|
|
|
|
|
this.enablePageScroll() |
|
|
this.enablePageScroll() |
|
|
|
|
|
|
|
|
// 重新加载数据
|
|
|
// 重新加载数据
|
|
|
@ -2859,10 +2878,15 @@ Page({ |
|
|
|
|
|
|
|
|
// 根据当前模式更新对应的规格信息
|
|
|
// 根据当前模式更新对应的规格信息
|
|
|
if (this.data.currentSpecMode === 'create') { |
|
|
if (this.data.currentSpecMode === 'create') { |
|
|
|
|
|
const newSupply = this.data.newSupply; |
|
|
|
|
|
newSupply.spec = selectedSpec; |
|
|
|
|
|
newSupply.specIndex = originalIndex; |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'newSupply.spec': selectedSpec, |
|
|
newSupply: newSupply |
|
|
'newSupply.specIndex': originalIndex |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
} else if (this.data.currentSpecMode === 'edit') { |
|
|
} else if (this.data.currentSpecMode === 'edit') { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'editSupply.spec': selectedSpec, |
|
|
'editSupply.spec': selectedSpec, |
|
|
@ -2986,9 +3010,14 @@ Page({ |
|
|
|
|
|
|
|
|
// 根据类型更新数据
|
|
|
// 根据类型更新数据
|
|
|
if (type === 'new') { |
|
|
if (type === 'new') { |
|
|
|
|
|
const newSupply = this.data.newSupply; |
|
|
|
|
|
newSupply.imageUrls = updatedImages; |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'newSupply.imageUrls': updatedImages |
|
|
newSupply: newSupply |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
} else { |
|
|
} else { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'editSupply.imageUrls': updatedImages |
|
|
'editSupply.imageUrls': updatedImages |
|
|
@ -3074,11 +3103,16 @@ Page({ |
|
|
const type = e.currentTarget.dataset.type || 'new'; // 默认处理new类型
|
|
|
const type = e.currentTarget.dataset.type || 'new'; // 默认处理new类型
|
|
|
|
|
|
|
|
|
if (type === 'new') { |
|
|
if (type === 'new') { |
|
|
const imageUrls = this.data.newSupply.imageUrls; |
|
|
const newSupply = this.data.newSupply; |
|
|
|
|
|
const imageUrls = newSupply.imageUrls; |
|
|
imageUrls.splice(index, 1); |
|
|
imageUrls.splice(index, 1); |
|
|
|
|
|
newSupply.imageUrls = imageUrls; |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'newSupply.imageUrls': imageUrls |
|
|
newSupply: newSupply |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
} else { |
|
|
} else { |
|
|
const imageUrls = this.data.editSupply.imageUrls; |
|
|
const imageUrls = this.data.editSupply.imageUrls; |
|
|
imageUrls.splice(index, 1); |
|
|
imageUrls.splice(index, 1); |
|
|
@ -3343,6 +3377,9 @@ Page({ |
|
|
showNameSelectModal: false, |
|
|
showNameSelectModal: false, |
|
|
showTabBar: true // 显示底部tab-bar
|
|
|
showTabBar: true // 显示底部tab-bar
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -3418,6 +3455,9 @@ Page({ |
|
|
showYolkSelectModal: false, |
|
|
showYolkSelectModal: false, |
|
|
showTabBar: true // 显示底部tab-bar
|
|
|
showTabBar: true // 显示底部tab-bar
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 实时保存到本地存储
|
|
|
|
|
|
wx.setStorageSync('newSupplyDraft', newSupply); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|