zhangxiaoxu123456
2021-12-17 4d4a844ef624dde8667b314d353599297f6cb8d9
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
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-toast ref="uToast"></u-toast>
                <u-message-input :mode="mode" :maxlength="maxlength" :value="value"
                :breathe="breathe" :bold="bold" @finish="finish" :dot-fill="dotFill"></u-message-input>
            </view>
        </view>
        <view class="u-config-wrap">
            <view class="u-config-title u-border-bottom">
                参数配置
            </view>
            <view class="u-config-item">
                <view class="u-item-title">模式选择</view>
                <u-subsection :list="['方框', '下划线', '中划线']" @change="modeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">输入长度</view>
                <u-subsection :list="[4, 5, 6]" @change="maxLengthChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <!-- #ifdef MP-WEIXIN -->
                <view class="u-item-title">初始值(为满足演示需要,微信小程序切换会有抖动,非性能问题)</view>
                <!-- #endif -->
                <!-- #ifndef MP-WEIXIN -->
                <view class="u-item-title">初始值</view>
                <!-- #endif -->
                <u-subsection :list="['空', '23', '678']" @change="valueChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">呼吸灯效果</view>
                <u-subsection :list="['是', '否']" @change="breatheChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">是否加粗</view>
                <u-subsection :list="['是', '否']" @change="boldChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">点替代输入值</view>
                <u-subsection current="1" :list="['是', '否']" @change="dotFillChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                mode: 'box',
                maxlength: 4,
                value: '', 
                bold: true,
                breathe: true,
                dotFill: false,
            }
        },
        computed: {
 
        },
        onLoad() {
 
        },
        methods: {
            modeChange(index) {
                this.mode = index == 0 ? 'box' : index == 1 ? 'bottomLine' : 'middleLine';
            },
            maxLengthChange(index) {
                this.maxlength = index == 0 ? 4 : index == 1 ? 5 : 6;
            },
            valueChange(index) {
                this.value = index == 0 ? '' : index == 1 ? '23' : '678';
            },
            breatheChange(index) {
                this.breathe = index == 0 ? true : false;
            },
            boldChange(index) {
                this.bold = index == 0 ? true : false;
            },
            dotFillChange(index) {
                this.dotFill = index == 0 ? true : false;
            },
            finish(value) {
                this.$refs.uToast.show({
                    title: '输入完成,值为:' + value,
                    type: 'success'
                })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .u-demo {}
</style>