mali-applet-ui 0.1.39 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,13 +16,13 @@
16
16
  </view>
17
17
  </view>
18
18
 
19
- <ml-popup v-model="showPopup" title="请选择" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
19
+ <ml-drawer v-model="showPopup" title="请选择" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
20
20
  <picker-view v-if="showPicker" :value="selectIndexs" @change="changeEvent" style="height: 400rpx;text-align: center;">
21
21
  <picker-view-column v-for="(num, index) in countLevel" :key="index">
22
22
  <view class="ml-cascader-picker-picker-item" v-for="(item, cIndex) in pickerDataMaps[index]" :key="cIndex">{{ item[optLabelField] }}</view>
23
23
  </picker-view-column>
24
24
  </picker-view>
25
- </ml-popup>
25
+ </ml-drawer>
26
26
  </view>
27
27
  </template>
28
28
 
@@ -0,0 +1,200 @@
1
+ <template>
2
+ <view class="ml-drawer" :class="[className || '', `placement-${placement || 'bottom'}`, {'is-visible': visible, 'is-animate': isAnimate}]" @tap="tapMaskEvent">
3
+ <view v-if="visible" class="ml-drawer-warpper" @tap.stop>
4
+ <view v-if="showHeader" class="ml-drawer-header">
5
+ <slot name="header">
6
+ <view v-if="title" class="ml-drawer-header-title">{{ title }}</view>
7
+ </slot>
8
+ </view>
9
+ <view class="ml-drawer-body" :style="bodyStyles">
10
+ <scroll-view scroll-y>
11
+ <slot></slot>
12
+ </scroll-view>
13
+ </view>
14
+ <view v-if="showConfirmButton || showCancelButton || showFooter" class="ml-drawer-footer">
15
+ <slot name="footer">
16
+ <ml-button v-if="showCancelButton" width="40%" round @click="cancelEvent">{{ cancelButtonText }}</ml-button>
17
+ <ml-button v-if="showConfirmButton" status="primary" width="40%" round @click="confirmEvent">{{ confirmButtonText }}</ml-button>
18
+ </slot>
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: 'MlDrawer',
27
+ props: {
28
+ value: Boolean,
29
+ title: String,
30
+ height: String,
31
+ width: String,
32
+ showHeader: {
33
+ type: Boolean,
34
+ default: true
35
+ },
36
+ showFooter: Boolean,
37
+ placement: String,
38
+ maskClosable: Boolean,
39
+ showConfirmButton: Boolean,
40
+ confirmButtonText: {
41
+ type: String,
42
+ default: '确认'
43
+ },
44
+ confirmClosable: Boolean,
45
+ showCancelButton: Boolean,
46
+ cancelButtonText: {
47
+ type: String,
48
+ default: '取消'
49
+ },
50
+ cancelClosable: {
51
+ type: Boolean,
52
+ default: true
53
+ },
54
+ className: String
55
+ },
56
+ data () {
57
+ return {
58
+ visible: false,
59
+ isAnimate: false,
60
+ animateTime: null
61
+ }
62
+ },
63
+ computed: {
64
+ bodyStyles () {
65
+ const wSty = this.width ? `width:${this.width};` : ''
66
+ const hSty = this.height ? `height:${this.height};` : ''
67
+ return `${wSty}${hSty}`
68
+ }
69
+ },
70
+ watch: {
71
+ value (val) {
72
+ if (val) {
73
+ this.open()
74
+ } else {
75
+ this.close()
76
+ }
77
+ }
78
+ },
79
+ created () {
80
+ this.$nextTick(() => {
81
+ if (this.value) {
82
+ this.open()
83
+ } else {
84
+ this.close()
85
+ }
86
+ })
87
+ },
88
+ methods: {
89
+ close () {
90
+ clearTimeout(this.animateTime)
91
+ this.isAnimate = true
92
+ this.isAnimate = false
93
+ this.animateTime = setTimeout(() => {
94
+ this.visible = false
95
+ this.$emit('input', false)
96
+ this.$emit('hide', {})
97
+ }, 300)
98
+ },
99
+ open () {
100
+ clearTimeout(this.animateTime)
101
+ this.isAnimate = false
102
+ this.visible = true
103
+ this.animateTime = setTimeout(() => {
104
+ this.isAnimate = true
105
+ this.$emit('show', {})
106
+ }, 20)
107
+ this.$emit('input', true)
108
+ },
109
+ tapMaskEvent () {
110
+ if (this.maskClosable) {
111
+ this.close()
112
+ }
113
+ },
114
+ cancelEvent () {
115
+ if (this.cancelClosable) {
116
+ this.close()
117
+ }
118
+ this.$emit('cancel', {})
119
+ },
120
+ confirmEvent () {
121
+ if (this.confirmClosable) {
122
+ this.close()
123
+ }
124
+ this.$emit('confirm', {})
125
+ }
126
+ }
127
+ }
128
+ </script>
129
+
130
+ <style lang="scss">
131
+ .ml-drawer {
132
+ display: none;
133
+ position: fixed;
134
+ top: 0;
135
+ left: 0;
136
+ width: $ml-page-full-width;
137
+ height: 100vh;
138
+ z-index: 999;
139
+ background-color: rgba(0, 0, 0, 0.4);
140
+ // #ifdef H5
141
+ left: 50%;
142
+ transform: translateX(-50%);
143
+ // #endif
144
+ &.is-visible {
145
+ display: block;
146
+ }
147
+ &.placement-left {
148
+ &.is-animate {
149
+ .ml-drawer-warpper {
150
+ transform: translateX(0);
151
+ }
152
+ }
153
+ .ml-drawer-warpper {
154
+ height: 100%;
155
+ transform: translateX(-100%);
156
+ }
157
+ }
158
+ &.placement-bottom {
159
+ &.is-animate {
160
+ .ml-drawer-warpper {
161
+ transform: translateY(0);
162
+ }
163
+ }
164
+ .ml-drawer-warpper {
165
+ width: 100%;
166
+ transform: translateY(100%);
167
+ }
168
+ }
169
+ .ml-drawer-warpper {
170
+ position: absolute;
171
+ bottom: 0;
172
+ left: 0;
173
+ padding-bottom: 20rpx;
174
+ background: #fff;
175
+ transition: transform 0.25s ease, transform 0.3s ease;
176
+ }
177
+ .ml-drawer-header {
178
+ padding: 10rpx 20rpx;
179
+ }
180
+ .ml-drawer-header-title {
181
+ text-align: center;
182
+ height: 70rpx;
183
+ line-height: 70rpx;
184
+ font-size: $uni-font-size-base;
185
+ overflow: hidden;
186
+ text-overflow: ellipsis;
187
+ white-space: nowrap;
188
+ }
189
+ .ml-drawer-body {
190
+ padding: 20rpx;
191
+ overflow: auto;
192
+ height: 500rpx;
193
+ }
194
+ .ml-drawer-footer {
195
+ display: flex;
196
+ flex-direction: row;
197
+ padding: 20rpx;
198
+ }
199
+ }
200
+ </style>
@@ -16,7 +16,7 @@
16
16
  </view>
17
17
  </view>
18
18
 
19
- <ml-popup v-model="showPopup" title="请选择省/市" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
19
+ <ml-drawer v-model="showPopup" title="请选择省/市" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
20
20
  <picker-view v-if="showPicker" :value="selectVals" @change="changeEvent" style="height: 400rpx;text-align: center;">
21
21
  <picker-view-column>
22
22
  <view class="ml-province-city-picker-picker-item" v-for="(item, index) in provinceList" :key="index">{{ item[optLabelField] }}</view>
@@ -25,7 +25,7 @@
25
25
  <view class="ml-province-city-picker-picker-item" v-for="(item, index) in cityList" :key="index">{{ item[optLabelField] }}</view>
26
26
  </picker-view-column>
27
27
  </picker-view>
28
- </ml-popup>
28
+ </ml-drawer>
29
29
  </view>
30
30
  </template>
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",