Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dxw_sdk_release
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
JIRA
JIRA
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
open
dxw_sdk_release
Commits
4aededc9
提交
4aededc9
authored
11月 22, 2023
作者:
wj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
批量创建视频
上级
536829e7
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
21 行删除
+28
-21
SDK.ts
SDK.ts
+28
-21
没有找到文件。
SDK.ts
浏览文件 @
4aededc9
/**
/**
* 鲸鱼游戏微信小游戏接入库
* 鲸鱼游戏微信小游戏接入库
* @author 推广技术部
* @author 推广技术部
* @time: 2023-11-
14
* @time: 2023-11-
22
*
*
*
调试分享异常问题
*
批量初始化视频广告
*
*
*/
*/
class
WechatSDK
{
class
WechatSDK
{
private
sdkVersion
:
string
=
"3.3.
3
"
;
private
sdkVersion
:
string
=
"3.3.
4
"
;
public
LaunchOptions
:
Object
;
// 启动参数对象
public
LaunchOptions
:
Object
;
// 启动参数对象
public
SystemInfo
:
Object
;
// 设备信息
public
SystemInfo
:
Object
;
// 设备信息
...
@@ -798,39 +798,44 @@ class WechatSDK {
...
@@ -798,39 +798,44 @@ class WechatSDK {
"1000"
:
"参数错误"
,
"1000"
:
"参数错误"
,
"1003"
:
"米大师Portal错误"
,
"1003"
:
"米大师Portal错误"
,
};
};
//
创建视频
广告
//
激励
广告
private
videoAd
:
any
=
null
;
// 微信视频广告对象
private
ADREWARDARR
:
Array
<
any
>
=
[];
// 微信视频广告对象数组
// 初始化激励视频
// 初始化激励视频
public
createWxVideoAd
=
async
(
adCallBack
:
AdCallBack
)
=>
{
public
createWxVideoAd
=
async
(
unitID
:
Array
<
UNITITEM
>
=
[])
=>
{
this
.
videoAd
=
await
(
wx
as
any
).
createRewardedVideoAd
({
for
(
let
i
=
0
;
i
<
unitID
.
length
;
i
++
)
{
adUnitId
:
SDKConfig
.
WXADUNITID
,
// mp后台配置的广告id
let
reward
=
await
(
wx
as
any
).
createRewardedVideoAd
({
adUnitId
:
unitID
[
i
].
id
,
// mp后台配置的广告id
});
});
this
.
videoA
d
.
onError
(
err
=>
{
rewar
d
.
onError
(
err
=>
{
console
.
log
(
'微信激励广告视频播放失败:'
,
err
);
console
.
log
(
'微信激励广告视频播放失败:'
,
err
);
adCallBack
.
onError
&&
adCallBack
.
onError
(
err
);
unitID
[
i
].
onError
&&
unitID
[
i
]
.
onError
(
err
);
});
});
// 监听广告关闭按钮
// 监听广告关闭按钮
this
.
videoA
d
.
onClose
(
res
=>
{
rewar
d
.
onClose
(
res
=>
{
// 用户点击【关闭广告】按钮
// 用户点击【关闭广告】按钮
adCallBack
.
onClose
&&
adCallBack
.
onClose
({
status
:
res
&&
res
.
isEnded
,
type
:
'video'
});
unitID
[
i
].
onClose
&&
unitID
[
i
].
onClose
({
status
:
res
&&
res
.
isEnded
,
type
:
'video'
,
sort
:
i
});
this
.
videoA
d
.
offClose
();
rewar
d
.
offClose
();
});
});
this
.
ADREWARDARR
[
i
]
=
reward
;
}
};
};
// 激励视频播放
// 激励视频播放
public
playAdVideo
=
async
(
Params
:
ProductInfo
,
callback
:
Function
,
retry
:
number
=
0
)
=>
{
public
playAdVideo
=
async
(
index
:
number
,
Params
:
ProductInfo
,
callback
:
Function
,
retry
:
number
=
0
)
=>
{
if
(
retry
>
2
)
{
if
(
retry
>
2
)
{
callback
({
status
:
false
});
callback
({
status
:
false
});
return
;
return
;
}
}
this
.
videoAd
.
load
()
let
reward
=
this
.
ADREWARDARR
[
index
];
reward
&&
reward
.
load
()
.
then
(()
=>
{
.
then
(()
=>
{
this
.
videoA
d
.
show
()
rewar
d
.
show
()
.
then
(()
=>
{
.
then
(()
=>
{
console
.
log
(
'微信激励广告视频播放成功.'
);
console
.
log
(
'微信激励广告视频播放成功.'
);
this
.
CustomReport
({
customeventName
:
"adVideoReport"
,
customeventData
:
{
...
Params
}
});
// 上报播放完成
//
this.CustomReport({ customeventName: "adVideoReport", customeventData: { ...Params } }); // 上报播放完成
callback
({
status
:
true
});
callback
({
status
:
true
});
})
})
.
catch
(
err
=>
this
.
playAdVideo
(
Params
,
callback
,
retry
++
));
.
catch
(
err
=>
this
.
playAdVideo
(
index
,
Params
,
callback
,
retry
++
));
});
});
}
}
...
@@ -859,10 +864,12 @@ declare interface ProductInfo {
...
@@ -859,10 +864,12 @@ declare interface ProductInfo {
role_name
:
string
role_name
:
string
}
}
declare
interface
AdCallBack
{
declare
interface
UNITITEM
{
onError
?:
Function
id
:
string
onClose
?:
Function
onError
:
Function
onClose
:
Function
}
}
// SDK后端接口(勿改)
// SDK后端接口(勿改)
const
Links
=
{
const
Links
=
{
init
:
SDKConfig
.
sdk_domain
+
"/weixin/access_token.php"
,
// 获取openid
init
:
SDKConfig
.
sdk_domain
+
"/weixin/access_token.php"
,
// 获取openid
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论