Commit d753103e authored by liupengfei's avatar liupengfei

正式

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