合并代码

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 // im
// util.loginTencent(userinfo) util.loginTencent(userinfo)
//
util.getUserinfo() util.getUserinfo()
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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