Commit d753103e authored by liupengfei's avatar liupengfei

正式

parent d242b4c7
......@@ -140,13 +140,13 @@ class MyAdvideo {
}
// 请求视频的来源
async getVideo() {
async getVideo(type = 1) {
if (this.isVideoIng) {
return;
}
this.isVideoIng = true;
this.strategy = 'dianxing';
const res = await this.stragegyFn[this.strategy].getVideo();
const res = await this.stragegyFn[this.strategy].getVideo(type);
console.log(res);
if (res) {
// 上报app?
......
......@@ -77,18 +77,17 @@ interface adRes {
ads: Array<any>
};
async function getVideo() {
async function getVideo(type) {
let videoRes = {};
try {
if (!config) {
const appInfo = await getAppInfo()
const appInfo = await getAppInfo(type)
console.log(appInfo);
console.log(getDefaultConfig());
const defaultConfig = defautToNew(getDefaultConfig(), reflectConfig);
console.log(defaultConfig);
config = createConfig(appInfo, defaultConfig);
}
config['requsetId'] = createUnique(config['network']['ip'])
const res: any = await window.fetch('http://47.95.31.238/adx/ssp/dspAdTest', {
const res: any = await window.fetch('http://47.95.31.238/adx/ssp/dspAdVideo', {
body: JSON.stringify(config),
headers: {
'content-type': 'application/json;charset=UTF-8',
......
......@@ -23,6 +23,19 @@ export const getUrl = (name) => {
return '';
};
// 获取网络信息
// 0- 未知网络 2- 2G
// 3- 3G
// 4- 4G
// 5- 5G
// 100-WIFI 101—ETHERNET 999--NEW_TYPE
const reflectObj = {
wifi: 100,
'2g': 2,
'3g': 3,
'4g': 4,
'5g': 5,
other: 0
};
export function getNetworkType(obj = {}) {
const ua = navigator.userAgent;
let networkStr = ua.match(/NetType\/\w+/) ? ua.match(/NetType\/\w+/)[0] : 'NetType/other';
......@@ -47,7 +60,7 @@ export function getNetworkType(obj = {}) {
default:
networkType = 'other';
}
if (obj[networkType]) {
if (obj.hasOwnProperty(networkType)) {
return obj[networkType];
}
return networkType;
......@@ -63,26 +76,40 @@ interface appInfo {
connectionType: number,
operatorType: number
}
// 1- 中国移动 2- 中国电信 3- 中国联通
const yunyingShang = {
'移动': 1,
'中国移动': 1,
'联通': 2,
'中国联通': 2,
'电信': 3,
'中国电信': 3,
'其他': 99
}
// 获取平台信息, app相关的,slotId , ip。
export function getAppInfo():Promise<appInfo> {
const tSlotId = getUrl('tSlotId');
console.log(tSlotId);
return new Promise((resolve) => {
// window.fetch(`https://activity.tuiatest.cn/commercialloanv/common/config/video/get?slotId=${tSlotId}`).then(res => {
// return res.json();
// }).then(res => {
// console.log(res);
// });
resolve({
appId: "ZG08HD",
appPackage: "com.test",
appName: "测试 APP",
appVersion: "1.1.0",
slotId: "test1030",
ip: "115.236.166.122",
connectionType: 4,
operatorType: 2
})
export function getAppInfo(type):Promise<appInfo> {
const tSlotId = getUrl('tSlotId') || 10000;
console.log();
return window.fetch(`https://activity.tuia.cn/commercialloanv/common/config/video/get?slotId=${tSlotId}`)
.then(res => {
return res.json();
}).then(res => {
console.log(res);
if (res.code === '0000000' && res.data) {
const config = res.data.config || [];
console.log(type);
const appInfo = config.find(e => e.platform === 'dianxing' && Number(e.type) === type)
const ipInfo = res.data.ipInfoDetail || {};
const ip = ipInfo.ip
const op = ipInfo.isp || '未知'
const operatorType = yunyingShang[op] || 99;
appInfo.ip = ip;
appInfo.operatorType = operatorType;
appInfo.connectionType = getNetworkType(reflectObj);
return appInfo;
} else {
return 'error';
}
});
}
......@@ -103,14 +130,7 @@ export function createUnique(ip) {
// imsi() 不做要求。
// ppi
// connt(网络状况) 优先传递
const reflectObj = {
wifi: 101,
'2g': 2,
'3g': 3,
'4g': 4,
'5g': 5,
other: 0
};
let defaultConfig;
export function getDefaultConfig() {
if (defaultConfig) return defaultConfig;
......
......@@ -85,7 +85,8 @@ export default class MapScene extends Scene {
}
},
() => { NetManager.ins.getIconAward(() => { }) },
window["slotidIcon"]
window["slotidIcon"],
1
)
}, this)
}
......
......@@ -7,6 +7,7 @@ import MyAdvideo from "../adVideo/adVideo";
import { stopBg, playBg } from "../soundCtrl";
let videoIns: MyAdvideo;
let videoContanier = document.querySelector('#video-contanier');
// 消消乐的监听
window['playingVideoClose'] = () => {
if (videoIns && videoIns.isPlaying) {
videoIns.isPlaying = false;
......@@ -27,6 +28,7 @@ export const handleVideo = (
returnCallback: (s: boolean) => void,
completeCallback: Function,
slotid: string,
type = 2,
) => {
Loading.instace.show();
if (!videoIns) {
......@@ -34,7 +36,7 @@ export const handleVideo = (
el: videoContanier
})
}
videoIns.getVideo().then((res) => {
videoIns.getVideo(type).then((res) => {
stopBg()
Loading.instace.hide();
if (res) {
......
......@@ -72,7 +72,7 @@ export default class VideoBuyPanel extends Panel {
}
},
() => { },
window["slotid"]
window["slotid"],
)
}, this);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment