更新聊天次数购买弹窗
修复bug
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
import {
|
||||
_decorator,
|
||||
Component,
|
||||
Label,
|
||||
Node,
|
||||
Sprite,
|
||||
tween,
|
||||
UIOpacity,
|
||||
} from "cc";
|
||||
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import { ShopData } from "../../data/ShopData";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import { ConfigId, ConfigManager } from "../../manager/ConfigManager";
|
||||
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { TipsPanel } from "./TipsPanel";
|
||||
import { NavigationManager } from "../../manager/NavigationManager";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PayToTalkPanel")
|
||||
export class PayToTalkPanel extends li_BaseView {
|
||||
base: UIOpacity;
|
||||
|
||||
categoryId: string;
|
||||
girlId: number;
|
||||
openUIDataCT(data) {
|
||||
this.categoryId = data.categoryId;
|
||||
this.girlId = data.girlId;
|
||||
}
|
||||
onLoadCT(): void {
|
||||
this.base = this.getComponent(UIOpacity);
|
||||
this.show();
|
||||
}
|
||||
|
||||
show() {
|
||||
if (!this.base) this.base = this.getComponent(UIOpacity);
|
||||
this.node.active = true;
|
||||
this.base.opacity = 0;
|
||||
|
||||
const cfg = ConfigManager.I.getDataById<PurchaseConfig>(ConfigId.Purchase);
|
||||
|
||||
tween(this.base).to(0.3, { opacity: 255 }).start();
|
||||
}
|
||||
|
||||
hide() {
|
||||
tween(this.base)
|
||||
.to(
|
||||
0.3,
|
||||
{ opacity: 0 },
|
||||
{
|
||||
onComplete: () => {
|
||||
NavigationManager.Instance.closePopupPanel(this.node);
|
||||
},
|
||||
}
|
||||
)
|
||||
.start();
|
||||
}
|
||||
|
||||
refresh() {}
|
||||
|
||||
onClick_BuyTime() {
|
||||
//购买次数
|
||||
//ChatController.Instance.resetChatCount();
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const chatIds = shopData.getChatIds();
|
||||
logger.log("聊天商品Id: ", chatIds);
|
||||
if (chatIds.length > 0) {
|
||||
this.reqBuyGood(chatIds[0], this.girlId);
|
||||
}
|
||||
}
|
||||
|
||||
onClick_BuyVip() {
|
||||
//购买VIP
|
||||
logger.log("购买vip");
|
||||
// const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
// const memberId = shopData.get7DayMemberId();
|
||||
// this.reqBuyGood(memberId, this.girlId);
|
||||
NavigationManager.Instance.openPopupPanel("PurchasePanel");
|
||||
}
|
||||
onClickClose() {
|
||||
this.hide();
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
async reqBuyGood(goodId: number, girlId: number) {
|
||||
// 请求购买商品
|
||||
const reqData = {
|
||||
goodId: goodId,
|
||||
girlId: girlId,
|
||||
};
|
||||
let res = await ShopService.I.reqBuyGood(reqData);
|
||||
logger.log("请求使用余额购买商品的响应数据:", res);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
girlData.setChatRemainCount(
|
||||
this.categoryId,
|
||||
girlId,
|
||||
resData.chatRemainCount
|
||||
);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
walletData.balance = Number(resData.balance);
|
||||
walletData.vipExpire = Number(resData.vipExpire);
|
||||
// 刷新界面
|
||||
TipsPanel.show(LanguageUtils.getText("payment.succeed"));
|
||||
|
||||
this.hide();
|
||||
} else {
|
||||
if (res && res.code) {
|
||||
const key = "error_code_" + res.code;
|
||||
TipsPanel.show(LanguageUtils.getText(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user