销售顾问结束服务逻辑处理

This commit is contained in:
zhonghua1
2026-01-01 05:38:08 +08:00
parent 0eef7b1e4b
commit f004a75483
5 changed files with 164 additions and 11 deletions

View File

@@ -8,7 +8,7 @@
<uni-nav-bar
:fixed="true"
:statusBar="true"
title="AI销系统"
title="AI销系统"
leftIcon="left"
@clickLeft="goBack"
color="#333"

View File

@@ -8,7 +8,7 @@
<uni-nav-bar
:fixed="true"
:statusBar="true"
title="AI销系统"
title="AI销系统"
leftIcon="left"
@clickLeft="goBack"
color="#333"

View File

@@ -8,7 +8,7 @@
<uni-nav-bar
:fixed="true"
:statusBar="true"
title="AI销系统"
title="AI销系统"
leftIcon="left"
@clickLeft="goBack"
color="#333"

View File

@@ -9,7 +9,7 @@
:fixed="true"
:statusBar="true"
:border="false"
title="AI销系统"
title="AI销系统"
leftIcon="left"
@clickLeft="goBack"
color="#333"
@@ -83,6 +83,9 @@
<text class="staff-name">{{ item.staffName }}</text>
</view>
<view class="service-status">
<view class="service-action-btn service-action-btn--finish" @click.stop="finishService(item)">
<text>结束</text>
</view>
<uni-icons type="bars" size="16" color="#007AFF"></uni-icons>
<text>服务中</text>
</view>
@@ -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;

View File

@@ -4,12 +4,12 @@
<statusBar></statusBar>
<!-- #endif -->
<!-- 头部返回 + 标题"AI销系统" -->
<!-- 头部返回 + 标题"AI销系统" -->
<view class="page-header">
<view class="page-header__back" @tap="onBack">
<text class="page-header__back-icon"></text>
</view>
<text class="page-header__title">AI销系统</text>
<text class="page-header__title">AI销系统</text>
<!-- 占位使标题居中 -->
<view class="page-header__right"></view>
</view>