This commit is contained in:
2025-07-17 17:18:21 +08:00
commit 1ffc1b5cf0
5309 changed files with 1150310 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,756 @@
import { _decorator, sys } from "cc";
import { SDKManager } from "../Channel/SDKManager";
import GlobalValue from "./GlobalValue";
import { I_UserInfo } from "../Config/CommonConfig";
import SubManager from "../../Sub/SubManager";
import Utils from "./Utils";
import { InnerMsgCode } from "../Config/InnerMsgCode";
const { ccclass, property } = _decorator;
/**
* http通讯
*/
@ccclass
export default class HttpUnit {
//业务接口
// static readonly ServerHttpHost = "https://xqmnyx.vip.hnhxzkj.com/api/"; //正式
static readonly ServerHttpHost = "https://test.xqmnyx.vip.hnhxzkj.com/api/"; //测试
//socket通讯
// static readonly SocketHost = "wss://www.confessioncontract.com/game/ai/response/"; //正式
static readonly SocketHost = "wss://www.confessioncontract.com/test/game/ai/response/"; //测试
static PlayerToken = ""; //登录时获取的token
static LoginState = 0; //登录状态 0未登录 1登录中 2已登录
static UserInfo:I_UserInfo = null; //用户数据
//后台设置
//ad_chat_times:看广告加聊天次数 register_chat_times:注册赠送聊天次数
//reset_day_ad:每日重置看广告次数 reset_day_share:每日重置分享次数 share_chat_times:分享可加聊天次数
//ad_tickets_times:看广告可加相亲次数 share_tickets_times:分享可加相亲次数
static SerSetting:any = {};
//单例
private static I: HttpUnit;
public static get ins(): HttpUnit {
if (this.I == null) {
this.I = new HttpUnit();
}
return this.I;
}
public constructor() {
}
public jsonToQueryString(json: any) {
var str = '';
if (typeof json == "object") {
str = "?";
for (var k in json) {
if (str != "?") {
str += "&";
}
str += k + "=" + json[k];
}
}
return str;
}
private objectToFormData(obj: Object): FormData {
const formData = new FormData();
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (Array.isArray(value)) {
for (const item of value) {
formData.append(key, item);
}
} else {
formData.append(key, value);
}
}
}
return formData;
}
private async quest(xhr: XMLHttpRequest, method: "GET" | "POST" | "PUT" = "GET", data: Object, formData: boolean = false) {
return new Promise((resolve, reason) => {
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 300) {
// console.log("[Http] 返回", xhr.response);
resolve(JSON.parse(xhr.response));
} else {
reason(xhr.status)
}
}
};
xhr.onerror = (error) => {
console.error("http request onerror");
SubManager.ShowPrompt("网络错误,请检查网络连接");
reason(error)
};
xhr.ontimeout = (e) => {
console.error("http request timeout");
SubManager.ShowPrompt("网络错误,请检查网络连接");
reason(e)
}
//根据POST和GET方式,选择是否发送msg数据
if (formData) {
xhr.send(this.objectToFormData(data));
} else {
if (method == 'POST') {
xhr.send(JSON.stringify(data));
} else if (method == 'PUT') {
xhr.send(JSON.stringify(data));
} else {
xhr.send();
}
}
});
}
/**是否已登录成功 */
public static IsLogin(): boolean {
return HttpUnit.LoginState == 2;
}
/**获取心动最大次数 */
public static GetXindongMaxCount() {
return 5;
}
/**获取最大相亲次数 */
public static GetXiangqinMaxTickets() {
//每天重置相亲次数
let num1 = HttpUnit.SerSetting.reset_game_day_match ? HttpUnit.SerSetting.reset_game_day_match.value : 5;
num1 = parseInt(num1) || 0;
//看广告加的相亲次数
let num2 = HttpUnit.SerSetting.ad_tickets_times ? HttpUnit.SerSetting.ad_tickets_times.value : 3;
num2 = parseInt(num2) || 0;
//分享加的相亲次数
let num3 = HttpUnit.SerSetting.share_tickets_times ? HttpUnit.SerSetting.share_tickets_times.value : 3;
num3 = parseInt(num3) || 0;
return num1 + num2 + num3;
}
/**获取可相亲次数 */
public static GetXiangqinTickets() {
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.ticket || 0;
return num;
}
/**获取可分享次数 - 相亲次数 */
public static GetXiangqinShareNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.game_share_num || 0;
return num;
}
/**获取可看广告次数 - 相亲次数 */
public static GetXiangqinAdNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.game_ad_num || 0;
return num;
}
/**获取可分享次数 - 聊天次数 */
public static GetTalkShareNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.level_share_num || 0;
return num;
}
/**获取可看广告次数 - 聊天次数 */
public static GetTalkAdNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.level_ad_num || 0;
return num;
}
/**获取看广告增加的聊天次数 */
public static GetTalkAdAddNum() {
let num = HttpUnit.SerSetting.ad_chat_times ? HttpUnit.SerSetting.ad_chat_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取分享增加的聊天次数 */
public static GetTalkShareAddNum() {
let num = HttpUnit.SerSetting.share_chat_times ? HttpUnit.SerSetting.share_chat_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取看广告增加的相亲次数 */
public static GetXiangqinAdAddNum() {
let num = HttpUnit.SerSetting.ad_tickets_times ? HttpUnit.SerSetting.ad_tickets_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取分享增加的相亲次数 */
public static GetXiangqinShareAddNum() {
let num = HttpUnit.SerSetting.share_tickets_times ? HttpUnit.SerSetting.share_tickets_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取昵称 */
public static GetNickName() {
if (!HttpUnit.UserInfo) {
return "游客"
}
let num = HttpUnit.UserInfo.nickname || "游客";
return num;
}
/**获取ID */
public static GetID() {
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.id || 0;
return num;
}
/**获取抖音侧边栏奖励是否已领取 */
public static IsBDSidebarReceive() {
if (!HttpUnit.UserInfo) {
return false
}
let isget = HttpUnit.UserInfo.is_receive == 1;
return isget;
}
/**获取友盟关卡记录 */
public static GetLevelRecord() {
if (!HttpUnit.UserInfo) {
return []
}
let levels = HttpUnit.UserInfo.levels || [];
return levels;
}
/**获取可领取的珍藏奖励列表 */
public static GetZhencangRewardList() {
if (!HttpUnit.UserInfo) {
return []
}
// let rewards = HttpUnit.UserInfo.zhanli_rewards || [];
let rewards = [1,2,3]; //测试代码
return rewards;
}
/**获取珍藏红点是否显示 */
public static IsHaveZhencangRedpoint() {
if (!HttpUnit.UserInfo) {
return false
}
let isget = HttpUnit.UserInfo.private_collection_mark == 1;
return isget;
}
/**获取回忆红点是否显示 */
public static IsHaveHuiyiRedpoint() {
if (!HttpUnit.UserInfo) {
return false
}
let isget = HttpUnit.UserInfo.heartbeat_memories_mark == 1;
return isget;
}
//region 登录
private loginCB: Function = null;
public login(cb: Function = null) {
this.loginCB = cb;
SDKManager.login((_loginData) => {
console.log("SDK登录成功", _loginData)
SDKManager.getUserInfo((userInfo) => {
console.log("SDK获取用户信息成功", userInfo)
// let serparam = {
// platform: _loginData.platform,
// code: _loginData.code,
// user_info: {nickName:userInfo.nickName, avatarUrl:userInfo.avatarUrl}
// }
_loginData.nickname = userInfo.nickName;
_loginData.avatar = userInfo.avatarUrl;
if (GlobalValue.IsTest) {
console.log("登录测试环境")
this.loginSer({platform:0, code:12345}, this.initData.bind(this))
} else {
if (_loginData.code == null) {
// let uuid = sys.localStorage.getItem('uuid');
// if (!uuid) {
// uuid = Date.now(); //当前时间戳
// sys.localStorage.setItem('uuid', uuid);
// }
// _loginData.code = uuid;
_loginData.platform = 0
_loginData.code = 123454
}
console.log("登录正式环境 loginData.code: ", _loginData)
this.loginSer(_loginData, this.initData.bind(this))
}
})
})
}
private initData(playerData) {
// playerData = playerData || {};
this.loginCB && this.loginCB(playerData);
}
//登录服务器
private async loginSer(msg, cb: Function = null) {
let data: any = await HttpUnit.ins.api("login", msg, "POST", true);
console.log("登录 玩家数据:", msg, data)
if (data && data.code == 1) {
HttpUnit.PlayerToken = data.data.token
HttpUnit.LoginState = 2
console.log("HttpUnit.PlayerToken:", HttpUnit.PlayerToken)
//获取玩家信息
// this.getUserInfo(cb);
HttpUnit.UserInfo = data.data.user_info;
//获取配置信息
this.getCommSetting();
cb && cb(data.data.user_info);
}else{
console.log("登陆失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`登陆失败,${data.msg}`);
} else {
SubManager.ShowPrompt(`登陆失败,服务器异常`);
}
cb && cb(null);
}
}
//获取关卡列表数据
public async getLevelList(cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/levels", {}, "POST", true);
console.log("关卡数据:", data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取关卡数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**开始关卡*/
public async levelStart(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/start", msg, "POST", true);
console.log("开始新关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("开始关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**推进关卡*/
public async sendUserTalk(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/propel", msg, "POST", true);
console.log("推进关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("推进关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
cb && cb(null);
}
}
/**结束关卡*/
public async sendLevelFinish(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/end", msg, "POST", true);
console.log("结束关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("结束关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**增加次数,更新关卡*/
public async addTalkCnt(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/update", msg, "POST", true);
console.log("更新关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("更新关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**获取AI语音*/
public async getAIVoice(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/voice", msg, "POST", true);
console.log("获取AI语音:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取AI语音失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**获取当前聊天状态*/
public async getTalkStage(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/status", msg, "POST", true);
console.log("获取当前聊天状态:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取当前聊天状态失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//非三星通关时继续关卡
public async sendGameContinue(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/continue", msg, "POST", true);
console.log("非三星通关时继续关卡:", data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("非三星通关时继续关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//重新获取用户信息
public async getUserData(cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/info", {}, "GET", true);
console.log("重新获取用户信息数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("重新获取用户信息数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//用户看广告
public async setUserAd(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/ad", msg, "POST", true);
console.log("看广告数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("看广告数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//用户分享
public async setUserShare(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/share", msg, "POST", true);
console.log("用户分享数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("用户分享数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//获取常用配置
public async getCommSetting(cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/setting", {}, "GET", true);
console.log("获取常用配置数据:", data)
if (data && data.code == 1) {
HttpUnit.SerSetting = {};
for (let i = 0; i < data.data.length; i++) {
let item = data.data[i];
HttpUnit.SerSetting[item.key] = item;
}
cb && cb();
}else{
console.log("获取常用配置数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//看广告解锁关卡
public async levelUnlock(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/unlock_level", msg, "POST", true);
console.log("看广告解锁关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("看广告解锁关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//获取抖音侧边栏奖励
public async getBDSidebarReward(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/receive_award", msg, "POST", true);
console.log("获取抖音侧边栏奖励:", msg, data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("获取抖音侧边栏奖励失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//添加友盟关卡记录
public async sendLevelRecord(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/add_level_record", msg, "POST", true);
console.log("添加友盟关卡记录:", msg, data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("添加友盟关卡记录失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//获得甜蜜暴击效果
public async sendTalkStrength(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/strength", msg, "POST", true);
console.log("获得甜蜜暴击效果:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获得甜蜜暴击效果失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//撤回一次聊天
public async sendTalkChehui(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/cancel", msg, "POST", true);
console.log("撤回一次聊天:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("撤回一次聊天失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//关卡提示事件上报
public async sendTipRecord(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/add_record_tip", msg, "POST", true);
console.log("关卡提示事件上报:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("关卡提示事件上报失败:"+ data);
// if (data && data.msg) {
// SubManager.ShowPrompt(`数据异常,${data.msg}`);
// }
}
}
//获取AI回复提示语
public async getAIAutoAns(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/tips", msg, "POST", true);
console.log("获取AI回复提示语:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取AI回复提示语失败:"+ data);
// if (data && data.msg) {
// SubManager.ShowPrompt(`数据异常,${data.msg}`);
// }
}
}
/**获取历史聊天记录*/
public async getTalkJilu(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/get_history", msg, "POST", true);
console.log("获取历史聊天记录:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取历史聊天记录失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**私家珍藏上报 limit:每页条数 page:当前页 type:类型 0待领取 1已领取 level_id:关卡ID*/
public async sendZhencangId(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/set_private_collection", msg, "POST", true);
console.log("私家珍藏上报:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("私家珍藏上报失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**获取私家珍藏列表*/
public async getZhencangList(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/get_private_collection", msg, "POST", true);
console.log("获取私家珍藏列表:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取私家珍藏列表失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**领取私家珍藏指定奖励*/
public async getZhencangReward(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/private_collection_award", msg, "POST", true);
console.log("领取私家珍藏指定奖励:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("领取私家珍藏指定奖励失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**清除私家珍藏红点*/
public async readRedpointZhencang(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/clear_private_collection_mark", msg, "POST", true);
console.log("清除私家珍藏红点:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
Utils.sendInnerMsg(InnerMsgCode.Data_ZhencangRedpoint, {})
}else{
console.log("清除私家珍藏红点失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
public async api(path: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, isFormData: boolean = false) {
let url = HttpUnit.ServerHttpHost + path;
// console.log("[Http] 请求Url:",url, " 方式:", method, " Authorization:", GlobalValue.PlayerToken, " 数据:", JSON.stringify(data) );
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// if (cc.sys.isNative) {
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// }
// xhr.setRequestHeader('authorization', Config.TOKEN);
//发送数据
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
xhr.setRequestHeader('Authorization', "Bearer " + HttpUnit.PlayerToken);
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, isFormData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**
* 发送请求
* @param url 接口地址
* @param data 消息字符串 (json格式)
* @param method 请求方式
* @param bLock 是否锁定屏幕
* @param formData 是否formData
* @returns
*/
public async send(url: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, formData: boolean = false) {
// console.log("[Http] 请求Url:",url, " 方式:", method, " 数据:", data);
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, formData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**解锁屏幕 */
private unlock() {
// LockScreenUI.ins.unShowloading();
// Config.loading.hide2();
}
/**锁屏 */
private lock() {
// Config.loading.show2();
// LockScreenUI.ins.Showloading('网络加载中请稍后...');
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "41e09b09-d5b9-4465-a604-b28cd186db53",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "41e09b09-d5b9-4465-a604-b28cd186db53@6c48a",
"displayName": "rose_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "41e09b09-d5b9-4465-a604-b28cd186db53",
"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": "41e09b09-d5b9-4465-a604-b28cd186db53@f9941",
"displayName": "rose_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "none",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 925,
"height": 1189,
"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": [
-462.5,
-594.5,
0,
462.5,
-594.5,
0,
-462.5,
594.5,
0,
462.5,
594.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1189,
925,
1189,
0,
0,
925,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-462.5,
-594.5,
0
],
"maxPos": [
462.5,
594.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "41e09b09-d5b9-4465-a604-b28cd186db53@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "41e09b09-d5b9-4465-a604-b28cd186db53@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "08e82231-96d6-44a0-8462-c580a24a596f",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "08e82231-96d6-44a0-8462-c580a24a596f@6c48a",
"displayName": "mochiduki_aoi_default",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "08e82231-96d6-44a0-8462-c580a24a596f",
"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": "08e82231-96d6-44a0-8462-c580a24a596f@f9941",
"displayName": "mochiduki_aoi_default",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -13.5,
"offsetY": -5.5,
"trimX": 76,
"trimY": 11,
"width": 746,
"height": 1178,
"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": [
-373,
-589,
0,
373,
-589,
0,
-373,
589,
0,
373,
589,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
76,
1178,
822,
1178,
76,
0,
822,
0
],
"nuv": [
0.08216216216216216,
0,
0.8886486486486487,
0,
0.08216216216216216,
0.990748528174937,
0.8886486486486487,
0.990748528174937
],
"minPos": [
-373,
-589,
0
],
"maxPos": [
373,
589,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "08e82231-96d6-44a0-8462-c580a24a596f@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "08e82231-96d6-44a0-8462-c580a24a596f@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "f98da039-ce72-4ec7-a113-ff1b1b934a38",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "f98da039-ce72-4ec7-a113-ff1b1b934a38@6c48a",
"displayName": "qingye_disgust",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "f98da039-ce72-4ec7-a113-ff1b1b934a38",
"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": "f98da039-ce72-4ec7-a113-ff1b1b934a38@f9941",
"displayName": "qingye_disgust",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "none",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 925,
"height": 1189,
"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": [
-462.5,
-594.5,
0,
462.5,
-594.5,
0,
-462.5,
594.5,
0,
462.5,
594.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1189,
925,
1189,
0,
0,
925,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-462.5,
-594.5,
0
],
"maxPos": [
462.5,
594.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "f98da039-ce72-4ec7-a113-ff1b1b934a38@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "f98da039-ce72-4ec7-a113-ff1b1b934a38@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "54fab7ca-17f8-4d83-9e42-a38da520a01b",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "54fab7ca-17f8-4d83-9e42-a38da520a01b@6c48a",
"displayName": "yuka_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "54fab7ca-17f8-4d83-9e42-a38da520a01b",
"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": "54fab7ca-17f8-4d83-9e42-a38da520a01b@f9941",
"displayName": "yuka_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 9.5,
"offsetY": -19.5,
"trimX": 66,
"trimY": 39,
"width": 812,
"height": 1150,
"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": [
-406,
-575,
0,
406,
-575,
0,
-406,
575,
0,
406,
575,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
66,
1150,
878,
1150,
66,
0,
878,
0
],
"nuv": [
0.07135135135135136,
0,
0.9491891891891892,
0,
0.07135135135135136,
0.9671993271656855,
0.9491891891891892,
0.9671993271656855
],
"minPos": [
-406,
-575,
0
],
"maxPos": [
406,
575,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "54fab7ca-17f8-4d83-9e42-a38da520a01b@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "54fab7ca-17f8-4d83-9e42-a38da520a01b@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 701 KiB

@@ -0,0 +1,314 @@
import { _decorator, Node, Sprite, tween, UIOpacity, UITransform, Vec3, view } 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, { E_TalkStage } from '../../Main/Manager/GameManager';
import ResManager from '../../Main/Manager/ResManager';
import GameRootUI from '../../Main/Common/GameRootUI';
import { ViewManager } from '../../Main/Manager/ViewManager';
import { I_LevelStepData } from '../../Main/Config/CommonConfig';
import AudioManager from '../../Main/Manager/AudioManager';
import { SDKManager } from '../../Main/Channel/SDKManager';
import SubManager from '../SubManager';
import HttpUnit from '../../Main/Common/HttpUnit';
const { ccclass, property } = _decorator;
//结算界面
@ccclass('Finish_UI')
export class Finish_UI extends li_BaseView {
private _nodeTab: any = {};
private _data: I_LevelStepData = null;
private picDefScale:Vec3; //图片默认缩放
private isPicFull:boolean = false; //图片是否全屏
//----重写父类接口---------------------------------------
onLoadCT() {
this.registerListenner();
Utils.parseNode(this.node, this._nodeTab)
this.picDefScale = (this._nodeTab.cgPic as Node).scale.clone();
GameRootUI.DisableOper(1)
}
openUIDataCT(data: any): void {
this._data = data
}
registerListenner() {
Utils.addInnerEL(InnerMsgCode.UI_ResartGame, this, this.resiveResartGame)
}
start() {
// GButton.BandClick(this._nodeTab.mask, ()=>{
// this.onBackClick();
// }, this, 0, null, null, false);
GButton.BandClick(this._nodeTab.cgPic, ()=>{
this.changePicScale();
}, this, 0, null, null, false);
GButton.BandClick(this._nodeTab.btnClose, ()=>{
this.onBackClick();
}, this);
GButton.BandClick(this._nodeTab.btnBack, ()=>{
this.onBackClick();
}, this);
GButton.BandClick(this._nodeTab.btnShare, ()=>{
SDKManager.show_reward_share(this.node.uuid, 1)
}, this);
GButton.BandClick(this._nodeTab.btnRestart, ()=>{
this.onRestartClick();
}, this);
GButton.BandClick(this._nodeTab.btnContinue, ()=>{
this.onContinueClick();
}, this);
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
console.log("结算界面分享回调", tag)
if (tag == 1) {
SubManager.ShowPrompt("分享成功")
// let sptShare:Sprite = this._nodeTab.btnShare.getComponent(Sprite)
// sptShare.grayscale = true
// GButton.RemoveClick(this._nodeTab.btnShare)
this.backToMain()
}
})
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
//星级
for (let i = 1; i <= 3; i++) {
let starSpt = this._nodeTab["star" + i].getComponent(Sprite)
let starPath = ""
let showAct = false
if(this._data.end_star == 3) {
starPath = "lv_23"
showAct = true
} else if (this._data.end_star < i) {
starPath = "lv_21"
} else {
starPath = "lv_22"
showAct = true
}
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
//动作
let starNode = this._nodeTab["starNode"+i]
if (showAct) {
this.doStarAction1(starNode, (i-1)*0.2)
} else {
this.doStarAction2(starNode, (i-1)*0.2)
}
}
//成功失败
let iswin = this._data.status == 0
let endPath = iswin ? "lv_19" : "lv_20"
let winSpt = this._nodeTab.winSpt.getComponent(Sprite)
ResManager.I.changeBundleSpriteFrame(winSpt, endPath, "Zhujiemian")
if (iswin) {
AudioManager.I.PlayEffect(10003); //胜利音效
} else {
AudioManager.I.PlayEffect(10001); //失败音效
}
//结算显示
let picPath = "" //表情图
let talkStr = "" //对话
if (this._data.end_star == 3) {
picPath = `cg3/${lvCfg.threeStarCG}`
talkStr = lvCfg.threeStarSummary
} else if (this._data.end_star == 2) {
picPath = `cg2/${lvCfg.twoStarCG}`
talkStr = lvCfg.twoStarSummary
} else if (this._data.end_star == 1) {
picPath = `cg1/${lvCfg.oneStarCG}`
talkStr = lvCfg.oneStarSummary
} else {
picPath = `cg0/${lvCfg.failureCG}`
talkStr = lvCfg.failureSummary
}
let cgPic = this._nodeTab.cgPic.getComponent(Sprite)
ResManager.I.changeBundleSpriteFrame(cgPic, picPath, "Raw")
Utils.setString(this._nodeTab.labTalk, talkStr)
//保存关卡星级
if (lvCfg.star < this._data.end_star) {
GameManager.SetLevelStar(GameManager.CurLevelId, this._data.end_star)
}
//按钮显示
let swtRestart = false
let swtContinue = false
let swtShare = false
if (this._data.end_star == 0) {
swtRestart = true
} else {
let curCnt = GameManager.srouceCnt
let stepData = GameManager.CurLevelData
if (curCnt < stepData.total_cnt) {
swtContinue = true
} else {
swtShare = true
}
}
this._nodeTab.btnRestart.active = swtRestart
this._nodeTab.btnContinue.active = swtContinue
this._nodeTab.btnShare.active = swtShare
this._nodeTab.labXQCount.active = swtRestart
//刷新npc表情
let emoInfo = GameManager.GetNpcEmoPic("")
let videoPath = HttpUnit.GetBgVideoUrl(emoInfo.emoName)
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {rolePath:emoInfo.rolePath, videoPath:videoPath, videoType: emoInfo.videoType})
//刷新玩家数据
Utils.setString(this._nodeTab.labXQCount, "")
HttpUnit.ins.getUserData((userData) => {
//剩余相亲次数
let xqnum = HttpUnit.GetXiangqinTickets()
Utils.setString(this._nodeTab.labXQCount, `剩余相亲次数:${xqnum}`)
})
}
update(deltaTime: number) {
}
//接收重玩消息
resiveResartGame(data:any) {
this.onClose()
}
//返回主界面
backToMain() {
GameManager.EndGame()
ViewManager.I.closeAllView();
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
}
//点击返回
onBackClick() {
this.backToMain()
}
//点击重玩
onRestartClick() {
GameRootUI.DisableOper(1)
GameManager.RestartGame()
}
//点击继续
onContinueClick() {
this._doContinueGame()
}
//继续游戏
private _doContinueGame() {
GameRootUI.DisableOper(0.5)
HttpUnit.ins.sendGameContinue({record_id:GameManager.RecordId, level_id:GameManager.CurLevelId}, (data) => {
if (data == null) return
Utils.sendInnerMsg(InnerMsgCode.Data_LevelStarUp, {level:GameManager.CurLevelId, star:this._data.end_star})
GameManager.TurnToStage(E_TalkStage.upTalkStatus, true)
this.onClose()
})
}
/**肖像放大缩小 */
changePicScale() {
let ttime = 0.3;
GameRootUI.DisableOper(ttime+0.1)
if (this.isPicFull) {
this.isPicFull = false;
tween((this._nodeTab.cgPic as Node))
.to(ttime, { scale: this.picDefScale }, { easing: 'quadOut' })
.start();
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
tween(hideNodeOpa)
.delay(ttime*0.7)
.to(ttime*0.3, { opacity: 255 }, { easing: 'quadOut' })
.start();
} else {
this.isPicFull = true;
let s = 1
let windowSize = view.getVisibleSize(); // 获取窗口大小
let picTf:UITransform = this._nodeTab.cgPic.getComponent(UITransform);
if (picTf.height < windowSize.height) {
s = windowSize.height / picTf.height;
}
let centerScale = this._nodeTab.center.scale;
if (centerScale.y < 1) {
s = s / centerScale.y; //根节点有做适配,这里还原适配做的缩放
}
tween((this._nodeTab.cgPic as Node))
.to(ttime, { scale: new Vec3(s, s, s) }, { easing: 'quadOut' })
.start();
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
tween(hideNodeOpa)
.to(ttime*0.3, { opacity: 0 }, { easing: 'quadOut' })
.start();
}
}
/**星星动作 */
private doStarAction1(node:Node, tdelay:number) {
let ttime = 0.5;
//透明效果
let opa = node.getComponent(UIOpacity)
if (!opa) {
opa = node.addComponent(UIOpacity)
}
opa.opacity = 0
tween(opa)
.delay(tdelay)
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
.start();
//缩放效果
node.setScale(new Vec3(3, 3, 3))
tween(node)
.delay(tdelay)
.to(ttime, { scale: new Vec3(1, 1, 1) }, { easing: 'quadIn' })
.start();
//旋转效果
tween(node)
.delay(tdelay)
// .to(ttime, { angle: 720 }, { easing: 'quadOut' })
.to(ttime, { eulerAngles: new Vec3(0, 0, 360) }, { easing: 'quadIn' })
.start();
}
private doStarAction2(node:Node, tdelay:number) {
let ttime = 0.5;
//透明效果
let opa = node.getComponent(UIOpacity)
if (!opa) {
opa = node.addComponent(UIOpacity)
}
opa.opacity = 0
tween(opa)
.delay(tdelay)
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
.start();
//缩放效果
tween(node)
.delay(tdelay)
.to(ttime*0.5, { scale: new Vec3(1.3, 1.3, 1.3) }, { easing: 'quadIn' })
.to(ttime*0.5, { scale: new Vec3(1, 1, 1) }, { easing: 'quadOut' })
.start();
}
}
@@ -0,0 +1,579 @@
import { _decorator, sys } from "cc";
import { SDKManager } from "../Channel/SDKManager";
import GlobalValue from "./GlobalValue";
import { I_UserInfo } from "../Config/CommonConfig";
import SubManager from "../../Sub/SubManager";
const { ccclass, property } = _decorator;
/**
* http通讯
*/
@ccclass
export default class HttpUnit {
// static readonly ServerHttpHost = "https://bls.vip.hnhxzkj.com/";
static readonly ServerHttpHost = "https://xqmnyx.vip.hnhxzkj.com/api/";
static PlayerToken = ""; //登录时获取的token
static LoginState = 0; //登录状态 0未登录 1登录中 2已登录
static UserInfo:I_UserInfo = null; //用户数据
//后台设置
//ad_chat_times:看广告加聊天次数 register_chat_times:注册赠送聊天次数
//reset_day_ad:每日重置看广告次数 reset_day_share:每日重置分享次数 share_chat_times:分享可加聊天次数
//ad_tickets_times:看广告可加相亲次数 share_tickets_times:分享可加相亲次数
static SerSetting:any = {};
//单例
private static I: HttpUnit;
public static get ins(): HttpUnit {
if (this.I == null) {
this.I = new HttpUnit();
}
return this.I;
}
public constructor() {
}
public jsonToQueryString(json: any) {
var str = '';
if (typeof json == "object") {
str = "?";
for (var k in json) {
if (str != "?") {
str += "&";
}
str += k + "=" + json[k];
}
}
return str;
}
private objectToFormData(obj: Object): FormData {
const formData = new FormData();
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (Array.isArray(value)) {
for (const item of value) {
formData.append(key, item);
}
} else {
formData.append(key, value);
}
}
}
return formData;
}
private async quest(xhr: XMLHttpRequest, method: "GET" | "POST" | "PUT" = "GET", data: Object, formData: boolean = false) {
return new Promise((resolve, reason) => {
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 300) {
// console.log("[Http] 返回", xhr.response);
resolve(JSON.parse(xhr.response));
} else {
reason(xhr.status)
}
}
};
xhr.onerror = (error) => {
console.error("http request onerror");
SubManager.ShowPrompt("网络错误,请检查网络连接");
reason(error)
};
xhr.ontimeout = (e) => {
console.error("http request timeout");
SubManager.ShowPrompt("网络错误,请检查网络连接");
reason(e)
}
//根据POST和GET方式,选择是否发送msg数据
if (formData) {
xhr.send(this.objectToFormData(data));
} else {
if (method == 'POST') {
xhr.send(JSON.stringify(data));
} else if (method == 'PUT') {
xhr.send(JSON.stringify(data));
} else {
xhr.send();
}
}
});
}
/**是否已登录成功 */
public static IsLogin(): boolean {
return HttpUnit.LoginState == 2;
}
/**获取心动最大次数 */
public static GetXindongMaxCount() {
return 5;
}
/**获取最大相亲次数 */
public static GetXiangqinMaxTickets() {
//每天重置相亲次数
let num1 = HttpUnit.SerSetting.reset_game_day_match ? HttpUnit.SerSetting.reset_game_day_match.value : 5;
num1 = parseInt(num1) || 0;
//看广告加的相亲次数
let num2 = HttpUnit.SerSetting.ad_tickets_times ? HttpUnit.SerSetting.ad_tickets_times.value : 3;
num2 = parseInt(num2) || 0;
//分享加的相亲次数
let num3 = HttpUnit.SerSetting.share_tickets_times ? HttpUnit.SerSetting.share_tickets_times.value : 3;
num3 = parseInt(num3) || 0;
return num1 + num2 + num3;
}
/**获取可相亲次数 */
public static GetXiangqinTickets() {
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.ticket || 0;
return num;
}
/**获取可分享次数 - 相亲次数 */
public static GetXiangqinShareNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.game_share_num || 0;
return num;
}
/**获取可看广告次数 - 相亲次数 */
public static GetXiangqinAdNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.game_ad_num || 0;
return num;
}
/**获取可分享次数 - 聊天次数 */
public static GetTalkShareNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.level_share_num || 0;
return num;
}
/**获取可看广告次数 - 聊天次数 */
public static GetTalkAdNum() {
//测试代码
if (GlobalValue.GMSwtitch) {
return 10
}
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.level_ad_num || 0;
return num;
}
/**获取看广告增加的聊天次数 */
public static GetTalkAdAddNum() {
let num = HttpUnit.SerSetting.ad_chat_times ? HttpUnit.SerSetting.ad_chat_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取分享增加的聊天次数 */
public static GetTalkShareAddNum() {
let num = HttpUnit.SerSetting.share_chat_times ? HttpUnit.SerSetting.share_chat_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取看广告增加的相亲次数 */
public static GetXiangqinAdAddNum() {
let num = HttpUnit.SerSetting.ad_tickets_times ? HttpUnit.SerSetting.ad_tickets_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取分享增加的相亲次数 */
public static GetXiangqinShareAddNum() {
let num = HttpUnit.SerSetting.share_tickets_times ? HttpUnit.SerSetting.share_tickets_times.value : 0;
num = parseInt(num) || 0;
return num;
}
/**获取昵称 */
public static GetNickName() {
if (!HttpUnit.UserInfo) {
return "游客"
}
let num = HttpUnit.UserInfo.nickname || "游客";
return num;
}
/**获取ID */
public static GetID() {
if (!HttpUnit.UserInfo) {
return 0
}
let num = HttpUnit.UserInfo.id || 0;
return num;
}
/**获取抖音侧边栏奖励是否已领取 */
public static IsBDSidebarReceive() {
if (!HttpUnit.UserInfo) {
return false
}
let isget = HttpUnit.UserInfo.is_receive == 1;
return isget;
}
//region 登录
private loginCB: Function = null;
public login(cb: Function = null) {
this.loginCB = cb;
SDKManager.login((_loginData) => {
console.log("SDK登录成功", _loginData)
SDKManager.getUserInfo((userInfo) => {
console.log("SDK获取用户信息成功", userInfo)
// let serparam = {
// platform: _loginData.platform,
// code: _loginData.code,
// user_info: {nickName:userInfo.nickName, avatarUrl:userInfo.avatarUrl}
// }
_loginData.nickname = userInfo.nickName;
_loginData.avatar = userInfo.avatarUrl;
if (GlobalValue.IsTest) {
console.log("登录测试环境")
this.loginSer({platform:0, code:12345}, this.initData.bind(this))
} else {
if (_loginData.code == null) {
// let uuid = sys.localStorage.getItem('uuid');
// if (!uuid) {
// uuid = Date.now(); //当前时间戳
// sys.localStorage.setItem('uuid', uuid);
// }
// _loginData.code = uuid;
_loginData.platform = 0
_loginData.code = 123454
}
console.log("登录正式环境 loginData.code: ", _loginData)
this.loginSer(_loginData, this.initData.bind(this))
}
})
})
}
private initData(playerData) {
playerData = playerData || {};
this.loginCB && this.loginCB(playerData);
}
//登录服务器
private async loginSer(msg, cb: Function = null) {
let data: any = await HttpUnit.ins.api("login", msg, "POST", true);
console.log("login:", msg, data)
if (data && data.code == 1) {
HttpUnit.PlayerToken = data.data.token
HttpUnit.LoginState = 2
console.log("HttpUnit.PlayerToken:", HttpUnit.PlayerToken)
//获取玩家信息
// this.getUserInfo(cb);
HttpUnit.UserInfo = data.data.user_info;
//获取配置信息
this.getCommSetting();
cb && cb(data.data.user_info);
}else{
console.log("登陆失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`登陆失败,${data.msg}`);
}
cb && cb(null);
}
}
//获取关卡列表数据
public async getLevelList(cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/levels", {}, "POST", true);
console.log("关卡数据:", data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取关卡数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**开始关卡*/
public async levelStart(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/start", msg, "POST", true);
console.log("开始新关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("开始关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**推进关卡*/
public async sendUserTalk(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/propel", msg, "POST", true);
console.log("推进关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("推进关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
cb && cb(null);
}
}
/**结束关卡*/
public async sendLevelFinish(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/end", msg, "POST", true);
console.log("结束关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("结束关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**增加次数,更新关卡*/
public async addTalkCnt(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/update", msg, "POST", true);
console.log("更新关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("更新关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**获取AI语音*/
public async getAIVoice(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/voice", msg, "POST", true);
console.log("获取AI语音:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取AI语音失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
/**获取当前聊天状态*/
public async getTalkStage(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/status", msg, "POST", true);
console.log("获取当前聊天状态:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取当前聊天状态失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//非三星通关时继续关卡
public async sendGameContinue(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/continue", msg, "POST", true);
console.log("非三星通关时继续关卡:", data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("非三星通关时继续关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//重新获取用户信息
public async getUserData(cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/info", {}, "GET", true);
console.log("重新获取用户信息数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("重新获取用户信息数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//用户看广告
public async setUserAd(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/ad", msg, "POST", true);
console.log("看广告数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("看广告数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//用户分享
public async setUserShare(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/share", msg, "POST", true);
console.log("用户分享数据:", data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("用户分享数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//获取常用配置
public async getCommSetting(cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/setting", {}, "GET", true);
console.log("获取常用配置数据:", data)
if (data && data.code == 1) {
HttpUnit.SerSetting = {};
for (let i = 0; i < data.data.length; i++) {
let item = data.data[i];
HttpUnit.SerSetting[item.key] = item;
}
cb && cb();
}else{
console.log("获取常用配置数据失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//看广告解锁关卡
public async levelUnlock(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/unlock_level", msg, "POST", true);
console.log("看广告解锁关卡:", msg, data)
if (data && data.code == 1) {
cb && cb(data.data);
}else{
console.log("看广告解锁关卡失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
//获取抖音侧边栏奖励
public async getBDSidebarReward(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("user/receive_award", msg, "POST", true);
console.log("获取抖音侧边栏奖励:", msg, data)
if (data && data.code == 1) {
HttpUnit.UserInfo = data.data;
cb && cb(data.data);
}else{
console.log("获取抖音侧边栏奖励失败:"+ data);
if (data && data.msg) {
SubManager.ShowPrompt(`数据异常,${data.msg}`);
}
}
}
public async api(path: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, isFormData: boolean = false) {
let url = HttpUnit.ServerHttpHost + path;
// console.log("[Http] 请求Url:",url, " 方式:", method, " Authorization:", GlobalValue.PlayerToken, " 数据:", JSON.stringify(data) );
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// if (cc.sys.isNative) {
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// }
// xhr.setRequestHeader('authorization', Config.TOKEN);
//发送数据
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
xhr.setRequestHeader('Authorization', "Bearer " + HttpUnit.PlayerToken);
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, isFormData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**
* 发送请求
* @param url 接口地址
* @param data 消息字符串 (json格式)
* @param method 请求方式
* @param bLock 是否锁定屏幕
* @param formData 是否formData
* @returns
*/
public async send(url: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, formData: boolean = false) {
// console.log("[Http] 请求Url:",url, " 方式:", method, " 数据:", data);
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, formData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**解锁屏幕 */
private unlock() {
// LockScreenUI.ins.unShowloading();
// Config.loading.hide2();
}
/**锁屏 */
private lock() {
// Config.loading.show2();
// LockScreenUI.ins.Showloading('网络加载中请稍后...');
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "b3272263-5fc6-4c99-b90f-d473b0963496",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "b3272263-5fc6-4c99-b90f-d473b0963496@6c48a",
"displayName": "phecda_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "b3272263-5fc6-4c99-b90f-d473b0963496",
"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": "b3272263-5fc6-4c99-b90f-d473b0963496@f9941",
"displayName": "phecda_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -5,
"trimX": 0,
"trimY": 10,
"width": 925,
"height": 1179,
"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": [
-462.5,
-589.5,
0,
462.5,
-589.5,
0,
-462.5,
589.5,
0,
462.5,
589.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1179,
925,
1179,
0,
0,
925,
0
],
"nuv": [
0,
0,
1,
0,
0,
0.9915895710681245,
1,
0.9915895710681245
],
"minPos": [
-462.5,
-589.5,
0
],
"maxPos": [
462.5,
589.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "b3272263-5fc6-4c99-b90f-d473b0963496@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "b3272263-5fc6-4c99-b90f-d473b0963496@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 737 KiB