|
@@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
|
|
|
import * as Parse from 'parse';
|
|
|
import { NavComponent } from '../../../app/components/nav/nav.component';
|
|
|
import { AiChatService } from '../../../services/aichart.service';
|
|
|
+import { HttpService } from '../../../services/http.service';
|
|
|
import {
|
|
|
ionicStandaloneModules,
|
|
|
ToastController,
|
|
@@ -16,22 +17,22 @@ import {
|
|
|
imports: [...ionicStandaloneModules, NavComponent, CommonModule, FormsModule],
|
|
|
})
|
|
|
export class WithdrawalComponent implements OnInit {
|
|
|
- constructor(
|
|
|
- private toastController: ToastController,
|
|
|
- private aiServ: AiChatService
|
|
|
- ) {}
|
|
|
+ rate: number = 0.1; //提现手续费率
|
|
|
+ service: number = 0; //提现手续费
|
|
|
+ received_price: number = 0; //实际到账金额
|
|
|
price: number = 0;
|
|
|
- income:{
|
|
|
- balance:number,
|
|
|
- used:number,
|
|
|
- total:number
|
|
|
+
|
|
|
+ income: {
|
|
|
+ balance: number;
|
|
|
+ used: number;
|
|
|
+ total: number;
|
|
|
} = {
|
|
|
- balance:0,
|
|
|
- used:0,
|
|
|
- total:0
|
|
|
- }
|
|
|
+ balance: 0,
|
|
|
+ used: 0,
|
|
|
+ total: 0,
|
|
|
+ };
|
|
|
|
|
|
- bankinfo: {
|
|
|
+ bankInfo: {
|
|
|
bankname: string;
|
|
|
name: string;
|
|
|
mobile: string;
|
|
@@ -42,12 +43,22 @@ export class WithdrawalComponent implements OnInit {
|
|
|
mobile: '',
|
|
|
bankcard: '',
|
|
|
};
|
|
|
- data: any = [
|
|
|
- { value: 0, name: '银行卡' },
|
|
|
- { value: 1, name: '微信' },
|
|
|
- ];
|
|
|
+ alipayInfo: {
|
|
|
+ alipay: string;
|
|
|
+ name: string;
|
|
|
+ } = {
|
|
|
+ alipay: '',
|
|
|
+ name: '',
|
|
|
+ };
|
|
|
value: Number = 0;
|
|
|
account?: Parse.Object;
|
|
|
+ type: string = '银行卡'; //提现方式
|
|
|
+ isOpenModal: boolean = false;
|
|
|
+ constructor(
|
|
|
+ private toastController: ToastController,
|
|
|
+ private http: HttpService,
|
|
|
+ private aiServ: AiChatService
|
|
|
+ ) {}
|
|
|
ngOnInit() {
|
|
|
this.getAccount();
|
|
|
}
|
|
@@ -58,56 +69,71 @@ export class WithdrawalComponent implements OnInit {
|
|
|
query.equalTo('company', this.aiServ.company);
|
|
|
this.account = await query.first();
|
|
|
if (this.account?.get('bank')) {
|
|
|
- this.bankinfo = this.account?.get('bank')[0];
|
|
|
+ this.bankInfo = this.account?.get('bank')[0];
|
|
|
}
|
|
|
console.log(this.account);
|
|
|
let anthorWallet = await this.aiServ.getAuthorWallet(id!);
|
|
|
this.income = anthorWallet;
|
|
|
}
|
|
|
- onChangePrice(){
|
|
|
+ onChangeSex(e: any) {
|
|
|
+ this.type = e.detail.value;
|
|
|
+ console.log(this.type);
|
|
|
+ }
|
|
|
+ onChangePrice() {
|
|
|
this.price = Math.round(this.price * 100) / 100;
|
|
|
}
|
|
|
- async withdrawal() {
|
|
|
+ openModal() {
|
|
|
if (
|
|
|
- !this.bankinfo.bankname ||
|
|
|
- !this.bankinfo.bankcard ||
|
|
|
- !this.bankinfo.mobile
|
|
|
+ this.type == '支付宝' &&
|
|
|
+ Object.values(this.alipayInfo).some(
|
|
|
+ (item) => item == '' || item == undefined
|
|
|
+ )
|
|
|
) {
|
|
|
- this.toast('请先绑定银行卡', 1500);
|
|
|
+ this.toast('请填写提现信息', 1500);
|
|
|
return;
|
|
|
+ } else if (
|
|
|
+ this.type == '银行卡' &&
|
|
|
+ Object.values(this.bankInfo).some(
|
|
|
+ (item) => item == '' || item == undefined
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ this.toast('请填写提现信息', 1500);
|
|
|
+ return
|
|
|
}
|
|
|
- if (!this.price || this.price < 0) {
|
|
|
- this.toast('请输入正确金额', 1500);
|
|
|
+ if (this.price < 200) {
|
|
|
+ this.toast('最低提现金额为200', 1500);
|
|
|
return;
|
|
|
}
|
|
|
if (this.income.balance < this.price) {
|
|
|
- this.toast('提现金额不得超过余额!', 1500);
|
|
|
+ this.toast('申请提现金额不得超过可提现余额', 1500);
|
|
|
return;
|
|
|
}
|
|
|
- if (this.price < 100) {
|
|
|
- this.toast('最低提现金额为100', 1500);
|
|
|
- return;
|
|
|
+ // this.service = Math.round(this.price * this.rate * 100) / 100;
|
|
|
+ this.isOpenModal = true;
|
|
|
+ }
|
|
|
+ async confirm() {
|
|
|
+ // if (!this.price || this.price < 0) {
|
|
|
+ // this.toast('请输入正确金额', 1500);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ let params = {
|
|
|
+ uid: Parse.User.current()?.id,
|
|
|
+ price: this.price,
|
|
|
+ bankInfo: this.bankInfo,
|
|
|
+ };
|
|
|
+ let res = await this.http.httpRequst(
|
|
|
+ 'https://server.fmode.cn/api/ailiao/withdraw',
|
|
|
+ params,
|
|
|
+ 'POST'
|
|
|
+ );
|
|
|
+ console.log(res);
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.toast('申请成功', 1500, 'success');
|
|
|
+ } else {
|
|
|
+ this.toast(res.message, 1500);
|
|
|
+ return
|
|
|
}
|
|
|
- let UserAgentWithdraw = Parse.Object.extend('UserAgentWithdraw');
|
|
|
- let userAgentWithdraw = new UserAgentWithdraw();
|
|
|
- userAgentWithdraw.set('count', Number(this.data.price));
|
|
|
- userAgentWithdraw.set('type', 'bank');
|
|
|
- userAgentWithdraw.set('name', this.bankinfo.name);
|
|
|
- userAgentWithdraw.set('count', this.price);
|
|
|
- userAgentWithdraw.set('status', '100');
|
|
|
- userAgentWithdraw.set('company', {
|
|
|
- __type: 'Pointer',
|
|
|
- className: 'Company',
|
|
|
- objectId: this.aiServ.company,
|
|
|
- });
|
|
|
- userAgentWithdraw.set('user', {
|
|
|
- __type: 'Pointer',
|
|
|
- className: '_User',
|
|
|
- objectId: Parse.User.current()?.id,
|
|
|
- });
|
|
|
- userAgentWithdraw.set('bank', this.bankinfo);
|
|
|
- await userAgentWithdraw.save();
|
|
|
- this.toast('申请成功', 1500);
|
|
|
+ this.isOpenModal = false;
|
|
|
history.back();
|
|
|
}
|
|
|
|