From f346150e2cc704a473dbc813e7497a076093ffb4 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: Sat, 20 Dec 2025 15:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=9A=E6=B7=BB=E5=8A=A0app.js=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=B9=B6=E5=A2=9E=E5=BC=BA=E5=85=A8=E5=B1=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 24 ++++++++++++++++++++++++ server-example/server-mysql.js | 24 +++--------------------- utils/api.js | 4 +++- 3 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..493c28d --- /dev/null +++ b/app.js @@ -0,0 +1,24 @@ +// app.js +App({ + globalData: { + userInfo: null, + currentTab: 'index' + }, + + // 更新当前选中的tab + updateCurrentTab(tabName) { + this.globalData.currentTab = tabName; + }, + + onLaunch() { + console.log('App launched'); + }, + + onShow() { + console.log('App shown'); + }, + + onHide() { + console.log('App hidden'); + } +}); diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index d548f94..30f31c5 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -8096,32 +8096,14 @@ app.post('/api/chat/add', async (req, res) => { 'INSERT INTO chat_list (user_phone, manager_phone) VALUES (?, ?)', { replacements: [user_phone, manager_phone] } ); - - // 2. 业务员手机号 -> 用户手机号 + res.status(200).json({ + success: true, await sequelize.query( 'INSERT INTO chat_list (user_phone, manager_phone) VALUES (?, ?)', { replacements: [manager_phone, user_phone] } ); - - console.log('✅ 成功插入两条聊天记录'); - - res.status(200).json({ - success: true, - code: 200, - message: '聊天记录添加成功', - data: { - user_phone, - manager_phone - } }); - } catch (error) { - console.error('添加聊天记录失败:', error); - res.status(500).json({ - success: false, - code: 500, - message: '添加聊天记录失败: ' + error.message - }); - } + console.log('✅ 成功插入两条聊天记录'); }); // 新增:获取业务员信息接口 - 根据手机号查询 diff --git a/utils/api.js b/utils/api.js index b5c68fe..466a843 100644 --- a/utils/api.js +++ b/utils/api.js @@ -2942,7 +2942,9 @@ module.exports = { // 更新全局数据 const app = getApp(); - app.globalData.userType = newType; + if (app && app.globalData) { + app.globalData.userType = newType; + } // 同时更新本地的userType存储 wx.setStorageSync('userType', newType);