| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
- import GameM, { VIDEO_TYPE } from "./GameM";
- import UiM, { PANEL_NAME } from "./UiM";
- import Main from "../Main";
- import Turntable from "../ui/Turntable";
- import InvestItem from "../prefabs/InvestItem";
- import Gift from "../ui/Gift";
- import HttpM from "./HttpM";
- import EffectNode from "../ui/EffectNode";
- import WxMgr from "./WxMgr";
- import Daily from "../ui/Daily";
- import { thirdVideoTS } from "./topon/AnyThinkAdsMgr/thirdVideoTS";
- import TreasureItem from "../prefabs/TreasureItem";
- import LogUtil from "../utils/LogUtil";
- import SwitchM from "./SwitchM";
- import InvestData from "../datas/InvestData";
- import TreasureData from "../datas/TreasureData";
- import CashOutData from "../datas/CashOutData";
- import { HTTP_TYPE } from "../datas/CommonData";
- import UsualCaidanData from "../datas/UsualCaidanData";
- import { MateData } from "../datas/MateData";
- import ClubData from "../datas/ClubData";
- import UIMng, { PanelType } from "../uiFrames/UIMng";
- import FightResultPanel from "../ui/FightResultPanel";
- import WealthPanel from "../ui/WealthPanel";
- import RichPanel from "../ui/RichPanel";
- import RichPropPanel from "../ui/RichPropPanel";
- import DownloadApkData from "../datas/DownloadApkData";
- import DailyCashData from "../datas/DailyCashData";
- import MoreGamePopNode from "../ui/MoreGamePopNode";
- import MoreGameData from "../datas/MoreGameData";
- import { TuCaoData } from "../datas/TuCaoData";
- /** 广告类 */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class AdM {
- private static instance: AdM = null
- static get Instance(): AdM {
- if (!this.instance) {
- this.instance = new AdM()
- }
- return this.instance
- }
- static videoType: VIDEO_TYPE
- //是否在登录之后上报邀请人id,用于上报裂变拉入的统计
- static sendReport: boolean = false
- // update (dt) {}
- watchVideo(videoType) {
- if (!GameM.commonData.toponLoaded) {
- EffectNode.instance.PlayTip('广告加载中,请稍后再试')
- return
- }
- if (!UiM.Instance.hallNode.getComponent(Main).checkCanVideo(false)) {
- return false
- }
- if (GameM.commonData.isWatchVideo) {
- return
- }
- AdM.videoType = videoType
- console.log("-->WatchVideo:", AdM.videoType)
- GameM.commonData.hasShowDisconnect = true
- //调用穿山甲广告接口
- if (GameM.commonData.isVideoTest) {
- //测试
- AdM.onVideoWatchEnd()
- }
- else {
- if (GameM.commonData.showFull) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showInter(1)
- }
- return
- }
- GameM.commonData.isWatchVideo = true
- let pop = 1;
- if (videoType == VIDEO_TYPE.hangUp) {
- pop = 2
- }
- if (cc.sys.platform != cc.sys.WECHAT_GAME) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showAd();
- }
- else {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "showVideo", "()V");
- }
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showAd();
- }
- else {
- jsb.reflection.callStaticMethod("GameConfig", "showVideo:", "");
- }
- }
- }
- else {
- WxMgr.getInstance().showRewardAd(pop)
- }
- }
- switch (AdM.videoType) {
- case VIDEO_TYPE.turnTable:
- AdM.onSendEvent('video_init_4', '看视频参加转盘', 'video_init')
- break
- case VIDEO_TYPE.invest:
- AdM.onSendEvent('video_init_10', '看视频参加投资', 'video_init')
- break
- case VIDEO_TYPE.investSpeed:
- AdM.onSendEvent('video_init_11', '看视频投资加速', 'video_init')
- break
- case VIDEO_TYPE.offLineDouble:
- AdM.onSendEvent('video_init_2', '离线奖励双倍领取视频', 'video_init')
- break
- case VIDEO_TYPE.newCarAward:
- AdM.onSendEvent('video_init_3', '合成新车拉起视频', 'video_init')
- break
- case VIDEO_TYPE.userLvUpAd:
- break;
- case VIDEO_TYPE.buyCarMainBtn:
- AdM.onSendEvent('video_init_1', '主界面看视频获得金币', 'video_init')
- break;
- case VIDEO_TYPE.carLvUp:
- AdM.onSendEvent('video_init_12', '看视频武将升级', 'video_init')
- break;
- case VIDEO_TYPE.freshOpenRed:
- AdM.onSendEvent('video_init_9', '看视频获得车位红包奖励', 'video_init')
- break;
- case VIDEO_TYPE.goVideo:
- break;
- case VIDEO_TYPE.join:
- AdM.onSendEvent('video_init_13', '看视频现金夺宝概率提升', 'video_init')
- break
- case VIDEO_TYPE.getTicket:
- AdM.onSendEvent('video_init_6', '看视频参加现金夺宝', 'video_init')
- break;
- case VIDEO_TYPE.gift_Prop:
- case VIDEO_TYPE.gift_redMoney:
- case VIDEO_TYPE.gift_gold:
- case VIDEO_TYPE.gift_box:
- AdM.onSendEvent('video_init_7', '看视频获得热气球奖励', 'video_init')
- break;
- case VIDEO_TYPE.clearCoolTime:
- AdM.onSendEvent('video_init_14', '看视频清除罢工', 'video_init')
- break;
- case VIDEO_TYPE.adRbProgressAd:
- AdM.onSendEvent('video_init_19', '看视频增加提现进度拉起', 'video_init')
- break;
- }
- return true
- }
- static setUserID() {
- // console.log('vvvvvv setUserID ')
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "setUserID", "(Ljava/lang/String;)V", GameM.commonData.uin);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "setUserID:", GameM.commonData.uin);
- }
- }
- static onWatchEnd(placementId = '', adunit_format = '', network_type = '', network_placement_id = '',
- network_firm_id, adsource_id, adsource_index, adsource_price,
- adsource_isheaderbidding, publisher_revenue, precision, ecpm_level) {
- this.onVideoWatchEnd(placementId, adunit_format, network_type, network_placement_id,
- network_firm_id, adsource_id, adsource_index, adsource_price,
- adsource_isheaderbidding, publisher_revenue, precision, ecpm_level)
- }
- /** 获取包名 */
- static getPackageName() {
- let packName = ''
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- packName = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "getPackageName", "()Ljava/lang/String;");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- packName = jsb.reflection.callStaticMethod("CsjAdReward", "getPackageName", "", GameM.commonData.uin);
- }
- return packName
- }
- static getWxAppId() {
- let appid = GameM.commonData.appid
- // let appid = 'wx1c85edd1010da534'
- let unicodeStr = ''
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- unicodeStr = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "getWXAppId", "()Ljava/lang/String;");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- unicodeStr = jsb.reflection.callStaticMethod("GameConfig", "getWXAppId:", GameM.commonData.uin);
- }
- if (unicodeStr.indexOf(';') != -1) {
- let unicodeArr = unicodeStr.split(';')
- appid = unicodeArr[0]
- let configVersionCode = unicodeArr[1]
- if (configVersionCode != "") {
- GameM.commonData.version = configVersionCode
- }
- }
- else {
- appid = unicodeStr
- }
- if (appid != "" && appid != null && appid != undefined) {
- GameM.commonData.appid = appid
- }
- console.log('getWxAppId ', ' unicodeStr = ' + unicodeStr + ' GameM.commonData.version = ' + GameM.commonData.version + ' GameM.commonData.appid = ' + GameM.commonData.appid)
- this.getAdvertisingChannel()
- GameM.globalStorage.init()
- AdM.checkPermission()
- }
- //获取邀请人uin
- static getInviteCode(sendReport: boolean = false) {
- LogUtil.logV("getInviteCode", "start")
- this.sendReport = sendReport
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- LogUtil.logV("getInviteCode", "android start")
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "getInviteCode", "()V");
- }
- // else if (cc.sys.os == cc.sys.OS_IOS) {
- // this.onSetInviteCode("")
- // }else{
- // this.onSetInviteCode("")
- // }
- }
- static onSetInviteCode(codeStr: string) {
- // GameM.ClubData.inviteUin ="" // "6dfdb39c7fc34c7c83b9e3673edd42e5"
- LogUtil.logV("onSetInviteCode", "start")
- if (codeStr != null && codeStr != undefined && codeStr != "") {
- let jsonObj = JSON.parse(codeStr)
- if (jsonObj.inviteuin) {
- GameM.ClubData.inviteUin = jsonObj.inviteuin
- }
- } else {
- GameM.ClubData.inviteUin = ""
- }
- if (GameM.ClubData.inviteUin != "") {
- if (this.sendReport) {
- this.sendReport = false
- let data =
- {
- "appId": GameM.commonData.appid,
- "uin": GameM.commonData.tmp_uin,
- "inviteUin": GameM.ClubData.inviteUin
- }
- GameM.httpM.httpGetComRsa('inviteInstalled', 'POST', JSON.stringify(data), (response) => {
- LogUtil.logV("onSetInviteCode: url", "inviteInstalled")
- LogUtil.logV("onSetInviteCode:errcode ", response.errcode)
- LogUtil.logV("onSetInviteCode:errmsg", response.errmsg)
- })
- this.openInstallReportRegister()
- // GameM.httpM.sendDatas(HTTP_TYPE.inviteInstalled,
- // data);
- return
- } else {
- let aa =
- {
- "inviteUin": GameM.ClubData.inviteUin
- }
- LogUtil.logV("getAccountInfo inviteUin", aa.inviteUin)
- LogUtil.logV("getAccountInfo uin", GameM.commonData.uin)
- GameM.httpM.sendDatas(HTTP_TYPE.bindRelation, aa)
- }
- } else {
- LogUtil.logV("onSetInviteCode", "inviteUin == null")
- }
- }
- //获得邀请码之后直接上报openinstall
- static openInstallReportRegister() {
- LogUtil.logV("getInviteCode", "start")
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- LogUtil.logV("getInviteCode", "android start")
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "openInstallReportRegister", "()V");
- }
- // else if (cc.sys.os == cc.sys.OS_IOS) {
- // this.onSetInviteCode("")
- // }else{
- // this.onSetInviteCode("")
- // }
- }
- /** 获取投放渠道 和 广告位信息*/
- static getAdvertisingChannel() {
- let str = ''
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- str = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "getAdvertisingChannel", "()Ljava/lang/String;");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- str = jsb.reflection.callStaticMethod("GameConfig", "getAdvertisingChannel:", GameM.commonData.uin);
- }
- let arr = str.split(',')
- let channel = arr[0]
- GameM.commonData.toponId = arr[1]
- GameM.commonData.toponKey = arr[2]
- GameM.commonData.rewardPlaceId = arr[3]
- GameM.commonData.interPlaceId = arr[4]
- GameM.commonData.nativePlaceId = arr[5]
- GameM.commonData.fullInterPlaceId = arr[6]
- GameM.commonData.bannerPlaceId = arr[7]
- GameM.commonData.advertisingChannel = parseInt(channel)
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().init();
- }
- }
- static onWatchCancleEnd() {
- EffectNode.instance.PlayTip('观看完视频才能领取奖励')
- GameM.commonData.isWatchVideo = false
- switch (AdM.videoType) {
- case VIDEO_TYPE.hangUp:
- UiM.Instance.hallNode.getComponent(Main).onHandUpAdFail();
- break;
- case VIDEO_TYPE.freshGet:
- UiM.Instance.redPackageNode.onDoubleGetVideoFail();
- break;
- case VIDEO_TYPE.turnTable:
- UiM.Instance.turntableNode.getComponent(Turntable).onTurnTableVideoFail()
- break;
- case VIDEO_TYPE.buyCarMainBtn:
- UiM.Instance.hallNode.getComponent(Main).onBuyCarAdFail()
- break;
- case VIDEO_TYPE.dailyGet:
- UiM.Instance.dailyNode.getComponent(Daily).onVideoFail()
- break;
- case VIDEO_TYPE.adRbProgressAd:
- TuCaoData.Ins.UpdateVideoProgressFial();
- break;
- default:
- AdM.destroyNative()
- break
- }
- }
- static onWatchFailEnd() {
- EffectNode.instance.PlayTip('加载视频中,请稍后再试')
- GameM.commonData.isWatchVideo = false
- switch (AdM.videoType) {
- case VIDEO_TYPE.hangUp:
- UiM.Instance.hallNode.getComponent(Main).onHandUpAdFail();
- break;
- case VIDEO_TYPE.freshGet:
- UiM.Instance.redPackageNode.onDoubleGetVideoFail();
- break;
- case VIDEO_TYPE.turnTable:
- UiM.Instance.turntableNode.getComponent(Turntable).onTurnTableVideoFail()
- break;
- case VIDEO_TYPE.buyCarMainBtn:
- UiM.Instance.hallNode.getComponent(Main).onBuyCarAdFail()
- //买车失败之后因为banner显示问题会挡住买车按钮
- if (thirdVideoTS.getInstance().getIsBannerShow()) {
- AdM.destroyBanner()
- }
- break;
- case VIDEO_TYPE.dailyGet:
- UiM.Instance.dailyNode.getComponent(Daily).onVideoFail()
- break;
- case VIDEO_TYPE.adRbProgressAd:
- TuCaoData.Ins.UpdateVideoProgressFial();
- break;
- default:
- AdM.destroyNative()
- break
- }
- }
- static WxLogin() {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- WxMgr.getInstance().gameLogin();
- }
- else {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "WxAuth", "()V");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "WxAuth:", "");
- }
- }
- }
- static onGetAccessCode(code) {
- GameM.commonData.wxCode = code
- AdM.deleteApks()
- HttpM.Instance.wxlogin()
- }
- /** 发送事件
- * @param eventID 事件ID
- * @param des 事件描述
- * @param taEventID 数数属性事件, ''不向数数发送事件
- */
- static onSendEvent(eventID: string, des: string, taEventID: string = '') {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- //买车次数只记录前200次
- if (taEventID == 'buy') {
- let id = Number(eventID.split('_')[1])
- if (id > 200) {
- return
- }
- }
- if (taEventID == 'shop_buy_car') {
- return
- }
- //合成操作不发埋点
- if (eventID.indexOf('operate') != -1) {
- return
- }
- //友盟埋点
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- //类型 taEventID = ''计数,其他为多属性
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "sendEvent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", taEventID, eventID, des);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "sendEvent:des:", eventID, des);
- }
- //数数埋点
- if (taEventID != '') {
- this.setTAEvent(taEventID, eventID, des)
- }
- //星云埋点
- if (eventID != "firstLoadIn" && eventID != 'loadStart') {
- GameM.commonData.sendCp(eventID, des)
- }
- }
- static sendUmeng(eventID: string, des: string) {
- //友盟埋点
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- //类型 taEventID = ''计数,其他为多属性
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "sendEvent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "", eventID, des);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "sendEvent:des:", eventID, des);
- }
- }
- /**UROI事件
- * @param eventID 事件随机ID
- * @param adID 不同广告生成的唯一id
- * @param adPlacementID 唯一广告位id
- * @param adOperate 广告事件
- * "ad_request",
- "ad_fill",
- "ad_show",
- "ad_click";
- * @param adType 广告类型
- "splash";
- "flow";
- "rewarded";
- "interstitial";
- "banner";
- "other";
- * @param adAdn 广告平台来源
- "facebook",
- "admob",
- "gdt",
- "bytedance_pangle",
- "baidu",
- "tanx",
- "other";
- * @param adPrice 计费价格
- * */
- static sendUROIEvent(eventID, adID, adPlacementID, adOperate, adType, adAdn, adPrice) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "sendUROIEvent",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
- eventID, adID, adPlacementID, adOperate, adType, adAdn, adPrice);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- }
- }
- /** 巨量 查看内容
- */
- static onViewContent() {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "viewContent", "()V");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- }
- }
- /** 快手监测事件
- * @param type 0 次留 1 七留 2 汽车最大等级 3 观看激励视频 4 注册事件 5 完件事件
- */
- static onKSEvent(type, lv = 0) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "onKSEvent", "(II)V", type, lv);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- }
- }
- static setClipboard(str) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- WxMgr.getInstance().clipboardData(str)
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "setClipboard", "(Ljava/lang/String;)V", str);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "setClipboard:", str);
- }
- EffectNode.instance.PlayTip('复制成功')
- }
- static sharePic() {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "sharePic", "()V");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "sharePic:", "");
- }
- }
- //裂变分享链接
- static shareClubInstallUrl(url: string, title: string, describe: string, imgUrl: string) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "shareInviteUrl",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", url, title, describe, imgUrl);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- //to do
- // jsb.reflection.callStaticMethod("GameConfig", "sharePic:", "");
- }
- }
- /** 界面增减 popNum 1 加 -1 减 */
- static popChange(popNum: number) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "popChange", "(I)V", popNum);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- }
- }
- static closePanelFromHome() {
- UiM.Instance.closePanelFromHome()
- }
- /** 返回显示弹窗 */
- static openDailyPanel() {
- UiM.Instance.hallNode.getComponent(Main).showDialyPanel()
- }
- /**广告播放结束
- * @param placementId 广告位id
- */
- public static onVideoWatchEnd(placementId = '', adunit_format = '', network_type = '', network_placement_id = '',
- network_firm_id = '', adsource_id = '', adsource_index = '', adsource_price = '',
- adsource_isheaderbidding = '', publisher_revenue = '', precision = '', ecpm_level = '') {
- // console.log('onVideoWatchEnd')
- UiM.Instance.hallNode.getComponent(Main).startVideoCoolDown()
- GameM.commonData.updateVideoTimes(placementId, adunit_format, network_type, network_placement_id,
- network_firm_id, adsource_id, adsource_index, adsource_price,
- adsource_isheaderbidding, publisher_revenue, precision, ecpm_level)
- AdM.onSendEvent('videoEnd', '所有视频结束统计')
- UsualCaidanData.Instance.addUsualProgress(1)
- if (GameM.commonData.gameAdd <= 7200) {
- AdM.onViewContent()
- AdM.onKSEvent(5)
- }
- AdM.videoReward()
- GameM.commonData.isWatchVideo = false
- GameM.commonData.hasTouch = true
- this.videoType = -1
- }
- static videoReward() {
- switch (AdM.videoType) {
- case VIDEO_TYPE.buyCar:
- UiM.Instance.hallNode.getComponent(Main).onVideoBuyCarEnd()
- // AdM.onSendEvent('videoEnd1', '商店买车拉起视频成功')
- break
- case VIDEO_TYPE.turnTable:
- UiM.Instance.turntableNode.getComponent(Turntable).onTurnTableVideoEnd()
- AdM.onSendEvent('video_end_4', '看视频参加转盘结束', 'video_end')
- break
- case VIDEO_TYPE.invest:
- InvestData.Instance.investItem.getComponent(InvestItem).onInvestVideoEnd()
- AdM.onSendEvent('video_end_10', '看视频参加投资结束', 'video_end')
- AdM.setTAEventUser(1, 'invest_videoTimes', 1)
- break
- case VIDEO_TYPE.investSpeed:
- InvestData.Instance.investItem.getComponent(InvestItem).onInvestVideoSpeedEnd()
- AdM.onSendEvent('video_end_10', '看视频投资加速结束', 'video_end')
- AdM.setTAEventUser(1, 'invest_videoTimes', 1)
- break
- case VIDEO_TYPE.offLineDouble:
- UiM.Instance.giftNode.getComponent(Gift).onOfflineWatchEnd()
- AdM.onSendEvent('video_end_2', '离线奖励双倍领取视频结束', 'video_end')
- break
- case VIDEO_TYPE.newCarAward:
- UiM.Instance.giftNode.getComponent(Gift).onGetCarDoubleWatchEnd()
- AdM.onSendEvent('video_end_3', '合成新车拉起视频结束', 'video_end')
- break
- case VIDEO_TYPE.gift_box:
- UiM.Instance.giftNode.getComponent(Gift).onGiftBoxWatchEnd()
- AdM.onSendEvent('video_end_7', '看视频获得热气球奖励结束', 'video_end')
- break
- case VIDEO_TYPE.gift_redMoney:
- UiM.Instance.giftNode.getComponent(Gift).onGiftRedMoneyAdEnd();
- AdM.onSendEvent('video_end_7', '看视频获得热气球奖励结束', 'video_end')
- break;
- case VIDEO_TYPE.userLvUpAd:
- UiM.Instance.rewardNode.BtnAdUserLvUpEnd();
- break;
- case VIDEO_TYPE.buyCarMainBtn:
- UiM.Instance.hallNode.getComponent(Main).onBuyCarAdEnd()
- AdM.onSendEvent('video_end_1', '主界面看视频获得金币结束', 'video_end')
- AdM.setTAEventUser(1, 'buyMain_videoTimes', 1)
- break;
- case VIDEO_TYPE.shopBuyCarBtn:
- UiM.Instance.hallNode.getComponent(Main).onShopBuyCarAdEnd()
- break;
- case VIDEO_TYPE.carLvUp:
- UiM.Instance.hallNode.getComponent(Main).carLvUpVideoEnd()
- AdM.onSendEvent('video_end_12', '看视频武将升级结束', 'video_end')
- break;
- // case VIDEO_TYPE.taskRwardAd:
- // UiM.Instance.rewardNode.BtnAdTaskEnd();
- // break;
- // case VIDEO_TYPE.hangUp:
- // UiM.Instance.hallNode.getComponent(Main).onHangUpAdEnd();
- // AdM.onSendEvent('videoEnd11', '自动拉起视频播放成功')
- // break;
- case VIDEO_TYPE.freshGet:
- UiM.Instance.redPackageNode.onDoubleGetVideoEnd();
- break;
- case VIDEO_TYPE.freshOpenRed:
- UiM.Instance.redPackageNode.onOpenVideoEnd();
- AdM.onSendEvent('video_end_9', '看视频获得车位红包奖励结束', 'video_end')
- break;
- case VIDEO_TYPE.dailyGet:
- UiM.Instance.dailyNode.getComponent(Daily).onVideoEnd()
- break
- case VIDEO_TYPE.dailyCash:
- UiM.Instance.redPackageNode.onDailyCashVideoEnd()
- break
- case VIDEO_TYPE.gift_gold:
- UiM.Instance.giftNode.getComponent(Gift).onGiftGoldADEnd()
- AdM.onSendEvent('video_end_7', '看视频获得热气球奖励结束', 'video_end')
- break
- case VIDEO_TYPE.getTicket:
- UiM.Instance.giftNode.getComponent(Gift).onGetTicketAdEnd()
- AdM.onSendEvent('video_end_6', '看视频参加现金夺宝结束', 'video_end')
- break
- case VIDEO_TYPE.join:
- if (TreasureData.Instance.curTreasureItem) {
- TreasureData.Instance.curTreasureItem.getComponent(TreasureItem).onDrawAdEnd()
- }
- AdM.onSendEvent('video_end_13', '看视频现金夺宝概率提升结束', 'video_end')
- break
- case VIDEO_TYPE.gift_Prop:
- LogUtil.logV("VIDEO_TYPE.gift_Prop", "")
- UiM.Instance.giftNode.getComponent(Gift).onPropADEnd()
- AdM.onSendEvent('video_end_7', '看视频获得热气球奖励结束', 'video_end')
- break
- case VIDEO_TYPE.fight2Double:
- LogUtil.logV("VIDEO_TYPE.fight2Double", "");
- (UIMng.Ins.GetPanel(PanelType.FightResultPanel) as FightResultPanel).AdDoubleEnd();
- break
- case VIDEO_TYPE.richFightAd:
- //LogUtil.logV("VIDEO_TYPE.fight2Double", "");
- (UIMng.Ins.GetPanel(PanelType.FightResultPanel) as FightResultPanel).AdRichEnd();
- AdM.onSendEvent(`video_end_16`, `取经战斗-全部奖励视频拉起成功`, 'video_end');
- break
- case VIDEO_TYPE.richCtrlAd:
- //LogUtil.logV("VIDEO_TYPE.fight2Double", "");
- (UIMng.Ins.GetPanel(PanelType.RichPropPanel) as RichPropPanel).AdRichCtrlEnd();
- AdM.onSendEvent(`video_end_17`, `取经免费获得遥控卡视频拉起成功`, 'video_end');
- break
- case VIDEO_TYPE.richGetDiceAd:
- (UIMng.Ins.GetPanel(PanelType.RichPropPanel) as RichPropPanel).DiceAdEnd();
- break;
- case VIDEO_TYPE.clearShield:
- (UIMng.Ins.GetPanel(PanelType.WealthPanel) as WealthPanel).AdEndClearShield();
- break
- case VIDEO_TYPE.clearCoolTime:
- LogUtil.logV("VIDEO_TYPE.clearCoolTime", "");
- UiM.Instance.giftNode.getComponent(Gift).clearCoolTime()
- AdM.onSendEvent('video_end_14', '看视频清除罢工成', 'video_end')
- break
- case VIDEO_TYPE.adRbProgressAd:
- AdM.onSendEvent('video_end_19', '看视频增加提现进度拉起成功', 'video_end')
- break
- }
- }
- /**
- * 显示类型
- * @param type 1 账号设置
- * 2 空投宝箱
- * 3 商店
- * 4 挂机收益
- * 5 投资
- * 6 转盘
- * 7 加速
- * 8 任务
- * 9 获得新车奖励弹窗
- * 10 账号升级弹窗
- * 11 金币获得弹窗
- * 12 升级汽车询问弹窗
- * 13 登陆豪礼
- * 14:小秘书
- * 15:免费领取手机
- * 16:提现
- * 17:现金夺宝
- * 18:汽车等级奖励
- * 19:每日提现(明日再来和关闭按钮)
- */
- static createInter(type) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (GameM.commonData.maxCarLevel <= 7) {
- return
- }
- if ((CashOutData.Instance.cashStatus.length + DailyCashData.Instance.dailyCashStatus.length) <= 0) {
- return
- }
- if (GameM.commonData.popInterArr.indexOf(type.toString()) == -1) {
- return
- }
- if (!GameM.commonData.adShowConfig) {
- return
- }
- if (Math.random() <= GameM.commonData.adShowConfig.insert_probability) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showInter(0);
- }
- else {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "createInter", "()V");
- }
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showInter(0);
- }
- else {
- jsb.reflection.callStaticMethod("GameConfig", "createInter:", "");
- }
- }
- }
- else {
- if (MoreGameData.Instance.interProperTotal <= 0) {
- return
- }
- if (Math.random() <= GameM.commonData.globalCfg.popMoreGame) {
- UiM.Instance.onPanel(PANEL_NAME.MoreGamePopNode, false, () => {
- let data = MoreGameData.Instance.getRandomInter()
- UiM.Instance.moreGamePopNode.getComponent(MoreGamePopNode).init(data)
- })
- }
- }
- }
- /** 显示banner */
- static showBanner() {
- LogUtil.logV('showBanner ', 'showBanner aa')
- if (SwitchM.forceMakeMoney) {
- LogUtil.logV('showBanner ', 'showBanner bb')
- if (GameM.commonData.useTopOn) {
- if (GameM.commonData.adShowConfig && GameM.commonData.adShowConfig.is_show_banner == 1) {
- LogUtil.logV('showBanner ', 'showBanner')
- thirdVideoTS.getInstance().showBanner()
- }
- }
- }
- }
- /** 销毁banner */
- static destroyBanner() {
- if (SwitchM.forceMakeMoney) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().destroyBanner()
- }
- }
- }
- /** 显示信息流 */
- static showNative(type = 0) {
- if (GameM.commonData.useTopOn) {
- thirdVideoTS.getInstance().showNative(type)
- }
- }
- /** 销毁信息流 */
- static destroyNative() {
- if (GameM.commonData.useTopOn) {
- if (thirdVideoTS.getInstance().getIsNativeShow()) {
- thirdVideoTS.getInstance().destroyNative()
- }
- }
- }
- static showTip(tip) {
- EffectNode.instance.PlayTip(tip)
- }
- static setTAEventRegister() {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- let talent = MateData.Ins.GetMateInfo()
- let commonStr = GameM.commonData.buyTimeTotal + ';' + GameM.commonData.nickname + ';' + GameM.commonData.appVersion + ';' + GameM.commonData.videoTimes + ';'
- + GameM.commonData.redMoney + ';' + GameM.commonData.gold + ';' + GameM.commonData.maxCarLevel + ';' + GameM.commonData.loginDays + ';' + talent
- + GameM.commonData.roleData.turntableTotal + ';' + GameM.commonData.roleData.shopTotal + ';' + GameM.commonData.roleData.investTotal + ';'
- + GameM.commonData.roleData.treasureTotal + ';' + GameM.commonData.roleData.airshipTotal
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "setTAEventRegister", "(Ljava/lang/String;)V",
- commonStr);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- let json = {
- role_name: GameM.commonData.nickname,
- TotalPayMoney: GameM.commonData.redMoney,
- level: GameM.commonData.roleData.lv,
- ad_number: GameM.commonData.videoTimes,
- highest_car_level: GameM.commonData.maxCarLevel,
- withdraw_amount: GameM.commonData.cashTotalNum
- }
- jsb.reflection.callStaticMethod("ThinkingEvent", "setTAEventRegister:", JSON.stringify(json));
- }
- }
- /**
- * 设置人物属性
- * @param type 0 set 1 add
- * @param property 属性名
- * @param value 数值
- */
- static setTAEventUser(type, property, value) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- let talent = MateData.Ins.GetMateInfo()
- let commonStr = GameM.commonData.buyTimeTotal + ';' + GameM.commonData.nickname + ';' + GameM.commonData.appVersion + ';' + GameM.commonData.videoTimes + ';'
- + GameM.commonData.redMoney + ';' + GameM.commonData.gold + ';' + GameM.commonData.maxCarLevel + ';' + GameM.commonData.loginDays + ';' + talent
- + GameM.commonData.roleData.turntableTotal + ';' + GameM.commonData.roleData.shopTotal + ';' + GameM.commonData.roleData.investTotal + ';'
- + GameM.commonData.roleData.treasureTotal + ';' + GameM.commonData.roleData.airshipTotal
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "setTAEventUser", "(Ljava/lang/String;ILjava/lang/String;F)V",
- commonStr, type, property, value);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- let json = {
- role_name: GameM.commonData.nickname,
- TotalPayMoney: GameM.commonData.redMoney,
- level: GameM.commonData.roleData.lv,
- ad_number: GameM.commonData.videoTimes,
- highest_car_level: GameM.commonData.maxCarLevel,
- withdraw_amount: GameM.commonData.cashTotalNum,
- type: type,
- property: property,
- value: value
- }
- jsb.reflection.callStaticMethod("ThinkingEvent", "setTAEventUser:", JSON.stringify(json));
- }
- }
- static setTAEvent(taEventID, eventID, des) {
- if (cc.sys.platform == cc.sys.WECHAT_GAME) {
- return
- }
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- let talent = MateData.Ins.GetMateInfo()
- let commonStr = GameM.commonData.buyTimeTotal + ';' + GameM.commonData.nickname + ';' + GameM.commonData.appVersion + ';' + GameM.commonData.videoTimes + ';'
- + GameM.commonData.redMoney + ';' + GameM.commonData.gold + ';' + GameM.commonData.maxCarLevel + ';' + GameM.commonData.loginDays + ';' + talent
- + GameM.commonData.roleData.turntableTotal + ';' + GameM.commonData.roleData.shopTotal + ';' + GameM.commonData.roleData.investTotal + ';'
- + GameM.commonData.roleData.treasureTotal + ';' + GameM.commonData.roleData.airshipTotal
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "setTAEvent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
- commonStr, taEventID, eventID, des);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- let json = {
- role_name: GameM.commonData.nickname,
- TotalPayMoney: GameM.commonData.redMoney,
- level: GameM.commonData.roleData.lv,
- ad_number: GameM.commonData.videoTimes,
- highest_car_level: GameM.commonData.maxCarLevel,
- withdraw_amount: GameM.commonData.cashTotalNum,
- taEventID: taEventID,
- eventID: eventID,
- des: des
- }
- jsb.reflection.callStaticMethod("ThinkingEvent", "setTAEvent:", JSON.stringify(json));
- }
- }
- static updateMachine(info) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- GameM.commonData.updateMachine(info)
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- GameM.commonData.updateMachine(info)
- }
- }
- /**判断是否可以显示开屏广告
- * @param state 1 可以 0 不可以
- * */
- static canShowSplash(state) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "canShowSplash", "(I)V", state);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "canShowSplash:", state);
- }
- }
- static showSplash() {
- AdM.onSendEvent('slashAd', '开屏', 'slashAd')
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "showSplash", "()V");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "showSplash:", "");
- }
- }
- /** 检查获取手机权限 */
- static checkPermission() {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "checkPermission", "()V");
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "checkPermission:", "");
- }
- }
- /** 安装apk
- * @param localPath 本地路径
- */
- static installApk(localPath) {
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "installApk", "(Ljava/lang/String;)V", localPath);
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "installApk:", "");
- }
- }
- /** 判断是否已经安装
- * @param packageName 包名
- */
- static canStartGame(packageName, start: boolean): boolean {
- let isExist = false
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- isExist = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "isStartGame", "(Ljava/lang/String;Z)Z", packageName, start);
- return isExist
- }
- else if (cc.sys.os == cc.sys.OS_IOS) {
- jsb.reflection.callStaticMethod("GameConfig", "installApk:", "");
- }
- return isExist
- }
- static updateActivateLog(sessionDuration) {
- LogUtil.logV('test>>> updateActivateLog ', sessionDuration)
- GameM.commonData.updateActivateLog(sessionDuration)
- }
- static getApkFileInfo(path: string): string {
- LogUtil.logV('getApkFileInfo', "")
- let str = ""
- // path = "/storage/emulated/0/Android/data/com.aries.hyxy.mz/cache/com_qq_e_download/apk/com.gtxj.gdttf.apk"
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- str = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "getApkIcon", "(Ljava/lang/String;)Ljava/lang/String;", path);
- LogUtil.logV("getApkFileInfo ", str)
- }
- return str
- }
- static saveLocalDownloadAPkFiles(allPath: string) {
- LogUtil.logV('saveLocalDownloadAPkFiles allPath ', allPath)
- DownloadApkData.Instance.setInDownloadApkFiles(allPath)
- }
- static checkPathApk() {
- LogUtil.logV('checkPathApk', "")
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "checkPathApk", "()V");
- }
- }
- static freshApkState() {
- DownloadApkData.Instance.freshInstallApk()
- }
- static deleteApks() {
- LogUtil.logV('deleteApks', "")
- if (cc.sys.os == cc.sys.OS_ANDROID) {
- jsb.reflection.callStaticMethod("org/cocos2dx/javascript/config/TTAdManagerHolder", "deleteApks", "()V");
- }
- }
- }
- window['AdM'] = AdM
|