This commit is contained in:
2025-07-17 17:18:21 +08:00
commit 1ffc1b5cf0
5309 changed files with 1150310 additions and 0 deletions
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

@@ -0,0 +1,262 @@
/**
* 公共配置文件
*/
export const G_GlobalNode: string = '__GLobal_Node';
export namespace CommonConfig {
//本地保存
export enum StorageConfigUtil {
BaseData = 'li_' + 1000, // 登录相关
Channel = 2000, //渠道相关
}
export enum StorageConfig {
SETTING_SHAKEON = StorageConfigUtil.BaseData + 1,
SETTING_MUSIC = StorageConfigUtil.BaseData + 2,
SETTING_SOUND = StorageConfigUtil.BaseData + 3,
GAME_CITY = StorageConfigUtil.BaseData + 4, //所在省
GAME_RANK_CITY = StorageConfigUtil.BaseData + 5, //省排行数据 AI
GAME_RANK_USER = StorageConfigUtil.BaseData + 6, //玩家排行数据 AI
GAME_RANK_CDTIME = StorageConfigUtil.BaseData + 7, //上次排行数据刷新时间戳 AI
GAME_SCORE = StorageConfigUtil.BaseData + 8, //玩家积分
GAME_SKIN_ID = StorageConfigUtil.BaseData + 9, //当前选择的皮肤id
GAME_PASSLV = StorageConfigUtil.BaseData + 10, //已完成关卡
DAILYCHALLENGE_PASSLV = StorageConfigUtil.BaseData + 11, //已完成每日挑战关卡
TOOL_KAIKONG = StorageConfigUtil.BaseData + 12, //开孔工具使用过
TOOL_RENYIZHI = StorageConfigUtil.BaseData + 13, //任意指工具使用过
TOOL_RENYIGUAN = StorageConfigUtil.BaseData + 14, //任意罐工具使用过
DD_REGISTTIME = StorageConfigUtil.BaseData + 15, //注册时间字符串
DD_LEVELOPER = StorageConfigUtil.BaseData + 16, //进入关卡且首次进度>0时(或第一次操作)
GUIDE_MAIN = StorageConfigUtil.BaseData + 17, //主界面引导是否完成
GUIDE_TALK = StorageConfigUtil.BaseData + 18, //聊天界面引导是否完成
DOUYIN_SIDEBAR = StorageConfigUtil.Channel + 1, //抖音渠道侧边栏奖励是否领取
}
//UI层级
export enum UILayerGroup {
Layer_ground = 0,
Layer_ui1 = 1,
Layer_ui2 = 2,
Layer_dialog = 3,
Layer_tips = 4,
Layer_top = 5,
}
}
/**关卡配置信息 */
export interface I_LevelConfig {
/**是关卡场景图资源的名称,注意关卡选择界面选中关卡后展示的场景图资源也是这个 */
bgImage: string;
/**后续进入关卡后,关卡中需要播放的音乐资源名称 */
bgm: string;
/**在关卡中,聊天历史信息展示里,角色使用的头像,圆形 80*80 */
characterAvatar: string;
/**关卡中,提示信息界面里需要展示的角色性格文本 */
characterDisposition: string;
/**角色聊天切换的表情立绘,这个暂时先不处理,后面我们需要和你沟通下,资源改成英文名看你怎么匹配(Ai 返回的判断还是中文的) */
characterEmojiSet: string;
/**关卡中,提示信息界面,喜好话题部分需要展示的文本信息 */
characterFavoriteTopic: string;
/**角色待机资源名称 */
characterStandbyPortrait: string;
/**角色默认立绘资源名称 */
characterFullLengthPortrait: string;
/**关卡提示信息界面里使用的角色半身胸像 */
characterHalfLengthPortrait: string;
/**关卡提示信息界面里,厌恶话题的展示文本信息 */
characterHateTopic: string;
/**角色名称,注意在关卡选择界面还有关卡中的聊天窗,关卡提示信息界面这几个地方都涉及展示 */
characterName: string;
/**角色职业设定信息,关卡提示信息界面里的职业部分展示 */
characterRole: string;
/**关卡选择界面里展示的关卡介绍文本信息 */
description: string;
/**关卡中对话得到高分后,额外向玩家展示的鼓励信息 */
encourageMessage: string;
/**结算图片 关卡 0 星,挑战失败的情况下在结算界面展示的 CG 资源名称 */
failureCG: string;
/**结算图片 关卡 1 星,挑战成功的情况下在结算界面展示的 CG 资源名称 */
oneStarCG: string;
/**结算图片 关卡 2 星,挑战成功的情况下在结算界面展示的 CG 资源名称 */
twoStarCG: string;
/**结算图片 关卡 3 星,那么需要展示的 CG 资源对应的名称 */
threeStarCG: string;
/**关卡中,对话得分特别低的情况下,额外给出的向玩家展示的鼓励信息 */
hateMessage: string;
/**关卡选择界面,菱形的头像资源名称 */
icon: string;
/**唯一的关卡 id 信息 */
id: string;
/**关卡是否已解锁,注意锁定状态仍然能够选择关卡,关卡选择界面中的背景和立绘需要切换做展示,但是玩家不能开启游戏哈 */
is_unlock: boolean;
/**npc名称 */
name: string;
/**关卡展示顺序 */
no: number;
/**关卡解锁需要通关的前置关卡 id 信息,对应id字段 */
preLevelId: string;
/**进入关卡后,角色发出给到玩家的开场白信息(历史聊天记录页面中也需要显示,一定是角色发出的第一句话) */
prologueMessage: string;
/**玩家在关卡中,点击随机填充按钮,需要随机选取一句,在输入框中填入,注意填入后不发送,玩家可修改,最终发送的信息还是以玩家点击发送按钮时,填入的信息为主 */
randomInputPool: string[];
/**关卡进行中的record_id,有值时要先获取一下之前的存档 */
record_id: string;
/**关卡历史最高分 */
score: number;
/**关卡历史最高星级 */
star: number;
/**关卡中,关卡提示信息界面里底部展示的提示信息文本,目前测试数据和关卡介绍信息一致,但后续会区分开来 */
tips: string;
/**Npc结算对话 3星时 */
threeStarSummary: string;
/**Npc结算对话 2星时 */
twoStarSummary: string;
/**Npc结算对话 1星时 */
oneStarSummary: string;
/**Npc结算对话 0星时 */
failureSummary: string;
/**Npc表情立绘 害羞 */
characterShyPortrait: string;
/**Npc表情立绘 厌恶 */
characterHatePortrait: string;
/**Npc表情立绘 开心 */
characterHappyPortrait: string;
/**关卡解锁类型 -1=未解锁 0=自动解锁 1=游戏通关解锁 2=手动解锁 */
unlock_type: number;
/**私家珍藏图片列表 */
photoAwards: I_ZhengCangConfig[];
/**关卡是否打过 */
is_played: boolean;
}
/**私家珍藏配置数据 */
export interface I_ZhengCangConfig {
/**图片名 */
giftImgName: string;
/**故事文本列表 */
giftStory: string[];
/**简述 */
giftSummary: string;
/**唯一id */
id: number;
/**对应关卡id */
levelId: string;
}
/**关卡对话数据 */
export interface I_LevelStepData {
/**当前聊天次数 */
current_cnt: number;
/**结束评分 */
end_star: number;
/**关卡id */
id: string;
/**最大聊天次数 */
max_cnt: number;
/**当前状态 0:成功 1:进行中 2:失败 3:剩余聊天次数不足 */
status: number;
/**可用总聊天次数 */
total_cnt: number;
/**心动次数 */
heartbeat_cnt: number;
/**剩余可看广告次数 */
ad_num: number;
/**剩余可分享次数 */
share_num: number;
/**剩余可撤回次数 */
can_use_cancel_cnt: number;
/**剩余可暴击次数 */
can_use_strength_cnt: number;
/**暴击是否生效 */
is_strength_take_effect: boolean;
/**甜蜜暴击已用次数 */
first_strength?: number;
/**撤回已用次数 */
first_cancel?: number;
}
/**npc长连接中的回复 */
export interface I_NpcTalkBack {
/**ai表情 */
aiEmoji:string;
/**ai回复 */
aiResponse:string;
/**ai评分 */
aiScore:number;
/**ai基础评分 */
aiBaseScore:number;
/**ai额外加分 */
aiAdditionalScore:number;
/**是否完成 */
isFinished:boolean;
/**聊天次数 */
sourceCnt:number;
/**玩家发的文本 */
userInput: string;
/**评价 -1=未生成 0=心动 1=普通 2=厌恶 */
judgement: number;
}
/**对话历史记录数据 */
export interface I_TalkRecordInfo {
/**对话内容 */
talk: string;
/**是否是玩家自己 */
isMe: boolean;
/**评分 小于0时不显示 */
score: number;
/**基础分 */
scoreBase: number;
/**额外加分 */
scoreAdditional: number;
}
/**玩家信息数据 */
export interface I_UserInfo {
id: number;
score: number;
status: number;
/**头像url */
avatar: string;
/**昵称 */
nickname: string;
/**剩余进入关卡次数 */
ticket: number;
/**剩余可看广告次数 - 进入关卡 */
game_ad_num: number;
/**剩余可分享次数 - 进入关卡 */
game_share_num: number;
/**剩余可看广告次数 - 聊天 */
level_ad_num: number;
/**剩余可分享次数 - 聊天 */
level_share_num: number;
/**抖音侧边栏奖励是否已领取 0未领取 1已领取 */
is_receive: number;
/**友盟关卡记录 */
levels: any[];
/**私家珍藏红点标记 0不显示 1显示 */
private_collection_mark: number;
/**心动回忆红点标记 0不显示 1显示 */
heartbeat_memories_mark: number;
/**剩余可免费获取珍藏的次数 */
free_private_collection: number;
// [property: string]: any;
}
/**心动回忆数据 */
export interface I_HuiyiInfo {
/**关卡id */
lvId: string;
/**星数 */
star: number;
/**是否解锁 */
unlock: boolean;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 782 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "9e3b15f2-114b-496a-8d49-d744d30b7fcd",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "9e3b15f2-114b-496a-8d49-d744d30b7fcd@6c48a",
"displayName": "jialin_stage_bg",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "9e3b15f2-114b-496a-8d49-d744d30b7fcd",
"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": "9e3b15f2-114b-496a-8d49-d744d30b7fcd@f9941",
"displayName": "jialin_stage_bg",
"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": "9e3b15f2-114b-496a-8d49-d744d30b7fcd@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "9e3b15f2-114b-496a-8d49-d744d30b7fcd@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "53787629-841e-4201-aac6-a32ec3c34d57",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "53787629-841e-4201-aac6-a32ec3c34d57@6c48a",
"displayName": "xinfu_default",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "53787629-841e-4201-aac6-a32ec3c34d57",
"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": "53787629-841e-4201-aac6-a32ec3c34d57@f9941",
"displayName": "xinfu_default",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -15,
"offsetY": -8,
"trimX": 26,
"trimY": 16,
"width": 843,
"height": 1173,
"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": [
-421.5,
-586.5,
0,
421.5,
-586.5,
0,
-421.5,
586.5,
0,
421.5,
586.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
26,
1173,
869,
1173,
26,
0,
869,
0
],
"nuv": [
0.02810810810810811,
0,
0.9394594594594594,
0,
0.02810810810810811,
0.9865433137089992,
0.9394594594594594,
0.9865433137089992
],
"minPos": [
-421.5,
-586.5,
0
],
"maxPos": [
421.5,
586.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "53787629-841e-4201-aac6-a32ec3c34d57@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "53787629-841e-4201-aac6-a32ec3c34d57@6c48a"
}
}
@@ -0,0 +1,805 @@
import { _decorator, instantiate, isValid, Label, Node, PageView, Prefab, Sprite, tween, Tween, UITransform, view } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import AudioManager from '../../Main/Manager/AudioManager';
import Utils from '../../Main/Common/Utils';
import { ViewManager } from '../../Main/Manager/ViewManager';
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
import li_BaseView from '../../Main/Common/li_BaseView';
import GameRootUI from '../../Main/Common/GameRootUI';
import ResManager from '../../Main/Manager/ResManager';
import HttpUnit from '../../Main/Common/HttpUnit';
import { SDKManager } from '../../Main/Channel/SDKManager';
import ScrollViewList from '../../Main/Common/ScrollViewList';
import GameManager, { E_TalkStage, E_TalkStatusType } from '../../Main/Manager/GameManager';
import { I_LevelConfig, I_NpcTalkBack } from '../../Main/Config/CommonConfig';
import SubManager from '../SubManager';
import { ByteDanceSDK } from '../../Main/Channel/bdSDK';
import GlobalValue, { VideoRoleType } from '../../Main/Common/GlobalValue';
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
import { E_AD_TARGET } from './TalkAdDialog';
const { ccclass, property } = _decorator;
//主界面
@ccclass('Start_UI')
export class Start_UI extends li_BaseView {
@property(ScrollViewList)
private Level_List: ScrollViewList = null
@property(Prefab)
private Level_Item: Prefab = null
private itemClone: any = null
@property(Prefab)
private GuidePageItem: Prefab = null //引导选择角色页签
private guidePageView: PageView = null //引导选择角色页签容器
private _nodeTab: any = {};
private _data;
private levelData: I_LevelConfig[] = []; //关卡数据
private curLevelIdx: number = 0; //当前关卡Idx
private lvUnlockId: string = ""; //解锁关卡id
//----重写父类接口---------------------------------------
onLoadCT() {
this.registerListenner();
Utils.parseNode(this.node, this._nodeTab)
this.itemClone = instantiate(this.Level_Item)
this.Level_List.setTemplateItem(this.itemClone)
this.guidePageView = this._nodeTab.guidePageView.getComponent(PageView)
Utils.setString(this._nodeTab.labNpcName, "")
Utils.setString(this._nodeTab.labNpcTalk, "")
}
openUIDataCT(data: any): void {
this._data = data
}
registerListenner() {
Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
Utils.addInnerEL(InnerMsgCode.UI_Talk_Back, this, this.resiveTalkBack)
Utils.addInnerEL(InnerMsgCode.UI_BD_Sidebar, this, this.resiveBDSidebar)
Utils.addInnerEL(InnerMsgCode.UI_Tj_huiyi_Lv, this, this.resiveHuiyiLv)
Utils.addInnerEL(InnerMsgCode.Data_BDSidebarReward, this, this.resiveBDSidebarReward)
Utils.addInnerEL(InnerMsgCode.Data_ZhencangUp, this, this.resiveZhencangUp)
Utils.addInnerEL(InnerMsgCode.Data_Redpoint, this, this.resiveZhencangRedpoint)
}
start() {
GButton.BandClick(this._nodeTab.btnStart, this.onStartClick, this, 10002);
GButton.BandClick(this._nodeTab.btnKefu, this.onKefuClick, this);
GButton.BandClick(this._nodeTab.btnAddTZCount, this.onAddTZClick, this);
GButton.BandClick(this._nodeTab.tzCountNode, this.onAddTZClick, this);
GButton.BandClick(this._nodeTab.btnSetting, this.onSettingClick, this);
GButton.BandClick(this._nodeTab.btnBDSidebar, this.onBDSidebarClick, this);
GButton.BandClick(this._nodeTab.btnGM, this.onGMClick, this);
GButton.BandClick(this._nodeTab.btnTujian, this.onTujianClick, this);
GButton.BandClick(this._nodeTab.btnReward, this.onRewardClick, this);
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
console.log("视频广告回调", tag)
if (tag == 1) {
// 加次数
HttpUnit.ins.setUserAd({type:1}, (data) => {
SubManager.ShowPrompt("观看视频成功,获得相亲次数")
this.refreshXiangqinTicket()
})
} else if (tag == 2) {
// 解锁关卡
HttpUnit.ins.levelUnlock({level_id: this.lvUnlockId}, (data) => {
// SubManager.ShowPrompt("关卡解锁成功")
this.refreshLevelList()
this.enterLevelAfterUnlock()
})
}
})
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
console.log("分享回调", tag)
if (tag == 1) {
// 加次数
HttpUnit.ins.setUserShare({type:1}, (data) => {
SubManager.ShowPrompt("分享成功,获得相亲次数")
this.refreshXiangqinTicket()
})
}
})
AudioManager.I.PlayMusic(1, true) //背景乐
GameRootUI.InitDisableOperUI(false)
GameRootUI.InitCrossUI(false)
this.setUIVisible(true)
this._nodeTab.rewardBox.active = false
this._nodeTab.rp_tujian.active = false
// this._nodeTab.labStart2.active = false //快手去掉英文
//客服按钮
this._nodeTab.btnKefu.active = SDKManager.KefuSupport()
//设置按钮
if (GlobalValue.GMSwtitch) {
this._nodeTab.btnSetting.active = true
this._nodeTab.btnGM.active = true
} else {
this._nodeTab.btnSetting.active = false
this._nodeTab.btnGM.active = false
}
//抖音侧边栏
this._nodeTab.btnBDSidebar.active = false
if (SDKManager.isByteDance()) {
this.refreshBdSidebarUI()
ByteDanceSDK.CheckSidebarState((state) =>{
if (state == true) {
this.refreshBdSidebarUI()
}
})
}
//重置引导
this.resetGuide()
GameRootUI.DisableOper(2)
//判断玩家权限是否已获取
if (!HttpUnit.IsLogin()) {
HttpUnit.ins.login((loginData) => {
console.log("主界面: 获取授权并登录成功!")
this.userInited()
})
} else {
this.userInited()
}
}
update(deltaTime: number) {
}
//GM界面关闭消息
resiveGMClose(data) {
Utils.Log("收到GM界面关闭消息")
}
//退出聊天消息
resiveTalkBack(data) {
Utils.Log("收到退出聊天消息")
AudioManager.I.PlayMusic(1, true) //背景乐
this.setUIVisible(true)
this.refreshLevelList()
HttpUnit.ins.getUserData((userData) => {
this.refreshXiangqinTicket()
})
}
//抖音侧边栏消息
resiveBDSidebar(data) {
this.refreshBdSidebarUI()
}
//领取抖音侧边栏奖励消息
resiveBDSidebarReward(data) {
this.refreshXiangqinTicket()
}
/**私家珍藏数据变化消息 */
resiveZhencangUp(data:any) {
this.refreshRewardUI()
}
/**刷新珍藏红点 */
resiveZhencangRedpoint(data: any) {
this.refreshTujianRedpoint();
}
/**前往回忆对应关卡 */
resiveHuiyiLv(data:any) {
let gotoIdx = -1
for (let i = 1; i < this.levelData.length; i++) {
if (this.levelData[i].id == data.lvId) {
gotoIdx = i
break
}
}
if (gotoIdx == -1) {
return
}
let scrollto = Math.max(0, gotoIdx - 2)
this.scheduleOnce(() => {
this.Level_List.scrollTo(scrollto)
}, 0.1)
// this.curLevelIdx = gotoIdx
this.changeLevel(gotoIdx, true)
}
//增加相亲次数
private doAddXiangqinCnt(add:number = 1) {
}
//显示主界面UI
setUIVisible(vis: boolean) {
this._nodeTab.UIRoot.active = vis
}
//刷新抖音侧边栏按钮显示状态
refreshBdSidebarUI() {
if (!SDKManager.isByteDance()) {
//不是抖音平台,不显示
this._nodeTab.btnBDSidebar.active = false
return
}
let stage = ByteDanceSDK.SidebarState
if (stage == 1) {
//前往
this._nodeTab.btnBDSidebar.active = true
// Utils.setString(this._nodeTab.labBDSidebar, "前往抖音侧边栏")
} else if (stage == 2) {
//从侧边栏返回
this._nodeTab.btnBDSidebar.active = false
// Utils.setString(this._nodeTab.labBDSidebar, "领取抖音侧边栏")
} else {
//版本不支持或奖励已领取
this._nodeTab.btnBDSidebar.active = false
}
}
//刷新玩家信息完毕
userInited() {
this.refreshSdkUI()
this.refreshLevelList()
this.refreshXiangqinTicket()
this.refreshTujianRedpoint()
GameManager.refreshZhencangCanget()
}
//刷新剩余相亲次数
private refreshXiangqinTicket() {
let xqnum = HttpUnit.GetXiangqinTickets()
// let xqmax = HttpUnit.GetXiangqinMaxTickets()
Utils.setString(this._nodeTab.labTZCount, xqnum + "")
Utils.setString(this._nodeTab.labBtnTZCount, "" + xqnum)
}
//刷新奖励按钮显示
private refreshRewardUI() {
let haveReward = GameManager.zhencangCanget.length > 0
this._dorefreshTujianReward(haveReward)
}
private _dorefreshTujianReward(haveReward:boolean) {
this._nodeTab.rewardBox.active = haveReward
if (haveReward) {
let rewardBox:Node = this._nodeTab.rewardBox
Tween.stopAllByTarget(rewardBox)
tween(rewardBox)
.delay(1.5)
.to(0.2, {angle: -30})
.to(0.2, {angle: 30})
.to(0.18, {angle: -22})
.to(0.18, {angle: 22})
.to(0.16, {angle: -16})
.to(0.16, {angle: 16})
.to(0.14, {angle: -10})
.to(0.14, {angle: 10})
.to(0.12, {angle: -6})
.to(0.12, {angle: 6})
.to(0.1, {angle: -3})
.to(0.1, {angle: 3})
.to(0.08, {angle: 0})
.union()
.repeatForever()
.start()
}
}
//刷新心动回忆入口红点
private refreshTujianRedpoint() {
let isshow = false
//心动回忆
if (!isshow) {
isshow = HttpUnit.IsHaveHuiyiRedpoint()
}
//私家珍藏
if (!isshow) {
isshow = HttpUnit.IsHaveZhencangRedpoint()
}
this._nodeTab.rp_tujian.active = isshow
}
//region 刷新关卡列表
private refreshLevelList() {
HttpUnit.ins.getLevelList((levelList) => {
if (levelList) {
GameRootUI.EnableOper()
GameManager.SetLevelCfg(levelList)
this.levelData = levelList
this.levelData.unshift({} as any) //在最前面插入一个占位数据,用于数组排版显示
this.Level_List.numItems = this.levelData.length
if (this.curLevelIdx < 1) {
this.curLevelIdx = 1
//自动滚动只在引导后生效
if (PlayerDataManager.I.GuideMainFinished) {
for (let i = 1; i < this.levelData.length; i++) {
if (this.levelData[i].is_unlock == true) {
if (this.curLevelIdx < i) {
this.curLevelIdx = i
}
} else {
break
}
}
if (this.curLevelIdx > 2) {
this.scheduleOnce(() => {
this.Level_List.scrollTo(this.curLevelIdx-2)
}, 0.1)
}
} else {
this.checkGuide()
}
}
this.changeLevel(this.curLevelIdx, true)
}
})
}
//刷新SDK相关的UI
refreshSdkUI() {
console.log("主界面:刷新SDK相关的UI...")
SDKManager.getUserInfo((data) => {
//头像
let spt = this._nodeTab.headIcon.getComponent(Sprite)
ResManager.I.changeRemoteSpriteFrame(spt, data.avatarUrl)
SDKManager.avatarUrl = data.avatarUrl
//名字
let nickName = this._nodeTab.nickName.getComponent(Label)
nickName.string = data.nickName
SDKManager.nickName = data.nickName
console.log("主界面 设置头像和名字:", data.avatarUrl, data.nickName)
})
//刷新id
let id = HttpUnit.GetID()
Utils.setString(this._nodeTab.userId, `ID:${id}`)
// Utils.setString(this._nodeTab.userId, `${id}`) //快手去掉英文
}
//region 关卡列表渲染
onRenderItemList(node: any, idx: number) {
if(!isValid(node)) {return}
if (!node.inited) {
node.inited = true;
Utils.parseNode(node);
}
GButton.RemoveClick(node)
//第一个是占位用的
if (idx == 0) {
node.l_rotateN.active = false
node.zhanweiNode.active = true
return
}
node.l_rotateN.active = true
node.zhanweiNode.active = false
let data = this.levelData[idx]
//npc名
// console.log("关卡列表渲染:", data.name)
//头像
let headPath = `headLevel/${data.icon}`
ResManager.I.changeBundleSpriteFrame(node.head1.getComponent(Sprite), headPath, "Raw")
//解锁状态
node.lockNode.active = data.is_unlock ? false : true
node.unlockNode.active = data.is_unlock ? true : false
if (data.is_unlock) {
//分数
Utils.setString(node.labScore, data.score)
//星级
if (data.star == 3) {
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_11", "Zhujiemian")
} else if (data.star == 2) {
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_10", "Zhujiemian")
} else if (data.star == 1) {
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_9", "Zhujiemian")
} else {
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_8", "Zhujiemian")
}
//满星效果
node.l_manxing.active = data.star == 3 ? true : false
if (data.star == 3) {
ResManager.I.changeBundleSpriteFrame(node.l_bg.getComponent(Sprite), "zjm_6", "Zhujiemian")
} else {
ResManager.I.changeBundleSpriteFrame(node.l_bg.getComponent(Sprite), "zjm_5", "Zhujiemian")
}
}
GButton.BandClick(node, ()=>{
this.changeLevel(idx)
}, this)
}
//切换关卡
changeLevel(idx:number, force:boolean = false) {
if (this.curLevelIdx == idx && !force) {
return
}
this.curLevelIdx = idx
let data = this.levelData[idx]
//名字
Utils.setString(this._nodeTab.labNpcName, data.characterName)
//介绍
Utils.setString(this._nodeTab.labNpcTalk, data.description)
//是否解锁
if (data.is_unlock) {
Utils.setString(this._nodeTab.labStart1, "游戏开始")
Utils.setString(this._nodeTab.labStart2, "GAME\nSTART")
} else {
Utils.setString(this._nodeTab.labStart1, "解锁关卡")
Utils.setString(this._nodeTab.labStart2, "UNLOCK\nGAME")
}
let bgPath = `bg/${data.bgImage}`
let rolePath = `role/${data.characterFullLengthPortrait}`
let videoPath = "http://www.confessioncontract.com/data/video/confession-contract/hanako_standby.mp4"
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {bgPath:bgPath, rolePath:rolePath, videoPath:videoPath, videoType: VideoRoleType.Idle})
}
//region 开始游戏
onStartClick() {
Utils.Log("点击开始游戏");
this.finishGuide()
if (this.curLevelIdx == 0) {
console.error("当前关卡为0,此关卡是占位用的")
return
}
let data = this.levelData[this.curLevelIdx]
let level_id = data.id
GameManager.EndGame()
//未解锁
if (data.is_unlock != true) {
if (HttpUnit.GetXiangqinTickets() <= 0) {
SubManager.ShowPrompt("今日相亲次数已耗尽,无法提前解锁更多关卡");
} else {
this.lvUnlockId = level_id
SubManager.ShowCommonAdDialog({
content: "关卡未解锁,需要通过本关卡的前置关卡,或观看广告提前解锁关卡,并消耗 1 点相亲次数进入关卡",
strAd: "观看广告",
strLeft: "返回",
adCallback: () => {
SDKManager.show_reward_video_ad(this.node.uuid, 2)
}
})
}
return
}
//检测存档
if (GlobalValue.LvHuancun && data.record_id && data.record_id != "") {
HttpUnit.ins.getTalkStage({record_id: data.record_id}, (_data) => {
if (_data) {
if (_data.level.status == E_TalkStatusType.talking) {
this._continueLevel(level_id, _data)
} else {
this._startNewLevel(level_id)
}
} else {
this._startNewLevel(level_id)
}
})
} else {
SubManager.ShowConfirm({
content: `确认消耗 1 点“相亲次数” 开始与【${data.name}】相亲吗?`,
strYes: "确认",
strNo: "返回",
yesCallback: () => {
this._startNewLevel(level_id)
}
})
}
}
//开始新关卡
private _startNewLevel(level_id) {
if (HttpUnit.GetXiangqinTickets() <= 0) {
SubManager.ShowPrompt("今日相亲次数已用完");
return;
}
GameManager.CurLevelId = level_id
HttpUnit.ins.levelStart({level_id:level_id}, (data) => {
GameManager.CurLevelData = data.level
GameManager.RecordId = data.record_id
GameManager.I.connetSorcket(data.record_id) //连接socket
this.setUIVisible(false)
AudioManager.I.StopMusic() //停止背景音乐,进去后播放当前关卡音乐
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
})
}
//region 继续关卡存档
private _continueLevel(level_id, data) {
// //测试代码
// if (true) {
// let img = "132"
// HttpUnit.ins.sendZhencangId({record_id:data.record_id, level_id:level_id, img:img}, (_data) => {
// if (_data) {
// SubManager.ShowPrompt("测试 获得珍藏卡:" + img)
// GameManager.refreshZhencangCanget()
// }
// })
// return
// }
SubManager.ShowConfirm({
content: "检测到进行中的记录,是否继续?",
strYes: "继续",
strNo: "重新开始",
yesCallback: () => {
//继续对话
let lvCfg = this.levelData[this.curLevelIdx]
let t_xindong = 0
let t_jidong = 0
let t_gandong = 0
let t_xihuan = 0
let t_taoyan = 0
//聊天记录
GameManager.AddTalkRecord({talk:lvCfg.prologueMessage, isMe:false, score:-1, scoreBase:-1, scoreAdditional:0})
let msg = data.messages || []
for (let i = 0; i < msg.length; i++) {
let m = msg[i]
let talkData: I_NpcTalkBack = {
aiEmoji: m.ai_emoji,
aiResponse: m.ai_response,
aiScore: m.ai_score || 0,
aiBaseScore: m.ai_base_score || 0,
aiAdditionalScore: m.ai_additional_score || 0,
isFinished: m.is_finished,
sourceCnt: m.source_cnt,
userInput: m.user_input,
judgement: m.judgement,
}
GameManager.CurNpcTalkData = talkData
GameManager.AddStepScore(m.ai_score) //记录本次分数
GameManager.AddTalkRecord({talk:m.user_input, isMe:true, score:-1, scoreBase:-1, scoreAdditional:0})
GameManager.AddTalkRecord({talk:m.ai_response, isMe:false, score:m.ai_score, scoreBase:talkData.aiBaseScore, scoreAdditional:talkData.aiAdditionalScore})
if (m.judgement == 0) {
t_xindong++
t_xihuan++
} else if (m.judgement == 2) {
t_taoyan++
}
if (m.ai_score >= 90) {
t_jidong++
}
if (m.ai_score >= 100) {
t_gandong++
}
}
GameManager.CurLevelId = level_id
GameManager.CurLevelData = data.level
GameManager.RecordId = data.record_id
GameManager.srouceCnt = data.level.current_cnt
GameManager.xindongCishu = t_xindong
GameManager.jidongCishu = t_jidong
GameManager.gandongCishu = t_gandong
GameManager.npcFixTalkCountXihuan = t_xihuan
GameManager.npcFixTalkCountTaoyan = t_taoyan
GameManager.TurnToStage(E_TalkStage.myTalk)
GameManager.I.connetSorcket(data.record_id) //连接socket
this.setUIVisible(false)
AudioManager.I.StopMusic() //停止背景音乐,进去后播放当前关卡音乐
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
},
noCallback: () => {
//结束上一次聊天
HttpUnit.ins.sendLevelRestartReport({record_id: data.record_id}, (data) => {
console.log("结束上一次聊天")
})
//重新开始
this._startNewLevel(level_id)
}
})
}
/**手动解锁关卡后进入 */
enterLevelAfterUnlock() {
this._startNewLevel(this.lvUnlockId)
this.lvUnlockId = ""
}
//点击客服
onKefuClick() {
SDKManager.OpenKefu()
}
//增加相亲次数
onAddTZClick() {
//测试代码
if (true) {
let emoPath = "http://www.confessioncontract.com/data/video/confession-contract/hanako_shy.mp4"
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {videoPath:emoPath, videoType: VideoRoleType.emo})
return
}
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
type: E_AD_TARGET.xiangqin, //加相亲次数
content: GlobalValue.XiangQinAdTipsStr,
adCallback: ()=>{
SDKManager.show_reward_video_ad(this.node.uuid, 1)
},
shareCallback: ()=>{
SDKManager.show_reward_share(this.node.uuid, 1)
}
})
}
//心动回忆
onTujianClick() {
//测试代码
if (true) {
let emoPath = "http://www.confessioncontract.com/data/video/confession-contract/hanako_laugh.mp4"
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {videoPath:emoPath, videoType: VideoRoleType.emo})
return
}
ViewManager.I.openBundlesView("UI/StartUI/Tujian_UI")
}
//设置
onSettingClick() {
ViewManager.I.openBundlesView("UI/StartUI/Setting_UI")
}
//gm
onGMClick() {
ViewManager.I.openBundlesView("UI/GM_UI")
}
//领取珍藏奖励
onRewardClick() {
if (GameManager.zhencangCanget.length == 0) {
SubManager.ShowConfirm({
content: "暂无可领取的奖励,任意关卡任意聊天达到 100 分即可领取奖励",
hideNo: true, //隐藏取消按钮
yesCallback: () => {
}
})
return
}
ViewManager.I.openBundlesView("UI/StartUI/TujianReward_UI")
}
//点击抖音侧边栏按钮
onBDSidebarClick() {
if (!SDKManager.isByteDance()) {
//不是抖音平台
return
}
ViewManager.I.openBundlesView("UI/StartUI/BDSidebar_UI")
}
//region 引导相关
private _guideInterval: number = 0.3 //引导间隔
//重置引导节点显示
private resetGuide() {
this._nodeTab.guideStep1.active = false
this._nodeTab.guideStep2.active = false
this._nodeTab.guideHandNode.active = false
this._nodeTab.btnStart.parent = this._nodeTab.startParent1
}
//检查引导
private checkGuide() {
if (PlayerDataManager.I.GuideMainFinished) {
return
}
this.doGuideStep1()
}
//引导步骤1 显示介绍弹窗
private doGuideStep1() {
GameRootUI.DisableOper(this._guideInterval)
this.scheduleOnce(() => {
this._nodeTab.guideStep1.active = true
GButton.RemoveAndBandClick(this._nodeTab.btnGs1Ok, this.onGuide1OkClick, this);
},this._guideInterval)
}
//引导步骤2 显示手
private doGuideStep2() {
GameRootUI.DisableOper(this._guideInterval)
this.scheduleOnce(() => {
this._nodeTab.guideStep2.active = true
this.scheduleOnce(() => {
let tempNode = instantiate(this.GuidePageItem)
let tntf = tempNode.getComponent(UITransform)
let wsize = view.getVisibleSize()
tntf.setContentSize(wsize.width, tntf.height)
//0号是占位的,从1开始
for (let i=1; i<this.levelData.length; i++) {
let data = this.levelData[i]
if (data.is_unlock) {
let node: any = instantiate(tempNode)
this.guidePageView.addPage(node)
Utils.parseNode(node)
//背景图
let bgPath = `bg/${data.bgImage}`
ResManager.I.changeBundleSpriteFrame(node.guideBg.getComponent(Sprite), bgPath, "Raw")
//角色立绘
let rolePath = `role/${data.characterFullLengthPortrait}`
ResManager.I.changeBundleSpriteFrame(node.guideRole.getComponent(Sprite), rolePath, "Raw")
//名字
Utils.setString(node.guideName, data.characterName)
//介绍
Utils.setString(node.guideDesc, data.description)
} else {
break
}
}
GButton.RemoveAndBandClick(this._nodeTab.gs2BtnKaishi, this.onGuideKaishiClick, this);
}, 0.1)
// this._nodeTab.guideHandNode.active = true
// this._nodeTab.btnStart.parent = this._nodeTab.startParent2
}, this._guideInterval)
}
//引导完成
private finishGuide() {
if (PlayerDataManager.I.GuideMainFinished) {
return
}
PlayerDataManager.I.SetGuideMainFinish(true)
this.resetGuide()
}
//翻页容器事件回调
guidePageViewEvent(param1, param2) {
// console.log("guidePageViewEvent", param1, param2)
this._nodeTab.gs2Zhisk.active = false
let pageIdx = this.guidePageView.curPageIdx
this.changeLevel(pageIdx+1)
}
//引导 下一步
onGuide1OkClick() {
this._nodeTab.guideStep1.active = false
this.doGuideStep2()
}
//引导 开始游戏
onGuideKaishiClick() {
// this.finishGuide()
// let pageIdx = this.guidePageView.curPageIdx
// let data = this.levelData[pageIdx+1]
// let level_id = data.id
// GameManager.EndGame()
// SubManager.ShowConfirm({
// content: `确认消耗 1 点“相亲次数” 开始与【${data.name}】相亲吗?`,
// strYes: "确认",
// strNo: "返回",
// yesCallback: () => {
// this._startNewLevel(level_id)
// }
// })
this.onStartClick()
}
}
@@ -0,0 +1,11 @@
{
"ver": "2.0.1",
"importer": "json",
"imported": true,
"uuid": "ce1d5a04-5bdb-46a4-a347-b41027b9ada2",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,47 @@
import { _decorator, Component, EditBox, Label, macro, Node, view } from 'cc';
import GameRootUI from './GameRootUI';
const { ccclass, property, requireComponent } = _decorator;
//输入框事件监听
@ccclass('EditBoxEvent')
// @requireComponent(EditBox) //装饰器,表示这个组件必须包含EditBox组件
export class EditBoxEvent extends Component {
private eb: EditBox = null!; //输入框组件
onLoad() {
}
start() {
this.eb = this.node.getComponent(EditBox)!;
// this.node.on('editing-did-began', this.onEditDidBegan, this);
this.node.on(EditBox.EventType.EDITING_DID_BEGAN, this.onEditDidBegan, this);
this.node.on(EditBox.EventType.EDITING_DID_ENDED, this.onEditDidEnded, this);
this.node.on(EditBox.EventType.EDITING_RETURN, this.onEditingReturn, this);
console.log("EditBoxEvent: start.")
}
update(deltaTime: number) {
}
onEditDidBegan(editbox, customEventData) {
console.log("EditBoxEvent: 开始编辑...")
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
// console.log("窗口大小 开始:", view.getVisibleSize(), GameRootUI.MainCamera)
}
onEditDidEnded(editbox, customEventData) {
console.log("EditBoxEvent: 结束编辑.")
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
// console.log("窗口大小 结束:", view.getVisibleSize(), GameRootUI.MainCamera)
}
onEditingReturn(editbox, customEventData) {
console.log("EditBoxEvent: 按下返回.")
}
}
@@ -0,0 +1,577 @@
import { randomRange } from "cc"
import GlobalValue from "../Common/GlobalValue"
import { I_SDK_UserInfo, I_SDK_UserInfo_Callback, SDKManager } from "./SDKManager"
import SubManager from "../../Sub/SubManager"
import Utils from "../Common/Utils"
import { InnerMsgCode } from "../Config/InnerMsgCode"
import HttpUnit from "../Common/HttpUnit"
//广告ID
const AD_AWARD = "1ntrdiqhmdket7v5fe"
const AD_SPLASH = "test"
const AD_BANNER = "test"
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;
private ShareSTime: any;
private ShareCb: any; //分享回调
private shareTxt = ["分享失败", "请分享到一个群", "请分享给一位好友", "分享过于频繁"]
/**侧边栏状态 =0不显示 =1显示前往按钮 =2从侧边栏返回 =3奖励已领取 */
private static _SidebarState:number = 0;
public static get SidebarState():number{
return ByteDanceSDK._SidebarState;
}
/**检测侧边栏功能是否可用 */
public static CheckSidebarState(cb:Function=null){
if (HttpUnit.IsBDSidebarReceive()) {
ByteDanceSDK._SidebarState = 3;
cb && cb(true);
return;
}
if (ByteDanceSDK._SidebarState > 0){
cb && cb(true);
return;
}
window['tt'].checkScene({
scene: "sidebar",
success: (res) => {
console.log("抖音 检测侧边栏功能->", res)
if (res.isExist == true) {
if (ByteDanceSDK._SidebarState == 0) {
ByteDanceSDK._SidebarState = 1
}
}
cb && cb(res.isExist == true);
},
fail: (res) => {
console.log("抖音 检测侧边栏功能失败->", res)
cb && cb(false);
}
})
}
/**前往侧边栏 */
public static GotoSidebar(cb:Function = null){
console.log("抖音 正在前往侧边栏...")
window["tt"].navigateToScene({
scene: "sidebar",
success(res) {
console.log("抖音 前往侧边栏 成功")
cb && cb(true);
},
fail(res) {
console.log("抖音 前往侧边栏 失败", res)
}
})
}
//初始化
init(cb: Function = null) {
console.log("init 抖音 初始化...")
// 保持屏幕常亮
window["tt"].setKeepScreenOn({
keepScreenOn: true,
success(res) {
},
fail(res) {
},
});
//小游戏回到前台
window['tt'].onShow((res)=>{
console.log("抖音 小游戏回到前台->", res)
if (!res) {
return;
}
// console.log("启动参数:", res.query);
// console.log("来源信息:", res.refererInfo);
// console.log("场景值:", res.scene);
// console.log("启动场景字段:", res.launch_from, ", ", res.location);
//返回小游戏场景值
if (res.query && res.query.ShareCode) {
GlobalValue.ShareTocusid = res.query.ShareCode
}
//从侧边栏返回
if (res.launch_from == "homepage" && res.location == "sidebar_card") {
console.log("从侧边栏返回, SidebarState=", ByteDanceSDK._SidebarState)
if (ByteDanceSDK._SidebarState == 1) {
ByteDanceSDK._SidebarState = 2
Utils.sendInnerMsg(InnerMsgCode.UI_BD_Sidebar, {})
//获取奖励
HttpUnit.ins.getBDSidebarReward({}, (data) => {
Utils.sendInnerMsg(InnerMsgCode.Data_BDSidebarReward, {})
SubManager.ShowConfirm({
content: "侧边栏奖励领取成功,相亲次数+1",
hideNo: true, //隐藏取消按钮
yesCallback: () => {
}
})
})
}
}
//处理分享事件
if (this.ShareCb) {
if (this.ShareSTime) {
let nT = new Date().getTime();
console.log("分享时间差 计算:",nT, this.ShareSTime);
if (nT - this.ShareSTime > 1500) {
let cb = this.ShareCb.succ
cb && cb()
} else {
this.tostErr()
}
}
this.ShareCb = null;
}
});
//小游戏被隐藏 记个时间
window['tt'].onHide(() => {
if (this.ShareCb) {
this.ShareSTime = new Date().getTime();
console.log("分享时间差 记录:", this.ShareSTime);
}
});
this.init_video();
this.init_splash();
this.init_banner();
this.qiangzhiUpdata(); //检测更新
cb && cb();
}
//分享失败
tostErr() {
let rint = Math.floor( randomRange(0, this.shareTxt.length - 1) )
SubManager.ShowPrompt(this.shareTxt[rint])
if (this.ShareCb) {
let cb = this.ShareCb.fail
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:2, code: null });
window["tt"].login({
force: false, //未登录时, 是否强制调起登录框
success(res) {
console.log(`抖音 - 登录成功 code=${res.code}, anonymousCode=${res.anonymousCode}`);
cb && cb({ platform:2, code: res.code });
},
fail(res) {
console.log(`抖音 - 登录失败`, res);
cb && cb({ platform:2, code: null });
},
})
}
private init_banner() {
if (AD_BANNER as any == "test") {
console.log("抖音 横幅广告id未配置,跳过此类型初始化")
return
}
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 (AD_SPLASH as any == "test") {
console.log("抖音 插屏广告id未配置,跳过此类型初始化")
return
}
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 (AD_AWARD as any == "test") {
console.log("抖音 激励广告id未配置,跳过此类型初始化")
return
}
if (!window["tt"] || !window["tt"].createRewardedVideoAd) return
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);
}
}
SDKManager.video_ad_back();
});
this.bd_video.onError((err) => {
});
}
//显示视频广告
show_video(callback:Function, tag:number) {
if (AD_AWARD as any == 'test') {
console.log('未接入广告ID,视频广告请求直接返回');
callback && callback();
SDKManager.video_ad_back();
return;
}
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;
}
}
//分享信息
shareInfo() {
return {
title: "告白契约", //Resource.getText(_shareInfo.invite_des),
query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(),
}
}
//主动拉起分享
show_share(rewardCB?:Function) {
// rewardCB && rewardCB()
console.log("主动拉起分享");
let info:any = this.shareInfo();
info.succ = rewardCB;
info.success = (res) => {
console.log("抖音 主动拉起分享成功", res);
}
info.fail = (err) => {
console.log("抖音 主动拉起分享失败", err);
}
// info.complete = (res) => {
// console.log("抖音 主动拉起分享完成", res);
// }
this.ShareCb = info;
window['tt'].shareAppMessage(info);
}
//获取设备分辨率
getWindowSize() {
return {width:screen.width, height: screen.height};
}
//显示游戏圈
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
}
//隐藏游戏圈
hide_gameClub() {
}
//检查是否支持base64音频播放
checkSupportBase64Audio() {
return true;
}
//播放base64音频
private _innerAudioContext: any = null;
private _iacIdx = 0 //音频播放索引
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)
}
let self = this;
const fs = window['tt'].getFileSystemManager();
//1.删除上一个音频
const lastPath = window['tt'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
console.log("抖音 正在删除上一个音频 ->", lastPath);
fs.removeSavedFile({
filePath: lastPath,
success(res) {
console.log("抖音 删除上一个音频成功", res);
},
fail(err) {
console.log("抖音 删除上一个音频失败", err);
},
complete(res) {
console.log("抖音 删除上一个音频完成", res);
//2.保存当前音频
//这里需要每次保存时换一下名字的原因是:innerAudioContext设置路径时如果路径相同,会认为还是同一个音频,不会重新加载,所以需要每次保存时换一下名字
self._iacIdx++;
const audioPath = window['tt'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
console.log("抖音 正在保存本次音频 ->", audioPath);
fs.writeFile({
filePath: audioPath,
data: substring,
encoding: 'base64',
success(res) {
if (self._innerAudioContext == null){
self._innerAudioContext = window['tt'].createInnerAudioContext();
// 添加播放结束的回调
self._innerAudioContext.onEnded(() => {
console.log("抖音 AI语音播放结束")
self._innerAudioContext.stop(); // 使用 stop 方法停止音频并重置播放状态
self._innerAudioContext.destroy(); // 销毁音频实例
self._innerAudioContext = null;
});
}
console.log("抖音 播放base64音频", audioPath)
self._innerAudioContext.src = audioPath;
self._innerAudioContext.play(); // 开始播放音频
},
fail(err) {
console.log("抖音 保存本次音频失败", err);
}
})
}
})
}
//region版本更新检测
//微信开发者工具上可以通过「编译模式」下的「下次编译模拟更新」开关来调试
qiangzhiUpdata() {
if (window['tt'].getUpdateManager == null) {
console.log("抖音 没有更新管理器", window['tt'].getUpdateManager)
return;
}
const updateManager = window['tt'].getUpdateManager();
//监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。
updateManager.onCheckForUpdate((res) => {
// 请求完新版本信息的回调
console.log("抖音 检查是否有新版本:", res.hasUpdate)
});
//监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调
updateManager.onUpdateReady(async () => {
window['tt'].showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
});
//监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调
updateManager.onUpdateFailed(function (err) {
console.log("抖音 新版本下载失败", err)
})
}
//客服功能是否支持
kefuSupport() {
console.log("抖音 不支持联系客服")
return false;
}
//进入联系客服
openKefu() {
console.log("抖音 进入联系客服")
}
//region 友盟+
umaInit() {
}
//友盟统计是否开启
umaSwt() {
return false;
}
//友盟事件统计
umaEvent(eventName: string, value: any = {}) {
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "92080a21-5e2a-458d-a863-f0e7bd83390f",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "92080a21-5e2a-458d-a863-f0e7bd83390f@6c48a",
"displayName": "jialin_stage_icon",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "92080a21-5e2a-458d-a863-f0e7bd83390f",
"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": "92080a21-5e2a-458d-a863-f0e7bd83390f@f9941",
"displayName": "jialin_stage_icon",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 138,
"height": 138,
"rawWidth": 138,
"rawHeight": 138,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-69,
-69,
0,
69,
-69,
0,
-69,
69,
0,
69,
69,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
138,
138,
138,
0,
0,
138,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-69,
-69,
0
],
"maxPos": [
69,
69,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "92080a21-5e2a-458d-a863-f0e7bd83390f@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "92080a21-5e2a-458d-a863-f0e7bd83390f@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 KiB