|
@@ -1,5 +1,6 @@
|
|
|
import {
|
|
|
- getSaleData
|
|
|
+ getSaleData,
|
|
|
+ cashOut
|
|
|
} from '~/api/sale'
|
|
|
import event from '~/mixins/event'
|
|
|
Page({
|
|
@@ -10,37 +11,58 @@ Page({
|
|
|
errMsg: '',
|
|
|
activationModal: false,
|
|
|
},
|
|
|
- async onShow() {
|
|
|
+ onShow() {
|
|
|
+ this.getIncome()
|
|
|
+ },
|
|
|
+ async getIncome() {
|
|
|
let allIncome = await getSaleData()
|
|
|
this.setData({
|
|
|
allIncome
|
|
|
})
|
|
|
},
|
|
|
- withdrawalFun() {
|
|
|
- if (this.data.money <= 0) {
|
|
|
- this.setData({
|
|
|
- errMsg: '请输入要提现的金额'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.data.money > this.data.allIncome.withdraw / 100) {
|
|
|
- this.setData({
|
|
|
- errMsg: '可提现金额不足'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.data.money > 500 || this.data.money < 50) {
|
|
|
- this.setData({
|
|
|
- errMsg: '提现金额需≥50元,单笔最高可提500元'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ async withdrawalFun() {
|
|
|
+ let money = this.data.money
|
|
|
+ /* if (isNaN(money)) {
|
|
|
+ this.setData({
|
|
|
+ errMsg: '金额不合法'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 判断金额是否超过两位小数
|
|
|
+ var decimalCount = (money.split('.')[1] || '').length;
|
|
|
+ if (decimalCount > 2) {
|
|
|
+ this.setData({
|
|
|
+ errMsg: '最多两位小数'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (money <= 0) {
|
|
|
+ this.setData({
|
|
|
+ errMsg: '请输入要提现的金额'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (money > this.data.allIncome.withdraw / 100) {
|
|
|
+ this.setData({
|
|
|
+ errMsg: '可提现金额不足'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (money > 500 || money < 50) {
|
|
|
+ this.setData({
|
|
|
+ errMsg: '提现金额需≥50元,单笔最高可提500元'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } */
|
|
|
+ let res = await cashOut({
|
|
|
+ amount: money * 100
|
|
|
+ })
|
|
|
this.setData({
|
|
|
activationModal: true,
|
|
|
})
|
|
|
+ this.getIncome()
|
|
|
},
|
|
|
clearMoney() {
|
|
|
- console.log('11');
|
|
|
this.setData({
|
|
|
money: "",
|
|
|
errMsg: ""
|