-
zhangwei
2024-09-30 2e61c194b816364fe4fbab967fee13dbefe86216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<template>
    <view class="full-page">
        <view class="content">
            <view class="balance">
                <view class="header chuany-flex chuany-justify-between chuany-align-center chuany-flex-wrap">
                    <view class="left chuany-align-center">
                        <text class="chuany-font40 c-p-r-10">¥</text>
                        <up-input border="surround" v-model="money" type="digit"></up-input>
                    </view>
                    <view class="right">
                        <up-button type="warning" size="small" shape="circle" text='提现'
                            @click='GetTransferMoney'></up-button>
                    </view>
                    <view class="chuany-font28">
                        可提现余额:¥<text class="c-p-l-10">{{balance}} 元</text>
                    </view>
                    <view class="chuany-font20 attention">
                        *注:最低提现0.3元,每日提现不可超过2000元
                    </view>
                </view>
 
            </view>
        </view>
    </view>
</template>
 
<script>
    import {
        mapActions,
        mapGetters,
        mapMutations
    } from 'vuex'
    export default {
        data() {
            return {
                money: null
            }
        },
        computed: {
            ...mapGetters(['userInfo', 'identity']),
            balance() {
                // if (this.identity == 'worker') {
                if (this.userInfo.userWorker) {
                    return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
                        .userWorker
                        .yiTiXianJine)
                } else {
                    return '0.00'
                }
                // } else {
                //     if (this.userInfo.userCompany) {
                //         return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
                //             .chongZhiYue :
                //             '0.00'
                //     } else {
                //         return '0.00'
                //     }
                // }
            }
        },
        onLoad() {},
        methods: {
            ...mapActions([
                'getUserInfo'
            ]),
            stringToNumber(str) {
                const match = str.match(/[\d.]+/); // 正则表达式匹配数字和点
                if (match) {
                    return parseFloat(match[0]); // 使用parseFloat转换
                }
                return 0; // 如果没有匹配到数字,返回NaN
            },
            GetTransferMoney() {
                if (!this.money) {
                    this.$util.showToast({
                        title: "请输入金额!",
                        icon: 'error'
                    });
                    return false
                }
                if (this.money < 0.3) {
                    this.$util.showToast({
                        title: "最低提现0.3元!",
                        icon: 'error'
                    });
                    return false
                }
                if (this.stringToNumber(this.money) > this.stringToNumber(this.balance)) {
                    this.$util.showToast({
                        title: "输入金额大于可提现金额!"
                    });
                    return false
                }
                this.$api.GetTransferMoney(this.money).then(res => {
                    if (res.code == 1) {
                        this.$util.showToast({
                            title: '提现成功!',
                        });
                        this.money = null
                        this.getUserInfo()
                        uni.navigateBack()
                    } else {
                        this.$util.showToast({
                            title: res.error ? res.error : '提现失败!’',
                        });
                    }
                })
            }
        }
    }
</script>
 
<style lang="scss">
    .content {
        width: 100%;
        height: 390rpx;
        background-color: #fed244;
        box-sizing: border-box;
        padding: 32rpx;
 
        .balance {
            width: 100%;
            height: 100%;
            box-sizing: border-box;
            background-color: #fff;
            border-radius: 20rpx;
            padding: 30rpx;
 
            .header {
                width: 100%;
                height: 100%;
                box-sizing: border-box;
                border: 1px solid #eeeff4;
                border-radius: 15rpx;
                padding: 25rpx;
                background-image: linear-gradient(to bottom, #f4f5fc, #ffffff);
                position: relative;
 
                .left {
                    display: flex;
                }
 
                .right {
                    width: 130rpx;
                }
            }
        }
    }
 
    .attention {
        margin: 3rpx;
        color: red;
        position: absolute;
        bottom: 5px;
    }
</style>