Commit c33b7955 by wxl

x

parent 1679c991
......@@ -5,7 +5,6 @@ import { useState } from "vue-vulcan";
export function useAuthData() {
const [authData, setAuth] = useState<UserData>(null, {storage: 'custome', key: 'auth'});
return {
authData,
setAuth
......
......@@ -6,7 +6,7 @@ import { useInjector, useRequest, useState } from "vue-vulcan";
import { useChannelStore } from "./useChannelStore";
import { useNetSocketStore } from "./useNetSocketStore";
type CallingState = 'net_error' | 'calling' | 'call_successed' | 'being_called' | 'call_accepted' | 'connecting' | 'free';
type CallingState = 'net_error' | 'calling' | 'call_successed' | 'callin' | 'call_accepted' | 'connecting' | 'free';
interface Caller extends UserData {
action: AnyRemoteSubFlag | 'none';
......@@ -72,10 +72,10 @@ export function useCallCenter() {
if(msg.msgMainFlag !== 'CallOffer') return;
switch(msg.msgSubFlag) {
case 'Request':
// 本地呼叫状态为free时,变更为being_called;不为free,则发送繁忙的回应。
// 本地呼叫状态为free时,变更为callin;不为free,则发送繁忙的回应。
console.log(`${currentMsg.value.fromName}呼叫,我目前的状态${myCallState.value}`)
if(myCallState.value === 'free') {
setCallState('being_called');
setCallState('callin');
setCaller({
id: msg.fromID,
nickname: msg.fromName,
......@@ -88,7 +88,7 @@ export function useCallCenter() {
}
//15S秒后若本地用户仍然处于被呼叫状态,则自动发出繁忙恢复,且将状态恢复为free
timer = setTimeout( () => {
if(myCallState.value === 'being_called'){
if(myCallState.value === 'callin'){
answerCaller('Busying', {id: currentMsg.value.fromID, nickname: currentMsg.value.fromName});
setCallState('free');
}
......@@ -106,8 +106,6 @@ export function useCallCenter() {
})
break;
}
})
// 监听呼叫目标的回应
watch(currentMsg, msg => {
......@@ -126,7 +124,6 @@ export function useCallCenter() {
})
/** 呼叫挂断功能 */
const hangup = (type?: 'leave' | 'cancel') => {
let flag: AnyRemoteMainFlag, toID: string;
switch(myCallState.value) {
......@@ -138,7 +135,7 @@ export function useCallCenter() {
flag = 'CallOffer';
toID = target.value?.id;
break;
case 'being_called':
case 'callin':
flag = 'CallAnswer';
toID = caller.value?.id;
break;
......@@ -169,7 +166,7 @@ export function useCallCenter() {
})
}
changeCallingState({channel_id: currentChannel.value?.channel_id, userIDs: JSON.stringify([
{userID: authData.value.id, callState: state==='free' ? 'idle' : 'callout'},
{userID: authData.value.id, callState: state==='free' ? 'idle' : state==='calling' ? 'callout' : 'callin'},
{userID: target.value?.id || caller.value?.id, callState: state==='free' ? 'idle' : 'callin'}
])});
})
......
......@@ -32,7 +32,6 @@ export function useChannelStore() {
return request({channel_id: cid});
}
const updateMembers = (ids: string[], type: 'join' | 'leave') => {
const current = channelMembers.value;
if(type === 'join') {
......
import { setKeepScreenOn } from "@tarojs/taro";
import { watch } from "vue";
import { useContacts } from "any-hooks/contacts/useContacts";
import { UserData } from "any-hooks/types/user";
import { onMounted, watch } from "vue";
import { useInjector, useState } from "vue-vulcan";
import { useCallCenter } from "./useCallCenter";
import { useChannelStore } from "./useChannelStore";
......@@ -31,9 +30,6 @@ export function useMeetingCenter() {
stopVideoConference();
}
/** 保持屏幕常亮 */
onMounted(() => setKeepScreenOn({keepScreenOn: true}));
/** 监听频道成员信息 */
const { channelMembers } = useInjector(useChannelStore);
const [meetingMembers, setMembers] = useState<MeetingMember[]>([]);
......
......@@ -33,7 +33,17 @@ export function useContacts() {
return contactHome
})
const freeContacts = computed( () => contacts.value.filter( item => item.is_calling === '0' && item.is_signin === '1'))
const freeContacts = computed( () => {
const list = contacts.value.filter( item => item.is_calling === '0' && item.is_signin === '1');
const frees = {} as {[props: string]: UserData[]}
list?.forEach( item => {
if(['3','4'].includes(item.permission) ) {
if(!frees[item.group_name]) frees[item.group_name] = [];
frees[item.group_name].push(item);
};
})
return frees
})
const getContactById = (pid: string, type?: 'uid'|'pid') => {
......
import { navigateTo, redirectTo, showToast } from "@tarojs/taro";
import { navigateTo, redirectTo, setKeepScreenOn, showToast } from "@tarojs/taro";
import { useCallCenter } from "any-hooks/communication/useCallCenter";
import { watch } from "vue";
import { onMounted, watch } from "vue";
import { useInjector } from "vue-vulcan";
import { useAppInitInfo } from "../common/useAppInitInfo";
......@@ -8,7 +8,12 @@ import { useAppInitInfo } from "../common/useAppInitInfo";
/** 在小程序平台监听远程联系人的呼叫动作 */
export function useCallerListener() {
const { caller, target, myCallState, answerCaller } = useInjector(useCallCenter);
const { checkCamearSetting } = useInjector(useAppInitInfo)
const { checkCamearSetting } = useInjector(useAppInitInfo);
onMounted(() => {
/** 保持屏幕常亮 */
onMounted(() => setKeepScreenOn({keepScreenOn: true}));
})
watch(caller, current => {
if(!current) return;
......@@ -42,7 +47,7 @@ export function useCallerListener() {
navigateTo({url: '/pages/calling/index'});
}
break;
case 'being_called':
case 'callin':
checkCamearSetting().then(r => {
r ? navigateTo({url: '/pages/calling/index'}) : answerCaller('NoDevice')
})
......
......@@ -3,7 +3,6 @@ import { request, showToast } from '@tarojs/taro';
export function useCustomeRequest(): RequesterFunc {
return function (url: string, reqs: RequestOptions) {
console.log('my url', url)
return request({
...reqs,
url,
......
import { useAuthData } from "../../../any-hooks/auth/useAuthData";
import { useAuthData } from "any-hooks/auth/useAuthData";
import { HttpIntercept, HttpResponse, HTTP_INTERCEPT, RequestOptions, useInjector } from "vue-vulcan";
import { showToast } from "@tarojs/taro";
......@@ -21,12 +21,6 @@ export function useHttpIntercept(): HttpIntercept {
})
}
const checkResData = (data: any) => {
if(data.success) return true;
showToast({title: data.msg, icon: 'none'});
return false;
}
const responseIntercept = (res: HttpResponse) => {
switch(res.status) {
case 404:
......@@ -43,6 +37,13 @@ export function useHttpIntercept(): HttpIntercept {
})
}
const checkResData = (data: any) => {
if(data.success) return true;
showToast({title: data.msg, icon: 'none'});
return false;
}
return {
requestIntercept,
responseIntercept
......
......@@ -24,7 +24,7 @@
<template>
<view class="page call-container">
<view class="call-box caller" v-if="myCallState==='being_called'">
<view class="call-box caller" v-if="myCallState==='callin'">
<image class="avatar" :src="caller?.avatar"></image>
<text class="tips" >{{caller?.nickname}}向您发起呼叫</text>
</view>
......@@ -35,7 +35,7 @@
</view>
<view class="operators" v-if="myCallState!=='free'">
<image v-if="myCallState==='being_called'" @tap="answerCaller('Connect')" class="op-icon" src="../../assets/answer3x.png"></image>
<image v-if="myCallState==='callin'" @tap="answerCaller('Connect')" class="op-icon" src="../../assets/answer3x.png"></image>
<image @tap="onTapHangup()" class="op-icon" src="../../assets/hangup.png"></image>
</view>
</view>
......
......@@ -5,7 +5,7 @@
const { filterGroups } = useInjector(useContacts);
const gotoGroupContacts = (id: string) => {
navigateTo({url: `/pages/group-contacts/index?id=${id}`})
navigateTo({url: `/pages/group-contacts/index?id=${id}`});
}
</script>
......
......@@ -27,7 +27,7 @@
<template>
<scroll-view :scrollY="true" class="invite-container page" :style="{top: topDistance+'px'}" >
<view class="contact-role-group" v-for="(group, key, index) in roleContacts" :key="index">
<view class="contact-role-group" v-for="(group, key, index) in freeContacts" :key="index">
<view class="role-name pd-2" :class="{hide: hideConfig[index]}" @tap="toggleHideByIndex(index)">{{key}}</view>
<view class="white-box" :style="{display: hideConfig[index] ? 'none' : 'block'}">
<view class="contact-item" v-for="(item, i) in group" :key="i" >
......@@ -47,13 +47,15 @@
<style lang="less">
.invite-container{
position: absolute;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
z-index: 1000;
top: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.65);
background-color: #fff;
z-index: 10000;
.contact-role-group{
background-color: #fff;
......@@ -100,7 +102,7 @@
display: inline-block;
background: #2b91e2;
color: #fff;
padding: 6px 12px;
padding: 2px 15px;
}
}
}
......
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