Skip to content

Commit 2e7c4cc

Browse files
tyrosninganderlu
authored andcommitted
fix: input value is userID
1 parent b674f95 commit 2e7c4cc

File tree

5 files changed

+67
-43
lines changed

5 files changed

+67
-43
lines changed

Web/TRTCScenesDemo/trtc-calling-web/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"core-js": "^3.6.5",
1414
"element-ui": "^2.13.2",
1515
"qs": "^6.9.4",
16-
"tim-js-sdk": "2.10.2",
17-
"trtc-calling-js": "^0.8.0",
16+
"tim-js-sdk": "2.15.0",
17+
"trtc-calling-js": "^1.0.1",
1818
"trtc-js-sdk": "^4.11.1",
19-
"tsignaling": "0.6.0",
19+
"tsignaling": "0.8.0",
2020
"vue": "^2.6.11",
2121
"vue-router": "^3.3.4",
2222
"vuex": "^3.5.1"

Web/TRTCScenesDemo/trtc-calling-web/src/components/audio-call/index.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class="audio-call-section-header"
55
>Welcome {{loginUserInfo && (loginUserInfo.name || loginUserInfo.userId)}}</div>
66
<div class="audio-call-section-title">语音通话</div>
7-
<search-user @callUser="handleCallUser" @cancelCallUser="handleCancelCallUser"></search-user>
7+
<search-user :callFlag="callFlag" :cancelFlag="cancelFlag" @callUser="handleCallUser" @cancelCallUser="handleCancelCallUser"></search-user>
88
<div :class="{ 'audio-conference': true, 'is-show': isShowAudioCall }">
99
<div class="audio-conference-header">语音通话区域</div>
1010

