修改bug

This commit is contained in:
yj 2024-12-03 09:25:04 +08:00
parent 782fc7150e
commit d0c8f67f3a
2 changed files with 34 additions and 19 deletions

View File

@ -16,6 +16,7 @@ Page({
},
onShow() {
const that = this;
onStop()
this.setData({
isJoin: false
})
@ -29,7 +30,6 @@ Page({
}
},
})
onStop()
wx.getStorage({
key: 'historicalList',
success(res: any) {
@ -39,6 +39,7 @@ Page({
if (that.data.meetingForm.roomNum) {
that.setData({
meetingForm: {
roomNum: that.data.meetingForm.roomNum,
roomName: res.data[res.data.length - 1].nickName
},
})
@ -93,12 +94,11 @@ Page({
});
},
async getRoomRtcToken(roomNum: string, callBack: Function): Promise<void> {
Promise.all([GetRoomRtcToken(roomNum), GetRoomRtcToken(roomNum + 'a'), GetAgoraConf()]).then(res => {
if (res[0].code === 200 && res[1].code === 200 && res[2].code === 200) {
Promise.all([GetRoomRtcToken(roomNum), GetAgoraConf()]).then(res => {
if (res[0].code === 200 && res[1].code === 200) {
callBack({
token: res[0].data,
tokenA: res[1].data,
appid: res[2].data
appid: res[1].data
})
}
})
@ -131,21 +131,34 @@ Page({
key: "user",
data: res.data
})
startSignalr(() => {
this.getRoomRtcToken(this.data.meetingForm.roomNum, (option) => {
agora.setOption({
token: option.token,
tokenA: option.tokenA,
channelId: this.data.meetingForm.roomNum,
appId: option.appid,
uid: res.data.uid,
screenShareId: res.data.screenShareId,
})
wx.navigateTo({
url: `/pages/meeting/index?roomNum=${this.data.meetingForm.roomNum}&nickName=${this.data.meetingForm.roomName}`
})
setTimeout(() => {
startSignalr((str) => {
if (str) {
this.setData({
isJoin: false
})
Message.error({
context: this,
offset: [90, 32],
duration: 3000,
content: str,
});
} else {
this.getRoomRtcToken(this.data.meetingForm.roomNum, (option) => {
agora.setOption({
token: option.token,
channelId: this.data.meetingForm.roomNum,
appId: option.appid,
uid: res.data.uid,
screenShareId: res.data.screenShareId,
})
wx.navigateTo({
url: `/pages/meeting/index?roomNum=${this.data.meetingForm.roomNum}&nickName=${this.data.meetingForm.roomName}`
})
})
}
})
})
}, 1000);
} else {
this.setData({
isJoin: false

View File

@ -14,6 +14,8 @@ export const startSignalr = async (callBack: Function) => {
.build();
connection.start().then(() => {
callBack()
}).catch((err) => {
callBack('服务器启动失败!请稍后重试。')
})
connection.onclose(() => {
startConnection()