协议调试
This commit is contained in:
@@ -488,6 +488,13 @@ export class GirlData extends BaseData {
|
||||
return oneData.getIsRelease();
|
||||
}
|
||||
|
||||
/** 保存 付费技师是否已经解锁 */
|
||||
public setIsRelease(categoryId: string, girlId: number, value: boolean): void {
|
||||
let oneData = this.getGrilUnlock(categoryId, girlId);
|
||||
if (!oneData) return;
|
||||
oneData.setIsRelease(value);
|
||||
}
|
||||
|
||||
/** 判断图片是否解锁 */
|
||||
public isImageUnlock(categoryId: string, girlId: number, id: number): boolean {
|
||||
let oneData = this.getGrilUnlock(categoryId, girlId);
|
||||
|
||||
@@ -53,45 +53,60 @@ export class ShopData extends BaseData {
|
||||
/** 获取所有商品 id */
|
||||
public get goodIds(): number[] { return this._goodIds; }
|
||||
|
||||
/** 是否是充值商品,首位数字为 1 */
|
||||
public isRechargeId(id: number): boolean {
|
||||
const firstDigit = id.toString()[0]; // 取首位字符
|
||||
return firstDigit === "1";
|
||||
}
|
||||
|
||||
/** 获取 充值商品的id数组,首位数字为 1 */
|
||||
private getRechargeIds(): number[] {
|
||||
public getRechargeIds(): number[] {
|
||||
let allId = this._goodIds;
|
||||
if (!allId) return [];
|
||||
// 获取所有 id
|
||||
let resultId = [];
|
||||
for (let one of allId) {
|
||||
const firstDigit = one.toString()[0]; // 取首位字符
|
||||
if (firstDigit === "1") {
|
||||
if (this.isRechargeId(one)) {
|
||||
resultId.push(one);
|
||||
}
|
||||
}
|
||||
return resultId;
|
||||
}
|
||||
|
||||
/** 是否是会员商品,首位数字为 2 */
|
||||
public isMemberId(id: number): boolean {
|
||||
const firstDigit = id.toString()[0]; // 取首位字符
|
||||
return firstDigit === "2";
|
||||
}
|
||||
|
||||
/** 获取 会员商品的id数组,首位数字为 2 */
|
||||
private getMemberIds(): number[] {
|
||||
public getMemberIds(): number[] {
|
||||
let allId = this._goodIds;
|
||||
if (!allId) return [];
|
||||
// 获取所有 id
|
||||
let resultId = [];
|
||||
for (let one of allId) {
|
||||
const firstDigit = one.toString()[0]; // 取首位字符
|
||||
if (firstDigit === "2") {
|
||||
if (this.isMemberId(one)) {
|
||||
resultId.push(one);
|
||||
}
|
||||
}
|
||||
return resultId;
|
||||
}
|
||||
|
||||
/** 是否是聊天商品,首位数字为 3 */
|
||||
public isChatId(id: number): boolean {
|
||||
const firstDigit = id.toString()[0]; // 取首位字符
|
||||
return firstDigit === "3";
|
||||
}
|
||||
|
||||
/** 获取 聊天商品的id数组,首位数字为 3 */
|
||||
private getChatIds(): number[] {
|
||||
public getChatIds(): number[] {
|
||||
let allId = this._goodIds;
|
||||
if (!allId) return [];
|
||||
// 获取所有 id
|
||||
let resultId = [];
|
||||
for (let one of allId) {
|
||||
const firstDigit = one.toString()[0]; // 取首位字符
|
||||
if (firstDigit === "3") {
|
||||
if (this.isChatId(one)) {
|
||||
resultId.push(one);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ import type { IGirlService } from "./IGirlService";
|
||||
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||
import { GirlConfig } from "../../config/GirlConfig";
|
||||
import { GirlDetailConfig } from "../../config/GirlDetailConfig";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
|
||||
export class MockGirlService implements IGirlService {
|
||||
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||
private randInt(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1)) + min; }
|
||||
@@ -240,20 +244,61 @@ export class MockGirlService implements IGirlService {
|
||||
}
|
||||
|
||||
// 解锁技师
|
||||
async reqUnlockGirl(_req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||
async reqUnlockGirl(req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||
// 延时
|
||||
await this.delay(180);
|
||||
// 请求数据
|
||||
const reqGirlId = req.id;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
const price = girlData.getGrilPrice(category.toString(), reqGirlId);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
// 余额
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSUnlockGirlRes = {};
|
||||
const res: proto.cs.ICSUnlockGirlRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
// 解锁资源
|
||||
async reqUnlockGirlRes(_req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||
async reqUnlockGirlRes(req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||
// 延时
|
||||
await this.delay(180);
|
||||
// 请求数据
|
||||
const reqGirlId = req.girlId;
|
||||
const resId = req.resId;
|
||||
const resType = req.type;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
let price = 0;
|
||||
if (resType === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
price = girlData.getGrilPhotoPrice(category.toString(), reqGirlId, resId);
|
||||
} else if (resType === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
price = girlData.getGrilVideoPrice(category.toString(), reqGirlId, resId);
|
||||
}
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
// 余额
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSUnlockResourceRes = {};
|
||||
const res: proto.cs.ICSUnlockResourceRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import type { IShopService } from "./IShopService";
|
||||
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
||||
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import { ShopData } from "../../data/ShopData";
|
||||
|
||||
export class MockShopService implements IShopService {
|
||||
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||
@@ -26,7 +30,7 @@ export class MockShopService implements IShopService {
|
||||
}
|
||||
|
||||
// 获取商品列表
|
||||
async reqShopList(_req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||
async reqShopList(req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||
// 延时
|
||||
await this.delay();
|
||||
// 配置数据
|
||||
@@ -46,11 +50,42 @@ export class MockShopService implements IShopService {
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
async reqBuyGood(_req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||
async reqBuyGood(req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||
// 延时
|
||||
await this.delay();
|
||||
// 请求数据
|
||||
const reqGirlId = req.girlId;
|
||||
const goodId = req.goodId;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
|
||||
let chatRemainCount = 0;
|
||||
if (shopData.isRechargeId(goodId)) {
|
||||
// 充值
|
||||
} else if (shopData.isMemberId(goodId)) {
|
||||
// 会员
|
||||
chatRemainCount = -1;
|
||||
} else if (shopData.isChatId(goodId)) {
|
||||
// 聊天
|
||||
const curCount = girlData.getChatRemainCount(category.toString(), reqGirlId);
|
||||
chatRemainCount = curCount + shopData.getCountById(goodId);
|
||||
}
|
||||
// 余额
|
||||
const price = shopData.getPriceById(goodId);
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSBuyGoodRes = {};
|
||||
const res: proto.cs.ICSBuyGoodRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
chatRemainCount,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,24 @@ import Utils from "../../../Main/Common/Utils";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import { PopupGirlDetailPanel } from "./PopupGirlDetailPanel";
|
||||
import { GirlListItem } from "../../uiitems/GirlListItem";
|
||||
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { PlayerDataService } from "db://assets/Scripts/chat18x/network/services/PlayerDataService";
|
||||
import { PlayerData } from "../../data/PlayerData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlListPopupPanel")
|
||||
export class GirlListPopupPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
private category: number;
|
||||
private girlId: number;
|
||||
|
||||
base: GirlListItem;
|
||||
openUIDataCT(data) {
|
||||
this.category = data.category;
|
||||
this.girlId = data.id;
|
||||
this.base = data.base;
|
||||
}
|
||||
@@ -28,13 +36,26 @@ export class GirlListPopupPanel extends li_BaseView {
|
||||
Close() {
|
||||
this.close();
|
||||
}
|
||||
buyCharacter() {
|
||||
async buyCharacter() {
|
||||
// 购买id为girlId的女生
|
||||
console.log(this.girlId);
|
||||
|
||||
if (true) {
|
||||
// 请求解锁
|
||||
const reqData = {
|
||||
id: this.girlId,
|
||||
};
|
||||
let res = await GirlService.I.reqUnlockGirl(reqData);
|
||||
console.log("请求解锁响应数据:", res);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
girlData.setIsRelease(this.category.toString(), this.girlId, true);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
walletData.balance = Number(resData.balance);
|
||||
walletData.vipExpire = Number(resData.vipExpire);
|
||||
// 刷新界面
|
||||
this.base.refreshBuy(true);
|
||||
this.close();
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ export class GirlListItem extends Component {
|
||||
this.nameKey = girlData.getGrilName(this.category.toString(), this.id);
|
||||
this.girlName.string = LanguageUtils.getText(this.nameKey);
|
||||
this.tagKey = girlData.getGrilTagKey(this.category.toString(), this.id);
|
||||
// 是否已经解锁
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
let desc = "";
|
||||
const tags = LanguageUtils.getText(this.tagKey).split("|");
|
||||
for (let i = 0; i < tags.length; i++) {
|
||||
@@ -148,13 +150,17 @@ export class GirlListItem extends Component {
|
||||
}
|
||||
|
||||
onClickDetail() {
|
||||
if (false) {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
// 是否已经解锁
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
if (isRelease) {
|
||||
NavigationManager.Instance.navigateToGirlDetail(this.id);
|
||||
ViewManager.I.closeView(this.baseNode);
|
||||
} else {
|
||||
//未解锁
|
||||
ViewManager.I.openBundlesView("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: this.category,
|
||||
id: this.id,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user