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