石广澎
2025-11-17 8771da2ccf6f7c3fd2a8c89a1a0e230c6386db7f
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
<template>
    <view>
        <view class="u-text-right u-font-30 color-666 u-p-20" @click="close">关闭</view>
        <view class="u-p-10 bord-box u-flex u-row-between">
            <view class="u-flex u-flex-wrap">
                <view v-for="(num,index) in numList" :key="index" class="num-item" hover-class="num-hover"
                    @click="inputStr(num)">{{num}}</view>
            </view>
            <view class="flex-1 u-flex-col">
                <view hover-class="num-hover" class="del-item u-flex u-row-center" @click="delStr">
                    <image src="@/static/imgs/del-icon.png" class="del-btn"></image>
                </view>
                <view hover-class="num-hover" class="flex-1 pay-btn u-font-30 color-fff font-bold" @click="pay">付款
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        props: {
            num: {
                type: String,
                default: ''
            }
        },
        watch: {
            num(val) {
                this.emitNum = val
            }
        },
        data() {
            return {
                emitNum: '',
                numList: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.']
            }
        },
        methods: {
            // 输入框
            inputStr(num) {
                var dotinx = this.emitNum.indexOf('.');
                if (dotinx != -1) {
                    if (num == '.') {
                        // 小数点不能重复添加
                        return;
                    }
                    if (dotinx == this.emitNum.length - 3) {
                        //小数点后面最多两位
                        return;
                    }
                } else if (num == '0' && this.emitNum == '0') {
                    // 首位的0最多1个
                    return;
                } else {
                    if (num != '.' && this.emitNum.length > 7) {
                        //整数不能超过10位
                        return;
                    }
                }
                if (num == '.' && this.emitNum == '') {
                    this.emitNum = '0.';
                } else if (num != '.' && this.emitNum == '0') {
                    this.emitNum = num;
                } else {
                    this.emitNum += num;
                }
                this.$emit('changeMoney', this.emitNum)
            },
            // 删除
            delStr() {
                this.emitNum = this.emitNum.slice(0, -1)
                this.$emit('changeMoney', this.emitNum)
            },
            // 支付
            pay() {
                this.$emit('pay')
            },
            // 关闭输入框
            close() {
                this.$emit('close')
            }
        }
    }
</script>
 
<style lang="scss">
    .bord-box {
        background-color: #F5F5F5;
    }
 
    .num-item {
        width: 175rpx;
        height: 80rpx;
        line-height: 80rpx;
        color: #333333;
        font-size: 32rpx;
        font-weight: bold;
        text-align: center;
        margin: 0 10rpx 10rpx 0;
        background-color: #FFFFFF;
    }
 
    .num-hover {
        opacity: 0.7;
    }
 
    .num-item:nth-child(10n) {
        width: 356rpx;
    }
 
    .h-100 {
        height: 100%;
    }
 
    .pay-btn {
        background-color: #D45159;
        border-radius: 16rpx;
        text-align: center;
        height: 270rpx;
        line-height: 270rpx;
        vertical-align: middle;
    }
 
    .del-item {
        width: 175rpx;
        height: 80rpx;
        margin-bottom: 10rpx;
        background-color: #FFFFFF;
    }
 
    .del-btn {
        width: 40rpx;
        height: 40rpx;
    }
</style>