liangjin
2021-03-22 f4e5a0b03b0cf679e6489d9d47e7fb8ab4672578
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
<!--
 * @Date: 2019-08-30 10:21:30
 * @LastEditors: 小明丶
 * @LastEditTime: 2019-09-02 10:52:10
 * @Description: 
 -->
<template>
    <div class="f-sample-confirm">
        <Confirm :title='title' :confirm-text='confirmText'
                 :hide-on-blur="true"
                 @on-hide="handleHide"
                 @on-confirm='confirmFunc' @on-cancel='cancelFunc'
                 :cancel-text='cancelText' :show-cancel-button='showCancelBtn' v-model="showModal">
            <div class="icon-box" v-if="showIcon">
                <i class="iconfont" :class="iconClass" :style="{color:iconColor}"></i>
            </div>
            <div class="content-box">
                <slot></slot>
            </div>
        </Confirm>
    </div>
</template>
<script>
    import {Confirm} from 'vux';
    export default {
        name: 'f-confirm',
        components: {
            Confirm
        },
        data() {
            return {
                showModal: false
            };
        },
        created(){
            this.showModal = this.value
        },
        props: {
            /**是否显示图标 */
            showIcon: {
                type: Boolean,
                default: false
            },
            /**图标类名 */
            iconClass: {
                type: String,
                default: 'scene_Staging-shenhezhong'
            },
            /**图标颜色 */
            iconColor: {
                type: String,
                default: '#fff'
            },
            /**标题 */
            title: {
                type: String
            },
            /**是否显示取消按钮 */
            showCancelBtn: {
                type: Boolean,
                default: true
            },
            /**确定按钮的文字 */
            confirmText: {
                type: String,
                default: '确定'
            },
            /**取消按钮的文字 */
            cancelText: {
                type: String,
                default: '取消'
            },
            value: {
                type: Boolean,
                default: false
            }
        },
        watch: {
            value(val) {
                this.showModal = val;
            }
        },
        methods: {
            confirmFunc(val) {
                this.$emit('on-confirm');
                this.$emit('input', false);
            },
            cancelFunc() {
                this.$emit('on-cancel');
                this.$emit('input', false);
            },
            handleHide () {
                this.$emit('on-hide');
                this.$emit('input', false);
            }
        },
       
    };
</script>
<style lang="less" >
    .f-sample-confirm {
        position: relative;
       .weui-dialog {
            overflow: inherit;
            .weui-dialog__ft {
                display: none;
                font-size: @font-size-primary;
                .weui-dialog__btn_primary {
                    color: @color-text-three;
                }
                .weui-dialog__btn_default {
                    color: @color-text-second;
                }
            }
        }
        .content-box {
            color: @color-text-second;
            font-size: @font-size-medium;
            line-height: 1.8;
            text-align: left;
        }
        .icon-box {
            position: absolute;
            top: -16%;
            left: 50%;
            width: 64px;
            height: 64px;
            line-height: 64px;
            border-radius: 50%;
            background-color: @color-text-three;
            text-align: center;
            transform: translateX(-50%);
            i {
                color: #fff;
                font-size: 32px;
            }
        }
    }
</style>