sadais-piui 1.2.7-beta15 → 1.2.7-beta151

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.
Files changed (75) hide show
  1. package/.prettierrc +8 -0
  2. package/components/pi-action-sheet/index.vue +260 -247
  3. package/components/pi-badge/index.vue +11 -1
  4. package/components/pi-bottom-bar/index.vue +1 -1
  5. package/components/pi-calendar/index.vue +207 -182
  6. package/components/pi-calendar-input/index.vue +61 -30
  7. package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
  8. package/components/pi-calendar-panel/index.vue +28 -12
  9. package/components/pi-canvas/index.vue +8 -1
  10. package/components/pi-cascader/index.vue +601 -0
  11. package/components/pi-checkbox/index.vue +8 -4
  12. package/components/pi-checkbox-group/index.vue +12 -11
  13. package/components/pi-circle-progress/index.vue +53 -16
  14. package/components/pi-code-input/index.vue +11 -3
  15. package/components/pi-collapse/index.vue +16 -6
  16. package/components/pi-collapse-item/index.vue +35 -22
  17. package/components/pi-date-picker/index.vue +512 -391
  18. package/components/pi-date-picker-input/index.vue +61 -30
  19. package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
  20. package/components/pi-dropdown/index.vue +34 -19
  21. package/components/pi-dropdown-item/index.vue +70 -58
  22. package/components/pi-form-item/index.vue +98 -20
  23. package/components/pi-grid/index.vue +1 -1
  24. package/components/pi-grid-item/index.vue +4 -4
  25. package/components/pi-img/index.vue +275 -267
  26. package/components/pi-img-cropper/index.vue +6 -3
  27. package/components/pi-input/index.vue +97 -36
  28. package/components/pi-list-item/index.vue +1 -1
  29. package/components/pi-marquee/index.vue +322 -310
  30. package/components/pi-marquee-pure-css/index.vue +267 -0
  31. package/components/pi-mask/index.vue +3 -1
  32. package/components/pi-modal/index.vue +311 -303
  33. package/components/pi-pagination/index.vue +13 -0
  34. package/components/pi-picker/index.vue +332 -317
  35. package/components/pi-popup/index.vue +4 -1
  36. package/components/pi-popup-select/index.vue +13 -4
  37. package/components/pi-radio/index.vue +12 -11
  38. package/components/pi-radio-group/index.vue +25 -5
  39. package/components/pi-regions-select/index.vue +6 -1
  40. package/components/pi-regions-select-input/index.vue +69 -31
  41. package/components/pi-search/index.vue +37 -2
  42. package/components/pi-section/index.vue +1 -1
  43. package/components/pi-select/index.vue +237 -22
  44. package/components/pi-select-input/index.vue +106 -41
  45. package/components/pi-stepper/index.vue +135 -121
  46. package/components/pi-steps/index.vue +115 -36
  47. package/components/pi-swiper/index.vue +22 -7
  48. package/components/pi-switch/index.vue +5 -1
  49. package/components/pi-table/index.vue +351 -0
  50. package/components/pi-tabs/index.vue +46 -10
  51. package/components/pi-upload-img/index.vue +895 -44
  52. package/components/pi-webview/index.vue +95 -82
  53. package/config/actionSheet.js +0 -1
  54. package/config/calendarInput.js +2 -1
  55. package/config/calendarPanel.js +2 -1
  56. package/config/cascader.js +22 -0
  57. package/config/circleProgress.js +12 -4
  58. package/config/codeInput.js +2 -1
  59. package/config/datePicker.js +29 -24
  60. package/config/datePickerInput.js +2 -1
  61. package/config/dropdown.js +3 -1
  62. package/config/input.js +5 -3
  63. package/config/marqueePureCss.js +18 -0
  64. package/config/regionsSelectInput.js +2 -1
  65. package/config/select.js +13 -1
  66. package/config/selectInput.js +2 -1
  67. package/config/steps.js +1 -1
  68. package/config/table.js +9 -0
  69. package/config/uploadImg.js +33 -11
  70. package/mixin/emitter.js +8 -1
  71. package/mixin/value-sync.js +5 -0
  72. package/package.json +5 -2
  73. package/scss/common.scss +11 -14
  74. package/scss/icon/icon.scss +2 -1
  75. package/scss/mixin.scss +5 -5
