From 8bc95e5e47d5c63b0a213c5577d9bbc00b61c219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Tue, 2 Dec 2025 14:50:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9app.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 9662778..5d3d1f1 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,7 @@ App({ onLaunch: function () { // 初始化应用 console.log('App Launch') - + //////aaaaaaaaaaaaaaaaaaaaaaaaaa // 初始化本地存储的标签和用户数据 if (!wx.getStorageSync('users')) { wx.setStorageSync('users', {}) From a04b3ee4545627936e5fd5187a550943da14490b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Tue, 2 Dec 2025 15:53:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=B4=A7=E6=BA=90=E6=9C=AC=E5=9C=B0=E7=BC=93=E5=AD=98=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E7=AD=89=E6=89=80=E6=9C=89=E5=AD=97=E6=AE=B5=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 4 +-- pages/seller/index.js | 54 ++++++++++++++++++++++++++++++++----- server-example/PATH.txt | 1 + server-example/settings.txt | 4 +++ 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 server-example/PATH.txt create mode 100644 server-example/settings.txt diff --git a/app.js b/app.js index 5d3d1f1..d276bc2 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,6 @@ App({ onLaunch: function () { // 初始化应用 console.log('App Launch') - //////aaaaaaaaaaaaaaaaaaaaaaaaaa // 初始化本地存储的标签和用户数据 if (!wx.getStorageSync('users')) { wx.setStorageSync('users', {}) @@ -103,6 +102,7 @@ App({ globalData: { userInfo: null, - currentTab: 'index' // 当前选中的tab + currentTab: 'index', // 当前选中的tab + showTabBar: true // 控制底部tab-bar显示状态 } }) diff --git a/pages/seller/index.js b/pages/seller/index.js index b2e8add..754ad6c 100644 --- a/pages/seller/index.js +++ b/pages/seller/index.js @@ -137,6 +137,16 @@ Page({ filteredSpecOptions: this.data.specOptions, filteredEditSpecOptions: this.data.specOptions }); + + // 尝试从本地存储加载草稿数据 + const draftData = wx.getStorageSync('newSupplyDraft'); + if (draftData) { + this.setData({ + newSupply: draftData + }); + console.log('从本地存储加载了草稿数据'); + } + console.log('卖家页面onLoad执行完毕'); }, @@ -1214,11 +1224,14 @@ Page({ e.stopPropagation(); } + // 从本地存储加载之前保存的货源数据 + const savedSupply = wx.getStorageSync('newSupplyDraft') || { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }; + // 直接显示创建货源弹窗,无需登录验证 this.setData({ showImagePreview: false, showModal: true, - newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } + newSupply: savedSupply }); // 锁定页面滚动 @@ -1229,7 +1242,6 @@ Page({ hideModal() { this.setData({ showModal: false, - newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }, showImagePreview: false // 确保图片预览弹窗关闭 }) // 恢复页面滚动 @@ -1286,6 +1298,9 @@ Page({ const newSupply = this.data.newSupply newSupply[field] = value this.setData({ newSupply }) + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); }, // 编辑输入处理 @@ -1453,6 +1468,10 @@ Page({ showModal: false, newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } }) + + // 清除本地存储的草稿数据 + wx.removeStorageSync('newSupplyDraft'); + this.enablePageScroll() // 重新加载数据 @@ -2859,10 +2878,15 @@ Page({ // 根据当前模式更新对应的规格信息 if (this.data.currentSpecMode === 'create') { + const newSupply = this.data.newSupply; + newSupply.spec = selectedSpec; + newSupply.specIndex = originalIndex; this.setData({ - 'newSupply.spec': selectedSpec, - 'newSupply.specIndex': originalIndex + newSupply: newSupply }); + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); } else if (this.data.currentSpecMode === 'edit') { this.setData({ 'editSupply.spec': selectedSpec, @@ -2986,9 +3010,14 @@ Page({ // 根据类型更新数据 if (type === 'new') { + const newSupply = this.data.newSupply; + newSupply.imageUrls = updatedImages; this.setData({ - 'newSupply.imageUrls': updatedImages + newSupply: newSupply }); + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); } else { this.setData({ 'editSupply.imageUrls': updatedImages @@ -3074,11 +3103,16 @@ Page({ const type = e.currentTarget.dataset.type || 'new'; // 默认处理new类型 if (type === 'new') { - const imageUrls = this.data.newSupply.imageUrls; + const newSupply = this.data.newSupply; + const imageUrls = newSupply.imageUrls; imageUrls.splice(index, 1); + newSupply.imageUrls = imageUrls; this.setData({ - 'newSupply.imageUrls': imageUrls + newSupply: newSupply }); + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); } else { const imageUrls = this.data.editSupply.imageUrls; imageUrls.splice(index, 1); @@ -3343,6 +3377,9 @@ Page({ showNameSelectModal: false, showTabBar: true // 显示底部tab-bar }); + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); } } }, @@ -3418,6 +3455,9 @@ Page({ showYolkSelectModal: false, showTabBar: true // 显示底部tab-bar }); + + // 实时保存到本地存储 + wx.setStorageSync('newSupplyDraft', newSupply); } } }, diff --git a/server-example/PATH.txt b/server-example/PATH.txt new file mode 100644 index 0000000..a5f0db3 --- /dev/null +++ b/server-example/PATH.txt @@ -0,0 +1 @@ +PATH=C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files\Java\jdk1.8.0_202\bin;C:\Program Files\Java\jdk1.8.0_202;C:\Program Files\Common Files\Oracle\Java\javapath;D:\vm\bin\;C:\Program Files (x86)\Razer Chroma SDK\bin;D:\apache-tomcat-8.0.32\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\ruanjian\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\18477\AppData\Local\nvm;C:\nvm4w\nodejs;C:\Users\18477\AppData\Roaming\MySQL;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\dotnet\;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Program Files\Java\jdk1.8.0_202\bin;D:\python\Scripts\;D:\python\;C:\Users\18477\AppData\Local\Microsoft\WindowsApps;C:\Users\18477\.dotnet\tools;D:\pycharm\PyCharm 2024.3.2\bin;;D:\VS Code\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2025.2.3\bin;C:\Users\18477\AppData\Local\nvm;C:\nvm4w\nodejs; diff --git a/server-example/settings.txt b/server-example/settings.txt new file mode 100644 index 0000000..e28a117 --- /dev/null +++ b/server-example/settings.txt @@ -0,0 +1,4 @@ +root: server-example +path: C:\Program Files\nodejs +arch: 64 +proxy: none