我智商爆棚
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.
wozhishangbaopeng/assets/FrameWork/Mgr/RYPlatformMgr.ts

127 lines
3.9 KiB

4 weeks ago
/*
* @Descripttion:
* @version: 1.0.0
* @Author: YeeChan
* @Date: 2020-07-23 16:59:58
*/
import AppConfig from "../Config/AppConfig";
import HttpUnit, { requestData } from "../NetWork/HttpUnit";
import RYAD from "../RYSDK/RYAD";
import RYSDK from "../RYSDK/RYSDK";
import { LogUtils } from "../Util/LogUtils";
//任游 运营平台
export default class RYPlatformMgr {
public static readonly urlRYWAdv_custom: string = "https://javasttts.renyouwangluo.cn/api/data/product/2result"//从ry_sdk中迁移过来的 wx
/**
* 广
* @param adv_id
*/
public static sendClickAd_custom(adv_id: string) {
if (AppConfig.UseRYSDK_custom) {
LogUtils.info_custom("运营上报:点击广告" + adv_id);
RYSDK.Instance_custom.STAT_custom.reportClickAd_custom(adv_id)
};
}
/**
* 广
* @param adv_id
*/
public static sendClickAdAllow_custom(adv_id: string) {
if (AppConfig.UseRYSDK_custom) {
LogUtils.info_custom("运营上报:点击广告成功 " + adv_id);
RYSDK.Instance_custom.STAT_custom.reportClickAdAllow_custom(adv_id)
};
}
/**
* 广
* @param id
* @param complete
* @param useLocalRandom
*/
public static getAD_custom(id: string, complete: Function, useLocalRandom?: boolean): boolean {
if (AppConfig.UseRYSDK_custom) {
RYSDK.Instance_custom.AD_custom.getAD_custom(id, complete, useLocalRandom);
return true;
}
return false;
}
public static getADList_custom(id: string, complete: Function, useLocalRandom?: boolean) {
this.getRYWADVData_custom(id, (data) => {
if (data.result && data.result.list) {
let datas_custom = data.result.list;
if (true == useLocalRandom) {
RYAD.sortDatas_custom(datas_custom);
}
complete(datas_custom)
} else {
LogUtils.networkError_custom("获取到广告数据 为NULL")
complete(null)
}
}, () => {
LogUtils.networkError_custom("获取到广告数据 为NULL")
complete(null)
})
}
/**
* 广
* @param locationid
* @param onSuccess
* @param onFail
*/
protected static getRYWADVData_custom(locationid, onSuccess: Function, onFail: Function) {
let timelog = Date.now();
var req = new requestData();
req.url_custom = this.urlRYWAdv_custom;
//req.data_custom.gameAppid = AppConfig.AppID_custom;
req.data_custom.timelog = timelog;
req.data_custom.key = locationid;
req.onSuccess_custom = onSuccess;
req.onFail_custom = onFail;
var completeFunc_custom = (res) => {
LogUtils.networkLog_custom(res, "http Success")
if (req.onSuccess_custom) {
req.onSuccess_custom(res);
}
req.onSuccess_custom = null;
req = null;
};
let fail = req.onFail_custom
var errorFunc_custom = (res) => {
LogUtils.networkLog_custom(res, "http fail")
if (fail) {
fail(res);
}
req && (req.onFail_custom = null);
fail = null;
req = null;
};
let headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["au"] = "renyou";
let sendMsg_custom = null
let para_custom = "";
for (const key of Object.keys(req.data_custom)) {
var value = req.data_custom[key];
para_custom += key + "=" + value + "&";
}
sendMsg_custom = para_custom;
HttpUnit.sendHttpUrl_custom(req, sendMsg_custom, completeFunc_custom, errorFunc_custom, headers);
}
}