123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- import HTTPS, { NetGet, NetPost } from "./HTTPS";
- import Tips from "./Tips";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class withdraw extends cc.Component {
- @property(cc.Node)
- RuleContent: cc.Node = null;
- @property(cc.Node)
- withdrawContent: cc.Node = null;
- @property(cc.Node)
- HistoryContent: cc.Node = null;
- @property(cc.Node)
- HistoryItem: cc.Node = null;
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- this.RuleContent.active = false
- let Close = this.node.getChildByName("Close")
- vv.deleteBtnEvent(Close, this)
- vv.addBtnEvent(Close, () => {
- this.node.active = false
- }, this)
- }
- protected onEnable(): void {
- this.getRule()
- }
- getRule() {
- let withdraw = this.node.getChildByName("withdraw")
- let history = this.node.getChildByName("history")
- withdraw.active = false
- history.active = false
- let Rule = this.node.getChildByName("Rule")
- Rule.active = true
- HTTPS.Instance.get(NetGet.rule).then(res => {
- if (res.code != 200) {
- Tips.Instance.show(res.msg)
- return
- }
- this.RuleContent.children[0].getChildByName("title").getComponent(cc.Label).string = '最小提现金额'
- this.RuleContent.children[0].getChildByName("reward").getComponent(cc.Label).string = res.data.min_amount
- this.RuleContent.children[1].getChildByName("title").getComponent(cc.Label).string = '最大提现金额'
- this.RuleContent.children[1].getChildByName("reward").getComponent(cc.Label).string = res.data.max_amount
- this.RuleContent.children[2].getChildByName("title").getComponent(cc.Label).string = '手续费率'
- this.RuleContent.children[2].getChildByName("reward").getComponent(cc.Label).string = res.data.fee_rate + '%'
- this.RuleContent.children[3].getChildByName("title").getComponent(cc.Label).string = '每日最大提现次数'
- this.RuleContent.children[3].getChildByName("reward").getComponent(cc.Label).string = res.data.daily_times
- this.RuleContent.children[4].getChildByName("title").getComponent(cc.Label).string = '今日已提现次数'
- this.RuleContent.children[4].getChildByName("reward").getComponent(cc.Label).string = res.data.today_times
- this.RuleContent.children[5].getChildByName("title").getComponent(cc.Label).string = '剩余提现次数'
- this.RuleContent.children[5].getChildByName("reward").getComponent(cc.Label).string = res.data.remain_times
- this.RuleContent.children[6].getChildByName("title").getComponent(cc.Label).string = '用户余额'
- this.RuleContent.children[6].getChildByName("reward").getComponent(cc.Label).string = res.data.balance
- this.RuleContent.active = true
- })
- }
- getwithdraw() {
- let Rule = this.node.getChildByName("Rule")
- let history = this.node.getChildByName("history")
- Rule.active = false
- history.active = false
- let withdraw = this.node.getChildByName("withdraw")
- withdraw.active = true
- }
- btnwithdraw() {
- let total = this.node.getComponentsInChildren(cc.EditBox)
-
- if (!total[0]?.string) {
- Tips.Instance.show('提现金额不能未空')
- return
- }
- if (!total[1].string) {
- Tips.Instance.show('提现方式不能未空')
- return
- }
- if (!total[2].string) {
- Tips.Instance.show('提现账号不能未空')
- return
- }
- if (!total[3].string) {
- Tips.Instance.show('真实姓名不能未空')
- return
- }
- HTTPS.Instance.post(NetPost.withdraw, {
- amount: total[0].string,//提现金额
- withdraw_type: total[1].string,//提现方式(alipay/wxpay/bank)
- account: total[2].string,//提现账号
- real_name:total[3].string,// 真实姓名
- }).then(res => {
- if (res.code != 200) {
- Tips.Instance.show(res.msg)
- return
- }
- Tips.Instance.show(res.msg)
- })
- }
- getwHistory() {
- let Rule = this.node.getChildByName("Rule")
- let withdraw = this.node.getChildByName("withdraw")
- Rule.active = false
- withdraw.active = false
- let history = this.node.getChildByName("history")
- history.active = true
- HTTPS.Instance.get(NetGet.withdrawHistory).then(res => {
- if (res.code != 200) {
- Tips.Instance.show(res.msg)
- return
- }
- this.HistoryContent.children.forEach(e => {
- e.active = false
- })
- for (let index = 0; index < res.data.list.length; index++) {
- const Data = res.data.list[index];
- let Node = this.HistoryContent[index] as cc.Node;
- if (!Node) {
- Node = cc.instantiate(this.HistoryItem) as cc.Node
- Node.parent = this.HistoryContent
- }
- let title = Node.getChildByName("title").getComponent(cc.Label)
- let type = Node.getChildByName("type").getComponent(cc.Label)
- let reward = Node.getChildByName("reward").getComponent(cc.Label)
- title.string = Data.withdraw_type_text + Data.actual_amount.toString()
- type.string = Data.status_text
- reward.string = Data.createtime
- Node.active = true
- }
- })
- }
- // update (dt) {}
- }
|