init
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 814 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "38136412-4b2a-48f3-a87c-c9e819318bf3",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "38136412-4b2a-48f3-a87c-c9e819318bf3@6c48a",
|
||||
"displayName": "hilaryvel_default",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "38136412-4b2a-48f3-a87c-c9e819318bf3",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "38136412-4b2a-48f3-a87c-c9e819318bf3@f9941",
|
||||
"displayName": "hilaryvel_default",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -0.5,
|
||||
"offsetY": -8.5,
|
||||
"trimX": 0,
|
||||
"trimY": 17,
|
||||
"width": 799,
|
||||
"height": 1012,
|
||||
"rawWidth": 800,
|
||||
"rawHeight": 1029,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-399.5,
|
||||
-506,
|
||||
0,
|
||||
399.5,
|
||||
-506,
|
||||
0,
|
||||
-399.5,
|
||||
506,
|
||||
0,
|
||||
399.5,
|
||||
506,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1012,
|
||||
799,
|
||||
1012,
|
||||
0,
|
||||
0,
|
||||
799,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
0.99875,
|
||||
0,
|
||||
0,
|
||||
0.9834791059280855,
|
||||
0.99875,
|
||||
0.9834791059280855
|
||||
],
|
||||
"minPos": [
|
||||
-399.5,
|
||||
-506,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
399.5,
|
||||
506,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "38136412-4b2a-48f3-a87c-c9e819318bf3@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "38136412-4b2a-48f3-a87c-c9e819318bf3@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781",
|
||||
"files": [
|
||||
".jpg",
|
||||
".json"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781@6c48a",
|
||||
"displayName": "minseo_3_cg",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781@f9941",
|
||||
"displayName": "minseo_3_cg",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 996,
|
||||
"height": 1280,
|
||||
"rawWidth": 996,
|
||||
"rawHeight": 1280,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-498,
|
||||
-640,
|
||||
0,
|
||||
498,
|
||||
-640,
|
||||
0,
|
||||
-498,
|
||||
640,
|
||||
0,
|
||||
498,
|
||||
640,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1280,
|
||||
996,
|
||||
1280,
|
||||
0,
|
||||
0,
|
||||
996,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-498,
|
||||
-640,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
498,
|
||||
640,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": false,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "15cbcb8f-23d2-46d9-b1c3-45ef3e012781@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "e0978abe-708b-41bb-965b-ab5ea73f0054",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "e0978abe-708b-41bb-965b-ab5ea73f0054@6c48a",
|
||||
"displayName": "tiannin_stage_icon",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "e0978abe-708b-41bb-965b-ab5ea73f0054",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "e0978abe-708b-41bb-965b-ab5ea73f0054@f9941",
|
||||
"displayName": "tiannin_stage_icon",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 174,
|
||||
"height": 174,
|
||||
"rawWidth": 174,
|
||||
"rawHeight": 174,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-87,
|
||||
-87,
|
||||
0,
|
||||
87,
|
||||
-87,
|
||||
0,
|
||||
-87,
|
||||
87,
|
||||
0,
|
||||
87,
|
||||
87,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
174,
|
||||
174,
|
||||
174,
|
||||
0,
|
||||
0,
|
||||
174,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-87,
|
||||
-87,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
87,
|
||||
87,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "e0978abe-708b-41bb-965b-ab5ea73f0054@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "e0978abe-708b-41bb-965b-ab5ea73f0054@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "4465841b-8a3a-4ee1-b855-2efa50094aa4",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "4465841b-8a3a-4ee1-b855-2efa50094aa4@6c48a",
|
||||
"displayName": "youmiaoxiang_default",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "4465841b-8a3a-4ee1-b855-2efa50094aa4",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "4465841b-8a3a-4ee1-b855-2efa50094aa4@f9941",
|
||||
"displayName": "youmiaoxiang_default",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -4.5,
|
||||
"offsetY": -33.5,
|
||||
"trimX": 176,
|
||||
"trimY": 67,
|
||||
"width": 564,
|
||||
"height": 1122,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-282,
|
||||
-561,
|
||||
0,
|
||||
282,
|
||||
-561,
|
||||
0,
|
||||
-282,
|
||||
561,
|
||||
0,
|
||||
282,
|
||||
561,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
176,
|
||||
1122,
|
||||
740,
|
||||
1122,
|
||||
176,
|
||||
0,
|
||||
740,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.19027027027027027,
|
||||
0,
|
||||
0.8,
|
||||
0,
|
||||
0.19027027027027027,
|
||||
0.943650126156434,
|
||||
0.8,
|
||||
0.943650126156434
|
||||
],
|
||||
"minPos": [
|
||||
-282,
|
||||
-561,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
282,
|
||||
561,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "4465841b-8a3a-4ee1-b855-2efa50094aa4@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "4465841b-8a3a-4ee1-b855-2efa50094aa4@6c48a"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,320 @@
|
||||
import { I_SDK_UserInfo, I_SDK_UserInfo_Callback } from "./SDKManager"
|
||||
|
||||
//广告ID
|
||||
const AD_AWARD = "xxxxx"
|
||||
const AD_SPLASH = "xxxxx"
|
||||
const AD_BANNER = "xxxxx"
|
||||
const AD_BANNER_INTERVAL = 30
|
||||
const AD_BANNER_HEIGHT = 130
|
||||
|
||||
export class ByteDanceSDK{
|
||||
|
||||
private bd_video:any = null;
|
||||
private bd_splash:any = null;
|
||||
private bd_banner:any = null;
|
||||
private bd_video_callback:Function = null;
|
||||
private bd_video_tag:number = null;
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
console.log("init 抖音 初始化...")
|
||||
// 保持屏幕常亮
|
||||
window["tt"].setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
success(res) {
|
||||
|
||||
},
|
||||
fail(res) {
|
||||
},
|
||||
});
|
||||
|
||||
this.init_video();
|
||||
this.init_splash();
|
||||
this.init_banner();
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
//检查权限
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
// cb && cb(true);
|
||||
if (autoKey == "userInfo") {
|
||||
autoKey = "scope.userInfo"
|
||||
}
|
||||
window['tt'].authorize({
|
||||
scope: autoKey,
|
||||
success(res:any) {
|
||||
console.log("抖音 - 检测权限状态 succ:", JSON.stringify(res))
|
||||
if (autoKey == "scope.userInfo" && res.data['scope.userInfo']) {
|
||||
cb && cb(true)
|
||||
} else {
|
||||
cb && cb(false)
|
||||
}
|
||||
},
|
||||
fail(res:any) {
|
||||
console.log("抖音 - 检测权限状态 fail:",JSON.stringify(res))
|
||||
cb && cb(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
getUserInfo(cb:I_SDK_UserInfo_Callback = null) {
|
||||
// cb && cb({ nickName:"", avatarUrl:"" });
|
||||
//getUserProfile报错未找到
|
||||
window["tt"].getUserInfo({
|
||||
force: false, //当宿主未登录时,是否强制拉起登录框
|
||||
success(res) {
|
||||
console.log("抖音 - 获取用户信息成功:", res);
|
||||
cb && cb({avatarUrl:res.userInfo.avatarUrl, nickName:res.userInfo.nickName}) //encryptedData
|
||||
},
|
||||
fail(res) {
|
||||
console.log("抖音 - 获取用户信息失败", res);
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//登录
|
||||
login(cb: Function = null) {
|
||||
// cb && cb({ platform:3, code: null });
|
||||
window["tt"].login({
|
||||
force: false, //未登录时, 是否强制调起登录框
|
||||
success(res) {
|
||||
console.log(`抖音 - 登录成功 code=${res.code}, anonymousCode=${res.anonymousCode}`);
|
||||
cb && cb({ platform:3, code: res.code });
|
||||
},
|
||||
fail(res) {
|
||||
console.log(`抖音 - 登录失败`, res);
|
||||
cb && cb({ platform:3, code: null });
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
private init_banner() {
|
||||
|
||||
if (!window["tt"] || !window["tt"].createBannerAd) return
|
||||
|
||||
const systemInfo = window["tt"].getSystemInfoSync();
|
||||
//if (systemInfo.appName.toUpperCase() == 'DOUYIN') return
|
||||
//if (systemInfo.appName.toUpperCase() == 'TOUTIAO' && systemInfo.platform == "ios") return
|
||||
|
||||
if (systemInfo.appName.toUpperCase() == 'DOUYIN' || systemInfo.platform == "ios") return
|
||||
|
||||
const { windowWidth, windowHeight } = window["tt"].getSystemInfoSync();
|
||||
var targetBannerAdWidth = 128+ 100
|
||||
var targetBannerAdHeight = AD_BANNER_HEIGHT
|
||||
// 创建一个居于屏幕底部正中的广告
|
||||
this.bd_banner = window["tt"].createBannerAd({
|
||||
adUnitId: AD_BANNER,
|
||||
adIntervals: AD_BANNER_INTERVAL,
|
||||
style: {
|
||||
width: targetBannerAdWidth,
|
||||
left:(windowWidth - targetBannerAdWidth) / 2,
|
||||
top: windowHeight - targetBannerAdHeight
|
||||
},
|
||||
});
|
||||
|
||||
// 尺寸调整时会触发回调
|
||||
// 注意:如果在回调里再次调整尺寸,要确保不要触发死循环!!!
|
||||
this.bd_banner.onResize(size => {
|
||||
this.bd_banner.style.left = (windowWidth - size.width) / 2;
|
||||
this.bd_banner.style.top = windowHeight - size.height;
|
||||
});
|
||||
|
||||
// bd_banner.onLoad(() => {
|
||||
// bd_banner
|
||||
// .show()
|
||||
// .then(() => {
|
||||
// console.log("init_banner 广告显示成功");
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log("init_banner 广告组件出现问题", err);
|
||||
// });
|
||||
// })
|
||||
}
|
||||
|
||||
private init_splash() {
|
||||
|
||||
this.preload_splash()
|
||||
}
|
||||
|
||||
private preload_splash() {
|
||||
if (!window["tt"] || !window["tt"].createInterstitialAd) return
|
||||
|
||||
if (this.bd_splash) {
|
||||
if (this.bd_splash['custom_show_stautus']) {
|
||||
this.bd_splash.destroy()
|
||||
this.bd_splash = null
|
||||
} else {
|
||||
if (!this.bd_splash['custom_load_stautus']) {
|
||||
this.bd_splash
|
||||
.load()
|
||||
.catch(err => {
|
||||
console.log("preload_splash err:",err);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bd_splash) return
|
||||
|
||||
// 创建插屏广告实例,会自动进行一次load
|
||||
this.bd_splash = window["tt"].createInterstitialAd({
|
||||
adUnitId: AD_SPLASH
|
||||
})
|
||||
this.bd_splash.onLoad(function(){
|
||||
this.bd_splash['custom_load_stautus'] = true
|
||||
})
|
||||
this.bd_splash.onClose(function(){
|
||||
this.bd_splash.destroy()
|
||||
this.bd_splash = null
|
||||
|
||||
this.preload_splash()
|
||||
})
|
||||
this.bd_splash.onError(function(err){
|
||||
console.log("bd_splash err:",err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private init_video() {
|
||||
|
||||
if (!window["tt"] || !window["tt"].createRewardedVideoAd) return
|
||||
|
||||
// 预加载视频广告
|
||||
// let global_this = this
|
||||
// function func_preload_wx_video() {
|
||||
// global_this.bd_video
|
||||
// .load()
|
||||
// .catch(err => {
|
||||
// });
|
||||
// }
|
||||
|
||||
this.bd_video = window["tt"].createRewardedVideoAd({
|
||||
adUnitId: AD_AWARD,
|
||||
});
|
||||
|
||||
this.bd_video.onClose(res => {
|
||||
if (res.isEnded) {
|
||||
if (this.bd_video_callback) {
|
||||
this.bd_video_callback(this.bd_video_tag);
|
||||
}
|
||||
}
|
||||
|
||||
//func_preload_wx_video()
|
||||
});
|
||||
|
||||
this.bd_video.onError((err) => {
|
||||
//func_preload_wx_video()
|
||||
});
|
||||
|
||||
//func_preload_wx_video()
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
if (!this.bd_video) return
|
||||
|
||||
this.bd_video_callback = callback;
|
||||
this.bd_video_tag = tag
|
||||
|
||||
this.bd_video
|
||||
.load()
|
||||
.then(() => {
|
||||
this.bd_video.show()
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
//已加载 未展示
|
||||
if (this.bd_splash && this.bd_splash['custom_load_stautus'] && !this.bd_splash['custom_show_stautus']) {
|
||||
this.bd_splash.show().then(() => {
|
||||
this.bd_splash['custom_show_stautus'] = true
|
||||
console.log("插屏广告展示成功");
|
||||
})
|
||||
} else {
|
||||
console.log("插屏广告展示失败");
|
||||
this.preload_splash()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.show(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.hide(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//移除
|
||||
clear_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.destroy(); //banner 默认隐藏(hide) 要打开
|
||||
this.bd_banner = null;
|
||||
}
|
||||
}
|
||||
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
rewardCB && rewardCB()
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
return {width:screen.width, height: screen.height};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return false;
|
||||
}
|
||||
//播放base64音频
|
||||
playBase64Audio(base64, loop) {
|
||||
if (!this.checkSupportBase64Audio()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let substring = base64;
|
||||
let qianzhui = "data:audio/x-wav;base64,"
|
||||
if(base64.startsWith(qianzhui)) {
|
||||
substring = base64.substring(qianzhui.length, base64.length)
|
||||
}
|
||||
|
||||
const backgroundAudioManager = window['tt'].getBackgroundAudioManager()
|
||||
const audioPath = window['wx'].env.USER_DATA_PATH + '/ordernew.mp3'
|
||||
const fs = window['tt'].getFileSystemManager();
|
||||
fs.writeFile({
|
||||
filePath: audioPath,
|
||||
data: substring,
|
||||
encoding: 'base64',
|
||||
success(res) {
|
||||
backgroundAudioManager.title = '回复'
|
||||
backgroundAudioManager.src = audioPath
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 478 KiB |
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"__version__": "1.0.1",
|
||||
"builder": {
|
||||
"options": {
|
||||
"web-desktop": {
|
||||
"enableAdsense": false,
|
||||
"enableTestAd": false,
|
||||
"__version__": "1.0.1",
|
||||
"AFPHostPropertyCode": "ca-host-pub-5396158963872751",
|
||||
"AFPHostDomain": "douyougame.com",
|
||||
"otherAFPHostPropertyCode": "",
|
||||
"otherAFPDomain": ""
|
||||
},
|
||||
"web-mobile": {
|
||||
"enableAdsense": false,
|
||||
"enableTestAd": false,
|
||||
"__version__": "1.0.1",
|
||||
"AFPHostPropertyCode": "ca-host-pub-5396158963872751",
|
||||
"AFPHostDomain": "douyougame.com",
|
||||
"otherAFPHostPropertyCode": "",
|
||||
"otherAFPDomain": ""
|
||||
}
|
||||
},
|
||||
"taskOptionsMap": {},
|
||||
"__version__": "1.3.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
import { _decorator, AudioClip, Button, Component, ImageAsset, JsonAsset, Label, Node, Prefab, ProgressBar, Sprite, SpriteFrame } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import Resource from '../../Main/Config/Resource';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import GlobalValue from '../../Main/Common/GlobalValue';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PreloadUI')
|
||||
export class PreloadUI extends Component {
|
||||
|
||||
private checkFinish = true; //检查完成
|
||||
private preloadFinish = false; //资源加载完成
|
||||
private loginFinish = false; //登录完成
|
||||
|
||||
private jinduBar: Node = null;
|
||||
private jinduFilled: Sprite = null;
|
||||
private LabProgress: Label = null;
|
||||
private btnLogin: Sprite = null; //登录按钮
|
||||
|
||||
start() {
|
||||
this.jinduBar = this.node.getChildByName("jinduBar");
|
||||
this.jinduFilled = this.jinduBar.getChildByName("jinduFilled").getComponent(Sprite);
|
||||
this.LabProgress = this.node.getChildByName("LabProgress").getComponent(Label);
|
||||
this.btnLogin = this.node.getChildByName("btnLogin").getComponent(Sprite);
|
||||
|
||||
//适配背景图
|
||||
let BG = this.node.getChildByName("BG");
|
||||
Utils.adjustBgPixelRatio(BG, 1)
|
||||
|
||||
this.jinduFilled.fillRange = 0;
|
||||
this.btnLogin.node.active = false;
|
||||
|
||||
this.preloadFiles()
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
if (this.checkFinish) {
|
||||
if (this.preloadFinish && this.loginFinish) {
|
||||
this.checkFinish = false
|
||||
this.enterGame()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//预加载文件
|
||||
preloadFiles() {
|
||||
let preloadTab = [
|
||||
{path:"Music/music_interface", bundleName: "Audio", ftype: AudioClip},
|
||||
{path:"bg/mengli_stage_bg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg0/mengli_0_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg1/mengli_1_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg2/mengli_2_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg3/mengli_3_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"role/mengli_default", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"Zjm/raw1", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"touming", bundleName: "common", ftype: ImageAsset},
|
||||
// {path:"chanpin_1_0", bundleName: "daoju", ftype: ImageAsset}, //有合图加载失败
|
||||
{path:"zjm_1", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
{path:"UI/GM_UI", bundleName: "PB", ftype: Prefab},
|
||||
{path:"commonGlobal", bundleName: "DataTable", ftype: JsonAsset},
|
||||
];
|
||||
let num_prefab = 0; //已加载数量
|
||||
let num_succeed = 0;//加载成功数量
|
||||
let preloadFunc = () => {
|
||||
if (num_prefab < preloadTab.length) {
|
||||
let cfg = preloadTab[num_prefab]
|
||||
ResManager.I.preLoadSubpackageFile(cfg.path, cfg.bundleName, cfg.ftype, (ret) => {
|
||||
num_prefab++;
|
||||
num_succeed++;
|
||||
let percent = 0.45 * (num_prefab / preloadTab.length)
|
||||
this.showLoadProgress(0.55 + percent);
|
||||
console.log("加载成功:", cfg.path);
|
||||
preloadFunc();
|
||||
}, (err)=>{
|
||||
num_prefab++;
|
||||
console.log("加载失败:", err);
|
||||
});
|
||||
} else {
|
||||
if (num_succeed >= num_prefab) {
|
||||
this.loadDataTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
preloadFunc();
|
||||
}
|
||||
|
||||
//加载配置表
|
||||
loadDataTable(){
|
||||
let dataArr = [
|
||||
"commonGlobal",
|
||||
// "levelHole",
|
||||
"Music",
|
||||
"Sound",
|
||||
]
|
||||
|
||||
//配置表使用方法: let cfgs = Resource.getConfig("Sound")
|
||||
let num_prefab = 0;
|
||||
let preloadFunc = () => {
|
||||
if (num_prefab < dataArr.length) {
|
||||
let cfgname = dataArr[num_prefab]
|
||||
ResManager.I.loadSubpackageDataTable(cfgname, (ret: JsonAsset) => {
|
||||
num_prefab++;
|
||||
Resource.addSubJsonConfig(cfgname, ret.json)
|
||||
preloadFunc();
|
||||
});
|
||||
} else {
|
||||
this.preloadFinish = true;
|
||||
this.onLogin();
|
||||
}
|
||||
}
|
||||
preloadFunc();
|
||||
}
|
||||
|
||||
//显示加载进度
|
||||
showLoadProgress(percent) {
|
||||
this.jinduFilled.fillRange = percent;
|
||||
}
|
||||
|
||||
//登录
|
||||
onLogin() {
|
||||
//初始化SDK信息
|
||||
SDKManager.init(() => {
|
||||
//检测是否有授权,有授权直接登录,没有授权就先进主界面,到主界面获取权限
|
||||
SDKManager.checkAutoSetting("userInfo", (ishave) => {
|
||||
if (ishave) {
|
||||
console.log("有授权,直接登录")
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
this.loginFinish = true
|
||||
})
|
||||
} else {
|
||||
console.log("没有授权,等待授权后登录")
|
||||
// this.loginFinish = true
|
||||
this.jinduBar.active = false
|
||||
this.LabProgress.node.active = false
|
||||
//登录按钮
|
||||
this.btnLogin.node.active = true
|
||||
let loginPath = ""
|
||||
if (SDKManager.isWenxin()) {
|
||||
loginPath = "login1"
|
||||
} else if (SDKManager.isByteDance()) {
|
||||
loginPath = "login2"
|
||||
} else if (SDKManager.isKuaishou()) {
|
||||
loginPath = "login3"
|
||||
}
|
||||
ResManager.I.changeResourceSpriteFrame(this.btnLogin, loginPath)
|
||||
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
this.loginFinish = true
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
enterGame() {
|
||||
let islogin = HttpUnit.IsLogin();
|
||||
console.log("进入游戏,登录状态:", islogin);
|
||||
this.jinduBar.active = false
|
||||
this.LabProgress.node.active = false
|
||||
this.btnLogin.node.active = false
|
||||
if (islogin) {
|
||||
} else {
|
||||
//没登录成功,先进主界面,在主界面里进行登录
|
||||
}
|
||||
ResManager.I.goMainScene(); //进入下一个场景
|
||||
// ResManager.I.goCustomScene("Test2DScene"); //进入自定义场景
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 207 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 853 KiB |
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"__version__": "1.0.1",
|
||||
"builder": {
|
||||
"common": {
|
||||
"polyfills": {
|
||||
"asyncFunctions": true
|
||||
},
|
||||
"buildPath": "project://build",
|
||||
"outputName": "web-mobile-console",
|
||||
"mainBundleCompressionType": "merge_dep",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "16b0d021-6436-4bbc-ba5e-05ebe3e84ba4"
|
||||
},
|
||||
"options": {
|
||||
"web-mobile": {
|
||||
"useWebGPU": false,
|
||||
"orientation": "portrait",
|
||||
"embedWebDebugger": true,
|
||||
"__version__": "1.0.1"
|
||||
}
|
||||
},
|
||||
"taskOptionsMap": {
|
||||
"1736573831185": {
|
||||
"useWebGPU": false,
|
||||
"orientation": "portrait",
|
||||
"embedWebDebugger": false,
|
||||
"__version__": "1.0.1"
|
||||
},
|
||||
"1736821502634": {
|
||||
"useWebGPU": false,
|
||||
"orientation": "portrait",
|
||||
"embedWebDebugger": true,
|
||||
"__version__": "1.0.1"
|
||||
}
|
||||
},
|
||||
"__version__": "1.3.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "ea67a30c-3f52-48ed-903e-dd89357e40bf",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "ea67a30c-3f52-48ed-903e-dd89357e40bf@6c48a",
|
||||
"displayName": "yeshchina_shy",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "ea67a30c-3f52-48ed-903e-dd89357e40bf",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "ea67a30c-3f52-48ed-903e-dd89357e40bf@f9941",
|
||||
"displayName": "yeshchina_shy",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -23,
|
||||
"offsetY": -3.5,
|
||||
"trimX": 96,
|
||||
"trimY": 7,
|
||||
"width": 687,
|
||||
"height": 1182,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-343.5,
|
||||
-591,
|
||||
0,
|
||||
343.5,
|
||||
-591,
|
||||
0,
|
||||
-343.5,
|
||||
591,
|
||||
0,
|
||||
343.5,
|
||||
591,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
96,
|
||||
1182,
|
||||
783,
|
||||
1182,
|
||||
96,
|
||||
0,
|
||||
783,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.10378378378378378,
|
||||
0,
|
||||
0.8464864864864865,
|
||||
0,
|
||||
0.10378378378378378,
|
||||
0.9941126997476871,
|
||||
0.8464864864864865,
|
||||
0.9941126997476871
|
||||
],
|
||||
"minPos": [
|
||||
-343.5,
|
||||
-591,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
343.5,
|
||||
591,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "ea67a30c-3f52-48ed-903e-dd89357e40bf@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "ea67a30c-3f52-48ed-903e-dd89357e40bf@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "0847624e-b436-4511-bd12-ce89a72e3759",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "0847624e-b436-4511-bd12-ce89a72e3759@6c48a",
|
||||
"displayName": "allie_laugh",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "0847624e-b436-4511-bd12-ce89a72e3759",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "0847624e-b436-4511-bd12-ce89a72e3759@f9941",
|
||||
"displayName": "allie_laugh",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0.5,
|
||||
"offsetY": -1,
|
||||
"trimX": 4,
|
||||
"trimY": 2,
|
||||
"width": 918,
|
||||
"height": 1187,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-459,
|
||||
-593.5,
|
||||
0,
|
||||
459,
|
||||
-593.5,
|
||||
0,
|
||||
-459,
|
||||
593.5,
|
||||
0,
|
||||
459,
|
||||
593.5,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
4,
|
||||
1187,
|
||||
922,
|
||||
1187,
|
||||
4,
|
||||
0,
|
||||
922,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.004324324324324324,
|
||||
0,
|
||||
0.9967567567567568,
|
||||
0,
|
||||
0.004324324324324324,
|
||||
0.9983179142136249,
|
||||
0.9967567567567568,
|
||||
0.9983179142136249
|
||||
],
|
||||
"minPos": [
|
||||
-459,
|
||||
-593.5,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
459,
|
||||
593.5,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "0847624e-b436-4511-bd12-ce89a72e3759@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "0847624e-b436-4511-bd12-ce89a72e3759@6c48a"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user