Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
# Conflicts: # assets/Scripts/chat18x/ui/panels/ThemePanel.ts
This commit is contained in:
@@ -8,6 +8,12 @@ import {
|
||||
UIOpacity,
|
||||
} from "cc";
|
||||
import { ChatController } from "../../core/ChatController";
|
||||
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';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PayToTalkSubpanel")
|
||||
@@ -24,6 +30,8 @@ export class PayToTalkSubpanel extends Component {
|
||||
vipBtnLabel: Label = null;
|
||||
|
||||
base: UIOpacity;
|
||||
categoryId: number;
|
||||
girlId: number;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.base = this.getComponent(UIOpacity);
|
||||
@@ -32,6 +40,8 @@ export class PayToTalkSubpanel extends Component {
|
||||
show(categoryId: string, girlId: number) {
|
||||
this.node.active = true;
|
||||
this.base.opacity = 0;
|
||||
this.categoryId = Number(categoryId);
|
||||
this.girlId = girlId;
|
||||
tween(this.base).to(0.3, { opacity: 255 }).start();
|
||||
}
|
||||
|
||||
@@ -54,11 +64,41 @@ export class PayToTalkSubpanel extends Component {
|
||||
onClick_BuyTime() {
|
||||
//购买次数
|
||||
//ChatController.Instance.resetChatCount();
|
||||
this.hide();
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const chatIds = shopData.getChatIds();
|
||||
console.log("聊天商品Id: ", chatIds);
|
||||
if (chatIds.length > 0) {
|
||||
this.reqBuyGood(chatIds[0], this.girlId);
|
||||
}
|
||||
}
|
||||
|
||||
onClick_BuyVip() {
|
||||
//购买VIP
|
||||
console.log("购买vip,未实现功能");
|
||||
console.log("购买vip");
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const memberId = shopData.get7DayMemberId();
|
||||
this.reqBuyGood(memberId, this.girlId);
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
async reqBuyGood(goodId: number, girlId: number) {
|
||||
// 请求购买商品
|
||||
const reqData = {
|
||||
goodId: goodId,
|
||||
girlId: girlId,
|
||||
};
|
||||
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);
|
||||
girlData.setChatRemainCount(this.categoryId.toString(), girlId, resData.chatRemainCount);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
walletData.balance = Number(resData.balance);
|
||||
walletData.vipExpire = Number(resData.vipExpire);
|
||||
// 刷新界面
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,14 @@ import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
||||
import { ThemeService } from "db://assets/Scripts/chat18x/network/services/ThemeService";
|
||||
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
|
||||
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
||||
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 { ShopData } from "../../data/ShopData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -117,6 +120,9 @@ export class ThemePanel extends li_BaseView {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 获取商品列表,提前把数据拿下来
|
||||
this.reqShopList();
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
@@ -193,6 +199,19 @@ export class ThemePanel extends li_BaseView {
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
// 获取商品列表
|
||||
async reqShopList() {
|
||||
// 请求购买商品
|
||||
const reqData = {};
|
||||
let res = await ShopService.I.reqShopList(reqData);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
shopData.goods = res.data;
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
||||
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
||||
|
||||
Reference in New Issue
Block a user