Browse Source

Merge pull request 'XFY' (#10) from XFY into master

Reviewed-on: http://8.137.125.67:4000/SwtTt29/Mini-Program/pulls/10
pull/1/head
SwtTt29 3 months ago
parent
commit
659f000dc6
  1. 4
      app.js
  2. 54
      pages/seller/index.js
  3. 1
      server-example/PATH.txt
  4. 4
      server-example/settings.txt

4
app.js

@ -2,7 +2,6 @@ App({
onLaunch: function () { onLaunch: function () {
// 初始化应用 // 初始化应用
console.log('App Launch') console.log('App Launch')
// 初始化本地存储的标签和用户数据 // 初始化本地存储的标签和用户数据
if (!wx.getStorageSync('users')) { if (!wx.getStorageSync('users')) {
wx.setStorageSync('users', {}) wx.setStorageSync('users', {})
@ -103,6 +102,7 @@ App({
globalData: { globalData: {
userInfo: null, userInfo: null,
currentTab: 'index' // 当前选中的tab currentTab: 'index', // 当前选中的tab
showTabBar: true // 控制底部tab-bar显示状态
} }
}) })

54
pages/seller/index.js

@ -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);
} }
} }
}, },

1
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;

4
server-example/settings.txt

@ -0,0 +1,4 @@
root: server-example
path: C:\Program Files\nodejs
arch: 64
proxy: none
Loading…
Cancel
Save