You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
7.3 KiB
188 lines
7.3 KiB
1 week ago
|
import QQMiniGameAPI from "../../Platform/qq/QQMiniGameAPI";
|
||
|
import WXAPI from "../../Platform/weixin/WXAPI";
|
||
|
import AppSwitchConfig from "../Config/AppSwitchConfig";
|
||
|
import { ryw_Event } from "../Event/EventEnum";
|
||
|
import EventMgr from "../Event/EventMgr";
|
||
|
import HttpUnit from "../NetWork/HttpUnit";
|
||
|
import AppPlatform from "../Util/AppPlatform";
|
||
|
|
||
|
export default class WudianMgr {
|
||
|
private static ipBlockFlag_custom: number = -1;
|
||
|
public static ryw_IpBlockFlag_custom(): number {
|
||
|
return WudianMgr.ipBlockFlag_custom;
|
||
|
}
|
||
|
/**
|
||
|
* 此方法调用很慢,所以要在游戏初始化的时候调用一次此方法
|
||
|
*
|
||
|
* @static
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static UpdateIpBlockState_custom(completed?: Function) {
|
||
|
HttpUnit.GetIpBlock_custom(
|
||
|
function (res) {
|
||
|
console.log("调用IpBlock接口成功,结果为:", res);
|
||
|
WudianMgr.ipBlockFlag_custom = res.code;
|
||
|
EventMgr.emitEvent_custom(ryw_Event.ryw_App_OnUpdateIpBlockState_custom, { ipBlockFlag: WudianMgr.ipBlockFlag_custom });
|
||
|
completed && completed();
|
||
|
},
|
||
|
()=>{
|
||
|
completed && completed();
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
/**
|
||
|
* IP是否被屏蔽
|
||
|
*
|
||
|
* @static
|
||
|
* @returns {boolean}
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static ryw_GetIpBlocked_custom(): boolean {
|
||
|
return WudianMgr.ipBlockFlag_custom == 0;
|
||
|
}
|
||
|
// /**
|
||
|
// * 得到用户进入的场景值
|
||
|
// *
|
||
|
// * @static
|
||
|
// * @returns {number}
|
||
|
// * @memberof WudianMgr
|
||
|
// */
|
||
|
// public static GetEntryScene_custom(): boolean {
|
||
|
// return WXAPI.getLaunchOptionsSync_custom().scene == 1006;
|
||
|
// }
|
||
|
/**
|
||
|
* 误点开关是否打开,包括了总开关和分时开关
|
||
|
*
|
||
|
* @static
|
||
|
* @returns {boolean}
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static ryw_IsSwitchOpen_custom(): boolean {
|
||
|
let mainSwitch_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudian_custom == 1;
|
||
|
let isOpenTime_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianTimeAvaliable_custom;
|
||
|
console.log("误点 Flag_custom 状态: ", "总开关:", mainSwitch_custom, "打开时间", isOpenTime_custom);
|
||
|
return mainSwitch_custom && isOpenTime_custom;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 完全封装好的误点Flag 去掉了IP屏蔽
|
||
|
*
|
||
|
* @readonly
|
||
|
* @static
|
||
|
* @type {boolean}
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static get wudianFlag_noIpBlock_custom(): boolean {
|
||
|
let mainSwitch_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudian_custom == 1;
|
||
|
let isOpenTime_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianTimeAvaliable_custom;
|
||
|
//let ipnotBlock = this.ipBlockFlag_custom == 0;
|
||
|
let launchScene_custom = AppPlatform.getLaunchOptionsSync_custom().scene;
|
||
|
|
||
|
if (AppPlatform.is_TT_GAME_custom()) {
|
||
|
mainSwitch_custom = true;
|
||
|
isOpenTime_custom = true;
|
||
|
}
|
||
|
|
||
|
let noEnterBySearch_custom: boolean = true;
|
||
|
let wudianSceneList_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianSceneList_custom;
|
||
|
for (let i = 0; i < wudianSceneList_custom.length; ++i) {
|
||
|
var wudianSceneValue = wudianSceneList_custom[i];
|
||
|
if (launchScene_custom == wudianSceneValue) {
|
||
|
noEnterBySearch_custom = false;
|
||
|
}
|
||
|
}
|
||
|
/* 测试功能,等删 */
|
||
|
// ipnotBlock = true;
|
||
|
console.log("误点 Flag_custom 状态: ", "总开关:", mainSwitch_custom, "场景进入", noEnterBySearch_custom, "打开时间",
|
||
|
isOpenTime_custom);
|
||
|
|
||
|
return mainSwitch_custom && noEnterBySearch_custom && isOpenTime_custom;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 完全封装好的误点Flag
|
||
|
*
|
||
|
* @readonly
|
||
|
* @static
|
||
|
* @type {boolean}
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static get wudianFlag_custom(): boolean {
|
||
|
let mainSwitch_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudian_custom == 1;
|
||
|
let isOpenTime_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianTimeAvaliable_custom;
|
||
|
let ipnotBlock_custom = this.ipBlockFlag_custom == 0;
|
||
|
let launchScene_custom = AppPlatform.getLaunchOptionsSync_custom().scene;
|
||
|
|
||
|
if (AppPlatform.is_TT_GAME_custom()) {
|
||
|
mainSwitch_custom = true;
|
||
|
isOpenTime_custom = true;
|
||
|
}
|
||
|
|
||
|
let noEnterBySearch_custom: boolean = true;
|
||
|
let wudianSceneList_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianSceneList_custom;
|
||
|
for (let i = 0; i < wudianSceneList_custom.length; ++i) {
|
||
|
let wudianSceneValue = wudianSceneList_custom[i];
|
||
|
if (launchScene_custom == wudianSceneValue) {
|
||
|
noEnterBySearch_custom = false;
|
||
|
}
|
||
|
}
|
||
|
/* 测试功能,等删 */
|
||
|
// ipnotBlock = true;
|
||
|
console.log("误点 Flag_custom 状态: ", "总开关:", mainSwitch_custom, "场景进入", noEnterBySearch_custom, "IP未被屏蔽", ipnotBlock_custom, "打开时间",
|
||
|
isOpenTime_custom);
|
||
|
|
||
|
return mainSwitch_custom && noEnterBySearch_custom && ipnotBlock_custom && isOpenTime_custom;
|
||
|
}
|
||
|
/**
|
||
|
* 没有涉及到定时开关的wudianFlag,自行整合按照时间开关的效果
|
||
|
*
|
||
|
* @static
|
||
|
* @returns {boolean}
|
||
|
* @memberof WudianMgr
|
||
|
*/
|
||
|
public static get NoTimeWudianFlag_custom(): boolean {
|
||
|
let mainSwitch_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudian_custom == 1;
|
||
|
let launchScene_custom = AppPlatform.getLaunchOptionsSync_custom().scene;
|
||
|
|
||
|
let noEnterBySearch_custom: boolean = true;
|
||
|
let wudianSceneList_custom = AppSwitchConfig.getInstance_custom().getAppSwitchData_custom().wudianSceneList_custom;
|
||
|
for (let i = 0; i < wudianSceneList_custom.length; ++i) {
|
||
|
let wudianSceneValue_custom = wudianSceneList_custom[i];
|
||
|
if (launchScene_custom == wudianSceneValue_custom) {
|
||
|
noEnterBySearch_custom = false;
|
||
|
}
|
||
|
}
|
||
|
let ipnotBlock_custom = WudianMgr.ipBlockFlag_custom == 0;
|
||
|
/* 测试功能,等删 */
|
||
|
// ipnotBlock = true;
|
||
|
console.log("误点 Flag_custom 状态: ", "总开关:", mainSwitch_custom, "场景进入", noEnterBySearch_custom, "IP未被屏蔽");
|
||
|
return mainSwitch_custom && noEnterBySearch_custom && ipnotBlock_custom;
|
||
|
}
|
||
|
|
||
|
|
||
|
public static get isEnterBySerach_custom(): boolean {
|
||
|
|
||
|
let launchScene = null;
|
||
|
if (AppPlatform.is_WECHAT_GAME_custom()) {
|
||
|
launchScene = WXAPI.getLaunchOptionsSync_custom().scene;
|
||
|
}
|
||
|
else if (AppPlatform.is_QQ_PLAY_custom()) {
|
||
|
launchScene = QQMiniGameAPI.getLaunchOptionsSync_custom().scene;
|
||
|
}
|
||
|
|
||
|
let noEnterBySearch: boolean = true;
|
||
|
var wudianSceneList = [1011, 1012, 1013, 1047]
|
||
|
for (var i = 0; i < wudianSceneList.length; ++i) {
|
||
|
var wudianSceneValue = wudianSceneList[i];
|
||
|
if (launchScene == wudianSceneValue) {
|
||
|
noEnterBySearch = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
console.log("场景进入", noEnterBySearch);
|
||
|
return noEnterBySearch;
|
||
|
}
|
||
|
}
|