hejianhao
11 小时以前 9fe43c140598f78665fcdc8068685ac075580769
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
<template>
    <u-popup :overlayOpacity="overlayOpacity" :show="show" mode="center" bgColor="transparent" @open="openPopup"
        :closeOnClickOverlay="false" zIndex="10071">
        <view class="bgImg px-61 pt-46 pb-37 br-28">
            <view class="txt-center font-bold fs-35 color2">
                提示
            </view>
            <slot></slot>
            <view class="fs-27">
                <view v-if="!isOneBtn" class="flex a-center j-between">
                    <view @tap.stop="closeFun" class="h-77 lh-77 shrink0 txt-center px-79 br-48 mr-33 border1">
                        {{closeText}}
                    </view>
                    <view @tap.stop="comfirmFun" class="px-79 py-19 br-48 color1 bgcolor1">{{confirmText}}</view>
                </view>
                <view v-else @tap.stop="comfirmFun" class="lh-70 txt-center w100 br-48 color1 bgcolor1">
                    {{confirmText}}<span v-if="isCountDown && num != 0">({{num}}S)</span>
                </view>
            </view>
        </view>
    </u-popup>
</template>
 
<script>
    export default {
        props: {
            confirmText: {
                type: String,
                default: '确认'
            },
            closeText: {
                type: String,
                default: '关闭'
            },
            isOneBtn: {
                type: Boolean,
                default: false
            },
            isCountDown: {
                type: Boolean,
                default: false
            },
            overlayOpacity: {
                type: Number,
                default: 0.5
            }
        },
        data() {
            return {
                timer: null,
                num: 3,
                show: false,
            }
        },
        methods: {
            openPopup() {
                this.timer = setInterval(() => {
                    this.num--
                    if (this.num == 1) {
                        setTimeout(() => {
                            this.num = 0
                            clearInterval(this.timer)
                        }, 900)
                    }
                }, 1000)
            },
            closeFun() {
                this.$emit('close')
                this.show = false
            },
            comfirmFun() {
                if (this.isCountDown && this.num != 0) {
                    return
                }
                this.$emit('comfirm')
                // this.show = false
            },
            showPopup() {
                this.show = true
            },
            closePopup() {
                this.show = false
            },
        }
    }
</script>
 
<style scoped lang="scss">
    .bgImg {
        width: 516rpx;
        background-image: url('/static/popupBg.png');
        background-size: 100% 212rpx;
        background-repeat: no-repeat;
        background-color: #fff;
    }
 
    .border1 {
        border: 2rpx solid rgba(0, 0, 0, 0.8);
        box-sizing: border-box;
    }
 
    .color1 {
        color: #fff;
    }
 
    .color2 {
        color: rgba(0, 0, 0, 0.8);
    }
 
    .bgcolor1 {
        background: linear-gradient(270deg, #FC8D55 0%, #FF4948 100%);
    }
</style>