bayi před 1 rokem
rodič
revize
d3744b7410

+ 2 - 0
api/sale.js

@@ -15,4 +15,6 @@ module.exports = {
     getSaleOrder: data => request('/v3/sale/order', 'get', data),
     // 获取收益明细列表
     getIncomeList: data => request('/v3/sale/income/list', 'get', data),
+    // 提现
+    cashOut: data => request('/v3/sale/income/cash', 'get', data),
 }

+ 2 - 3
salesperson/pages/history/index.less

@@ -10,7 +10,7 @@
     }
 
     .total {
-        margin: 16rpx 0 0;
+        margin: 12rpx 0 0;
         background: #FFFFFF;
         border-radius: 20rpx;
 
@@ -28,8 +28,7 @@
         top: 0;
         left: 0;
         height: 100vh;
-        padding-top: 250rpx;
-        padding-bottom: 130rpx;
+        padding: 250rpx 14rpx 130rpx;
         box-sizing: border-box;
         z-index: -1;
 

+ 2 - 3
salesperson/pages/history/index.wxss

@@ -9,7 +9,7 @@
   background: #FFFAEA;
 }
 .container .total {
-  margin: 16rpx 0 0;
+  margin: 12rpx 0 0;
   background: #FFFFFF;
   border-radius: 20rpx;
 }
@@ -25,8 +25,7 @@
   top: 0;
   left: 0;
   height: 100vh;
-  padding-top: 250rpx;
-  padding-bottom: 130rpx;
+  padding: 250rpx 14rpx 130rpx;
   box-sizing: border-box;
   z-index: -1;
 }

+ 44 - 22
salesperson/pages/withdrawal/index.js

@@ -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: ""

+ 2 - 2
salesperson/pages/withdrawal/index.wxml

@@ -7,8 +7,8 @@
             <view class="title">提现金额</view>
             <view class="inputBox">
                 <view class="icon">¥</view>
-                <input class="input" type="number" placeholder="可提现金额{{filters.twoDecimal(allIncome.withdraw)}}元"
-                    maxlength="5" value="{{money}}" bindinput="setMoney" />
+                <input class="input" type="digit" placeholder="可提现金额{{filters.twoDecimal(allIncome.withdraw)}}元"
+                    maxlength="7" value="{{money}}" bindinput="setMoney" />
                 <view class="close" bindtap="clearMoney">×</view>
             </view>
             <view class="warning" wx:if="{{errMsg!=''}}">{{errMsg}}</view>