This commit is contained in:
yj 2024-11-26 14:15:29 +08:00
parent 5ca4929a45
commit cc16814256
3 changed files with 10 additions and 32 deletions

View File

@ -17,3 +17,7 @@ export const GetRoomRtcToken = (roomNum: string) => Request({
url: `/room/tk/rtc?roomNum=${roomNum}`,
method: 'get',
})
export const GetOpenId = (code: string) => Request({
url: `/pub/mini-openid?js_code=${code}`,
method: 'get',
})

View File

@ -1,4 +1,4 @@
import { GetCheckoutRoomNum, PostAnonLogin, GetAgoraConf, GetRoomRtcToken } from '../../api/form/index'
import { GetCheckoutRoomNum, PostAnonLogin, GetAgoraConf, GetRoomRtcToken, GetOpenId } from '../../api/form/index'
import { getUUID } from '../../utils/utils'
import { Message } from 'tdesign-miniprogram';
import { startSignalr, onStop } from '../../utils/singlr';
@ -15,14 +15,6 @@ Page({
historicalList: [],
},
onShow() {
// wx.login({
// //成功放回
// success: (res) => {
// const { code } = res
// // appid=wx99885b1c181cda72&secret=edd9cdb04c3f59fe70f2a70c396e5b0d
// }
// })
const that = this;
wx.getStorage({
key: 'isConnected',
@ -150,18 +142,12 @@ Page({
GetCheckoutRoomNum(this.data.meetingForm.roomNum).then(res => {
if (res.code === 200) {
if (res.data) {
wx.getStorage({
key: "deviceId",
success(res: any) {
navigateToMeeting(res.data)
},
fail() {
const uuid = getUUID()
wx.setStorage({
key: "deviceId",
data: uuid
wx.login({
success: (res) => {
const { code } = res
GetOpenId(code).then(res => {
navigateToMeeting(res.data)
})
navigateToMeeting(uuid)
}
})
} else {

View File

@ -2,18 +2,6 @@ export const role = {
ID: ['1', '3']
}
export const getUUID = (): string => {
var s = [] as any;
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4";
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
s[8] = s[13] = s[18] = s[23] = "-";
return s.join("")
}
export const getStorage = async (key: string): Promise<void> => {
return new Promise((resolve, reject) => {
wx.getStorage({