| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { _decorator, Component, EditBox, EventHandle, EventHandler, js, Label, Node, utils } from 'cc';
- import { UtilsPanel } from '../../scene/script/UtilsPanel';
- import { Pay } from './Pay';
- const { ccclass } = _decorator;
- @ccclass('PayCustom')
- export class PayCustom extends Component {
-
- private lb_gold: Label = null;
- private edit_money: EditBox = null;
- private money = 0;
- protected onLoad(){
- UtilsPanel.getAllNeedCom(this, this.node, false);
- let handler = new EventHandler();
- handler.target = this.node;
- handler.component = js.getClassName(this);
- handler.handler = "checkNum";
- this.edit_money.textChanged.push(handler)
- }
- protected start(): void {
- this.money = Pay.data_shop.MinMoney;
- this.edit_money.string = this.money + "";
- this.refreshGold();
- }
- private checkNum(text: string){
- let index = text.indexOf(".");
- let revise = false;
- if(index > -1){
- revise = true;
- text = text.replace(".", "");
- }
- let num = parseInt(text);
- if(num < Pay.data_shop.MinMoney){
- revise = true;
- num = Pay.data_shop.MinMoney
- text = "" + num;
- }
- if(revise){
- //@ts-ignore
- this.edit_money._impl._edTxt.value = text;
- this.edit_money.string = text;
- }
- if(num != this.money){
- this.money = num;
- this.refreshGold();
- }
- }
- private refreshGold(){
- this.lb_gold.string = Pay.clacGold(this.money) + "";
- }
- private onCloseClick(){
- this.node.destroy();
- }
- private onBuyClick(){
- Pay.buy(this.money);
- }
- }
|