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