| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- cc.Class({
- extends: cc.Component,
- properties: {
- amountValue: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- inputContainer: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- inputInviteValue: {
- default: 1,
- visible: false
- },
- isOutCnt: false,
- },
- inputValue(value, e) {
- var numberTemp = new RegExp("^[A-Za-z0-9]+$");
- if (numberTemp.test(value)) {
- if (Number(value) >= 1) {
- this.inputInviteValue = Number(value);
- } else {
- this.inputInviteValue = 1;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
- }
- } else {
- this.inputInviteValue = 1;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
- console.log("请输入整数的倍数", this.inputInviteValue);
- }
- },
- setInfo() {
- this.amountValue.string = Math.floor( GlobalD.GameData.CNTDrawBalance * 100) / 100;
- },
- onclose() {
- this.node.active = false;
- },
-
- onPanelCntWithdraw() {
- //todo 判断一下amount
- console.log(this.inputInviteValue,GlobalD.GameData.CNTDrawBalance);
- if (this.inputInviteValue > GlobalD.GameData.CNTDrawBalance) {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "提现的cnt不足!", 2, () => {
- console.log("finish toast!");
- });
- return;
- }
- if (this.isOutCnt) {
- console.warn("点击提现过快!");
- return;
- }
- this.isOutCnt = true;
- GlobalD.GameData.onCntWithdraw(this.inputInviteValue, (data) => {
- this.isOutCnt = false;
- const [err, tx] = data;
- if (err === null) {
- console.log(tx) //String|null 交易唯一哈市
- GlobalD.GameData.onCntCanWithdrawBalance((data) => {
- console.log("站内收益余额:",GlobalD.GameData.CNTDrawBalance);
- //更新数据
- this.setInfo();
- });
- //更新钱包余额,
- GlobalD.dapp.cntBalance().then((cntBalance) => {
- // console.log("更新cnt:" + cntBalance) // string, 精度18,需要自行处理省略几位小数
- GlobalD.GameData.SetCNT(cntBalance);
- });
- //更新日志数据
- cc.find("GameNode/ManageDapp").getComponent("ManageDapp").onUpdateCntList();
-
-
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "成功提现!", 1, () => {
- console.log("finish toast!");
- });
- } else {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), err, 2, () => {
- console.log("finish toast!");
- });
- }
- });
- }
- });
|