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