beelink/public/js/presetting.js

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-12 09:27:59 +00:00
/* global $ setBtnClickFuc genTestUserSig */
// preset before starting RTC
class Presetting {
init() {
// populate userId/roomId
$('#userId').val('user_30400097');
$('#roomId').val(parseInt(Math.random() * 100000));
const roomId = this.query('roomId');
const userId = this.query('userId');
if (roomId) {
$('#roomId').val(roomId);
}
if (userId) {
$('#userId').val(userId);
}
$('#main-video-btns').hide();
$('.mask').hide();
setBtnClickFuc();
}
query(name) {
const match = window.location.search.match(new RegExp('(\\?|&)' + name + '=([^&]*)(&|$)'));
return !match ? '' : decodeURIComponent(match[2]);
}
login(share, callback) {
2020-11-12 10:03:30 +00:00
let userId = window.mid;
2021-01-25 08:13:53 +00:00
if (share == 1) {
2020-11-12 09:27:59 +00:00
userId = 'share_' + userId;
2021-01-25 08:13:53 +00:00
}else if(share == 2){
userId = 'ceshi_' + userId;
2020-11-12 09:27:59 +00:00
}
console.log(userId)
2020-11-12 09:43:45 +00:00
let sdkAppId;
let userSig;
2020-11-12 10:03:30 +00:00
let roomId = window.roomid;
2020-11-12 09:43:45 +00:00
genTestUserSig(userId).then((res)=>{
sdkAppId = res.id;
userSig = res.data
callback({
sdkAppId,
userId,
userSig,
roomId
});
})
2020-11-12 09:27:59 +00:00
2020-11-12 09:43:45 +00:00
2020-11-12 09:27:59 +00:00
}
}