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

View File

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