init
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import HttpUnit from "../Common/HttpUnit";
|
||||
import { SDKManager } from "./SDKManager";
|
||||
|
||||
export class WebSDK{
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
console.log("init webSDK");
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
//检查权限
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
cb && cb(true);
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
getUserInfo(cb:Function = null) {
|
||||
let name = HttpUnit.GetNickName();
|
||||
cb && cb({ nickName:name, avatarUrl:"https://hxzgame.vip.hnhxzkj.com/lzx/XiangQin/webHead.png" });
|
||||
}
|
||||
|
||||
//region 登录
|
||||
login(cb: Function = null) {
|
||||
cb && cb({ platform:2, code: null });
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
callback && callback({ code: 0, tag: tag });
|
||||
SDKManager.video_ad_back();
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner(...args) {
|
||||
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner(...args) {
|
||||
|
||||
}
|
||||
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
rewardCB && rewardCB();
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
return {width:screen.width, height: screen.height};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
|
||||
}
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return true;
|
||||
}
|
||||
//播放base64音频
|
||||
private _audioInst:HTMLAudioElement = null;
|
||||
playBase64Audio(base64:string, loop:boolean) {
|
||||
let substring = base64;
|
||||
let qianzhui = "data:audio/x-wav;base64,"
|
||||
if(base64.startsWith(qianzhui)) {
|
||||
substring = base64.substring(qianzhui.length, base64.length)
|
||||
}
|
||||
|
||||
// 解码 Base64 字符串为二进制数据
|
||||
const binaryData = atob(substring);
|
||||
|
||||
// 创建一个包含二进制数据的 Uint8Array
|
||||
const byteArray = new Uint8Array(binaryData.length);
|
||||
for (let i = 0; i < binaryData.length; i++) {
|
||||
byteArray[i] = binaryData.charCodeAt(i);
|
||||
}
|
||||
|
||||
// 创建 Blob 对象,指定 MIME 类型为音频格式(例如 mp3)
|
||||
const audioBlob = new Blob([byteArray], { type: 'audio/mp3' });
|
||||
|
||||
// 创建音频 URL
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
|
||||
console.log("web 播放base64音频", audioUrl)
|
||||
// 创建音频元素并播放
|
||||
if (this._audioInst == null) {
|
||||
this._audioInst = new Audio(audioUrl);
|
||||
} else {
|
||||
this._audioInst.src = audioUrl;
|
||||
}
|
||||
this._audioInst.play();
|
||||
|
||||
}
|
||||
|
||||
//客服功能是否支持
|
||||
kefuSupport() {
|
||||
console.log("web 不支持联系客服")
|
||||
return false;
|
||||
}
|
||||
//进入联系客服
|
||||
openKefu() {
|
||||
console.log("web 进入联系客服")
|
||||
}
|
||||
|
||||
//region 友盟+
|
||||
umaInit() {
|
||||
}
|
||||
//友盟统计是否开启
|
||||
umaSwt() {
|
||||
return false;
|
||||
}
|
||||
//友盟事件统计
|
||||
umaEvent(eventName: string, value: any = {}) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user