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
| <template>
| <view v-if="dtype" class="use-empty-container tac" :class="eStyle == 'round' ? 'padding-sm' : ''" :style="{ height: height }">
| <view class="use-empty h-full dflex-c dflex-flow-c" :class="eStyle == 'round' ? 'round border-radius bg-main' : ''">
| <image v-if="imgurl" :src="imgurl"></image>
| <view v-if="tip" class="title padding-sm">{{tip}}</view>
| <view v-if="btnTip" class="no-border use-btn" @click="to">{{btnTip}}</view>
| </view>
| </view>
| </template>
|
| <script>
| export default {
| props: {
| eStyle: {
| type: String,
| default: 'square'
| },
| eType: {
| type: String,
| default: 'other'
| },
| tip: {
| type: String,
| default: '暂无数据'
| },
| btnTip: {
| type: [String, Boolean],
| default: '去逛逛'
| },
| btnGoto: {
| type: String,
| default: '/pages/tabbar/home'
| },
| auto: {
| type: Boolean,
| default: !0
| },
| height: {
| type: String,
| default: '100vh'
| }
| },
| computed: {
| dtype: {
| get(){
| console.log('get dtype', arguments);
| let imgobj = this.imgs.find(x => x.type == this.eType);
| this.imgurl = imgobj ? imgobj.url : this.imgurl_dft;
| return this.eType
| },
| set(val){
| console.log('set dtype', arguments);
| }
| }
| },
| data() {
| return {
| imgurl_dft: '/static/images/empty/empty.jpg',
| imgurl: '',
| imgs: [
| { type: 'cart', url: '/static/images/empty/empty.jpg' },
| { type: 'search', url: '/static/images/empty/search.jpg' },
| { type: 'other', url: '/static/images/empty/empty.jpg' }
| ]
| };
| },
| methods: {
| to() {
| this.$emit('goto', {
| type: 'goto'
| });
|
| if (this.auto) {
| // 跳转指定页
| uni.switchTab({
| url: this.btnGoto
| })
| }
| }
| }
| };
| </script>
|
| <style lang="scss">
| .use-empty-container{
| .use-empty {
| .round {
| padding: 25% 50rpx;
|
| button {
| width: 220rpx;
| }
| }
| image {
| width: 160rpx;
| height: 160rpx;
| }
|
| .title {
| color: #c0c0c0;
| }
|
| .use-btn {
| font-size: $font-base + 2upx;
| display: inline-block;
| }
| }
| }
| </style>
|
|