聊天室url修正
This commit is contained in:
@@ -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(() => {
|
||||
// 初始化用户信息
|
||||
|
||||
Reference in New Issue
Block a user