From bd87a4cde92ce0188824d5522781449eba0a0f2d 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 17:01:16 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=A2=E6=9C=8D=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=92=8C=E8=A7=92=E8=89=B2=E7=AD=9B=E9=80=89=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/customer-service/index.js | 16 +++++++++++++---
pages/index/index.js | 8 +++++---
pages/index/index.wxml | 4 ++--
server-example/server-mysql.js | 16 +++++++++++++---
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/pages/customer-service/index.js b/pages/customer-service/index.js
index b3ed1a4..5e517c9 100644
--- a/pages/customer-service/index.js
+++ b/pages/customer-service/index.js
@@ -8,7 +8,8 @@ Page({
searchKeyword: '',
selectedArea: '全部',
totalCount: 0,
- onlineCount: 0
+ onlineCount: 0,
+ userType: 'seller' // 初始化用户类型,默认为销售员
},
// 获取客服列表的方法
@@ -18,9 +19,12 @@ Page({
// 导入API工具并使用正确的请求方法
const api = require('../../utils/api');
+ // 获取当前用户类型参数
+ const userType = this.data.userType || 'seller';
+
const res = await new Promise((resolve, reject) => {
wx.request({
- url: 'http://localhost:3003/api/managers',
+ url: `http://localhost:3003/api/managers?type=${userType}`,
method: 'GET',
timeout: 15000,
header: {
@@ -191,7 +195,13 @@ Page({
}
},
- onLoad: function () {
+ onLoad: function (options) {
+ // 获取页面参数(seller=销售员,buyer=采购员)
+ this.setData({
+ userType: options.type || 'seller' // 默认销售员
+ });
+ console.log('客服列表页面加载,类型:', this.data.userType);
+
// 加载客服列表
this.loadCustomerServices();
diff --git a/pages/index/index.js b/pages/index/index.js
index f254c19..ae91af7 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -32,11 +32,13 @@ Page({
},
// 跳转到客服列表页面
- navigateToCustomerService() {
+ navigateToCustomerService(e) {
+ // 获取按钮类型(seller=我要买蛋,buyer=我要卖蛋)
+ const userType = e.currentTarget.dataset.type;
wx.navigateTo({
- url: '/pages/customer-service/index',
+ url: `/pages/customer-service/index?type=${userType}`,
success: function() {
- console.log('成功跳转到客服列表页面');
+ console.log('成功跳转到客服列表页面,类型:', userType);
},
fail: function(error) {
console.error('跳转到客服列表页面失败:', error);
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 1774abe..b40a050 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -27,8 +27,8 @@
-
-
+
+
diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js
index fd9ce5f..b679e69 100644
--- a/server-example/server-mysql.js
+++ b/server-example/server-mysql.js
@@ -6481,14 +6481,24 @@ app.get('/api/online-stats', async (req, res) => {
});
}
});
-// REST API接口 - 获取客服列表 - 修改为按照用户需求:工位名为采购员且有电话号码
+// REST API接口 - 获取客服列表 - 支持按角色类型查询(销售员/采购员)
app.get('/api/managers', async (req, res) => {
try {
- // 查询userlogin数据库中的personnel表,获取工位为销售员且有电话号码的用户
+ // 获取请求参数中的角色类型(seller=销售员,buyer=采购员)
+ const { type } = req.query;
+ console.log('获取客服列表请求,类型:', type);
+
+ // 根据角色类型确定查询的projectName值
+ let projectName = '销售员'; // 默认查询销售员
+ if (type === 'buyer') {
+ projectName = '采购员'; // 如果类型为buyer,查询采购员
+ }
+
+ // 查询userlogin数据库中的personnel表,获取指定工位且有电话号码的用户
// 根据表结构选择所有需要的字段
const [personnelData] = await sequelize.query(
'SELECT id, managerId, managercompany, managerdepartment, organization, projectName, name, alias, phoneNumber, avatarUrl FROM userlogin.personnel WHERE projectName = ? AND phoneNumber IS NOT NULL AND phoneNumber != "" ORDER BY id ASC',
- { replacements: ['销售员'] }
+ { replacements: [projectName] }
);
// 查询chat_online_status表获取客服在线状态(添加错误处理)