合并代码
This commit is contained in:
parent
53990198d5
commit
be1027eb38
|
@ -32,7 +32,8 @@
|
|||
})
|
||||
|
||||
// 腾讯im登录
|
||||
// util.loginTencent(userinfo)
|
||||
util.loginTencent(userinfo)
|
||||
//
|
||||
util.getUserinfo()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ export const news = {
|
|||
query: param
|
||||
})
|
||||
},
|
||||
|
||||
//获取好友列表
|
||||
getFriendList() {
|
||||
return util.request({
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue