Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
85051832
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
85051832
编写于
11月 23, 2021
作者:
d-u-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update: H5 ad 引入新的源
上级
851e7aa8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
94 addition
and
21 deletion
+94
-21
src/platforms/h5/view/components/ad/index.vue
src/platforms/h5/view/components/ad/index.vue
+94
-21
未找到文件。
src/platforms/h5/view/components/ad/index.vue
浏览文件 @
85051832
...
...
@@ -252,10 +252,9 @@ class AdScript {
this
.
_cache
=
{}
}
load
(
data
,
success
,
fail
)
{
const
provider
=
data
.
provider
load
(
provider
,
script
,
success
,
fail
)
{
if
(
this
.
_cache
[
provider
]
===
undefined
)
{
this
.
loadScript
(
data
)
this
.
loadScript
(
script
)
}
if
(
this
.
_cache
[
provider
]
===
1
)
{
...
...
@@ -271,12 +270,10 @@ class AdScript {
}
}
loadScript
(
data
)
{
const
provider
=
data
.
provider
loadScript
(
provider
,
script
)
{
this
.
_cache
[
provider
]
=
0
var
ads
=
document
.
createElement
(
'
script
'
)
ads
.
setAttribute
(
'
id
'
,
'
uniad_provider
'
+
provider
)
const
script
=
data
.
script
for
(
const
var1
in
script
)
{
ads
.
setAttribute
(
var1
,
script
[
var1
])
}
...
...
@@ -298,6 +295,59 @@ class AdScript {
}
}
class
AdTencent
{
static
get
instance
()
{
if
(
this
.
_instance
==
null
)
{
this
.
_instance
=
new
AdTencent
()
}
return
this
.
_instance
}
constructor
()
{
this
.
_instance
=
null
this
.
_callback
=
{}
this
.
_cache
=
{}
window
.
TencentGDT
=
window
.
TencentGDT
||
[]
}
load
(
appid
,
placementid
,
success
,
fail
)
{
if
(
!
this
.
_callback
[
placementid
])
{
this
.
_callback
[
placementid
]
=
[]
}
this
.
_callback
[
placementid
].
push
({
success
,
fail
})
if
(
!
this
.
_cache
[
placementid
])
{
this
.
_cache
[
placementid
]
=
{
isReady
:
false
}
window
.
TencentGDT
.
push
({
app_id
:
appid
,
placement_id
:
placementid
,
type
:
'
native
'
,
count
:
1
,
onComplete
:
(
res
)
=>
{
this
.
_cache
[
placementid
].
isReady
=
true
this
.
_callback
[
placementid
].
forEach
(({
success
,
fail
})
=>
{
if
(
res
&&
Array
.
isArray
(
res
)
&&
res
.
length
)
{
success
(
res
[
0
])
}
else
{
fail
(
res
)
}
this
.
_callback
[
placementid
].
length
=
0
})
}
})
}
if
(
this
.
_cache
[
placementid
].
isReady
===
true
)
{
window
.
TencentGDT
.
NATIVE
.
loadAd
(
placementid
)
}
}
}
const
CHECK_RENDER_DELAY
=
1000
const
CHECK_RENDER_RETRY
=
5
const
DEFAULT_WIDESCREEN_WIDTH
=
750
...
...
@@ -361,10 +411,12 @@ export default {
this
.
_pi
=
0
this
.
_clearCheckTimer
()
this
.
$refs
.
container
.
innerHTML
=
''
this
.
_isReady
=
false
},
_loadData
(
adpid
)
{
this
.
_reset
()
const
aid
=
adpid
||
(
this
.
_isWidescreen
?
this
.
adpidWidescreen
:
this
.
adpid
)
const
id
=
adpid
||
this
.
adpid
const
aid
=
(
this
.
_isWidescreen
?
(
this
.
adpidWidescreen
||
id
)
:
id
)
AdConfig
.
instance
.
get
(
aid
,
(
b
,
a
)
=>
{
this
.
_b
=
b
this
.
_pl
=
a
...
...
@@ -379,26 +431,47 @@ export default {
}
const
data
=
this
.
_pl
[
this
.
_pi
]
const
providerId
=
data
.
a1
this
.
_b
[
providerId
].
provider
=
providerId
const
providerConfig
=
this
.
_b
[
data
.
a1
][
data
.
t
]
AdScript
.
instance
.
load
(
this
.
_b
[
providerId
],
()
=>
{
this
.
_renderAdView
(
this
.
_b
[
providerId
],
data
)
},
(
err
)
=>
{
this
.
$trigger
(
'
error
'
,
{},
err
)
})
},
_renderAdView
(
provider
,
data
)
{
var
randomId
=
this
.
_randomId
()
if
(
data
.
a1
===
'
10011
'
)
{
AdTencent
.
instance
.
load
(
data
.
a3
,
data
.
a2
,
(
res
)
=>
{
window
.
TencentGDT
.
NATIVE
.
renderAd
(
res
,
randomId
)
})
this
.
_startCheckTimer
()
}
else
if
(
data
.
a1
===
'
10012
'
)
{
this
.
_renderAdView
(
providerConfig
,
data
,
randomId
)
}
else
{
AdScript
.
instance
.
load
(
data
.
t
,
providerConfig
.
script
,
()
=>
{
this
.
_renderAdView
(
providerConfig
,
data
,
randomId
)
},
(
err
)
=>
{
this
.
$trigger
(
'
error
'
,
{},
err
)
})
}
},
_renderAdView
(
providerConfig
,
data
,
randomId
)
{
var
adView
=
document
.
createElement
(
'
div
'
)
adView
.
setAttribute
(
'
class
'
,
randomId
)
adView
.
setAttribute
(
'
id
'
,
randomId
)
this
.
$refs
.
container
.
innerHTML
=
''
this
.
$refs
.
container
.
append
(
adView
)
let
bindThis
=
window
provider
.
s
.
split
(
'
.
'
).
reduce
((
total
,
currentValue
)
=>
{
bindThis
=
total
return
total
[
currentValue
]
},
window
).
bind
(
bindThis
)(
data
.
a2
,
randomId
,
2
)
if
(
data
.
a1
===
'
10011
'
)
{
}
else
if
(
data
.
a1
===
'
10012
'
)
{
var
adScript
=
document
.
createElement
(
'
script
'
)
const
script
=
providerConfig
.
script
for
(
const
var1
in
script
)
{
adScript
.
setAttribute
(
var1
,
script
[
var1
])
}
adView
.
appendChild
(
adScript
)
}
else
{
let
bindThis
=
window
providerConfig
.
s
.
split
(
'
.
'
).
reduce
((
total
,
currentValue
)
=>
{
bindThis
=
total
return
total
[
currentValue
]
},
window
).
bind
(
bindThis
)(
data
.
a2
,
randomId
,
2
)
}
this
.
_startCheckTimer
()
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录