修复已知问题

This commit is contained in:
bobobobo
2026-01-26 23:19:37 +08:00
parent 92ca8d72ce
commit 33bf08c981
15 changed files with 460 additions and 121 deletions

View File

@@ -1,27 +1,56 @@
<script setup>
import { ref } from 'vue'
import { ref, computed } from 'vue'
import TUICore, { TUIConstants } from '@tencentcloud/tui-core-lite'
import { useUI } from '@/utils/use-ui'
import { navigateTo } from '@/utils/router'
import TUIChatEngine, {
TUIFriendService
TUIFriendService,
TUIGroupService
} from '@tencentcloud/chat-uikit-engine-lite'
const { showLoading, hideLoading } = useUI()
const loading = ref(false)
const searchValue = ref('')
const searchList = ref([])
const isSearc = ref(false)
// const isSearc = ref(false)
// 是否是好友
const isFriend = ref(false)
/** 群列表 */
const searchGroup = ref([])
const isSearc = computed(() => {
return searchList.value.length === 0 && searchGroup.value.length === 0
})
const onCancel = () => {
isFriend.value = false
isSearc.value = false
searchGroup.value = []
searchList.value = []
}
const search = () => {
/** 群查询 */
const getGroup = () => {
showLoading()
loading.value = true
TUICore.callService({
serviceName: TUIConstants.TUISearch.SERVICE.NAME,
method: TUIConstants.TUISearch.SERVICE.METHOD.SEARCH_GROUP,
params: {
groupID: searchValue.value
}
})
.then(res => {
searchGroup.value = [res.data.group]
})
.catch(err => {
searchGroup.value = []
console.log(err, '==')
loading.value = false
hideLoading()
})
}
const search = async () => {
if (!searchValue.value) {
return
}
@@ -63,17 +92,29 @@
loading.value = false
hideLoading()
})
getGroup()
}
const onAdd = item => {
navigateTo('/pages/adduser/details', { id: item.userID })
}
const onDetails = item => {
if (isFriend.value) {
navigateTo('/pages/adduser/details', { id: item.userID, type: '1' })
const onDetails = (item, state) => {
if (state == 1) {
navigateTo('/pages/adduser/details', {
id: item.groupID,
type: '9'
})
} else {
onAdd(item)
if (isFriend.value) {
navigateTo('/pages/adduser/details', {
id: item.userID,
type: '1'
})
} else {
onAdd(item)
}
}
}
</script>
@@ -86,13 +127,14 @@
radius="100"
bgColor="#f4f4f4"
textColor="#333333"
placeholder="请输入用户手机号"
placeholder="请输入用户手机号/群ID进行搜索"
@confirm="search"
@cancel="onCancel"
></uni-search-bar>
<cb-empty v-if="isSearc" name="未搜索到此账号"></cb-empty>
<!-- 好友列表 -->
<cb-empty v-if="!loading && isSearc" name="未搜索到"></cb-empty>
<view v-if="!loading" class="user-list">
<!-- 好友列表 -->
<view
v-for="item in searchList"
:key="item.userID"
@@ -117,6 +159,32 @@
<button v-else @click.stop="onAdd(item)">添加</button>
</view>
</view>
<!-- 群列表 -->
<view
v-for="item in searchGroup"
:key="item.groupID"
class="card"
@click="onDetails(item, 1)"
>
<image
v-if="item?.avatar"
:src="item?.avatar"
mode="aspectFill"
class="avatar"
></image>
<view v-else class="avatar">
<uni-icons type="contact-filled" size="130rpx"></uni-icons>
</view>
<view class="right-box">
<view class="name-box">
<text>{{ item.name || '未知名称' }}</text>
<text>{{ item.groupID }}</text>
</view>
<text class="tag-but">群聊</text>
<!-- <text v-if="isFriend" class="tag">已添加</text>
<button v-else @click.stop="onAdd(item)">添加</button> -->
</view>
</view>
</view>
</view>
</template>
@@ -147,6 +215,12 @@
font-size: 32rpx;
color: #999999;
}
.tag-but {
padding: 4rpx 20rpx;
background: #00d9c5;
color: #fff;
border-radius: 30rpx;
}
.name-box {
height: 96rpx;
display: flex;