This commit is contained in:
yj 2024-11-26 11:53:27 +08:00
parent 85cfd2e39f
commit 7209fa2cd0
2 changed files with 61 additions and 43 deletions

View File

@ -1,7 +1,7 @@
import { GetCheckoutRoomNum, PostAnonLogin, GetAgoraConf, GetRoomRtcToken } from '../../api/form/index' import { GetCheckoutRoomNum, PostAnonLogin, GetAgoraConf, GetRoomRtcToken } from '../../api/form/index'
import { getUUID } from '../../utils/utils' import { getUUID } from '../../utils/utils'
import { Message } from 'tdesign-miniprogram'; import { Message } from 'tdesign-miniprogram';
import { onStop, startSignalr } from '../../utils/singlr'; import { startSignalr, onStop } from '../../utils/singlr';
import { agora } from '../../utils/agora' import { agora } from '../../utils/agora'
Page({ Page({
data: { data: {
@ -15,8 +15,26 @@ Page({
historicalList: [], historicalList: [],
}, },
onShow() { onShow() {
// wx.login({
// //成功放回
// success: (res) => {
// const { code } = res
// // appid=wx99885b1c181cda72&secret=edd9cdb04c3f59fe70f2a70c396e5b0d
// }
// })
onStop() onStop()
const that = this; const that = this;
wx.getStorage({
key: 'isConnected',
success(res: any) {
if (res.data) {
this.setData({
netWorkErrorDialog: true,
})
}
},
})
wx.getStorage({ wx.getStorage({
key: 'historicalList', key: 'historicalList',
success(res: any) { success(res: any) {
@ -32,41 +50,33 @@ Page({
}, },
}) })
}, },
onLoad(option) { onLoad() {
if (option.redirect) { wx.authorize({
this.setData({ scope: 'scope.record',
netWorkErrorDialog: true, success: () => {
isRecord: true, this.setData({
isCamera: true, isRecord: true,
}) })
} else { },
wx.authorize({ fail: () => {
scope: 'scope.record', this.setData({
success: () => { isRecord: false,
this.setData({ })
isRecord: true, }
}) });
}, wx.authorize({
fail: () => { scope: 'scope.camera',
this.setData({ success: () => {
isRecord: false, this.setData({
}) isCamera: true,
} })
}); },
wx.authorize({ fail: () => {
scope: 'scope.camera', this.setData({
success: () => { isCamera: false,
this.setData({ })
isCamera: true, }
}) });
},
fail: () => {
this.setData({
isCamera: false,
})
}
});
}
}, },
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), GetRoomRtcToken(roomNum + 'a'), GetAgoraConf()]).then(res => {
@ -80,6 +90,10 @@ Page({
}) })
}, },
closeDialog() { closeDialog() {
wx.setStorage({
key: "isConnected",
data: false
})
this.setData({ this.setData({
netWorkErrorDialog: false netWorkErrorDialog: false
}) })

View File

@ -785,9 +785,11 @@ Page({
if (res.isConnected && (res.networkType !== 'none' || res.networkType !== 'unknown')) { if (res.isConnected && (res.networkType !== 'none' || res.networkType !== 'unknown')) {
} else { } else {
wx.navigateTo({ wx.setStorage({
url: `/pages/form/index?redirect=true` key: "isConnected",
data: true
}) })
wx.navigateBack()
} }
}, },
scroll() { scroll() {
@ -797,11 +799,13 @@ Page({
query.exec((res) => { query.exec((res) => {
const listItemRects = res[1]; const listItemRects = res[1];
listItemRects.forEach(rect => { listItemRects.forEach(rect => {
if (rect.top < res[0].height && rect.top + rect.height > 0) { if (rect.dataset.item.src && rect.dataset.item.enableCamera) {
agora.unmute(Number(rect.dataset.item.uid), 'video') if (rect.top < res[0].height && rect.top + rect.height > 0) {
} else { agora.unmute(Number(rect.dataset.item.uid), 'video')
if (rect.dataset.item.uid != this.data.currentUid) { } else {
agora.mute(Number(rect.dataset.item.uid), 'video') if (rect.dataset.item.uid != this.data.currentUid) {
agora.mute(Number(rect.dataset.item.uid), 'video')
}
} }
} }
}); });