Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -93,6 +93,22 @@ export class ShopData extends BaseData {
|
|||||||
return resultId;
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取7天会员的 id */
|
||||||
|
public get7DayMemberId(): number {
|
||||||
|
const ids = this.getMemberIds();
|
||||||
|
const length = ids.length;
|
||||||
|
if (length <= 0) return 0;
|
||||||
|
return ids[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取30天会员的 id */
|
||||||
|
public get30DayMemberId(): number {
|
||||||
|
const ids = this.getMemberIds();
|
||||||
|
const length = ids.length;
|
||||||
|
if (length <= 1) return 0;
|
||||||
|
return ids[1];
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否是聊天商品,首位数字为 3 */
|
/** 是否是聊天商品,首位数字为 3 */
|
||||||
public isChatId(id: number): boolean {
|
public isChatId(id: number): boolean {
|
||||||
const firstDigit = id.toString()[0]; // 取首位字符
|
const firstDigit = id.toString()[0]; // 取首位字符
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { HttpShopService } from "./HttpShopService";
|
|||||||
import { MockShopService } from "./MockShopService";
|
import { MockShopService } from "./MockShopService";
|
||||||
|
|
||||||
// 模拟开关
|
// 模拟开关
|
||||||
const USE_MOCK = true;
|
const USE_MOCK = false;
|
||||||
|
|
||||||
export class ShopService implements IShopService {
|
export class ShopService implements IShopService {
|
||||||
private static _I: ShopService | null = null;
|
private static _I: ShopService | null = null;
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import { InnerEventCode, InnerMsgCode } from "../../../Main/Config/InnerMsgCode"
|
|||||||
import { DataManager, DataId } from "../../data/DataManager";
|
import { DataManager, DataId } from "../../data/DataManager";
|
||||||
import { WalletData } from "../../data/WalletData";
|
import { WalletData } from "../../data/WalletData";
|
||||||
import { ShopData } from "../../data/ShopData";
|
import { ShopData } from "../../data/ShopData";
|
||||||
|
import { GirlData } from "../../data/GirlData";
|
||||||
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
||||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||||
|
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -25,7 +27,6 @@ export class PurchasePanel extends li_BaseView {
|
|||||||
private vipTime7: Label;
|
private vipTime7: Label;
|
||||||
private vipPrice30: Label;
|
private vipPrice30: Label;
|
||||||
private vipTime30: Label;
|
private vipTime30: Label;
|
||||||
private tryBuyId: number;
|
|
||||||
|
|
||||||
@property([PurchasePanelItem])
|
@property([PurchasePanelItem])
|
||||||
public items: PurchasePanelItem[] = [];
|
public items: PurchasePanelItem[] = [];
|
||||||
@@ -53,26 +54,32 @@ export class PurchasePanel extends li_BaseView {
|
|||||||
|
|
||||||
bandBtn() {
|
bandBtn() {
|
||||||
GButton.BandClick(
|
GButton.BandClick(
|
||||||
this._nodeTab.BuyVipBtn,
|
this._nodeTab.Buy7DayVipBt,
|
||||||
() => {
|
() => {
|
||||||
//TODO:购买vip
|
//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
|
this
|
||||||
);
|
);
|
||||||
GButton.BandClick(
|
GButton.BandClick(
|
||||||
this._nodeTab.BuyDiamondBtn,
|
this._nodeTab.Buy30DayVipBtn,
|
||||||
() => {
|
() => {
|
||||||
//TODO:购买钻石
|
//TODO:购买vip
|
||||||
console.log("购买钻石,商品id:" + this.tryBuyId);
|
console.log("购买Vip 30");
|
||||||
|
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||||
|
const memberId = shopData.get30DayMemberId();
|
||||||
|
this.reqBuyGood(memberId);
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
GButton.BandClick(
|
GButton.BandClick(
|
||||||
this._nodeTab.QUIT,
|
this._nodeTab.ReturnBtn,
|
||||||
() => {
|
() => {
|
||||||
//TODO:购买钻石
|
this.onClose();
|
||||||
ViewManager.I.closeView(this.node);
|
GameRootUI.I.showDefaultView();
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
@@ -98,16 +105,12 @@ export class PurchasePanel extends li_BaseView {
|
|||||||
|
|
||||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||||
// VIP会员
|
// VIP会员
|
||||||
const memberIds = shopData.getMemberIds();
|
const memberId7 = shopData.get7DayMemberId();
|
||||||
for (let i = 0; i < memberIds.length; i++) {
|
const price7 = shopData.getOriginalPriceById(memberId7);
|
||||||
const id = memberIds[i];
|
this.vipPrice7.string = `$ ${price7}`;
|
||||||
const price = shopData.getOriginalPriceById(id);
|
const memberId30 = shopData.get30DayMemberId();
|
||||||
if (i === 0) {
|
const price30 = shopData.getOriginalPriceById(memberId30);
|
||||||
this.vipPrice7.string = `$ ${price}`;
|
this.vipPrice30.string = `$ ${price30}`;
|
||||||
} else if (i === 1) {
|
|
||||||
this.vipPrice30.string = `$ ${price}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 充值商品
|
// 充值商品
|
||||||
const rechargeIds = shopData.getRechargeIds();
|
const rechargeIds = shopData.getRechargeIds();
|
||||||
for (let index = 0; index < this.items.length; index++) {
|
for (let index = 0; index < this.items.length; index++) {
|
||||||
@@ -118,7 +121,7 @@ export class PurchasePanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDiamondTag(id: number) {
|
setDiamondTag(id: number) {
|
||||||
this.tryBuyId = id;
|
this.reqBuyGood(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayerMerData() {
|
getPlayerMerData() {
|
||||||
@@ -152,6 +155,27 @@ export class PurchasePanel extends li_BaseView {
|
|||||||
).replace("${leftTime}", leftTime);
|
).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() {
|
onDestroy() {
|
||||||
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {
|
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
uid: Label;
|
uid: Label;
|
||||||
itemInst: GirlListItem;
|
itemInst: GirlListItem;
|
||||||
content: Node;
|
content: Node;
|
||||||
|
private vipLeftTime: Label;
|
||||||
recId: number;
|
recId: number;
|
||||||
recName: Label;
|
recName: Label;
|
||||||
recSprite: Sprite;
|
recSprite: Sprite;
|
||||||
@@ -50,6 +50,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
this.uid = this._nodeTab.uid.getComponent(Label);
|
this.uid = this._nodeTab.uid.getComponent(Label);
|
||||||
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
||||||
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
||||||
|
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
||||||
|
|
||||||
this.registerListener();
|
this.registerListener();
|
||||||
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
||||||
@@ -63,6 +64,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
async Show() {
|
async Show() {
|
||||||
//some temp data
|
//some temp data
|
||||||
this.refreshCoinNum();
|
this.refreshCoinNum();
|
||||||
|
this.refreshVipExpire();
|
||||||
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
||||||
this.uid.string = "uid: " + accountData.accId;
|
this.uid.string = "uid: " + accountData.accId;
|
||||||
this.recId = 1;
|
this.recId = 1;
|
||||||
@@ -167,8 +169,10 @@ export class ThemePanel extends li_BaseView {
|
|||||||
private refreshVipExpire() {
|
private refreshVipExpire() {
|
||||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||||
const vipExpire = walletData.vipExpire;
|
const vipExpire = walletData.vipExpire;
|
||||||
// TODO
|
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
||||||
|
this.vipLeftTime.string = LanguageUtils.getText(
|
||||||
|
"purchasepanel.vip_left"
|
||||||
|
).replace("${leftTime}", leftTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy(): void {
|
onDestroy(): void {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { PurchasePanel } from "../ui/panels/PurchasePanel";
|
|||||||
import { PurchaseConfig } from "../../schema/schema";
|
import { PurchaseConfig } from "../../schema/schema";
|
||||||
import { DataManager, DataId } from "../data/DataManager";
|
import { DataManager, DataId } from "../data/DataManager";
|
||||||
import { ShopData } from "../data/ShopData";
|
import { ShopData } from "../data/ShopData";
|
||||||
|
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("PurchasePanelItem")
|
@ccclass("PurchasePanelItem")
|
||||||
@@ -17,6 +19,8 @@ export class PurchasePanelItem extends Component {
|
|||||||
public init(base: PurchasePanel, goodId: number) {
|
public init(base: PurchasePanel, goodId: number) {
|
||||||
this.baseView = base;
|
this.baseView = base;
|
||||||
this.goodId = goodId;
|
this.goodId = goodId;
|
||||||
|
|
||||||
|
GButton.BandClick(this.node, this.onClickThis, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public show() {
|
public show() {
|
||||||
@@ -27,8 +31,7 @@ export class PurchasePanelItem extends Component {
|
|||||||
this.price.string = price.toString();
|
this.price.string = price.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickThis() {
|
async onClickThis() {
|
||||||
this.baseView.setDiamondTag(this.goodId);
|
this.baseView.setDiamondTag(this.goodId);
|
||||||
console.log("点击了");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1746,7 +1746,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "text",
|
"_name": "vipText",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"__editorExtras__": {},
|
"__editorExtras__": {},
|
||||||
"_parent": {
|
"_parent": {
|
||||||
|
|||||||
+1
-1
Submodule proto_cs updated: f055100cf0...9ec1d4f077
Reference in New Issue
Block a user