聊天室url修正
This commit is contained in:
@@ -79,9 +79,9 @@
|
||||
</view>
|
||||
|
||||
<!-- 普通用户/客服消息 -->
|
||||
<view v-else :class="msg.senderType === 'guest' ? 'self' : 'other'">
|
||||
<view v-else :class="msg.senderId === currentUserId ? 'self' : 'other'">
|
||||
<!-- 对方消息(左侧) -->
|
||||
<view class="message-row other-row" v-if="msg.senderType !== 'guest'">
|
||||
<view class="message-row other-row" v-if="msg.senderId !== currentUserId">
|
||||
<view>
|
||||
<view class="avatar">
|
||||
<text class="avatar-text">{{ msg.senderName?.charAt(0) || '客' }}</text>
|
||||
@@ -174,11 +174,25 @@ const currentUserName = ref<string>('我')
|
||||
function loadUserInfo() {
|
||||
try {
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
const loginDomain = uni.getStorageSync('loginDomain')
|
||||
if (userInfo) {
|
||||
const user = typeof userInfo === 'string' ? JSON.parse(userInfo) : userInfo
|
||||
currentUserId.value = user.userId || user.id || ''
|
||||
currentUserName.value = user.username || user.nickName || '我'
|
||||
// 优先从 loginDomain.userInfo 获取用户名
|
||||
if (loginDomain) {
|
||||
const domain = typeof loginDomain === 'string' ? JSON.parse(loginDomain) : loginDomain
|
||||
if (domain.userInfo && domain.userInfo.username) {
|
||||
currentUserName.value = domain.userInfo.username
|
||||
} else if (domain.userInfo && domain.userInfo.realName) {
|
||||
currentUserName.value = domain.userInfo.realName
|
||||
} else {
|
||||
currentUserName.value = user.username || user.nickName || user.realName || user.name || '用户'
|
||||
}
|
||||
} else {
|
||||
currentUserName.value = user.username || user.nickName || user.realName || user.name || '用户'
|
||||
}
|
||||
}
|
||||
console.log('[chatRoom] 用户信息:', currentUserId.value, currentUserName.value)
|
||||
} catch (e) {
|
||||
console.error('获取用户信息失败:', e)
|
||||
}
|
||||
|
||||
@@ -903,3 +903,53 @@
|
||||
.skip-auth-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
// 模拟用户选择列表样式
|
||||
.mock-user-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.mock-user-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
font-weight: 500;
|
||||
padding-left: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.mock-user-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.mock-user-item:active {
|
||||
background: #e9ecef;
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.user-phone {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
<view class="header" :style="{ paddingTop: headerPaddingTop + 'px', height: headerTotalHeight + 'px' }">
|
||||
<text class="title">泰豪小电</text>
|
||||
<view class="header-right">
|
||||
<button class="workcase-btn" @tap="showUserSelector">
|
||||
<text class="btn-text">{{userInfo.username || '切换'}}</text>
|
||||
</button>
|
||||
<button class="workcase-btn" @tap="goToChatRoomList">
|
||||
<text class="btn-text">聊天室</text>
|
||||
</button>
|
||||
@@ -178,22 +181,48 @@
|
||||
<view class="modal-mask"></view>
|
||||
<view class="modal-content phone-auth-content">
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">欢迎使用泰豪小电</text>
|
||||
<text class="modal-title">选择测试用户</text>
|
||||
</view>
|
||||
<view class="modal-body phone-auth-body">
|
||||
<view class="auth-icon-wrap">
|
||||
<text class="auth-icon">📱</text>
|
||||
<view class="mock-user-list">
|
||||
<view class="mock-user-group">
|
||||
<text class="group-title">管理员</text>
|
||||
<view class="mock-user-item" @tap="selectMockUser('17857100375', '超级管理员', '17857100375')">
|
||||
<text class="user-name">超级管理员</text>
|
||||
<text class="user-phone">17857100375</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mock-user-group">
|
||||
<text class="group-title">工程师</text>
|
||||
<view class="mock-user-item" @tap="selectMockUser('13870055185', '魏瑶', '75719954')">
|
||||
<text class="user-name">魏瑶</text>
|
||||
<text class="user-phone">13870055185</text>
|
||||
</view>
|
||||
<view class="mock-user-item" @tap="selectMockUser('15170466624', '刘杰', 'liujie1370984851')">
|
||||
<text class="user-name">刘杰</text>
|
||||
<text class="user-phone">15170466624</text>
|
||||
</view>
|
||||
<view class="mock-user-item" @tap="selectMockUser('15170037929', '万家明', 'WJM15170037929')">
|
||||
<text class="user-name">万家明</text>
|
||||
<text class="user-phone">15170037929</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mock-user-group">
|
||||
<text class="group-title">客户</text>
|
||||
<view class="mock-user-item" @tap="selectMockUser('19100185270', '戴斌', 'BaiBin0714')">
|
||||
<text class="user-name">戴斌</text>
|
||||
<text class="user-phone">19100185270</text>
|
||||
</view>
|
||||
<view class="mock-user-item" @tap="selectMockUser('15797790517', '余其跃', 'a540378218')">
|
||||
<text class="user-name">余其跃</text>
|
||||
<text class="user-phone">15797790517</text>
|
||||
</view>
|
||||
<view class="mock-user-item" @tap="selectMockUser('15879126468', '李小华', 'wxid_vgmmzfdcwx9021')">
|
||||
<text class="user-name">李小华</text>
|
||||
<text class="user-phone">15879126468</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="auth-desc">为了给您提供更好的服务,需要获取您的手机号用于身份识别和工单通知</text>
|
||||
</view>
|
||||
<view class="modal-footer phone-auth-footer">
|
||||
<button
|
||||
class="modal-btn confirm phone-auth-btn"
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="onGetPhoneNumber"
|
||||
>
|
||||
<text class="btn-text">授权手机号登录</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -364,7 +393,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 获取手机号回调
|
||||
// 获取手机号回调(保留用于正式环境)
|
||||
async function onGetPhoneNumber(e: any) {
|
||||
console.log('获取手机号回调:', e)
|
||||
|
||||
@@ -462,6 +491,72 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 选择模拟用户(测试用)
|
||||
async function selectMockUser(phone: string, name: string, wechatId: string) {
|
||||
showPhoneAuthModal.value = false
|
||||
uni.showLoading({ title: '登录中...' })
|
||||
|
||||
try {
|
||||
// 调用 identify 接口,使用模拟模式
|
||||
const identifyRes = await guestAPI.identify({
|
||||
phone: phone,
|
||||
wechatId: wechatId,
|
||||
username: name,
|
||||
mockMode: true,
|
||||
loginType: 'wechat_miniprogram'
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (identifyRes.success && identifyRes.data) {
|
||||
const loginDomain = identifyRes.data
|
||||
|
||||
// 保存登录信息
|
||||
uni.setStorageSync('token', loginDomain.token || '')
|
||||
uni.setStorageSync('userInfo', JSON.stringify(loginDomain.user))
|
||||
uni.setStorageSync('loginDomain', JSON.stringify(loginDomain))
|
||||
uni.setStorageSync('wechatId', wechatId)
|
||||
|
||||
// 更新用户信息
|
||||
userInfo.value = {
|
||||
wechatId: wechatId,
|
||||
username: name,
|
||||
phone: phone,
|
||||
userId: loginDomain.user?.userId || ''
|
||||
}
|
||||
|
||||
// 判断用户类型
|
||||
if (loginDomain.user?.status === 'guest') {
|
||||
userType.value = false
|
||||
} else {
|
||||
userType.value = true
|
||||
}
|
||||
|
||||
console.log('模拟登录成功:', userInfo.value)
|
||||
uni.showToast({ title: `${name} 登录成功`, icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: identifyRes.message || '登录失败',
|
||||
icon: 'none'
|
||||
})
|
||||
showPhoneAuthModal.value = true
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('模拟登录失败:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: error.message || '登录失败',
|
||||
icon: 'none'
|
||||
})
|
||||
showPhoneAuthModal.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 显示用户选择弹窗(切换人员)
|
||||
function showUserSelector() {
|
||||
showPhoneAuthModal.value = true
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
// 初始化用户信息
|
||||
|
||||
@@ -1149,17 +1149,39 @@ async function submitWorkcase() {
|
||||
}
|
||||
|
||||
// 撤销工单
|
||||
function handleRevoke() {
|
||||
async function handleRevoke() {
|
||||
uni.showModal({
|
||||
title: '撤销确认',
|
||||
content: '确认撤销该工单?撤销后无法恢复',
|
||||
success: (res) => {
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
// TODO: 调用 API 撤销工单
|
||||
uni.showToast({
|
||||
title: '工单已撤销',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.showLoading({ title: '撤销中...' })
|
||||
try {
|
||||
const result = await workcaseAPI.revokeWorkcase(workcaseId.value)
|
||||
uni.hideLoading()
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '工单已撤销',
|
||||
icon: 'success'
|
||||
})
|
||||
// 刷新工单详情
|
||||
setTimeout(() => {
|
||||
loadWorkcaseDetail()
|
||||
}, 500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: result.message || '撤销失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error: any) {
|
||||
uni.hideLoading()
|
||||
console.error('撤销工单失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '撤销失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user