合并代码

This commit is contained in:
sx 2025-01-06 09:45:10 +08:00
parent 53990198d5
commit be1027eb38
6 changed files with 92 additions and 54 deletions

View File

@ -32,7 +32,8 @@
})
// im
// util.loginTencent(userinfo)
util.loginTencent(userinfo)
//
util.getUserinfo()
}
}

View File

@ -128,6 +128,7 @@ export const news = {
query: param
})
},
//获取好友列表
getFriendList() {
return util.request({

View File

@ -1445,13 +1445,16 @@ const util = {
// 登录腾讯聊天
loginTencent(userinfo) {
api.login.getIMToken({}).then(rs => {
//
const imSig = rs.msg
// #ifdef APP
// 音视频登录
const loginParams = {
SDKAppID: util.config.TChat.SDKAppID,
userID: userinfo.id + '',
userSig: rs.msg,
userSig: imSig,
}
// #ifdef APP
uni.$TUICallKit.login(loginParams, res => {
if (res.code === 0) {
console.log('[TUICallKit] login success.');
@ -1463,7 +1466,7 @@ const util = {
uni.$chat.login({
userID: userinfo.id + '',
userSig: rs.msg,
userSig: imSig,
}).then(rs => {
console.log('im login success', rs)
})
@ -1480,6 +1483,7 @@ const util = {
api.mine.getUserinfo().then(rs => {
if (rs.code === 200) {
reslove(rs.data)
const userinfo = rs.data
// 提交
store.commit('setState', {
key: 'userinfo',

View File

@ -18,7 +18,10 @@
import util from '@/common/js/util.js'
//
import TencentCloudChat from '@tencentcloud/chat';
//
import api from '@/api/index.js'
// api
import newsApi from '@/api/news.js'
import pinyin from 'js-pinyin'
const {
proxy
@ -191,6 +194,8 @@
removelistener()
})
const viewData = ref([])
//
function addlistener() {
let onFriendListUpdated = (event) => {
@ -209,14 +214,30 @@
function getFriendList() {
// sdk
let isReady = uni.$chat.isReady();
console.log('isReady', isReady)
if (!isReady) {
setTimeout(function() {
getFriendList()
}, 200);
}, 1000);
return
}
newsApi.getFriendList().then(rs => {
if (rs.code == 200) {
viewData.value = rs.data;
// book
console.log('好友列表:', viewData.value);
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
return
uni.$chat.getFriendList().then(rs => {
console.log('friend', rs)
if (rs.code == 0) {
@ -376,7 +397,8 @@
<view class="li" v-for="(item, index) in userList.data" :key="item.key" :id="item.key">
<view class="letter ptb10 plr30 c666 f20">{{ item.letter }}</view>
<view class="child pl30 pr50">
<uni-swipe-action-item :right-options="rightOption" v-for="(user, secIndex) in item.child" :key="secIndex" @click="handleSwipeAction($event,user)">
<uni-swipe-action-item :right-options="rightOption" v-for="(user, secIndex) in item.child"
:key="secIndex" @click="handleSwipeAction($event,user)">
<view class="item rows ptb20" @click="handleUser(user)">
<image class="wh80 avatar cir" :src="user.profile.avatar" mode="aspectFill" />
<view class="name thd f1 ml20 c333 f32">{{user.remark || user.profile.nick}}</view>
@ -391,8 +413,10 @@
</scroll-view>
<!-- 字母列表 -->
<view class="letterBox c666 f22" @touchstart="handleTouchStart" @touchmove.stop.prevent="handleTouchMove" @touchend="handleTouchEnd">
<view class="item fmid ptb5 plr20" v-for="(item, index) in letterList" :key="item" @click="handleLetter(item)">{{ item.name }}</view>
<view class="letterBox c666 f22" @touchstart="handleTouchStart" @touchmove.stop.prevent="handleTouchMove"
@touchend="handleTouchEnd">
<view class="item fmid ptb5 plr20" v-for="(item, index) in letterList" :key="item"
@click="handleLetter(item)">{{ item.name }}</view>
</view>
</view>

View File

@ -13,7 +13,10 @@
} from 'vuex'
import {
onLoad,
onUnload,
} from '@dcloudio/uni-app'
//
import TencentCloudChat from '@tencentcloud/chat';
//
import apex from '@/components/header/apex'
@ -27,12 +30,9 @@
import msgList from '@/components/news/msgList'
//
import footerMneu from '@/components/footerMenu/footerMenu'
import videoApi from '@/api/video.js';
//
import util from '@/common/js/util.js'
// api
import newsApi from '@/api/news.js'
// vuex
//
import util from '@/common/js/util.js'
// vuex
const store = useStore()
//
const menuList = reactive([{
@ -60,51 +60,55 @@
const menuIndex = ref('')
//
const showSearch = ref(false)
// im
const imLoad = ref(false)
//
const userinfo = computed(() => {
let result = store.state.userinfo
return result
return store.state.userinfo
})
//
const menuCurrent = computed(() => {
let result = menuList[menuIndex.value]
return result
return menuList[menuIndex.value]
})
onLoad(() => {
//
handleMenuIndex(2)
handleMenuIndex(0)
//
addListener()
})
/**
* 切换下标
* @param {Number} index
*/
function handleMenuIndex(index) {
if (menuIndex.value === index) return
menuIndex.value = index
if (!menuList[index].load) menuList[index].load = true
//
if (index === 0) {
getFriends();
}
}
const viewData = ref([])
//
function getFriends() {
newsApi.getFriendList().then(response => {
if (response.success) {
viewData.value = response.data;
// book
console.log('好友列表:', viewData.value);
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
onUnload(() => {
//
removeListener()
})
//
function addListener() {
uni.$chat.on(TencentCloudChat.EVENT.SDK_READY, imLoading);
}
// im
function imLoading() {
imLoad.value = true
}
//
function removeListener() {
uni.$chat.off(TencentCloudChat.EVENT.SDK_READY);
}
/**
* 切换下标
* @param {Number} index
*/
function handleMenuIndex(index) {
if (menuIndex.value === index) return
menuIndex.value = index
if (!menuList[index].load) menuList[index].load = true
}
//
function showActionSheet() {
uni.showActionSheet({
@ -155,10 +159,14 @@
</script>
<template>
<view class="page" v-if="!userinfo.id && 0">
<view class="page" v-if="!userinfo.id">
<noLogin class="f1" />
</view>
<view class="" v-else-if="!imLoad">
加载中
</view>
<view class="page" v-else>
<apex>
<template #left>

View File

@ -14,8 +14,8 @@ export default defineConfig({
changeOrigin: true,
},
"/user": {
// target: "http://192.168.1.241:8080",
target: "http://7fee92ac.r22.cpolar.top",
target: "http://192.168.1.241:8080",
// target: "http://7fee92ac.r22.cpolar.top",
changeOrigin: true,
},
"/coreplay": {
@ -27,8 +27,8 @@ export default defineConfig({
changeOrigin: true,
},
"/video": {
// target: "http://192.168.1.241:8080",
target: "http://7fee92ac.r22.cpolar.top",
target: "http://192.168.1.241:8080",
// target: "http://7fee92ac.r22.cpolar.top",
changeOrigin: true,
},
}