@@ -39,7 +39,6 @@
3939
import { mapState } from "vuex";
4040
import SearchUser from "../search-user";
4141
import { getUserDetailInfoByUserid } from "../../service";
42-
import config from "../../config";
4342
4443
export default {
4544
name: "AudioCall",
@@ -59,7 +58,9 @@ export default {
5958
return {
6059
isShowAudioCall: false,
6160
isAudioOn: true,
62-
userId2User: {}
61+
userId2User: {},
62+
callFlag: false,
63+
cancelFlag: false,
6364
};
6465
},
6566
mounted() {
@@ -92,23 +93,25 @@ export default {
9293
},
9394
methods: {
9495
handleCallUser: function({ param }) {
95-
if (!param) {
96-
this.$message.error("请输入拨叫号码");
97-
return;
98-
}
96+
this.callFlag = true
9997
this.$trtcCalling.call({
10098
userID: param,
101-
type: this.TrtcCalling.CALL_TYPE.AUDIO_CALL,
102-
timeout: config.CallTimeout
103-
});
104-
this.$store.commit("userJoinMeeting", this.loginUserInfo.userId);
105-
this.$store.commit("updateCallStatus", "calling");
106-
this.$store.commit("updateIsInviter", true);
99+
type: this.TrtcCalling.CALL_TYPE.VIDEO_CALL
100+
}).then(()=>{
101+
this.callFlag = false
102+
this.$store.commit("userJoinMeeting", this.loginUserInfo.userId);
103+
this.$store.commit("updateCallStatus", "calling");
104+
this.$store.commit("updateIsInviter", true);
105+
})
106+
107107
},
108108
handleCancelCallUser: function() {
109-
this.$trtcCalling.hangup();
110-
this.$store.commit("dissolveMeeting");
111-
this.$store.commit("updateCallStatus", "idle");
109+
this.cancelFlag = true
110+
this.$trtcCalling.hangup().then(()=>{
111+
this.cancelFlag = false
112+
this.$store.commit("dissolveMeeting");
113+
this.$store.commit("updateCallStatus", "idle");
114+
})
112115
},
113116
toggleAudio: function() {
114117
this.isAudioOn = !this.isAudioOn;

Web/TRTCScenesDemo/trtc-calling-web/src/components/login/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="user-login">
3-
<el-input placeholder="电话号码" v-model="UserID" maxlength="11" class="phone-num"></el-input>
3+
<el-input placeholder="用户ID" v-model="UserID" maxlength="11" class="phone-num"></el-input>
44
<el-button class="user-login-btn" @click="handleLogin">登陆</el-button>
55
</div>
66
</template>
@@ -21,7 +21,7 @@ export default {
2121
handleLogin: async function() {
2222
console.log("userid");
2323
if (!this.UserID) {
24-
this.$message.error("请输入电话号码");
24+
this.$message.error("请输入用户ID");
2525
return;
2626
}
2727

Web/TRTCScenesDemo/trtc-calling-web/src/components/search-user/index.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<div class="search-user-container" v-if="callStatus !== 'connected'">
33
<div class="search-section">
4-
<el-input class="inline-input" v-model="searchInput" maxlength="11" placeholder="请输入呼叫号码"></el-input>
4+
<el-input class="inline-input" v-model="searchInput" maxlength="11" placeholder="请输入用户ID"></el-input>
55
</div>
66

77
<div v-show="callStatus !== 'connected'" class="search-user-list">
88
<div v-if="callStatus === 'calling' && isInviter" class="calling-user-footer">
99
<el-button class="user-item-join-btn calling">呼叫中...</el-button>
10-
<el-button class="user-item-cancel-join-btn" @click="handleCancelCallBtnClick">取消</el-button>
10+
<el-button class="user-item-cancel-join-btn" :disabled="cancel" :loading="cancel" @click="handleCancelCallBtnClick">取消</el-button>
1111
</div>
12-
<el-button v-else @click="handleCallBtnClick(searchInput)" class="user-item-join-btn">呼叫</el-button>
12+
<el-button v-else @click="handleCallBtnClick(searchInput)" :disabled="call" class="user-item-join-btn">呼叫</el-button>
1313
</div>
1414
</div>
1515
</template>
@@ -20,12 +20,22 @@ import { getSearchHistory } from "../../utils";
2020
2121
export default {
2222
name: "SearchUser",
23+
props:{
24+
callFlag: {
25+
type: Boolean
26+
},
27+
cancelFlag:{
28+
type: Boolean
29+
},
30+
},
2331
data() {
2432
return {
2533
searchInput: "",
2634
callUserId: "",
2735
searchResultList: [],
28-
searchHistoryUser: getSearchHistory()
36+
searchHistoryUser: getSearchHistory(),
37+
call: false,
38+
cancel: false
2939
};
3040
},
3141
computed: {
@@ -52,23 +62,27 @@ export default {
5262
if (newStatus === "idle") {
5363
this.callUserId = "";
5464
}
65+
},
66+
callFlag(newVal) {
67+
this.call = newVal
68+
},
69+
cancelFlag(newVal) {
70+
this.cancel = newVal
5571
}
5672
},
5773
methods: {
5874
handleCallBtnClick: function(param) {
5975
if (param === this.loginUserInfo.userId) {
60-
this.$message("请输入正确号码");
76+
this.$message("请输入正确用户ID");
6177
return;
6278
}
79+
this.call = true
6380
this.callUserId = param;
6481
this.$emit("callUser", { param });
6582
},
6683
handleCancelCallBtnClick: function() {
6784
// 对方刚接受邀请,但进房未成功
68-
if (this.isAccepted && this.callStatus !== "connected") {
69-
return;
70-
}
71-
this.callUserId = "";
85+
this.cancel = true
7286
this.$emit("cancelCallUser");
7387
}
7488
}

Web/TRTCScenesDemo/trtc-calling-web/src/components/video-call/index.vue

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class="video-call-section-header"
55
>Welcome {{loginUserInfo && (loginUserInfo.name || loginUserInfo.userId)}}</div>
66
<div class="video-call-section-title">视频通话</div>
7-
<search-user @callUser="handleCallUser" @cancelCallUser="handleCancelCallUser"></search-user>
7+
<search-user :callFlag="callFlag" :cancelFlag="cancelFlag" @callUser="handleCallUser" @cancelCallUser="handleCancelCallUser"></search-user>
88
<div :class="{ 'video-conference': true, 'is-show': isShowVideoCall }">
99
<div class="video-conference-header">视频通话区域</div>
1010

@@ -49,7 +49,7 @@
4949
import { mapState } from "vuex";
5050
import SearchUser from "../search-user";
5151
import { getUsernameByUserid } from "../../service";
52-
import config from "../../config";
52+
5353
export default {
5454
name: "VideoCall",
5555
components: {
@@ -70,7 +70,9 @@ export default {
7070
isShowVideoCall: false,
7171
isVideoOn: true,
7272
isAudioOn: true,
73-
userId2Name: {}
73+
userId2Name: {},
74+
callFlag: false,
75+
cancelFlag: false,
7476
};
7577
},
7678
mounted() {
@@ -103,20 +105,25 @@ export default {
103105
},
104106
methods: {
105107
handleCallUser: function({ param }) {
106-
// 可设置超时
108+
this.callFlag = true
107109
this.$trtcCalling.call({
108110
userID: param,
109-
type: this.TrtcCalling.CALL_TYPE.VIDEO_CALL,
110-
timeout: config.CallTimeout
111-
});
112-
this.$store.commit("userJoinMeeting", this.loginUserInfo.userId);
113-
this.$store.commit("updateCallStatus", "calling");
114-
this.$store.commit("updateIsInviter", true);
111+
type: this.TrtcCalling.CALL_TYPE.VIDEO_CALL
112+
}).then(()=>{
113+
this.callFlag = false
114+
this.$store.commit("userJoinMeeting", this.loginUserInfo.userId);
115+
this.$store.commit("updateCallStatus", "calling");
116+
this.$store.commit("updateIsInviter", true);
117+
})
118+
115119
},
116120
handleCancelCallUser: function() {
117-
this.$trtcCalling.hangup();
118-
this.$store.commit("dissolveMeeting");
119-
this.$store.commit("updateCallStatus", "idle");
121+
this.cancelFlag = true
122+
this.$trtcCalling.hangup().then(()=>{
123+
this.cancelFlag = false
124+
this.$store.commit("dissolveMeeting");
125+
this.$store.commit("updateCallStatus", "idle");
126+
})
120127
},
121128
startMeeting: function() {
122129
if (this.meetingUserIdList.length >= 3) {

0 commit comments

Comments
 (0)