zhaoxiaoqiang
2021-07-28 731b56e3ee7068ed721c2c4ed7413bb2f8699042
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
/*
 * @Author: hzq
 * @Date: 2018-08-07 09:23:43
 * @Last Modified by: hzq
 * @Last Modified time: 2018-08-13 16:11:17
 * @文件说明:非文字提示组件-成功、失败、网络异常
 * @使用方式:this.$toast({
                            type: 'success||fail||network',
                            text: '冻结成功'
                        });
 */
<template>
    <div class="f-toast">
        <div v-if="toastType">
            <toast :value="true" position="middle" :is-show-mask="true" :time="1000" @on-hide="onHide">
                <div slot="default" class="slot">
                    <i class="iconfont" :class="iconClass"></i>
                    <div>{{toastText}}</div>
                </div>
            </toast>
        </div>
    </div>
</template>
 
<script>
    import {Toast} from 'vux';
    export default {
        name: 'f-toast',
        components: {Toast},
        computed: {
            iconClass() {
                // 计算iconfont
                if (this.$store.state.toastType === 'success')
                    return 'scene_Staging-chenggong';
                else if (this.$store.state.toastType === 'fail')
                    return 'scene_Staging-shibai';
                else if (this.$store.state.toastType === 'network')
                    return 'scene_Staging-wangluoyichang';
            },
            toastType() {
                return this.$store.state.toastType;
            },
            toastText() {
                return this.$store.state.toastText;
            }
        },
        methods: {
            onHide() {
                this.$toast({type: '', tetx: ''});
            }
        }
    };
</script>
 
<style lang="less" scoped>
    .f-toast {
        & /deep/ .weui-toast {
            width: 84px;
            height: 84px;
            min-height: 84px;
            .weui-icon_toast {
                display: none;
            }
            .weui-toast__content {
                height: 84px;
                min-height: 84px;
                margin: 0;
                font-size: @font-size-small;
                .slot {
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    align-items: center;
                    height: 84px;
                    min-height: 84px;
                    .iconfont {
                        font-size: 28px;
                    }
                }
            }
        }
    }
</style>