From f004a75483bf007e63096f1088044d68882b2151 Mon Sep 17 00:00:00 2001 From: zhonghua1 Date: Thu, 1 Jan 2026 05:38:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E9=A1=BE=E9=97=AE=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E6=9C=8D=E5=8A=A1=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/champion/champion.vue | 2 +- pages/customer/customer-refactored.vue | 2 +- pages/customer/customer.vue | 2 +- pages/reception/reception.vue | 165 ++++++++++++++++++++++++- pages/team/team.vue | 4 +- 5 files changed, 164 insertions(+), 11 deletions(-) diff --git a/pages/champion/champion.vue b/pages/champion/champion.vue index a020ebd..88e17ea 100644 --- a/pages/champion/champion.vue +++ b/pages/champion/champion.vue @@ -8,7 +8,7 @@ {{ item.staffName }} + + 结束 + 服务中 @@ -525,8 +528,39 @@ import { getApiUrl } from "@/common/config.js"; }, onLoad() { this.fetchServiceStatusList(); + // 加载当前登录用户信息,填充销售姓名和电话 + this.loadCurrentUserInfo(); }, methods: { + /** + * 加载当前登录用户信息,填充销售姓名和电话 + */ + loadCurrentUserInfo() { + try { + // 从本地存储获取登录响应信息 + const loginResponse = uni.getStorageSync('backend-login-response') || {}; + + // 填充销售姓名 + if (loginResponse.userName) { + this.receptionForm.salesName = loginResponse.userName; + } + + // 填充销售电话:如果电话为空,则使用姓名作为电话 + if (loginResponse.phone) { + this.receptionForm.salesPhone = loginResponse.phone; + } else if (loginResponse.userName) { + // 如果电话为空,使用姓名作为电话 + this.receptionForm.salesPhone = loginResponse.userName; + } + + // 如果有 userId,也可以填充到 salesId + if (loginResponse.userId) { + this.receptionForm.salesId = String(loginResponse.userId); + } + } catch (e) { + console.error('加载当前登录用户信息失败:', e); + } + }, goBack() { uni.navigateBack(); }, @@ -534,6 +568,9 @@ import { getApiUrl } from "@/common/config.js"; this.activeTab = tab; if (tab === 'status') { this.fetchServiceStatusList(); + } else if (tab === 'reception') { + // 切换到开始接待标签页时,重新加载当前登录用户信息 + this.loadCurrentUserInfo(); } else if (tab === 'tag') { this.tagViewMode = 'list'; // 当进入标签管理页面时,请求接口填充数据 @@ -721,6 +758,99 @@ import { getApiUrl } from "@/common/config.js"; // 查看服务详情 console.log('查看服务详情', item); }, + async finishService(item) { + if (!item || !item.id) { + uni.showToast({ + title: '无法获取服务记录ID', + icon: 'none' + }); + return; + } + + uni.showModal({ + title: '确认结束', + content: `确定要结束这条服务记录吗?`, + success: async (res) => { + if (res.confirm) { + try { + uni.showLoading({ + title: '结束中...' + }); + + const url = getApiUrl('/api/audioManagement/finishServiceById'); + + // 获取认证信息 + let tenantId = ''; + let token = ''; + try { + tenantId = uni.getStorageSync('backend-tenant-id') || ''; + token = uni.getStorageSync('backend-token') || ''; + } catch (e) { + console.error('获取认证信息失败:', e); + } + + // 构建请求头 + const headers = { + 'Content-Type': 'application/json' + }; + if (token) { + headers['Authorization'] = `Bearer ${token}`; + } + if (tenantId) { + headers['X-Tenant-Id'] = tenantId; + } + + // 构建请求体 + const requestData = { + id: item.id + }; + + const finishRes = await uni.request({ + url: url, + method: 'POST', + data: requestData, + header: headers, + timeout: 30000 + }); + + uni.hideLoading(); + + if (finishRes.statusCode === 200 && finishRes.data && finishRes.data.success) { + uni.showToast({ + title: finishRes.data?.message || '结束服务成功', + icon: 'success' + }); + // 结束成功后刷新列表 + this.serviceStatusPage.current = 1; + this.fetchServiceStatusList({ force: true }); + } else { + uni.showToast({ + title: finishRes.data?.message || '结束服务失败', + icon: 'none' + }); + } + } catch (error) { + uni.hideLoading(); + console.error('结束服务失败:', error); + // 根据错误类型提供更详细的错误信息 + let errorMessage = '结束服务失败,请重试'; + if (error.errMsg) { + if (error.errMsg.includes('timeout')) { + errorMessage = '请求超时,请检查网络连接后重试'; + } else if (error.errMsg.includes('fail')) { + errorMessage = '网络请求失败,请检查网络连接'; + } + } + uni.showToast({ + title: errorMessage, + icon: 'none', + duration: 3000 + }); + } + } + } + }); + }, onGenderChange(e) { this.receptionForm.gender = e.detail.value; }, @@ -797,9 +927,9 @@ import { getApiUrl } from "@/common/config.js"; id: retrievedId ? String(retrievedId) : this.receptionForm.id, customerName: customer.customerName || this.receptionForm.customerName, customerSource: customer.customerSource || this.receptionForm.customerSource, - dealershipId: customer.dealershipId || this.receptionForm.dealershipId, + dealershipId: customer.dealershipId ? String(customer.dealershipId) : this.receptionForm.dealershipId, dealershipName: customer.dealershipName || this.receptionForm.dealershipName, - salesId: customer.salesId || this.receptionForm.salesId, + salesId: customer.salesId ? String(customer.salesId) : this.receptionForm.salesId, salesName: customer.salesName || this.receptionForm.salesName, salesPhone: String(resolvedSalesPhone), recordingCount: customer.recordingCount ?? this.receptionForm.recordingCount, @@ -843,6 +973,8 @@ import { getApiUrl } from "@/common/config.js"; detailedAddress: "", contactCount: 0 }; + // 重置后重新填充当前登录用户信息 + this.loadCurrentUserInfo(); uni.showToast({ title: "已取消", icon: "none" @@ -888,9 +1020,9 @@ import { getApiUrl } from "@/common/config.js"; customerName: this.receptionForm.customerName?.trim(), contact: trimmedContact, customerSource: this.receptionForm.customerSource?.trim() || "", - dealershipId: this.receptionForm.dealershipId?.trim() || "", + dealershipId: String(this.receptionForm.dealershipId || '').trim() || "", dealershipName: this.receptionForm.dealershipName?.trim() || "", - salesId: this.receptionForm.salesId?.trim() || "", + salesId: String(this.receptionForm.salesId || '').trim() || "", salesName: this.receptionForm.salesName?.trim() || "", recordingCount: Number(this.receptionForm.recordingCount) || 0, intendedModel: this.receptionForm.intendedModel?.trim() || "", @@ -1557,12 +1689,12 @@ import { getApiUrl } from "@/common/config.js"; .service-status { display: flex; align-items: center; + gap: 8rpx; } .service-status text { font-size: 26rpx; color: #007AFF; - margin-left: 8rpx; } .customer-tags { @@ -1724,6 +1856,27 @@ import { getApiUrl } from "@/common/config.js"; font-size: 26rpx; color: #999; } + + .service-action-btn { + padding: 6rpx 16rpx; + border-radius: 4rpx; + font-size: 26rpx; + font-weight: 400; + display: flex; + align-items: center; + justify-content: center; + margin-right: 12rpx; + cursor: pointer; + } + + .service-action-btn--finish { + color: #007AFF; + background-color: transparent; + } + + .service-action-btn--finish:active { + opacity: 0.7; + } .service-status-empty { padding: 48rpx 0; diff --git a/pages/team/team.vue b/pages/team/team.vue index 2869eef..cb2a6c0 100644 --- a/pages/team/team.vue +++ b/pages/team/team.vue @@ -4,12 +4,12 @@ - + - AI销管系统 + AI销冠系统