diff --git a/assets/Scripts/chat18x/data/GirlData.ts b/assets/Scripts/chat18x/data/GirlData.ts index 35059608..3a2b56ef 100644 --- a/assets/Scripts/chat18x/data/GirlData.ts +++ b/assets/Scripts/chat18x/data/GirlData.ts @@ -399,6 +399,7 @@ export class GirlData extends BaseData { let price = oneData.getGrilPhotoPrice(id); return price / 100; } + /** 获取技师图片的价格 */ public getGrilPhotoPrice( categoryId: string, @@ -440,27 +441,7 @@ export class GirlData extends BaseData { categoryId: string, girlId: number ): number[] { - let oneData = this.getGrilDetail(categoryId, girlId); - if (!oneData) return []; - // 所有id - let allId = oneData.getAllGrilVideoId(); - // 用来展示的id - let displayIds = []; - for (let id of allId) { - let price = oneData.getGrilVideoPrice(id); - if (price <= 0) { - // 价格为0,代表免费 - displayIds.push(id); - } else { - // 价格大于0,代表付费 - let isUnlock = this.isVideoUnlock(categoryId, girlId, id); - if (isUnlock) { - // 已经解锁 - displayIds.push(id); - } - } - } - return displayIds; + return this.getAllGrilVideoId(categoryId, girlId); } /** 获取第一个技师视频的资源路径 */ diff --git a/assets/Scripts/chat18x/data/WalletData.ts b/assets/Scripts/chat18x/data/WalletData.ts index 77db0d4c..cd726fad 100644 --- a/assets/Scripts/chat18x/data/WalletData.ts +++ b/assets/Scripts/chat18x/data/WalletData.ts @@ -34,6 +34,11 @@ export class WalletData extends BaseData { Utils.sendInnerMsg(InnerMsgCode.BalanceChange, this._balance); } + /** 获取原来的余额,除100 */ + public getOriginalBalance(): number { + return this._balance / 100; + } + /** 获取余额 */ public get balance(): number { return this._balance; diff --git a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts index 57aa1ea1..0b4fb8a4 100644 --- a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts @@ -188,7 +188,7 @@ export class GirlDetailPanel extends li_BaseView { bindVideoToggle() { const girlData = DataManager.I.getDataById(DataId.Girl); - let ids = girlData.getAllGrilVideoId(this.category.toString(), this.id); + let ids = girlData.getAllDisplayGrilVideoId(this.category.toString(), this.id); this.refreshImgs(2, this.category, this.id, ids); } diff --git a/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts b/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts index d44c03d3..f8240935 100644 --- a/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/PopupGirlDetailPanel.ts @@ -1,24 +1,35 @@ -import { _decorator, Component, Node } from "cc"; +import { _decorator, Component, Node, Label } from "cc"; import li_BaseView from "../../../Main/Common/li_BaseView"; import { GButton } from "../../../Main/Common/GButton"; import Utils from "../../../Main/Common/Utils"; import { DetailImageItem } from "../../uiitems/DetailImageItem"; +import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService"; +import { DataManager, DataId } from "../../data/DataManager"; +import { GirlData } from "../../data/GirlData"; +import { WalletData } from "../../data/WalletData"; +import proto from "db://assets/Scripts/proto/proto.pb.js"; const { ccclass, property } = _decorator; @ccclass("PopupGirlDetailPanel") export class PopupGirlDetailPanel extends li_BaseView { private _nodeTab: any = {}; - + private priceLabel: Label; + private category: number; private girlId: number; private resId: number; private base: DetailImageItem; openUIDataCT(data) { + this.category = data.category; this.resId = data.resId; this.girlId = data.girlId; this.base = data.base; } onLoadCT() { Utils.parseNode(this.node, this._nodeTab); + const girlData = DataManager.I.getDataById(DataId.Girl); + // 价格 + this.priceLabel = this._nodeTab.Price.getComponent(Label); + this.priceLabel.string = girlData.getGrilPhotoOriginalPrice(this.category.toString(), this.girlId, this.resId).toString(); this.registerListener(); } registerListener() { diff --git a/assets/Scripts/chat18x/ui/panels/ThemePanel.ts b/assets/Scripts/chat18x/ui/panels/ThemePanel.ts index 573b2753..41a0e3f8 100644 --- a/assets/Scripts/chat18x/ui/panels/ThemePanel.ts +++ b/assets/Scripts/chat18x/ui/panels/ThemePanel.ts @@ -22,6 +22,8 @@ import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlSe import { DataManager, DataId } from "../../data/DataManager"; import { ThemeData } from "../../data/ThemeData"; import { GirlData } from "../../data/GirlData"; +import { WalletData } from "../../data/WalletData"; +import { AccountData } from "../../data/AccountData"; import proto from 'db://assets/Scripts/proto/proto.pb.js'; const { ccclass, property } = _decorator; @@ -31,6 +33,7 @@ export class ThemePanel extends li_BaseView { private _nodeTab: any = {}; coinNum: Label; + uid: Label; itemInst: GirlListItem; content: Node; @@ -44,6 +47,7 @@ export class ThemePanel extends li_BaseView { Utils.parseNode(this.node, this._nodeTab); this.coinNum = this._nodeTab.coinNum.getComponent(Label); + this.uid = this._nodeTab.uid.getComponent(Label); this.recName = this._nodeTab.characterNameText.getComponent(Label); this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite); @@ -58,7 +62,9 @@ export class ThemePanel extends li_BaseView { rectNameKey: string; async Show() { //some temp data - this.coinNum.string = (50.0).toString(); + this.refreshCoinNum(); + const accountData = DataManager.I.getDataById(DataId.Account); + this.uid.string = "uid: " + accountData.accId; this.recId = 1; if (this.cache) { for (let i = this.cache.length - 1; i >= 0; i--) { @@ -127,10 +133,10 @@ export class ThemePanel extends li_BaseView { this.recName.string = LanguageUtils.getText(this.rectNameKey); }); Utils.addInnerEL(InnerMsgCode.BalanceChange, this, () => { - - }); + this.refreshCoinNum(); + }); Utils.addInnerEL(InnerMsgCode.VipExpireChange, this, () => { - + this.refreshVipExpire(); }); } @@ -150,9 +156,30 @@ export class ThemePanel extends li_BaseView { console.log("打开信箱"); } + // 刷新余额 + private refreshCoinNum() { + const walletData = DataManager.I.getDataById(DataId.Wallet); + const balance = walletData.getOriginalBalance(); + this.coinNum.string = balance.toString(); + } + + // 刷新 vip失效时间戳 + private refreshVipExpire() { + const walletData = DataManager.I.getDataById(DataId.Wallet); + const vipExpire = walletData.vipExpire; + // TODO + + } + onDestroy(): void { Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => { this.recName.string = LanguageUtils.getText(this.rectNameKey); }); + Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => { + + }); + Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => { + + }); } } diff --git a/assets/Scripts/chat18x/uiitems/DetailImageItem.ts b/assets/Scripts/chat18x/uiitems/DetailImageItem.ts index a359d4fd..b427134a 100644 --- a/assets/Scripts/chat18x/uiitems/DetailImageItem.ts +++ b/assets/Scripts/chat18x/uiitems/DetailImageItem.ts @@ -60,7 +60,16 @@ export class DetailImageItem extends Component { this.base.setVideEnable(true); }, }; - const isRelease = randomRange(0, 1) > 0.5; + // 数据 + const girlData = DataManager.I.getDataById(DataId.Girl); + let isRelease = false; + if (this.type === 1) { + // 图片 + isRelease = girlData.isImageUnlock(this.category.toString(), this.girlId, this.resId); + } else if (this.type === 2) { + // 视频 + isRelease = girlData.isVideoUnlock(this.category.toString(), this.girlId, this.resId); + } if (isRelease) { if (this.url) { ViewManager.I.openBundlesView("ShowPanel", data); @@ -68,6 +77,7 @@ export class DetailImageItem extends Component { } } else { ViewManager.I.openBundlesView("PopupGirlDetailPanel", { + category: this.category, resId: this.resId, girlId: this.girlId, base: this, @@ -142,8 +152,11 @@ export class DetailImageItem extends Component { let imgPath = ""; this.video.enabled = type === 2; this.priceFrame.active = type === 2; + let price = 0; + let isUnlock = false; if (type === 1) { // 图片 + price = girlData.getGrilPhotoOriginalPrice(this.category.toString(), this.girlId, this.resId); this.url = girlData.getGrilPhotoPic( this.category.toString(), this.girlId, @@ -151,8 +164,10 @@ export class DetailImageItem extends Component { ); imgPath = this.url; this.isImage = true; + isUnlock = girlData.isImageUnlock(this.category.toString(), this.girlId, this.resId); } else if (type === 2) { // 视频 + price = girlData.getGrilVideoOriginalPrice(this.category.toString(), this.girlId, this.resId); this.isImage = false; this.url = girlData.getGrilVideoPath( this.category.toString(), @@ -165,7 +180,7 @@ export class DetailImageItem extends Component { this.resId ); - const isUnlock = girlData.isVideoUnlock( + isUnlock = girlData.isVideoUnlock( this.category.toString(), this.girlId, this.resId @@ -175,9 +190,9 @@ export class DetailImageItem extends Component { } else { imgPath = this.url + "_thumbnail"; } - this.priceFrame.active = data.price > 0; + this.priceFrame.active = price > 0; - this.videoPrice.string = data.price.toString(); + this.videoPrice.string = price.toString(); } ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => { diff --git a/proto_cs b/proto_cs index f055100c..9ec1d4f0 160000 --- a/proto_cs +++ b/proto_cs @@ -1 +1 @@ -Subproject commit f055100cf0f378ddd96d8e153655b5166c65e6e8 +Subproject commit 9ec1d4f07754a1c91f80bf1e3c583d42e42049b2