| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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]+$");
- // this.inputInviteValue = value.replace(/[^\d^\.]+/g, '');
- // this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
- 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 = 0;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
- console.log("请输入整数的倍数", this.inputInviteValue);
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "请输入整数提现!", 1);
- }
- },
- 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(0 === this.inputInviteValue || this.inputInviteValue.length == 0){
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "请输入提现的数量", 1);
- return;
- }
- if (this.inputInviteValue > GlobalD.GameData.CNTDrawBalance) {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "提现的cnt不足!", 2);
- 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);
- } else {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), err, 2);
- }
- });
- }
- });
|