| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { _decorator, Component, Node, Label } from 'cc';
- import { DataSystem } from '../core/data/DataSystem';
- import { Http } from '../core/net/Http';
- import { WindowSystem } from '../core/ui/window/WindowSystem';
- import { UserData } from '../data/UserData';
- const { ccclass, property, requireComponent } = _decorator;
- /**神台提现面板 */
- @ccclass('Withdrawal')
- @requireComponent(Http)
- export class Withdrawal extends Component {
- @property({ tooltip: "可提现余额", type: Label })
- public moneyLabel: Label;
- private userData: UserData;
- start() {
- this.userData = DataSystem.getData(UserData);
- this.moneyLabel.string = (this.userData.contribution / 10000).toFixed(2) + '元';
- }
- update() {
- DataSystem.watch(UserData, 'contribution') && (this.moneyLabel.string = (this.userData.contribution / 10000).toFixed(2) + '元');
- }
- /**
- * 贡献提现
- */
- public async onWithdrawal() {
- if (DataSystem.getData(UserData).contribution < 3000) {
- WindowSystem.showTips('提现金额小于0.3元,不能提现');
- return;
- }
- let result = await this.getComponent(Http).send("/api/user/Withdraw", { type: 1 });
- if (result && result.code && result.code > 0) {
- WindowSystem.showTips('提现失败,错误码:' + [result.code]);
- } else {
- if (result.message) {
- WindowSystem.showTips(result.message);
- }
- else {
- WindowSystem.showTips("提现成功,72小时内到账");
- DataSystem.getData(UserData).contribution = 0;
- }
- }
- }
- }
|