Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -11,8 +11,10 @@ import { InnerEventCode, InnerMsgCode } from "../../../Main/Config/InnerMsgCode"
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import { ShopData } from "../../data/ShopData";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -25,7 +27,6 @@ export class PurchasePanel extends li_BaseView {
|
||||
private vipTime7: Label;
|
||||
private vipPrice30: Label;
|
||||
private vipTime30: Label;
|
||||
private tryBuyId: number;
|
||||
|
||||
@property([PurchasePanelItem])
|
||||
public items: PurchasePanelItem[] = [];
|
||||
@@ -53,26 +54,32 @@ export class PurchasePanel extends li_BaseView {
|
||||
|
||||
bandBtn() {
|
||||
GButton.BandClick(
|
||||
this._nodeTab.BuyVipBtn,
|
||||
this._nodeTab.Buy7DayVipBt,
|
||||
() => {
|
||||
//TODO:购买vip
|
||||
console.log("购买Vip");
|
||||
console.log("购买Vip 7");
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const memberId = shopData.get7DayMemberId();
|
||||
this.reqBuyGood(memberId);
|
||||
},
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this._nodeTab.BuyDiamondBtn,
|
||||
this._nodeTab.Buy30DayVipBtn,
|
||||
() => {
|
||||
//TODO:购买钻石
|
||||
console.log("购买钻石,商品id:" + this.tryBuyId);
|
||||
//TODO:购买vip
|
||||
console.log("购买Vip 30");
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const memberId = shopData.get30DayMemberId();
|
||||
this.reqBuyGood(memberId);
|
||||
},
|
||||
this
|
||||
);
|
||||
);
|
||||
GButton.BandClick(
|
||||
this._nodeTab.QUIT,
|
||||
this._nodeTab.ReturnBtn,
|
||||
() => {
|
||||
//TODO:购买钻石
|
||||
ViewManager.I.closeView(this.node);
|
||||
this.onClose();
|
||||
GameRootUI.I.showDefaultView();
|
||||
},
|
||||
this
|
||||
);
|
||||
@@ -98,16 +105,12 @@ export class PurchasePanel extends li_BaseView {
|
||||
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
// VIP会员
|
||||
const memberIds = shopData.getMemberIds();
|
||||
for (let i = 0; i < memberIds.length; i++) {
|
||||
const id = memberIds[i];
|
||||
const price = shopData.getOriginalPriceById(id);
|
||||
if (i === 0) {
|
||||
this.vipPrice7.string = `$ ${price}`;
|
||||
} else if (i === 1) {
|
||||
this.vipPrice30.string = `$ ${price}`;
|
||||
}
|
||||
}
|
||||
const memberId7 = shopData.get7DayMemberId();
|
||||
const price7 = shopData.getOriginalPriceById(memberId7);
|
||||
this.vipPrice7.string = `$ ${price7}`;
|
||||
const memberId30 = shopData.get30DayMemberId();
|
||||
const price30 = shopData.getOriginalPriceById(memberId30);
|
||||
this.vipPrice30.string = `$ ${price30}`;
|
||||
// 充值商品
|
||||
const rechargeIds = shopData.getRechargeIds();
|
||||
for (let index = 0; index < this.items.length; index++) {
|
||||
@@ -118,7 +121,7 @@ export class PurchasePanel extends li_BaseView {
|
||||
}
|
||||
|
||||
setDiamondTag(id: number) {
|
||||
this.tryBuyId = id;
|
||||
this.reqBuyGood(id);
|
||||
}
|
||||
|
||||
getPlayerMerData() {
|
||||
@@ -152,6 +155,27 @@ export class PurchasePanel extends li_BaseView {
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
async reqBuyGood(goodId: number) {
|
||||
// 请求购买商品
|
||||
const reqData = {
|
||||
goodId: goodId,
|
||||
girlId: 0,
|
||||
};
|
||||
let res = await ShopService.I.reqBuyGood(reqData);
|
||||
console.log("请求使用余额购买商品的响应数据:", res);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
walletData.balance = Number(resData.balance);
|
||||
walletData.vipExpire = Number(resData.vipExpire);
|
||||
// 刷新界面
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export class ThemePanel extends li_BaseView {
|
||||
uid: Label;
|
||||
itemInst: GirlListItem;
|
||||
content: Node;
|
||||
|
||||
private vipLeftTime: Label;
|
||||
recId: number;
|
||||
recName: Label;
|
||||
recSprite: Sprite;
|
||||
@@ -50,6 +50,7 @@ export class ThemePanel extends li_BaseView {
|
||||
this.uid = this._nodeTab.uid.getComponent(Label);
|
||||
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
||||
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
||||
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
||||
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
||||
@@ -63,6 +64,7 @@ export class ThemePanel extends li_BaseView {
|
||||
async Show() {
|
||||
//some temp data
|
||||
this.refreshCoinNum();
|
||||
this.refreshVipExpire();
|
||||
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
||||
this.uid.string = "uid: " + accountData.accId;
|
||||
this.recId = 1;
|
||||
@@ -167,8 +169,10 @@ export class ThemePanel extends li_BaseView {
|
||||
private refreshVipExpire() {
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const vipExpire = walletData.vipExpire;
|
||||
// TODO
|
||||
|
||||
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
|
||||
Reference in New Issue
Block a user