@@ -1,267 +1,275 @@
1
- <template>
2
- <view class="pi-img" :style="[rectStyle]">
3
- <view
4
- class="pi-align-center"
5
- :style="[rectStyle, imageStyle, customStyle]"
6
- :class="[customClass]"
7
- @tap="handleButtonTap"
8
- >
9
- <image
10
- :src="src"
11
- :mode="mode"
12
- :lazy-load="lazyLoad"
13
- :style="[rectStyle, imageStyle]"
14
- :show-menu-by-longpress="showMenuByLongpress"
15
- @error="handleError"
16
- @load="handleLoad"
17
- />
18
- <view class="pi-abso-center">
19
- <!-- 加载中 -->
20
- <template v-if="src && loading">
21
- <!-- 加载中样式 -->
22
- <slot v-if="$slots.loading" name="loading" />
23
- <pi-loading
24
- v-else
25
- :show="loading"
26
- :type="loadingType"
27
- :color="loadingColor"
28
- :size="loadingSize"
29
- />
30
- </template>
31
- <!-- 加载失败 -->
32
- <template v-if="src && error">
33
- <!-- 加载失败样式 -->
34
- <slot v-if="$slots.error" name="error" />
35
- <view class="pi-icon-pic" />
36
- </template>
37
- </view>
38
- </view>
39
- <view v-if="badge || dot" class="img-badge" :class="{ dot }" :style="[badgeStyle]">
40
- {{ badge }}
41
- </view>
42
- <view v-if="dot" />
43
- </view>
44
- </template>
45
-
46
- <script>
47
- /**
48
- * 注意,必须指定宽度和高度,否则没办法显示低图和加载错误占位图
49
- * 如果要自定义loading底图和请求失败图,请使用slot对本组件进行二次封装
50
- */
51
- import { getConfig } from '../../config'
52
- import { debounce } from '@sadais/piui-tool/tools/common'
53
-
54
- const TAG = 'PiImg'
55
- const { img } = getConfig()
56
-
57
- export default {
58
- name: 'PiImg',
59
- props: {
60
- // 自定义样式
61
- customStyle: {
62
- type: Object,
63
- default() {
64
- // {}
65
- return img.customStyle
66
- }
67
- },
68
- // 自定义样式类
69
- customClass: {
70
- type: String,
71
- default() {
72
- // ''
73
- return img.customClass
74
- }
75
- },
76
- // 图片地址
77
- src: {
78
- type: String,
79
- // ''
80
- default: img.src
81
- },
82
- // 裁剪模式
83
- mode: {
84
- type: String,
85
- // 'widthFix'
86
- default: img.mode
87
- },
88
- // 宽度
89
- width: {
90
- type: [String, Number],
91
- // '100%'
92
- default: img.width
93
- },
94
- // 高度
95
- height: {
96
- type: [String, Number],
97
- // 'auto'
98
- default: img.height
99
- },
100
- // 是否显示图标右上角小红点
101
- dot: {
102
- type: Boolean,
103
- // false
104
- default: img.dot
105
- },
106
- // 小红点的半径
107
- dotRadius: {
108
- type: [String, Number],
109
- // 16
110
- default: img.dotRadius
111
- },
112
- // 图标右上角徽标的内容
113
- badge: {
114
- type: [String, Number],
115
- // ''
116
- default: img.badge
117
- },
118
- // 图片形状
119
- shape: {
120
- // `'round'-圆形` `'square'-方形`
121
- type: String,
122
- // 'square'
123
- default: img.shape,
124
- validator: function(value) {
125
- return ['square', 'round'].includes(value)
126
- }
127
- },
128
- // shape为square的时候设置
129
- borderRadius: {
130
- type: [String, Number],
131
- // 0
132
- default: img.borderRadius
133
- },
134
- // 是否懒加载
135
- lazyLoad: {
136
- type: Boolean,
137
- // true
138
- default: img.lazyLoad
139
- },
140
- // 开启长按图片显示识别微信小程序码菜单
141
- showMenuByLongpress: {
142
- type: Boolean,
143
- // true
144
- default: img.showMenuByLongpress
145
- },
146
- // 是否显示加载中的图标或者自定义的slot
147
- showLoading: {
148
- type: Boolean,
149
- // true
150
- default: img.showLoading
151
- },
152
- // 加载中颜色
153
- loadingColor: {
154
- type: String,
155
- // '#c1c1c1'
156
- default: img.loadingColor
157
- },
158
- // loading类型
159
- loadingType: {
160
- // `'spinner'-菊花` `'round'-圆环`
161
- type: String,
162
- // 'spinner'
163
- default: img.loadingType,
164
- validator: function(value) {
165
- return ['spinner', 'round'].includes(value)
166
- }
167
- },
168
- // 尺寸
169
- loadingSize: {
170
- type: [String, Number],
171
- // 32
172
- default: img.loadingSize
173
- },
174
- // 是否显示加载中的图标或者自定义的slot
175
- showError: {
176
- type: Boolean,
177
- // true
178
- default: img.showError
179
- },
180
- // 默认不解析 webP 格式,只支持网络资源
181
- webp: {
182
- type: Boolean,
183
- // false
184
- default: img.webp
185
- }
186
- },
187
- data() {
188
- return {
189
- loading: this.showLoading,
190
- // 图片是否加载错误,如果是,则显示错误占位图
191
- error: false
192
- }
193
- },
194
- computed: {
195
- getDotRadius() {
196
- return this.$pi.common.addUnit(this.dotRadius)
197
- },
198
- rectStyle() {
199
- return {
200
- width: this.$pi.common.addUnit(this.width),
201
- height: this.$pi.common.addUnit(this.height)
202
- }
203
- },
204
- badgeStyle() {
205
- const style = {}
206
- if (this.dot) {
207
- style.width = this.getDotRadius
208
- style.height = this.getDotRadius
209
- }
210
- return style
211
- },
212
- imageStyle() {
213
- return {
214
- overflow: 'hidden',
215
- borderRadius: this.shape === 'round' ? '50%' : this.$pi.common.addUnit(this.borderRadius)
216
- }
217
- }
218
- },
219
- methods: {
220
- handleButtonTap: debounce(function(e) {
221
- this.$emit('click', e)
222
- }, 200),
223
- handleError() {
224
- console.log(TAG, '图片加载失败')
225
- this.error = true
226
- this.loading = false
227
- // 图片加载完成
228
- this.$emit('load')
229
- },
230
- handleLoad() {
231
- console.log(TAG, '图片加载成功')
232
- this.error = false
233
- this.loading = false
234
- this.$emit('load')
235
- }
236
- }
237
- }
238
- </script>
239
-
240
- <style lang="scss" scoped>
241
- .pi-img {
242
- position: relative;
243
- .img-badge {
244
- position: absolute;
245
- top: 0;
246
- right: 0;
247
- box-sizing: border-box;
248
- min-width: 16px;
249
- padding: 0 3px;
250
- font-size: 12px;
251
- font-weight: 500;
252
- line-height: 1.2;
253
- color: #ffffff;
254
- text-align: center;
255
- background-color: #ee0a24;
256
- border: 1px solid #ffffff;
257
- border-radius: 16px;
258
- transform: translate(50%, -50%);
259
- transform-origin: 100%;
260
- &.dot {
261
- min-width: 0;
262
- background-color: #ee0a24;
263
- border-radius: 100%;
264
- }
265
- }
266
- }
267
- </style>
1
+ <template>
2
+ <view class="pi-img" :style="[rectStyle]">
3
+ <view
4
+ class="pi-align-center"
5
+ :style="[rectStyle, imageStyle, customStyle]"
6
+ :class="[customClass]"
7
+ @tap="handleButtonTap"
8
+ >
9
+ <image
10
+ :src="src"
11
+ :mode="mode"
12
+ :lazy-load="lazyLoad"
13
+ :style="[rectStyle, imageStyle]"
14
+ :show-menu-by-longpress="showMenuByLongpress"
15
+ :webp="webp"
16
+ @error="handleError"
17
+ @load="handleLoad"
18
+ />
19
+ <view class="pi-abso-center">
20
+ <!-- 加载中 -->
21
+ <template v-if="src && loading">
22
+ <!-- 加载中样式 -->
23
+ <slot v-if="$slots.loading" name="loading" />
24
+ <pi-loading
25
+ v-else
26
+ :show="loading"
27
+ :type="loadingType"
28
+ :color="loadingColor"
29
+ :size="loadingSize"
30
+ />
31
+ </template>
32
+ <!-- 加载失败 -->
33
+ <template v-if="src && error">
34
+ <!-- 加载失败样式 -->
35
+ <slot v-if="$slots.error" name="error" />
36
+ <view v-else class="pi-icon-pic" />
37
+ </template>
38
+ </view>
39
+ </view>
40
+ <view
41
+ v-if="badge || dot"
42
+ class="img-badge"
43
+ :class="{ dot }"
44
+ :style="[badgeStyle]"
45
+ >
46
+ {{ badge }}
47
+ </view>
48
+ <view v-if="dot" />
49
+ </view>
50
+ </template>
51
+
52
+ <script>
53
+ /**
54
+ * 注意,必须指定宽度和高度,否则没办法显示低图和加载错误占位图
55
+ * 如果要自定义loading底图和请求失败图,请使用slot对本组件进行二次封装
56
+ */
57
+ import { getConfig } from '../../config'
58
+ import { debounce } from '@sadais/piui-tool/tools/common'
59
+
60
+ const TAG = 'PiImg'
61
+ const { img } = getConfig()
62
+
63
+ export default {
64
+ name: 'PiImg',
65
+ props: {
66
+ // 自定义样式
67
+ customStyle: {
68
+ type: Object,
69
+ default() {
70
+ // {}
71
+ return img.customStyle
72
+ }
73
+ },
74
+ // 自定义样式类
75
+ customClass: {
76
+ type: String,
77
+ default() {
78
+ // ''
79
+ return img.customClass
80
+ }
81
+ },
82
+ // 图片地址
83
+ src: {
84
+ type: String,
85
+ // ''
86
+ default: img.src
87
+ },
88
+ // 裁剪模式
89
+ mode: {
90
+ type: String,
91
+ // 'widthFix'
92
+ default: img.mode
93
+ },
94
+ // 宽度
95
+ width: {
96
+ type: [String, Number],
97
+ // '100%'
98
+ default: img.width
99
+ },
100
+ // 高度
101
+ height: {
102
+ type: [String, Number],
103
+ // 'auto'
104
+ default: img.height
105
+ },
106
+ // 是否显示图标右上角小红点
107
+ dot: {
108
+ type: Boolean,
109
+ // false
110
+ default: img.dot
111
+ },
112
+ // 小红点的半径
113
+ dotRadius: {
114
+ type: [String, Number],
115
+ // 16
116
+ default: img.dotRadius
117
+ },
118
+ // 图标右上角徽标的内容
119
+ badge: {
120
+ type: [String, Number],
121
+ // ''
122
+ default: img.badge
123
+ },
124
+ // 图片形状
125
+ shape: {
126
+ // `'round'-圆形` `'square'-方形`
127
+ type: String,
128
+ // 'square'
129
+ default: img.shape,
130
+ validator: function(value) {
131
+ return ['square', 'round'].includes(value)
132
+ }
133
+ },
134
+ // shape为square的时候设置
135
+ borderRadius: {
136
+ type: [String, Number],
137
+ // 0
138
+ default: img.borderRadius
139
+ },
140
+ // 是否懒加载
141
+ lazyLoad: {
142
+ type: Boolean,
143
+ // true
144
+ default: img.lazyLoad
145
+ },
146
+ // 开启长按图片显示识别微信小程序码菜单
147
+ showMenuByLongpress: {
148
+ type: Boolean,
149
+ // true
150
+ default: img.showMenuByLongpress
151
+ },
152
+ // 是否显示加载中的图标或者自定义的slot
153
+ showLoading: {
154
+ type: Boolean,
155
+ // true
156
+ default: img.showLoading
157
+ },
158
+ // 加载中颜色
159
+ loadingColor: {
160
+ type: String,
161
+ // '#c1c1c1'
162
+ default: img.loadingColor
163
+ },
164
+ // loading类型
165
+ loadingType: {
166
+ // `'spinner'-菊花` `'round'-圆环`
167
+ type: String,
168
+ // 'spinner'
169
+ default: img.loadingType,
170
+ validator: function(value) {
171
+ return ['spinner', 'round'].includes(value)
172
+ }
173
+ },
174
+ // 尺寸
175
+ loadingSize: {
176
+ type: [String, Number],
177
+ // 32
178
+ default: img.loadingSize
179
+ },
180
+ // 是否显示加载中的图标或者自定义的slot
181
+ showError: {
182
+ type: Boolean,
183
+ // true
184
+ default: img.showError
185
+ },
186
+ // 默认不解析 webP 格式,只支持网络资源
187
+ webp: {
188
+ type: Boolean,
189
+ // false
190
+ default: img.webp
191
+ }
192
+ },
193
+ data() {
194
+ return {
195
+ loading: this.showLoading,
196
+ // 图片是否加载错误,如果是,则显示错误占位图
197
+ error: false
198
+ }
199
+ },
200
+ computed: {
201
+ getDotRadius() {
202
+ return this.$pi.common.addUnit(this.dotRadius)
203
+ },
204
+ rectStyle() {
205
+ return {
206
+ width: this.$pi.common.addUnit(this.width),
207
+ height: this.$pi.common.addUnit(this.height)
208
+ }
209
+ },
210
+ badgeStyle() {
211
+ const style = {}
212
+ if (this.dot) {
213
+ style.width = this.getDotRadius
214
+ style.height = this.getDotRadius
215
+ }
216
+ return style
217
+ },
218
+ imageStyle() {
219
+ return {
220
+ overflow: 'hidden',
221
+ borderRadius:
222
+ this.shape === 'round'
223
+ ? '50%'
224
+ : this.$pi.common.addUnit(this.borderRadius)
225
+ }
226
+ }
227
+ },
228
+ methods: {
229
+ handleButtonTap: debounce(function(e) {
230
+ this.$emit('click', e)
231
+ }, 200),
232
+ handleError() {
233
+ console.log(TAG, '图片加载失败')
234
+ this.error = true
235
+ this.loading = false
236
+ // 图片加载完成
237
+ this.$emit('load')
238
+ },
239
+ handleLoad() {
240
+ this.error = false
241
+ this.loading = false
242
+ this.$emit('load')
243
+ }
244
+ }
245
+ }
246
+ </script>
247
+
248
+ <style lang="scss" scoped>
249
+ .pi-img {
250
+ position: relative;
251
+ .img-badge {
252
+ position: absolute;
253
+ top: 0;
254
+ right: 0;
255
+ box-sizing: border-box;
256
+ min-width: 16px;
257
+ padding: 0 3px;
258
+ font-size: 12px;
259
+ font-weight: 500;
260
+ line-height: 1.2;
261
+ color: #ffffff;
262
+ text-align: center;
263
+ background-color: #ee0a24;
264
+ border: 1px solid #ffffff;
265
+ border-radius: 16px;
266
+ transform: translate(50%, -50%);
267
+ transform-origin: 100%;
268
+ &.dot {
269
+ min-width: 0;
270
+ background-color: #ee0a24;
271
+ border-radius: 100%;
272
+ }
273
+ }
274
+ }
275
+ </style>
@@ -18,7 +18,7 @@
18
18
  v-if="canvasId"
19
19
  :id="canvasId"
20
20
  :canvas-id="canvasId"
21
- style="position: absolute; left: -500000px; top: -500000px;"
21
+ style="position: absolute; left: -500000px; top: -500000px"
22
22
  :style="canvasStyle"
23
23
  />
24
24
  </view>
@@ -175,7 +175,7 @@ export default {
175
175
  this.initImage()
176
176
  }
177
177
  },
178
- created() {
178
+ mounted() {
179
179
  uni.getSystemInfo({
180
180
  success: result => {
181
181
  this.ratio = result.windowWidth / 750
@@ -187,7 +187,10 @@ export default {
187
187
  },
188
188
  methods: {
189
189
  async initUI() {
190
- const { width, height } = await this.getContainerSize()
190
+ const { width, height } = (await this.getContainerSize()) || {
191
+ width: 0,
192
+ height: 0
193
+ }
191
194
  this.root = {
192
195
  width,
193
196
  height