import { _decorator, Component, Node, EditBox, Label, loader, log } from "cc"; const { ccclass, property } = _decorator; import { rachageModel } from "./rachageModel"; // import { tanchuan } from "./TanChuang"; import BigNumber from "bignumber.js"; import TBG from "./tgb"; const ETH_CONTRACT = "0x3865194cD048f7b14b465a96907fB6546B888216"; @ccclass("rechargeNum") export class rechargeNum extends Component { data = {}; @property(Label) public Name = null; @property(Label) public EthPrice = null; @property(Label) public UsdtPrice = null; @property(rachageModel) RachageModel: rachageModel = null; @property(EditBox) RechageNum: EditBox | null = null; @property(Label) privateddress: Label | null = null; @property(Label) Eth: Label | null = null; public_address = null; private_address = null; init(data) { this.node.getChildByName("name").getComponent(Label).string = data.name; this.node.getChildByName("usdtPrice").getComponent(Label).string = data.usdt_price; this.node.getChildByName("ethPrice").getComponent(Label).string = data.eth_price; this.node.getChildByName("privateddress").getComponent(Label).string = data.private_address; localStorage.setItem("address", data.private_address); } rechagenum = null; start() { // this.private_address = this.node.getChildByName("privateddress"); // this.rechagenum = this.node.getChildByName("RechageNum"); } initData() { let to_address = this.public_address.getComponent(Label).string; let number = this.rechagenum.getComponent(EditBox).string; let data = { to_address: to_address, number: number, }; console.log(data); return data; } // async text() { // const tbg = new TBG({}); // const account = await tbg.login(); // const data = {}; // let address = localStorage.getItem("address"); // console.log(address); // let num = new BigNumber(Number(this.RechageNum.string)); // let eth = new BigNumber(Number(this.Eth.string)); // log(eth, num); // const ReNum = new BigNumber(10 ** 18).times(num); // const number = ReNum.times(eth); // console.log(number); // const res = await tbg.sendTransaction({ // from: account, // to: address, // value: number, // }); // console.log(res); // } update(deltaTime: number) {} }