| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import JsbSystem from "../../../mk/system/JsbSystem";
- const { ccclass } = cc._decorator;
- @ccclass
- export default class WarnTipData {
- //当前状态 0-无处理;1-警告;2-封广告30分钟;3-封广告12小时;4-用户拉黑
- curSolution = 0;
- tipArr = ['',
- '您点击广告太频繁了,请降低点击广告频率以免被封!',
- '您点击广告太频繁了,禁止看广告30分钟!',
- '您点击广告太频繁了,禁止看广告12小时!',
- '系统检测到您的账号存在异常,禁止登陆游戏!']
- /** 屏蔽广告源数组 */
- shutdown_ads = null;
- /** topon广告位数组 */
- AdIDArr = [];
- setSolution(solution) {
- if (this.curSolution != solution) {
- //除了状态0,其他状态只有级别比当前状态高才会赋值,避免异步导致低级状态覆盖高级状态
- if (solution == 0 || this.curSolution < solution) {
- this.curSolution = solution;
- }
- mk.storage.setStorage('solution', this.curSolution);
- }
- if (this.curSolution == 4) {
- mk.ui.openPanel('module/warnTip/WarnTipPanel');
- }
- }
- /** 设置屏蔽广告位 */
- setShutdownAds(stAds) {
- if (this.shutdown_ads != stAds) {
- this.shutdown_ads = stAds;
- if (this.shutdown_ads && this.shutdown_ads.length > 0) {
- let tempArr = this.AdIDArr.slice();
- let len = this.shutdown_ads.length;
- for (let i = 0; i < len; i++) {
- let adData = this.shutdown_ads[i];
- let index = tempArr.indexOf(adData.placementId);
- if (index != -1) {
- JsbSystem.setFilterAdSourceIdList(adData.placementId, adData.adsourceIds.join(','));
- console.log('屏蔽广告位:', adData.placementId + " 广告源拼接:" + adData.adsourceIds.join(','));
- tempArr.splice(index, 1);
- }
- else {
- console.error('没有对应的广告位:', adData.placementId)
- }
- }
- let len1 = tempArr.length;
- if (len1 > 0) {
- console.log('未屏蔽广告位拼接:', tempArr.join(','));
- for (let i = 0; i < len1; i++) {
- JsbSystem.setFilterAdSourceIdList(tempArr[i], '');
- }
- }
- }
- else {
- console.log('不需要屏蔽广告:', this.AdIDArr.join(','));
- let len2 = this.AdIDArr.length;
- for (let i = 0; i < len2; i++) {
- JsbSystem.setFilterAdSourceIdList(this.AdIDArr[i], '');
- }
- }
- }
- }
- async getUserShutdownAds(callback) {
- console.log('getUserShutdownAds ', '调用getUserShutdownAds ');
- let data = {}
- let response = await mk.http.sendData('getUserShutdownAds', data)
- if (response && response.errcode == 0) {
- mk.console.logSingle('getUserShutdownAds ', response);
- if (response.data) {
- gData.warnTipData.setShutdownAds(response.data.shutdown_ads);
- }
- callback();
- }
- else {
- mk.console.logSingle('getUserShutdownAds 无返回 ', response);
- }
- }
- }
|