Commit 92b5c4ae by wxl

fix bugs

parent e7d97607
...@@ -5,12 +5,12 @@ import { useAuthData } from "./useAuthData"; ...@@ -5,12 +5,12 @@ import { useAuthData } from "./useAuthData";
export function useLogOut() { export function useLogOut() {
const [, request] = useRequest<any>('/loginOut', { auto: false }); const [, request] = useRequest<any>('/loginOut', { auto: false });
const { setAuth } = useInjector(useAuthData); const { setAuth } = useInjector(useAuthData);
const { close } = useInjector(useNetSocketStore) const { close } = useInjector(useNetSocketStore);
const submitLogOut = (data: {login_id: string}) => { const submitLogOut = (data: {login_id: string}) => {
return request(data).then( _ => { return request(data).then( _ => {
setAuth(null);
close(); close();
setAuth(null);
}); });
} }
......
...@@ -20,6 +20,8 @@ export function useCallCenter() { ...@@ -20,6 +20,8 @@ export function useCallCenter() {
const { sendMsg, currentMsg } = useInjector(useNetSocketStore); const { sendMsg, currentMsg } = useInjector(useNetSocketStore);
const { authData } = useInjector(useAuthData); const { authData } = useInjector(useAuthData);
let timer;
/** 主动呼叫功能 */ /** 主动呼叫功能 */
const [target, setTarget] = useState<Caller>(null); const [target, setTarget] = useState<Caller>(null);
const [myCallState, setCallState] = useState<CallingState>('free'); const [myCallState, setCallState] = useState<CallingState>('free');
...@@ -39,8 +41,8 @@ export function useCallCenter() { ...@@ -39,8 +41,8 @@ export function useCallCenter() {
} }
}) })
}) })
//8S后若本地用户仍处于主动呼叫状态,则自动挂断 //18S后若本地用户仍处于主动呼叫状态,则自动挂断
setTimeout(() => { timer = setTimeout(() => {
if(myCallState.value === 'calling') hangup(); if(myCallState.value === 'calling') hangup();
}, 18000) }, 18000)
} }
...@@ -60,6 +62,7 @@ export function useCallCenter() { ...@@ -60,6 +62,7 @@ export function useCallCenter() {
msgMainFlag: 'CallAnswer', msgMainFlag: 'CallAnswer',
msgSubFlag: subFlag msgSubFlag: subFlag
}) })
clearTimeout(timer)
} }
/** 呼叫监听功能 */ /** 呼叫监听功能 */
...@@ -83,13 +86,13 @@ export function useCallCenter() { ...@@ -83,13 +86,13 @@ export function useCallCenter() {
} else{ } else{
answerCaller('Busying', {id: msg.fromID, nickname: msg.fromName}); answerCaller('Busying', {id: msg.fromID, nickname: msg.fromName});
} }
//10S秒后若本地用户仍然处于被呼叫状态,则自动发出繁忙恢复,且将状态恢复为free //15S秒后若本地用户仍然处于被呼叫状态,则自动发出繁忙恢复,且将状态恢复为free
setTimeout( () => { timer = setTimeout( () => {
if(myCallState.value === 'being_called'){ if(myCallState.value === 'being_called'){
answerCaller('Busying', {id: currentMsg.value.fromID, nickname: currentMsg.value.fromName}); answerCaller('Busying', {id: currentMsg.value.fromID, nickname: currentMsg.value.fromName});
setCallState('free'); setCallState('free');
} }
}, 10000) }, 15000)
break; break;
case 'Hangup': case 'Hangup':
//对方中断呼叫,则将呼叫状态改为free //对方中断呼叫,则将呼叫状态改为free
...@@ -133,11 +136,11 @@ export function useCallCenter() { ...@@ -133,11 +136,11 @@ export function useCallCenter() {
break; break;
case 'calling': case 'calling':
flag = 'CallOffer'; flag = 'CallOffer';
toID = target.value.id; toID = target.value?.id;
break; break;
case 'being_called': case 'being_called':
flag = 'CallAnswer'; flag = 'CallAnswer';
toID = caller.value.id; toID = caller.value?.id;
break; break;
} }
...@@ -151,6 +154,7 @@ export function useCallCenter() { ...@@ -151,6 +154,7 @@ export function useCallCenter() {
type === 'leave' && setCallState('free'); type === 'leave' && setCallState('free');
setTarget(null); setTarget(null);
setCaller(null); setCaller(null);
clearTimeout(timer);
} }
/** 监听呼叫状态,当状态变回free时,重置channel的信息,同时向服务器广播 */ /** 监听呼叫状态,当状态变回free时,重置channel的信息,同时向服务器广播 */
......
...@@ -17,7 +17,7 @@ export interface SocketSettings { ...@@ -17,7 +17,7 @@ export interface SocketSettings {
export type ConnectStatus = 'ready' | 'opening' | 'onerror' | 'closed' | 'reconnect'; export type ConnectStatus = 'ready' | 'opening' | 'onerror' | 'closed' | 'reconnect';
export type AnyRemoteMainFlag = 'Heart' | 'Login' | 'Broadcast' | 'Home' | 'CallOffer' | 'CallAnswer' | 'ChannelChat' | 'NotifyUpdateUserList' | 'SetAtts' | 'Login'; export type AnyRemoteMainFlag = 'Heart' | 'Login' | 'Broadcast' | 'Home' | 'CallOffer' | 'CallAnswer' | 'ChannelChat' | 'NotifyUpdateUserList' | 'SetAtts' | 'Login';
export type AnyRemoteSubFlag = 'Request' | 'Busying' | 'Connect' | 'Hangup' | 'UpdateUserList' | 'OtherLoginIn'; export type AnyRemoteSubFlag = 'Request' | 'Busying' | 'Connect' | 'Hangup' | 'UpdateUserList' | 'OtherLoginIn' | 'NoDevice';
export interface AnyRemoteSocketMessage { export interface AnyRemoteSocketMessage {
fromID?: string; fromID?: string;
......
...@@ -22,15 +22,15 @@ export default { ...@@ -22,15 +22,15 @@ export default {
{ {
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"text": "联系人", "text": "联系人",
"iconPath": "assets/contacts.png", "iconPath": "assets/Contact@3x.png",
"selectedIconPath": "assets/contacts_a.png" "selectedIconPath": "assets/Contact-Check@3x.png"
}, },
{ {
"pagePath": "pages/mine/index", "pagePath": "pages/mine/index",
"text": "个人中心", "text": "个人中心",
"iconPath": "assets/user_center.png", "iconPath": "assets/Personal@3x.png",
"selectedIconPath": "assets/user_center_a.png" "selectedIconPath": "assets/Personal-Check@3x.png"
} }
] ]
}, }
} }
<script lang="ts" setup=""> <script lang="ts" setup>
import { navigateTo } from "@tarojs/taro"; import { navigateTo, showToast } from "@tarojs/taro";
import { defineProps } from "@vue/runtime-core"; import { defineProps } from "@vue/runtime-core";
import { useCallCenter } from "any-hooks/communication/useCallCenter"; import { useCallCenter } from "any-hooks/communication/useCallCenter";
import { UserData } from "any-hooks/types/user"; import { UserData } from "any-hooks/types/user";
import { useAppInitInfo } from "src/hooks/common/useAppInitInfo";
import { useInjector } from "vue-vulcan"; import { useInjector } from "vue-vulcan";
const {data} = defineProps<{data: UserData}>(); const {data} = defineProps<{data: UserData}>();
const { callContact } = useInjector(useCallCenter); const { callContact, myCallState } = useInjector(useCallCenter);
const { checkCamearSetting } = useInjector(useAppInitInfo);
const gotoDetail = (id: string) => { const gotoDetail = (id: string) => {
navigateTo({url: '/pages/contact-detail/index?id='+ id}) navigateTo({url: '/pages/contact-detail/index?id='+ id});
}
const onTapCall = (data: UserData) => {
if(myCallState.value !== 'free') {
showToast({title: '您当前已在通话中,无法发起呼叫'});
} else {
checkCamearSetting().then( r => {
r ? callContact(data) : showToast({title: '您未授权摄像头权限,请在设置中打开摄像头授权', icon: 'none'});
})
}
} }
</script> </script>
...@@ -21,7 +33,7 @@ ...@@ -21,7 +33,7 @@
<view>{{data.nickname}}</view> <view>{{data.nickname}}</view>
<text>{{data.group_name}}</text> <text>{{data.group_name}}</text>
</view> </view>
<image v-if="data.is_signin === '1'" @tap.stop="callContact(data)" class="call" src="../assets/call3x.png" mode="widthFix"/> <image v-if="data.is_signin === '1'" @tap.stop="onTapCall(data)" class="call" src="../assets/call3x.png" mode="widthFix"/>
<image v-else class="call" src="../assets/call-no3x.png" mode="widthFix"/> <image v-else class="call" src="../assets/call-no3x.png" mode="widthFix"/>
</view> </view>
</template> </template>
......
<script lang="ts" setup> <script lang="ts" setup>
import { useAuthData } from 'any-hooks/auth/useAuthData';; import { useAuthData } from 'any-hooks/auth/useAuthData';
import { useMeetingCenter } from 'any-hooks/communication/useMeetingCenter'; import { useMeetingCenter } from 'any-hooks/communication/useMeetingCenter';
import { defineProps } from 'vue'; import { defineProps } from 'vue';
import { useInjector } from 'vue-vulcan'; import { useInjector } from 'vue-vulcan';
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
v-on:error="onError" v-on:error="onError"
:debug="!0" :debug="!0"
/> />
<view class="cover" > <view class="cover">
<text class="name">{{authData.nickname}}</text> <text class="name">{{authData.nickname}}</text>
<image class="avatar" v-if="mode==='audio'" :src="authData.avatar" mode="widthFix"/> <image class="avatar" v-if="mode==='audio'" :src="authData.avatar" mode="widthFix"/>
</view> </view>
......
...@@ -2,11 +2,13 @@ import { navigateTo, redirectTo, showToast } from "@tarojs/taro"; ...@@ -2,11 +2,13 @@ import { navigateTo, redirectTo, showToast } from "@tarojs/taro";
import { useCallCenter } from "any-hooks/communication/useCallCenter"; import { useCallCenter } from "any-hooks/communication/useCallCenter";
import { watch } from "vue"; import { watch } from "vue";
import { useInjector } from "vue-vulcan"; import { useInjector } from "vue-vulcan";
import { useAppInitInfo } from "../common/useAppInitInfo";
/** 在小程序平台监听远程联系人的呼叫动作 */ /** 在小程序平台监听远程联系人的呼叫动作 */
export function useCallerListener() { export function useCallerListener() {
const { caller, target, myCallState } = useInjector(useCallCenter); const { caller, target, myCallState, answerCaller } = useInjector(useCallCenter);
const { checkCamearSetting } = useInjector(useAppInitInfo)
watch(caller, current => { watch(caller, current => {
if(!current) return; if(!current) return;
...@@ -41,7 +43,10 @@ export function useCallerListener() { ...@@ -41,7 +43,10 @@ export function useCallerListener() {
} }
break; break;
case 'being_called': case 'being_called':
navigateTo({url: '/pages/calling/index'}); checkCamearSetting().then(r => {
r ? navigateTo({url: '/pages/calling/index'}) : answerCaller('NoDevice')
})
break; break;
case 'call_accepted': case 'call_accepted':
case 'call_successed': case 'call_successed':
......
import { getMenuButtonBoundingClientRect } from "@tarojs/taro"; import { authorize, getMenuButtonBoundingClientRect, getSetting } from "@tarojs/taro";
import { ref } from "vue"; import { ref } from "vue";
export function useAppInitInfo() { export function useAppInitInfo() {
const rect = getMenuButtonBoundingClientRect(); const rect = getMenuButtonBoundingClientRect();
const topDistance = ref(rect.height + rect.top + 10) const topDistance = ref(rect.height + rect.top + 10);
const checkCamearSetting = () => {
return getSetting().then(res => {
if(res.authSetting["scope.camera"]) {
return true
} else {
return new Promise((resolve) => {
authorize({
scope: 'scope.camera',
success: () => resolve(true),
fail: () => resolve(false)
})
})
}
})
}
return { return {
rect, rect,
topDistance topDistance,
checkCamearSetting
} }
} }
\ No newline at end of file
import { CUSTOME_REQUESTER, RequesterFunc, RequestOptions } from 'vue-vulcan'; import { CUSTOME_REQUESTER, RequesterFunc, RequestOptions } from 'vue-vulcan';
import { request } from '@tarojs/taro'; import { request, showToast } from '@tarojs/taro';
export function useCustomeRequest(): RequesterFunc { export function useCustomeRequest(): RequesterFunc {
return function (url: string, reqs: RequestOptions) { return function (url: string, reqs: RequestOptions) {
...@@ -7,6 +7,9 @@ export function useCustomeRequest(): RequesterFunc { ...@@ -7,6 +7,9 @@ export function useCustomeRequest(): RequesterFunc {
return request({ return request({
...reqs, ...reqs,
url, url,
fail(err) {
showToast({title: '网络错误,请稍后再试', icon: 'none'})
}
}) as Promise<any> }) as Promise<any>
}; };
} }
......
...@@ -2,14 +2,28 @@ ...@@ -2,14 +2,28 @@
import { useInjector } from 'vue-vulcan'; import { useInjector } from 'vue-vulcan';
import { useContacts } from 'any-hooks/contacts/useContacts'; import { useContacts } from 'any-hooks/contacts/useContacts';
import { useCallCenter } from 'any-hooks/communication/useCallCenter'; import { useCallCenter } from 'any-hooks/communication/useCallCenter';
import { navigateTo } from '@tarojs/taro'; import { navigateTo, showToast } from '@tarojs/taro';
import { useAppInitInfo } from 'src/hooks/common/useAppInitInfo';
import { UserData } from 'any-hooks/types/user';
const { callContact } = useInjector(useCallCenter); const { callContact, myCallState } = useInjector(useCallCenter);
const { contacts, roleContacts } = useInjector(useContacts); const { contacts, roleContacts } = useInjector(useContacts);
const { checkCamearSetting } = useInjector(useAppInitInfo)
const gotoDetail = (id: string) => { const gotoDetail = (id: string) => {
navigateTo({url: '/pages/contact-detail/index?id='+ id}) navigateTo({url: '/pages/contact-detail/index?id='+ id})
} }
const onTapCall = (data: UserData) => {
if(myCallState.value !== 'free') {
showToast({title: '您当前已在通话中,无法发起呼叫'})
} else {
console.log('检查摄像头权限')
checkCamearSetting().then( r => {
r ? callContact(data) : showToast({title: '您未授权摄像头权限,请在设置中打开摄像头授权', icon: 'none'});
})
}
}
</script> </script>
<template> <template>
...@@ -23,7 +37,7 @@ ...@@ -23,7 +37,7 @@
<view>{{item.nickname}}</view> <view>{{item.nickname}}</view>
<text>{{item.group_name}}</text> <text>{{item.group_name}}</text>
</view> </view>
<image v-if="item.is_signin === '1'" @tap.stop="callContact(item)" class="call" src="../../assets/call3x.png" mode="widthFix"/> <image v-if="item.is_signin === '1'" @tap.stop="onTapCall(item)" class="call" src="../../assets/call3x.png" mode="widthFix"/>
<image v-else class="call" src="../../assets/call-no3x.png" mode="widthFix"/> <image v-else class="call" src="../../assets/call-no3x.png" mode="widthFix"/>
</view> </view>
</view> </view>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<scroll-view class="home-contents" :scrollY="true" @scroll="onScroll"> <scroll-view class="home-contents" :scrollY="true" @scroll="onScroll">
<view class="tabs pd-1"> <view class="tabs pd-1">
<text class="tab-item contacts" :class="{active: viewMode==='items'}" @tap="setViewMode('items');setKeyWord('')">联系人</text> <text class="tab-item contacts" :class="{active: viewMode==='items'}" @tap="setViewMode('items');setKeyWord('')">联系人</text>
<text class="tab-item group" :class="{active: viewMode==='groups'}" @tap="setViewMode('groups');setKeyWord('')">群组</text> <!-- <text class="tab-item group" :class="{active: viewMode==='groups'}" @tap="setViewMode('groups');setKeyWord('')">群组</text> -->
</view> </view>
<view class="list"> <view class="list">
<contacts-list v-if="viewMode === 'items'"></contacts-list> <contacts-list v-if="viewMode === 'items'"></contacts-list>
...@@ -88,9 +88,10 @@ ...@@ -88,9 +88,10 @@
} }
} }
.list{ .list{
border-top-right-radius: 20px; border-top-right-radius: 25px;
border-top-left-radius: 20px; border-top-left-radius: 25px;
min-height: 600px; min-height: 600px;
overflow: hidden;
} }
.contact-list{ .contact-list{
.contact-item{ .contact-item{
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
const { target } = useInjector(useCallCenter); const { target } = useInjector(useCallCenter);
const { streamList, localPushurl, voiceMute, mode, switchLocalMicState, switchVideoOrAudio, leave } = useInjector(useMeetingCenter); const { streamList, localPushurl, voiceMute, mode, switchLocalMicState, switchVideoOrAudio, leave } = useInjector(useMeetingCenter);
const { topDistance } = useAppInitInfo(); const { topDistance, rect } = useAppInitInfo();
/* 监听流的数量,自动退出会议 */ /* 监听流的数量,自动退出会议 */
watch(streamList, (current, last) => { watch(streamList, (current, last) => {
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
if(activeVideo.value === -2) { if(activeVideo.value === -2) {
setActive(index); setActive(index);
} else { } else {
setActive(-2) setActive(-2);
} }
} }
...@@ -69,10 +69,10 @@ ...@@ -69,10 +69,10 @@
callContact(user); callContact(user);
setInviting(false); setInviting(false);
} }
</script> </script>
<template> <template>
<image class="navi-back" src="../../assets/arrow_left.png" mode="widthFix" :style="{top: rect.top+'px'}" @tap="navigateBack()"></image>
<view class ="meeting-container page col-page" :style="{paddingTop: topDistance+'px'}"> <view class ="meeting-container page col-page" :style="{paddingTop: topDistance+'px'}">
<invite v-if="inviting" @choose="onInvite($event)" @cancel="setInviting(false)"></invite> <invite v-if="inviting" @choose="onInvite($event)" @cancel="setInviting(false)"></invite>
<!-- <view class="c-info" style="color:#fff"> <!-- <view class="c-info" style="color:#fff">
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
v-for="(item, key) in streamList" v-for="(item, key) in streamList"
:key="key" :key="key"
:stream="item" :stream="item"
:class="{active: activeVideo===key, hide: activeVideo!==-2}" :class="{active: activeVideo===key, hide: activeVideo!==-2, mini: streamList.length > 5}"
@tap="toggleActive(key)" @tap="toggleActive(key)"
> >
</stream-player> </stream-player>
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
class="video-item" class="video-item"
v-if="localPushurl" v-if="localPushurl"
:url="localPushurl" :url="localPushurl"
:class="{active: activeVideo===-1, hide: activeVideo!==-2}" :class="{active: activeVideo===-1, hide: activeVideo!==-2, mini: streamList.length > 5}"
@tap="toggleActive(-1)" @tap="toggleActive(-1)"
> >
</stream-pusher> </stream-pusher>
...@@ -139,8 +139,16 @@ ...@@ -139,8 +139,16 @@
</template> </template>
<style lang="less"> <style lang="less">
.navi-back{
width: 20px;
height: 20px;
left: 20px;
position: absolute;
z-index: 1000;
}
.meeting-container{ .meeting-container{
background: #333; background: #333;
.videos{ .videos{
flex:1; flex:1;
text-align: center; text-align: center;
...@@ -154,6 +162,10 @@ ...@@ -154,6 +162,10 @@
display: inline-block; display: inline-block;
background: #000; background: #000;
color: #fff; color: #fff;
&.mini{
width: 33.3%;
height: 200px;
}
&.waiting{ &.waiting{
line-height: 300px; line-height: 300px;
} }
......
...@@ -42,13 +42,17 @@ ...@@ -42,13 +42,17 @@
background-color: rgba(0, 0, 0, 0.65); background-color: rgba(0, 0, 0, 0.65);
.contacts{ .contacts{
display: flex; display: flex;
// justify-content: space-between;
padding: 0 30px; padding: 0 30px;
flex-wrap: wrap;; flex-wrap: wrap;
.contact-item{ .contact-item{
color: #fff; color: #fff;
margin: 0 15px; margin: 0 15px;
width: 175px; width: 175px;
text-align: center;
.avatar{
width: 80px;
height: 80px;
}
} }
} }
} }
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
const { submitLogOut } = useLogOut(); const { submitLogOut } = useLogOut();
const onLogOut = () => { const onLogOut = () => {
showModal({ showModal({
title: '是否确认退出当前账号?', title: '是否确认退出当前账号?'
}).then( res => { }).then( res => {
if(res.confirm) return submitLogOut({login_id: authData.value.id}); if(res.confirm) return submitLogOut({login_id: authData.value?.id});
return null return null
}).then(res => { }).then(res => {
res!== null && reLaunch({url: '/pages/login/index'}); res!== null && reLaunch({url: '/pages/login/index'});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment