@@ -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 : 8 rpx ;
}
. service - status text {
font - size : 26 rpx ;
color : # 007 AFF ;
margin - left : 8 rpx ;
}
. customer - tags {
@@ -1724,6 +1856,27 @@ import { getApiUrl } from "@/common/config.js";
font - size : 26 rpx ;
color : # 999 ;
}
. service - action - btn {
padding : 6 rpx 16 rpx ;
border - radius : 4 rpx ;
font - size : 26 rpx ;
font - weight : 400 ;
display : flex ;
align - items : center ;
justify - content : center ;
margin - right : 12 rpx ;
cursor : pointer ;
}
. service - action - btn -- finish {
color : # 007 AFF ;
background - color : transparent ;
}
. service - action - btn -- finish : active {
opacity : 0.7 ;
}
. service - status - empty {
padding : 48 rpx 0 ;