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
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
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-toast :type="type" ref="uToast"></u-toast>
                <u-notice-bar :autoplay="autoplay" :playState="playState" :speed="speed" @getMore="getMore" 
                :mode="mode" @end="end" @close="close" @click="click" :show="show" :type="type" :list="list"
                :moreIcon="moreIcon" :volumeIcon="volumeIcon" :duration="duration" :isCircular="isCircular"></u-notice-bar>
            </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 :current="3" :list="['primary', 'success', 'error', 'warning', 'none']" @change="typeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">滚动模式</view>
                <u-subsection :current="current" :list="['水平', '垂直']" @change="modeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">是否衔接(水平模式有效)</view>
                <u-subsection :list="['是', '否']" @change="isCircularChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">状态</view>
                <u-subsection :list="['播放', '暂停']" @change="playStateChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">速度</view>
                <u-subsection :current="1" :list="['慢', '正常', '快']" @change="speedChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">图标</view>
                <u-subsection :list="['显示', '隐藏']" @change="iconChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                show: true,
                autoplay: false,
                type: 'warning',
                list: [
                    '锦瑟无端五十弦,一弦一柱思华年',
                    '庄生晓梦迷蝴蝶,望帝春心托杜鹃',
                    '沧海月明珠有泪,蓝田日暖玉生烟'
                ],
                mode: 'horizontal',
                playState: 'play',
                speed: 160,
                duration: 2000,
                moreIcon: true,
                volumeIcon: true,
                isCircular: true,
                current: 0
            }
        },
        onLoad() {
            
        },
        methods: {
            typeChange(index) {
                let type = ['primary', 'success', 'error', 'warning', 'none'];
                this.type = type[index];
            },
            modeChange(index) {
                this.current = index;
                this.mode = index == 0 ? 'horizontal' : 'vertical';
            },
            playStateChange(index) {
                this.playState = index == 0 ? 'play' : 'paused';
            },
            speedChange(index) {
                if(index == 0) {
                    this.$nextTick(() => {
                        this.speed = 50;
                        this.duration = 6000;
                    })
                } else if(index == 1) {
                    this.$nextTick(() => {
                        this.speed = 160;
                        this.duration = 2000;
                    })
                } else {
                    this.$nextTick(() => {
                        this.speed = 350;
                        this.duration = 400;
                    })
                }
            },
            iconChange(index) {
                if(index == 0) {
                    this.moreIcon = true;
                    this.volumeIcon = true;
                } else {
                    this.moreIcon = false;
                    this.volumeIcon = false;
                }
            },
            isCircularChange(index) {
                this.isCircular = index == 0 ? true : false;
                this.current = 0;
                this.mode = 'horizontal';
            },
            close() {
                this.toast(`点击了关闭图标`);
            },
            click(index) {
                if(this.mode == 'horizontal' && this.isCircular) {
                    this.toast('此模式无法获取Index值');
                } else {
                    this.toast(`点击了第${index + 1}条消息`);
                }
                
            },
            getMore() {
                this.toast(`点击了更多图标`);
            },
            toast(title) {
                this.$refs.uToast.show({
                    title: title,
                    type: 'warning'
                })
            },
            end() {
                // console.log('end');
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .item {
        margin-top: 30px;
    }
</style>