123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import {
- getSaleData,
- cashOut
- } from '~/api/sale'
- import event from '~/mixins/event'
- Page({
- behaviors: [event],
- data: {
- allIncome: {},
- money: '',
- errMsg: '',
- activationModal: false,
- },
- onShow() {
- this.getIncome()
- },
- async getIncome() {
- let allIncome = await getSaleData()
- this.setData({
- allIncome
- })
- },
- 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() {
- this.setData({
- money: "",
- errMsg: ""
- });
- },
- setMoney({
- detail
- }) {
- this.setData({
- money: detail.value
- });
- },
- jump({
- currentTarget
- }) {
- wx.navigateTo({
- url: `/salesperson/pages/${currentTarget.dataset.url}/index`,
- })
- },
- closeModal() {
- this.setData({
- activationModal: false
- })
- },
- })
|