This commit is contained in:
2025-07-17 17:18:21 +08:00
commit 1ffc1b5cf0
5309 changed files with 1150310 additions and 0 deletions
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "b06be357-8e86-402d-9a07-f32ccf8cf891",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "b06be357-8e86-402d-9a07-f32ccf8cf891@6c48a",
"displayName": "setting_5",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "b06be357-8e86-402d-9a07-f32ccf8cf891",
"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": "b06be357-8e86-402d-9a07-f32ccf8cf891@f9941",
"displayName": "setting_5",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 2,
"width": 87,
"height": 100,
"rawWidth": 91,
"rawHeight": 104,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-43.5,
-50,
0,
43.5,
-50,
0,
-43.5,
50,
0,
43.5,
50,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
2,
102,
89,
102,
2,
2,
89,
2
],
"nuv": [
0.02197802197802198,
0.019230769230769232,
0.978021978021978,
0.019230769230769232,
0.02197802197802198,
0.9807692307692307,
0.978021978021978,
0.9807692307692307
],
"minPos": [
-43.5,
-50,
0
],
"maxPos": [
43.5,
50,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "b06be357-8e86-402d-9a07-f32ccf8cf891@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "b06be357-8e86-402d-9a07-f32ccf8cf891@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,261 @@
import { _decorator, instantiate, Label, Layout, Node, Prefab, ScrollView, Sprite, tween, UIOpacity, UITransform } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import Utils from '../../Main/Common/Utils';
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
import li_BaseView from '../../Main/Common/li_BaseView';
import GameManager from '../../Main/Manager/GameManager';
import ResManager from '../../Main/Manager/ResManager';
import { SDKManager } from '../../Main/Channel/SDKManager';
import { ViewManager } from '../../Main/Manager/ViewManager';
import { E_AD_TARGET } from './TalkAdDialog';
import SubManager from '../SubManager';
import HttpUnit from '../../Main/Common/HttpUnit';
const { ccclass, property } = _decorator;
//聊天记录界面
@ccclass('Record_UI')
export class Record_UI extends li_BaseView {
@property(Prefab)
private talkDescItem: Prefab = null;
@property(Prefab)
private talkNpcItem: Prefab = null;
@property(Prefab)
private talkUserItem: Prefab = null;
private _nodeTab: any = {};
private talkSV: ScrollView = null;
private _data;
private itemNodeList: any[] = [];
private itemDataList: any[] = [];
//----重写父类接口---------------------------------------
onLoadCT() {
this.registerListenner();
Utils.parseNode(this.node, this._nodeTab)
this.talkSV = this._nodeTab.talkSV.getComponent(ScrollView);
}
openUIDataCT(data: any): void {
this._data = data
}
registerListenner() {
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
}
start() {
GButton.BandClick(this._nodeTab.btnBack, ()=>{
this.onClose();
}, this);
//撤回按钮
GButton.BandClick(this._nodeTab.chehuiNode, ()=>{
let cellLen = this.itemDataList.length
if (cellLen <= 1) {
SubManager.ShowPrompt("没有可以撤回的对话")
return
}
let contStr = ""
let levelData = GameManager.CurLevelData
if (!levelData || levelData.can_use_cancel_cnt <= 0) {
contStr = "关卡内撤回次数已用完"
} else {
contStr = `观看广告,可撤回最近一次对话并返还 1 次对话次数,剩余${levelData.can_use_cancel_cnt}次`
}
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
type: E_AD_TARGET.chehui, //撤回,并加聊天次数
content: contStr,
adCallback: ()=>{
SDKManager.show_reward_video_ad(this.node.uuid, 1)
},
shareCallback: ()=>{
SDKManager.show_reward_share(this.node.uuid, 1)
}
})
}, this);
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
console.log("视频广告回调", tag)
if (tag == 1) {
// 撤回聊天
this.doChehuiTalk()
}
})
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
console.log("分享回调", tag)
if (tag == 1) {
// 撤回聊天
this.doChehuiTalk()
}
})
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
//npc名字
Utils.setString(this._nodeTab.npcName, lvCfg.name)
//介绍
let descClone:any = instantiate(this.talkDescItem)
this._nodeTab.talkLay.addChild(descClone);
Utils.parseNode(descClone);
Utils.setString(descClone.labDesc, lvCfg.tips)
let descOpa:UIOpacity = descClone.getComponent(UIOpacity)
descOpa.opacity = 0
tween(descOpa).to(0.2, {opacity: 255}).start()
this.itemNodeList = []
this.itemDataList = []
let talkLay: Layout = this.talkSV.content.getComponent(Layout)
let talkCellLen = GameManager.TalkRecordList.length
let aniTime = 0 //滚动动作总时间
talkLay.enabled = false;
for (let i=0; i<talkCellLen; i++) {
// for (let i=talkCellLen-1; i>=0; i--) {
let info = GameManager.TalkRecordList[i];
let titem = info.isMe ? this.talkUserItem : this.talkNpcItem;
let itemClone:any = instantiate(titem);
this._nodeTab.talkLay.addChild(itemClone);
Utils.parseNode(itemClone);
this.itemNodeList.push(itemClone);
this.itemDataList.push(info);
//头像
let spt = itemClone.headIcon.getComponent(Sprite)
if (info.isMe) {
let avatarUrl = SDKManager.avatarUrl;
if (avatarUrl == "" || avatarUrl == null) {
SDKManager.getUserInfo((data) => {
ResManager.I.changeRemoteSpriteFrame(spt, data.avatarUrl)
})
} else {
ResManager.I.changeRemoteSpriteFrame(spt, avatarUrl)
}
} else {
let headPath = `head/${lvCfg.characterAvatar}`
ResManager.I.changeBundleSpriteFrame(spt.getComponent(Sprite), headPath, "Raw")
}
//对话文本
Utils.setString(itemClone.labTalk, info.talk)
//基础得分
let scoreBase = info.scoreBase || -1;
if (info.isMe || scoreBase < 0) {
itemClone.labScore.active = false;
} else {
itemClone.labScore.active = true;
Utils.setString(itemClone.labScore, `得分:${scoreBase}`)
}
//额外加分
let scoreAdditional = info.scoreAdditional || 0;
if (info.isMe || scoreAdditional <= 0) {
itemClone.labScoreAdd.active = false;
} else {
itemClone.labScoreAdd.active = true;
Utils.setString(itemClone.labScoreAdd, `加分:${scoreAdditional}`)
}
//动作
let kuangOpa:UIOpacity = itemClone.kuang.getComponent(UIOpacity)
kuangOpa.opacity = 1;
// let didx = talkCellLen-1-i;
let didx = i;
let tdelay = didx * 0.03;
let self = this;
if (i == talkCellLen-1) {
aniTime = 0.2 + tdelay;
}
tween(kuangOpa)
.delay(0.2 + tdelay)
.to(0.2, { opacity: 255 })
.call(()=>{
//滚动到当前节点处
self.talkSV.scrollToPercentVertical((talkCellLen-1-i) / talkCellLen, 0.1);
//调整框宽度
let labTf:UITransform = itemClone.labTalk.getComponent(UITransform);
let kuangTf:UITransform = itemClone.kuang.getComponent(UITransform);
kuangTf.width = labTf.width + 30;
})
.start();
}
//延迟一下,设置文本换行模式
this.scheduleOnce(()=>{
for (let i=0; i<this.itemNodeList.length; i++) {
let item = this.itemNodeList[i];
let labTf:UITransform = item.labTalk.getComponent(UITransform);
let lab:Label = item.labTalk.getComponent(Label);
if (labTf.height < 50) { //小于50,说明没换行,改为自动宽度
lab.overflow = Label.Overflow.NONE;
} else {
lab.overflow = Label.Overflow.RESIZE_HEIGHT;
}
}
}, 0.1)
//延迟一下,调整文本框的宽度。高度由layout自动调整
this.scheduleOnce(()=>{
talkLay.enabled = true;
}, 0.15)
//撤回按钮显示动画
let chehuiOpa: UIOpacity = this._nodeTab.chehuiNode.getComponent(UIOpacity);
chehuiOpa.opacity = 0;
tween(chehuiOpa)
.delay(aniTime)
.to(0.2, {opacity: 255})
.start();
//刷新撤回次数
this.refreshChehuiCount()
}
update(deltaTime: number) {
}
/**刷新撤回次数 */
refreshChehuiCount() {
let levelData = GameManager.CurLevelData
let n_cur = levelData.can_use_cancel_cnt || 0
let n_max = 3
Utils.setString(this._nodeTab.labChehui, n_cur + "/" + n_max)
}
/**撤回上一轮发言 */
doChehuiTalk() {
HttpUnit.ins.sendTalkChehui({record_id: GameManager.RecordId}, (data) => {
if (data) {
SubManager.ShowPrompt("撤回成功,已返还聊天次数")
GameManager.CurLevelData = data.level
GameManager.srouceCnt = data.level.current_cnt
GameManager.RemoveLastRoundTalkRecord()
GameManager.RemoveLastSetpScore()
GameManager.removeLastNpcTalkData()
Utils.sendInnerMsg(InnerMsgCode.Data_ChehuiUp, {})
this.onClose()
// this.refreshChehuiCount()
// let cellLen = this.itemNodeList.length
// if (cellLen > 1) {
// for (let i=cellLen-1; i>=0; i--) {
// let item: Node = this.itemNodeList[i]
// let info = this.itemDataList[i]
// item.removeFromParent()
// this.itemNodeList.splice(i, 1)
// this.itemDataList.splice(i, 1)
// if (info && info.isMe) {
// break
// }
// }
// GameManager.RemoveLastRoundTalkRecord()
// }
}
})
}
}
@@ -0,0 +1,68 @@
export class WebSDK{
//初始化
init(cb: Function = null) {
console.log("init webSDK");
cb && cb();
}
//检查权限
checkAutoSetting(autoKey:string, cb:Function = null) {
cb && cb(true);
}
//获取用户信息
getUserInfo(cb:Function = null) {
cb && cb({ nickName:"默认用户", avatarUrl:"" });
}
//登录
login(cb: Function = null) {
cb && cb({ platform:2, code: null });
}
//显示视频广告
show_video(callback:Function, tag:number) {
callback && callback({ code: 0, tag: tag });
}
//显示插屏
show_splash() {
}
//显示Banner
show_banner(...args) {
}
//隐藏Banner
hide_banner(...args) {
}
//主动拉起分享
show_share(rewardCB?:Function) {
rewardCB && rewardCB();
}
//获取设备分辨率
getWindowSize() {
return {width:screen.width, height: screen.height};
}
//显示游戏圈
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
}
//隐藏游戏圈
hide_gameClub() {
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "6a388ae2-858b-4c9c-9698-838785c0b128",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "6a388ae2-858b-4c9c-9698-838785c0b128@6c48a",
"displayName": "ninian_stage_bg",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "6a388ae2-858b-4c9c-9698-838785c0b128",
"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": "6a388ae2-858b-4c9c-9698-838785c0b128@f9941",
"displayName": "ninian_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": "6a388ae2-858b-4c9c-9698-838785c0b128@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "6a388ae2-858b-4c9c-9698-838785c0b128@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 936 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "c7145641-b2fa-4121-8fba-01d7bfaed642",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "c7145641-b2fa-4121-8fba-01d7bfaed642@6c48a",
"displayName": "zjm_20",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "c7145641-b2fa-4121-8fba-01d7bfaed642",
"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": "c7145641-b2fa-4121-8fba-01d7bfaed642@f9941",
"displayName": "zjm_20",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 36,
"height": 36,
"rawWidth": 36,
"rawHeight": 36,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-18,
-18,
0,
18,
-18,
0,
-18,
18,
0,
18,
18,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
36,
36,
36,
0,
0,
36,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-18,
-18,
0
],
"maxPos": [
18,
18,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "c7145641-b2fa-4121-8fba-01d7bfaed642@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "c7145641-b2fa-4121-8fba-01d7bfaed642@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "5c08a468-e28f-479c-b28d-55b719af0197",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "5c08a468-e28f-479c-b28d-55b719af0197@6c48a",
"displayName": "nanamiya_rie_disgust",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "5c08a468-e28f-479c-b28d-55b719af0197",
"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": "5c08a468-e28f-479c-b28d-55b719af0197@f9941",
"displayName": "nanamiya_rie_disgust",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 9.5,
"offsetY": -6,
"trimX": 89,
"trimY": 12,
"width": 766,
"height": 1177,
"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": [
-383,
-588.5,
0,
383,
-588.5,
0,
-383,
588.5,
0,
383,
588.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
89,
1177,
855,
1177,
89,
0,
855,
0
],
"nuv": [
0.09621621621621622,
0,
0.9243243243243243,
0,
0.09621621621621622,
0.9899074852817493,
0.9243243243243243,
0.9899074852817493
],
"minPos": [
-383,
-588.5,
0
],
"maxPos": [
383,
588.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "5c08a468-e28f-479c-b28d-55b719af0197@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "5c08a468-e28f-479c-b28d-55b719af0197@6c48a"
}
}
@@ -0,0 +1,490 @@
import { randomRange, view } from "cc";
import GlobalValue from "../Common/GlobalValue";
import SubManager from "../../Sub/SubManager";
import { I_SDK_UserInfo_Callback } from "./SDKManager";
import Utils from "../Common/Utils";
//广告ID
const wx_banner_ad_unit_id = 'test'
const wx_splash_ad_unit_id = 'test'
const wx_video_ad_unit_id = 'test'
export class WXSDK{
static g_InGameScene = null; //游戏场景值
private wx_video:any = null;
private wx_splash:any = null;
private wx_banner:any = null;
private wx_video_callback:Function = null;
private wx_video_tag:number = null;
private wx_gameClub:any = null; //游戏圈按钮
private ShareSTime: any;
private ShareCb: any; //分享回调
private shareTxt = ["分享失败", "请分享到一个群", "请分享给一位好友", "分享过于频繁"]
//初始化
init(cb: Function = null) {
// 保持屏幕常亮
window['wx'].setKeepScreenOn({ keepScreenOn: true });
WXSDK.g_InGameScene = window['wx'].getLaunchOptionsSync().scene;
console.log('init 微信 - 进入游戏的场景值', WXSDK.g_InGameScene);
//显示分享按钮
window['wx'].showShareMenu({
withShareTicket: true,
menus: ["shareAppMessage", "shareTimeline"],
});
window['wx'].onShareAppMessage(() => {
return this.shareInfo();
});
window['wx'].onShareTimeline(() => {
return this.shareInfo();
})
//小游戏回到前台
window['wx'].onShow(this.onWxShow.bind(this));
//小游戏被隐藏 记个时间
window['wx'].onHide(() => {
if (this.ShareCb) {
this.ShareSTime = new Date().getTime();
console.log("分享时间差 记录:", this.ShareSTime);
}
});
this.init_video(); //初始化视频广告
this.init_splash(); //初始化插屏广告
this.init_banner(); //初始化Banner广告 弹窗广告
cb && cb();
}
//小游戏回到前台
onWxShow(data: any) {
console.log("onWxShow:" + JSON.stringify(data))
//返回小游戏场景值
if (data && data.query && data.query.ShareCode) {
GlobalValue.ShareTocusid = data.query.ShareCode
}
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;
}
}
//分享失败
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()
}
}
/**获取用户授权状态
* @param autoKey string 授权类型 userInfo=用户信息,对应接口wx.getUserInfo
*/
checkAutoSetting(autoKey:string, cb:Function = null) {
window['wx'].getSetting({
success(res:any) {
console.log("微信 - 检测权限状态 succ:",JSON.stringify(res))
if (autoKey == "userInfo" && res.authSetting['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) {
console.log("微信 - 正在获取用户信息...")
var self = this;
window['wx'].getUserInfo({
success: (res) => {
console.log("微信 - 获取用户信息成功:", res);
cb && cb({avatarUrl:res.userInfo.avatarUrl, nickName:res.userInfo.nickName})
},
fail: (err) => {
console.log("微信 - 获取用户信息失败:", err);
self.openUserAuthorize(cb);
}
})
}
//申请用户信息授权
openUserAuthorize(cb: any) {
var self = this;
window['wx'].getSetting({
scope: 'scope.userInfo',
success(res:any) {
console.log("微信 authorize succ:",JSON.stringify(res))
if (res.authSetting['scope.userInfo']) {
self.getUserInfo(cb)
} else {
let systemInfo = window['wx'].getSystemInfoSync();
let button = window['wx'].createUserInfoButton({
type: 'text',
text: '',
// @ts-ignore
style: {
left: 0,
top: 0,
width: systemInfo.screenWidth,
height: systemInfo.screenHeight,
backgroundColor: '#00000000',//最后两位为透明度
textAlign: "center",
}
});
console.log("微信 点击开始游戏授权用户信息")
button.onTap((res) => {
button.destroy();
// if (res.userInfo) {
// console.log(res.userInfo)
// //此时可进行登录操作
// cb && cb(res.userInfo)
// }
console.log("微信 点击Tap", res)
self.getUserInfo(cb)
});
}
},
fail(err) {
console.log('微信 - authorize fail', err);
}
})
}
//微信登录
login(cb: Function = null) {
window['wx'].login({
success: (res) => {
if (res.code) {
console.log('微信 - 登录成功', res.code);
cb && cb({ platform:1, code: res.code });
} else {
console.log('微信 - 登录失败', res.errMsg);
cb && cb({ platform:1, code: null });
}
},
fail(res: any) {
console.log(`微信 login 调用失败`);
console.log(res.anonymousCode)
cb && cb({ platform:1, code: null });
},
});
}
//初始化视频广告
private init_video() {
this.wx_video = window['wx'].createRewardedVideoAd({
adUnitId: wx_video_ad_unit_id
});
this.wx_video.onLoad(() => {
console.log('onLoad event emit');
});
this.wx_video.onError((err) => {
console.log('onError event emit', err);
});
this.wx_video.onClose(res => {
console.log('onClose event emit',res);
// 用户点击了【关闭广告】按钮
// 小于 2.1.0 的基础库版本,res 是一个 undefined
if (res && res.isEnded || res === undefined) {
// 正常播放结束,可以下发游戏奖励
if (this.wx_video_callback) {
this.wx_video_callback(this.wx_video_tag);
}
}
else {
// 播放中途退出,不下发游戏奖励
//wx_video_callback(-1);
}
});
}
//初始化插屏广告
private init_splash() {
// 创建插屏广告实例,提前初始化
if (window['wx'].createInterstitialAd){
this.wx_splash = window['wx'].createInterstitialAd({
adUnitId: wx_splash_ad_unit_id
});
this.wx_splash.onLoad(() => {
console.log('splash onLoad event emit');
});
this.wx_splash.onError((err) => {
console.log('splash onError event emit', err);
});
this.wx_splash.onClose(res => {
console.log('splash onClose event emit', res);
});
}
}
//初始化Banner
private init_banner() {
let winSize = window['wx'].getSystemInfoSync();
let bannerHeight = 80;
let bannerWidth = 300;
this.wx_banner = window['wx'].createBannerAd({
adUnitId: wx_banner_ad_unit_id,
adIntervals: 30,
style: {
left: (winSize.windowWidth- bannerWidth)/2,
top: winSize.windowHeight- bannerHeight,
width: bannerWidth,
}
});
//微信缩放后得到banner的真实高度,从新设置banner的top 属性
this.wx_banner.onResize(res => {
this.wx_banner.style.top = winSize.windowHeight - this.wx_banner.style.realHeight;
})
this.wx_banner.onError(res => {
})
}
//显示视频广告
show_video(callback:Function, tag:number) {
if (wx_video_ad_unit_id == 'test') {
console.log('未接入广告ID,视频广告请求直接返回');
callback && callback();
return;
}
if (this.wx_video) {
this.wx_video_callback = callback;
this.wx_video_tag = tag;
this.wx_video.load()
.then(() => {
this.wx_video.show()
.catch(err => {
this.wx_video.load()
.then(() => this.wx_video.show())
})
})
}
}
//显示插屏
show_splash() {
// 在适合的场景显示插屏广告
// if (this.wx_splash) {
// this.wx_splash.show().catch((err) => {
// this.wx_splash.load().then(()=>{
// })
// })
// }
if (this.wx_splash) {
this.wx_splash
.load()
.then(() => {
this.wx_splash.show();
})
.catch(err => {
console.log(err);
});
}
}
//显示Banner
show_banner() {
if (this.wx_banner) {
this.wx_banner.show(); //banner 默认隐藏(hide) 要打开
}
}
//隐藏Banner
hide_banner() {
if (this.wx_banner) {
this.wx_banner.hide(); //banner 默认隐藏(hide) 要打开
}
}
/**分享图片*/
private SharePicAry = [
{id:"7wUnG0FFQry/nCdxI9kKYQ==", url:"https://mmocgame.qpic.cn/wechatgame/W9Az4zfwkAvic2MPaoBEdYEMVht0VwJv6eQF2myMU8IIFbQAZ92Fg73Qp9MUdPMj8/0"},
{id:"NCa1cR9YSWinaozMovG6kQ==", url:"https://mmocgame.qpic.cn/wechatgame/uRnpa1JW3rTyYxQHVUI2OaUmHZStMSWfoXPpx7AgceIN2EuqE2DRicDNjcBTA7arK/0"},
{id:"adU43/q3Te+86ThFH+8R+g==", url:"https://mmocgame.qpic.cn/wechatgame/fVu8XV4rOQv0iaLzIr4m67DZAOgN1NDe7jSCDoT2ibHuqRkacaeHCdCopIgLzrlBibR/0"},
{id:"k93MB1OQQzGuHDv6LhlJ4g==", url:"https://mmocgame.qpic.cn/wechatgame/rrYFeia8mywog7QfGagj9Uiad5Sicu3qNhV6IQcgVkZbUjibaWe70SUsvp9vNESBpje7/0"},
{id:"/ry07TA6SXea+AoABH1D+w==", url:"https://mmocgame.qpic.cn/wechatgame/f0cXVicm8xoT33Txqf2o2CRyreAicOiaHh8JFlbxHaDibYWZoBulHTF9v1s3EaUWfaMk/0"},
{id:"hYrwZorvQaOP3XbbC77PZw==", url:"https://mmocgame.qpic.cn/wechatgame/HEsiaI4wLnb2SVCthB5pZeBULvWsk71EdlK1WUXic23cPuzeWribbjibjlebOPyNy1wL/0"},
{id:"nzn7R/iLQoerxHhYbEM6AQ==", url:"https://mmocgame.qpic.cn/wechatgame/fxaAdTaO5GvRicwozj7sfUiat1ef3XLgjicLLZpeJYWtjyBjIhfh7TP2aZzOItwlpff/0"},
{id:"RvJk1ZZzR1iwqKvI39Rt8w==", url:"https://mmocgame.qpic.cn/wechatgame/WibiboKxDQsGxnVMhxebwvouMGnn5MKJibF18lS1iaibo1yrWnoTJgPAIgVX3dZEkV0Ta/0"},
{id:"6OgcDWd5SI2R2SmnOxs3Gw==", url:"https://mmocgame.qpic.cn/wechatgame/bpd6RQyPEB7xsoqyzribiaGnibELo6xARRPSLsgtickwcMHtSv920nweBbxIG7OiaJXFo/0"},
{id:"6qb2SmFBRgi3pv+pUIbulA==", url:"https://mmocgame.qpic.cn/wechatgame/LXCSUXdVagducqPcChicS5yQWqna7oduKCnzwlG11a7W1Lx6Rwv4Y1tBsMVWqP4Fs/0"},
{id:"rdrtaMpJTd6CtMI3dJikHg==", url:"https://mmocgame.qpic.cn/wechatgame/Zzc9s1q36erWTkUxLDjqOus62PTTysBW4PGUaDO5Pr67kT3g9W3HlMakBSiaicxGdH/0"},
{id:"sflrnBurRxC2dow0iuQNEg==", url:"https://mmocgame.qpic.cn/wechatgame/YiacDpfxzCGbXUHmtMmcfr8gIF7DicDib6q0pJaiaWXbTWOBGkCbpeuMic1SMgr91v43K/0"},
{id:"GkB88GpmR6KvjrV3yMxeWA==", url:"https://mmocgame.qpic.cn/wechatgame/f4fzfIKfgFIBFWxjsFibMUHKQA72JutALOXbuM3vaS0W9ZSUjC2rysb5Tic23lQb95/0"},
{id:"UxAhraIxTayr/3Mdhi0Uzg==", url:"https://mmocgame.qpic.cn/wechatgame/qDv24VqH6NBBP0IXNJ2EbSScIic6WsX0KcLJSNs1ThibYJx6QnDnKIT59CcIQSnZvD/0"},
{id:"ISSkaxiBRhyn3yZh2AS0eQ==", url:"https://mmocgame.qpic.cn/wechatgame/22HxqYDEUu1yelwdMR30ntjn6rzaYf8QJgrOkFlteicoqbacSptHiaNgK7cygteg99/0"},
{id:"m0GQ8b4YTU2u1So1Wr9Rjg==", url:"https://mmocgame.qpic.cn/wechatgame/D8nvAYkIticAEYwTBb3uC83TVferTkpqU5Akj8XGwPCYfNZibTeunZVd5ticqHxvgHC/0"},
{id:"F6j57H82QyyiD1i0MaS+0g==", url:"https://mmocgame.qpic.cn/wechatgame/FtniagLR3ueTRx3ibhy98G6pGdC69A38n9jUrVFHEhL9gqceaUnaTpmQHkiaPU1JE4h/0"},
{id:"dqd9Gfx2QGKilvChFwoc7Q==", url:"https://mmocgame.qpic.cn/wechatgame/yauvGchcicTl0zx4dYqfhAxl40k7ZbVM59VbPjDPcouesWbPrpsFQzNvfsSUYwUkb/0"},
]
//分享信息
shareInfo() {
let rand = Utils.getRandomInt(0, this.SharePicAry.length-1);
let picmap = this.SharePicAry[rand];
console.log("分享图片:", rand, picmap);
return {
title: "我在“告白契约”中相亲,邂逅了非常有趣的小姐姐,你也来试试吧~", //Resource.getText(_shareInfo.invite_des),
query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(),
imageUrl: picmap.url,
imageUrlId: picmap.id,
}
}
//主动拉起分享
show_share(rewardCB?:Function) {
console.log("主动拉起分享");
let info:any = this.shareInfo();
info.succ = rewardCB;
info.fail = null;
this.ShareCb = info;
window['wx'].shareAppMessage(info);
}
//获取设备分辨率
getWindowSize() {
let windowinfo = window['wx'].getWindowInfo();
return {width:windowinfo.screenWidth, height: windowinfo.screenHeight};
}
//显示游戏圈
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
console.log("显示游戏圈");
if (this.wx_gameClub) {
this.wx_gameClub.show();
}else {
let windowinfo = window['wx'].getWindowInfo();
let x = windowinfo.screenWidth * leftRatio;
let y = windowinfo.screenHeight * topRatio;
let w = windowinfo.screenWidth * widthRatio; //按钮宽高
let h = windowinfo.screenHeight * heightRatio;
console.log("游戏圈按钮配置:", windowinfo, leftRatio, topRatio, widthRatio, heightRatio, x, y, w, h);
this.wx_gameClub = window['wx'].createGameClubButton({
type: 'string',
text: '',
// type: 'image',
icon: 'green',
style: {
left: x, //这个坐标对应UI上的按钮时,按钮要勾选适配
top: y,
width: w,
height: h,
},
})
}
}
//隐藏游戏圈
hide_gameClub() {
console.log("隐藏游戏圈");
if (this.wx_gameClub) {
this.wx_gameClub.hide();
}
}
//检查是否支持base64音频播放
checkSupportBase64Audio() {
return true;
}
//播放base64音频
private _innerAudioContext: any = null;
private _iacIdx = 0 //音频播放索引
playBase64Audio(base64, loop) {
if (!this.checkSupportBase64Audio()) {
console.log("微信平台不支持base64音频播放");
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['wx'].getFileSystemManager();
//1.删除上一个音频
const lastPath = window['wx'].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['wx'].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['wx'].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);
}
})
}
})
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "505cfcdf-b588-490f-8616-ca933acbc433",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "505cfcdf-b588-490f-8616-ca933acbc433@6c48a",
"displayName": "qingye_2_cg",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "505cfcdf-b588-490f-8616-ca933acbc433",
"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": "505cfcdf-b588-490f-8616-ca933acbc433@f9941",
"displayName": "qingye_2_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": "505cfcdf-b588-490f-8616-ca933acbc433@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "505cfcdf-b588-490f-8616-ca933acbc433@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB