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
| <template>
| <view class="popTips" :class="isShow ? 'show' : ''">
| <view class="box">
| <view v-if="icon && icon !== 'none'" class="iconfont_box">
| <i v-if="icon == 'success'" class="iconfont iconfont icon-duihao"></i>
| <i v-else class="iconfont iconfont icon-tishi"></i>
| </view>
| <view v-html="title ? title : '温馨提示'"></view>
| </view>
| </view>
| </template>
|
| <script>
| export default {
| name: "showTips",
| data() {
| return {
| icon: 'none',
| isShow: false,
| title: '温馨提示',
| center: false,
| duration: 3000,
| timer: null,
| success: null,
| isEventResister: false,
| };
| },
| // mounted() {
| // if (!this.isEventResister) {
| // uni.$on('showTips', this.show)
| // } else {
| // console.error('mounted again')
| // }
| // },
| // beforeDestroy() {
| // this.isEventResister=false;
| // uni.$off('showTips', this.show)
| // },
| methods: {
| show(data) {
| //if (this.$parent.isPageShow == true) {
| console.log('get showTips data', data, this);
| let that = this;
| let arr = ['isShow', 'title', 'icon', 'duration', 'success'];
| for (var i in data) {
| if (arr.indexOf(i) >= 0) {
| that.$set(that, i, data[i]);
| }
| }
| that.$set(that, 'isShow', false);
| that.$nextTick(() => {
| that.$set(that, 'isShow', (new Date()).getTime());
| that.$forceUpdate();
| clearTimeout(that.timer);
| that.timer = setTimeout(() => {
| that.$set(that, 'isShow', false);
| if (that.success && that.success !== 'undefined') that.success();
| clearTimeout(that.timer);
| }, that.duration)
| });
| //}
| },
| }
| }
| </script>
|
| <style lang="scss" scoped>
| .popTips {
| position: fixed;
| left: 0;
| top: 0;
| width: 100%;
| height: 100%;
| z-index: 11111;
| display: none;
|
| &.show {
| display: block;
| }
|
| .box {
| font-size: 24rpx;
| line-height: 1.5em;
| width: max-content;
| max-width: 450rpx;
| padding: 30rpx;
| background: rgba(0, 0, 0, .7);
| color: #ffffff;
| text-align: center;
| position: absolute;
| left: 50%;
| top: 50%;
| transform: translate(-50%, -50%);
| border-radius: 14rpx;
|
| .iconfont_box {
| margin-bottom: 20rpx;
| }
|
| .iconfont {
| font-size: 60rpx !important;
| }
| }
| }
| </style>
|
|