sadais-piui 1.1.2-beta → 1.2.0
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.
- package/CHANGELOG.md +482 -240
- package/components/pi-bottom-bar/index.vue +11 -2
- package/components/pi-circle-progress/index.vue +196 -173
- package/components/pi-count-up/index.vue +68 -62
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
- package/components/pi-dropdown/index.vue +152 -151
- package/components/pi-dropdown-item/index.vue +169 -41
- package/components/pi-form-item/index.vue +13 -1
- package/components/pi-img-cropper/index.vue +20 -16
- package/components/pi-img-cropper/touch.js +5 -3
- package/components/pi-input/index.vue +9 -2
- package/components/pi-notify/index.vue +132 -48
- package/components/pi-popup/index.vue +1 -3
- package/components/pi-select/index.vue +2 -2
- package/components/pi-steps/index.vue +141 -96
- package/components/pi-switch/index.vue +2 -3
- package/components/pi-tabs/index.vue +1 -2
- package/components/pi-upload-img/index.vue +104 -32
- package/config/bottomBar.js +1 -0
- package/config/checkbox.js +1 -1
- package/config/circleProgress.js +13 -0
- package/config/countUp.js +13 -0
- package/config/dropdown.js +17 -8
- package/config/dropdownItem.js +23 -5
- package/config/form.js +3 -3
- package/config/imgCropper.js +4 -2
- package/config/notify.js +6 -2
- package/config/steps.js +10 -5
- package/config/{upload-img.js → uploadImg.js} +6 -3
- package/index.js +2 -2
- package/package.json +3 -3
- package/scss/variable.scss +1 -1
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</slot>
|
|
40
40
|
<!-- 如果配置了图片地址,使用图片 -->
|
|
41
41
|
<pi-img
|
|
42
|
-
v-if="getSelectedImg.src"
|
|
42
|
+
v-if="getSelectedImg.src && item.isSelected"
|
|
43
43
|
:src="getSelectedImg.src"
|
|
44
44
|
:mode="getSelectedImg.mode"
|
|
45
45
|
:width="getSelectedImg.width"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
/>
|
|
60
60
|
<!-- 默认使用复选框 -->
|
|
61
61
|
<pi-checkbox
|
|
62
|
-
v-
|
|
62
|
+
v-if="!getSelectedImg.src"
|
|
63
63
|
readonly
|
|
64
64
|
:value="item.isSelected"
|
|
65
65
|
:name="getSelectedCheckbox.name"
|
|
@@ -1,70 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="pi-steps" :style="[customStyle, { flexDirection: direction }]" :class="customClass">
|
|
3
3
|
<view
|
|
4
|
-
v-for="(item, index) in
|
|
4
|
+
v-for="(item, index) in getItems"
|
|
5
5
|
:key="index"
|
|
6
6
|
class="pi-steps-item"
|
|
7
7
|
:style="itemStyle"
|
|
8
|
-
:class="[itemClass,
|
|
8
|
+
:class="[itemClass, item.mode, direction, { active: index < val }]"
|
|
9
9
|
>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<!-- 数字-->
|
|
23
|
-
<view
|
|
24
|
-
v-if="mode === 'number'"
|
|
25
|
-
class="pi-steps-item-number"
|
|
26
|
-
:style="{
|
|
27
|
-
backgroundColor: item.bgColor,
|
|
28
|
-
borderColor: item.borderColor,
|
|
29
|
-
width: size + 'rpx',
|
|
30
|
-
height: size + 'rpx'
|
|
31
|
-
}"
|
|
32
|
-
>
|
|
33
|
-
<text
|
|
34
|
-
v-if="current < index"
|
|
35
|
-
:style="{
|
|
36
|
-
color: item.color
|
|
37
|
-
}"
|
|
38
|
-
>
|
|
39
|
-
{{ index + 1 }}
|
|
40
|
-
</text>
|
|
41
|
-
<pi-icon v-else :name="icon" color="#ffffff" />
|
|
42
|
-
</view>
|
|
43
|
-
|
|
44
|
-
<!-- 图标 -->
|
|
45
|
-
<view v-if="mode === 'icon'">
|
|
10
|
+
<view class="step-icon pi-flex-row-center" :style="[item.style]">
|
|
11
|
+
<template v-if="item.mode === 'dot'">
|
|
12
|
+
<view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
|
|
13
|
+
</template>
|
|
14
|
+
<!-- 数字-->
|
|
15
|
+
<template v-if="item.mode === 'number'">
|
|
16
|
+
<text v-if="index >= val">
|
|
17
|
+
{{ index + 1 }}
|
|
18
|
+
</text>
|
|
19
|
+
<pi-icon v-else name="check" color="#ffffff" />
|
|
20
|
+
</template>
|
|
21
|
+
<!-- 图标 -->
|
|
46
22
|
<pi-icon
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
:
|
|
51
|
-
:
|
|
23
|
+
v-if="item.mode === 'icon'"
|
|
24
|
+
:custom-style="item.icon.customStyle"
|
|
25
|
+
:custom-class="item.icon.customClass"
|
|
26
|
+
:name="item.icon.name"
|
|
27
|
+
:dot="item.icon.dot"
|
|
28
|
+
:dot-radius="item.icon.dotRadius"
|
|
29
|
+
:badge="item.icon.badge"
|
|
30
|
+
:color="item.icon.color"
|
|
31
|
+
:size="item.icon.size"
|
|
32
|
+
:class-prefix="item.icon.classPrefix"
|
|
52
33
|
/>
|
|
53
34
|
</view>
|
|
54
35
|
|
|
55
36
|
<!-- 文字 -->
|
|
56
|
-
<view :class="['pi-steps-item-text
|
|
57
|
-
<
|
|
58
|
-
|
|
37
|
+
<view :class="['pi-steps-item-text']" :style="{ color: item.style.fontColor }">
|
|
38
|
+
<slot name="item" :item="item" :index="index" :active="index < val">
|
|
39
|
+
<view>{{ item.name }}</view>
|
|
40
|
+
<text class="pi-fz-20" style="word-break:break-all">{{ item.desc }}</text>
|
|
41
|
+
</slot>
|
|
59
42
|
</view>
|
|
60
43
|
|
|
61
44
|
<!-- 中线 -->
|
|
62
|
-
<view
|
|
63
|
-
v-if="index < items.length - 1"
|
|
64
|
-
class="pi-steps-item-line"
|
|
65
|
-
:class="['pi-steps-item-line-' + mode]"
|
|
66
|
-
:style="lineStyle"
|
|
67
|
-
>
|
|
45
|
+
<view v-if="index < items.length - 1" class="pi-steps-item-line" :style="[lineStyle]">
|
|
68
46
|
<pi-line :direction="direction" length="100%" :hair-line="false" :color="color" />
|
|
69
47
|
</view>
|
|
70
48
|
</view>
|
|
@@ -141,45 +119,102 @@ export default {
|
|
|
141
119
|
type: String,
|
|
142
120
|
default: steps.currentColor
|
|
143
121
|
},
|
|
144
|
-
// 选中图标
|
|
145
|
-
icon: {
|
|
146
|
-
type: String,
|
|
147
|
-
default: steps.icon
|
|
148
|
-
},
|
|
149
122
|
// 排列方向,row|column
|
|
150
123
|
direction: {
|
|
151
124
|
type: String,
|
|
152
125
|
default: steps.direction
|
|
153
126
|
},
|
|
154
|
-
//
|
|
127
|
+
// 圆点大小
|
|
155
128
|
size: {
|
|
156
129
|
type: String,
|
|
157
130
|
default: steps.size
|
|
131
|
+
},
|
|
132
|
+
// 图标配置
|
|
133
|
+
icon: {
|
|
134
|
+
type: Object,
|
|
135
|
+
default() {
|
|
136
|
+
return steps.icon
|
|
137
|
+
}
|
|
158
138
|
}
|
|
159
139
|
},
|
|
160
140
|
data() {
|
|
161
141
|
return {}
|
|
162
142
|
},
|
|
163
143
|
computed: {
|
|
144
|
+
getDotMaxSize() {
|
|
145
|
+
return this.items.reduce((pre, cur) => {
|
|
146
|
+
const icon = this.$pi.lang.mergeDeep(this.getIcon, cur.icon)
|
|
147
|
+
const size = parseInt(icon.size || this.size, 10)
|
|
148
|
+
return size > pre ? size : pre
|
|
149
|
+
}, 0)
|
|
150
|
+
},
|
|
164
151
|
lineStyle() {
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
const style = {}
|
|
153
|
+
const size = this.getDotMaxSize / 2 + 'rpx'
|
|
167
154
|
this.direction === 'column' ? (style.left = size) : (style.top = size)
|
|
168
155
|
return style
|
|
169
156
|
},
|
|
170
|
-
|
|
171
|
-
return this.
|
|
157
|
+
getCurrentColor() {
|
|
158
|
+
return this.currentColor || this.color
|
|
172
159
|
},
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
|
|
161
|
+
getIcon() {
|
|
162
|
+
return this.$pi.lang.mergeDeep(steps.rightIcon, this.icon)
|
|
163
|
+
},
|
|
164
|
+
getItems() {
|
|
165
|
+
const getSize = this.$pi.common.addUnit(this.size)
|
|
166
|
+
const getDotMaxSize = this.$pi.common.addUnit(this.getDotMaxSize)
|
|
167
|
+
|
|
168
|
+
return this.items.map((originitem, index) => {
|
|
169
|
+
const item = { ...originitem, dotStyle: {} }
|
|
170
|
+
const style = {}
|
|
171
|
+
item.mode = item.mode || this.mode
|
|
172
|
+
item.icon = this.$pi.lang.mergeDeep(this.getIcon, item.icon)
|
|
173
|
+
if (item.mode === 'dot') {
|
|
174
|
+
style.width = getDotMaxSize
|
|
175
|
+
style.height = getDotMaxSize
|
|
176
|
+
item.dotStyle.width = getSize
|
|
177
|
+
item.dotStyle.height = getSize
|
|
178
|
+
}
|
|
179
|
+
if (item.mode === 'number') {
|
|
180
|
+
style.width = getDotMaxSize
|
|
181
|
+
style.height = getDotMaxSize
|
|
182
|
+
style.color = '#ffffff'
|
|
183
|
+
}
|
|
175
184
|
if (index === this.val) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
185
|
+
// 当前步骤
|
|
186
|
+
style.fontColor = this.getCurrentColor
|
|
187
|
+
if (item.mode === 'icon') {
|
|
188
|
+
style.color = this.getCurrentColor
|
|
189
|
+
} else if (item.mode === 'dot') {
|
|
190
|
+
item.dotStyle.backgroundColor = this.getCurrentColor
|
|
191
|
+
} else {
|
|
192
|
+
style.backgroundColor = this.getCurrentColor
|
|
193
|
+
}
|
|
194
|
+
} else if (index < this.val && this.activeColor) {
|
|
195
|
+
// 已激活步骤
|
|
196
|
+
style.fontColor = this.activeColor
|
|
197
|
+
if (item.mode === 'icon') {
|
|
198
|
+
style.color = this.activeColor
|
|
199
|
+
} else if (item.mode === 'dot') {
|
|
200
|
+
item.dotStyle.backgroundColor = this.getCurrentColor
|
|
201
|
+
} else {
|
|
202
|
+
style.backgroundColor = this.activeColor
|
|
203
|
+
}
|
|
204
|
+
} else if (index > this.val) {
|
|
205
|
+
// 未激活步骤
|
|
206
|
+
style.fontColor = this.color
|
|
207
|
+
if (item.mode === 'dot') {
|
|
208
|
+
item.dotStyle.backgroundColor = this.color
|
|
209
|
+
}
|
|
210
|
+
if (item.mode === 'icon') {
|
|
211
|
+
style.color = this.color
|
|
212
|
+
}
|
|
213
|
+
if (item.mode === 'number') {
|
|
214
|
+
style.backgroundColor = this.color
|
|
215
|
+
}
|
|
182
216
|
}
|
|
217
|
+
item.style = style
|
|
183
218
|
return item
|
|
184
219
|
})
|
|
185
220
|
}
|
|
@@ -198,10 +233,17 @@ export default {
|
|
|
198
233
|
align-items: flex-start;
|
|
199
234
|
flex: 1;
|
|
200
235
|
font-size: 26rpx;
|
|
201
|
-
|
|
236
|
+
&.row {
|
|
202
237
|
display: flex;
|
|
203
238
|
flex-direction: column;
|
|
204
239
|
align-items: center;
|
|
240
|
+
.pi-steps-item-text {
|
|
241
|
+
margin-top: 14rpx;
|
|
242
|
+
text-align: center;
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
align-items: center;
|
|
246
|
+
}
|
|
205
247
|
.pi-steps-item-line {
|
|
206
248
|
position: absolute;
|
|
207
249
|
left: 75%;
|
|
@@ -210,44 +252,47 @@ export default {
|
|
|
210
252
|
}
|
|
211
253
|
}
|
|
212
254
|
|
|
213
|
-
|
|
255
|
+
&.column {
|
|
214
256
|
display: flex;
|
|
215
257
|
flex-direction: row;
|
|
216
258
|
justify-content: flex-start;
|
|
259
|
+
align-items: center;
|
|
217
260
|
min-height: 120rpx;
|
|
261
|
+
.pi-steps-item-text {
|
|
262
|
+
width: 95%;
|
|
263
|
+
margin-left: 14rpx;
|
|
264
|
+
display: flex;
|
|
265
|
+
flex-direction: column;
|
|
266
|
+
}
|
|
218
267
|
.pi-steps-item-line {
|
|
219
268
|
position: absolute;
|
|
220
|
-
top:
|
|
269
|
+
top: 75%;
|
|
221
270
|
z-index: 0;
|
|
222
271
|
height: 50%;
|
|
223
272
|
}
|
|
224
273
|
}
|
|
225
|
-
|
|
274
|
+
.item-dot,
|
|
275
|
+
.step-icon {
|
|
226
276
|
border-radius: 50%;
|
|
227
|
-
&-column {
|
|
228
|
-
margin-top: 4rpx;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
&-number {
|
|
232
|
-
display: flex;
|
|
233
|
-
align-items: center;
|
|
234
|
-
justify-content: center;
|
|
235
277
|
overflow: hidden;
|
|
236
|
-
border: 1px solid #8799a3;
|
|
237
|
-
border-radius: 50%;
|
|
238
278
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
text
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
279
|
+
|
|
280
|
+
&.active {
|
|
281
|
+
.pi-steps-item-text {
|
|
282
|
+
color: $pi-primary-color;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.item-dot {
|
|
286
|
+
background-color: $pi-primary-color;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
&.icon .step-icon {
|
|
290
|
+
color: $pi-primary-color;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&.number .step-icon {
|
|
294
|
+
background-color: $pi-primary-color;
|
|
295
|
+
}
|
|
251
296
|
}
|
|
252
297
|
}
|
|
253
298
|
}
|
|
@@ -192,7 +192,7 @@ export default {
|
|
|
192
192
|
display: inline-block;
|
|
193
193
|
width: 2em;
|
|
194
194
|
height: 1em;
|
|
195
|
-
border:
|
|
195
|
+
border: 2rpx solid #e5e5e5;
|
|
196
196
|
transition: background-color $pi-animation-duration;
|
|
197
197
|
.switch-node {
|
|
198
198
|
position: relative;
|
|
@@ -200,8 +200,7 @@ export default {
|
|
|
200
200
|
background: #ffffff;
|
|
201
201
|
border-radius: 50%;
|
|
202
202
|
/* stylelint-disable */
|
|
203
|
-
box-shadow: -2rpx 4rpx 4rpx 0 rgba(0, 0, 0, 0.1),
|
|
204
|
-
0 4rpx 23rpx 0 rgba(0, 0, 0, 0.08),
|
|
203
|
+
box-shadow: -2rpx 4rpx 4rpx 0 rgba(0, 0, 0, 0.1), 0 4rpx 23rpx 0 rgba(0, 0, 0, 0.08),
|
|
205
204
|
0 0 4rpx 0 rgba(0, 0, 0, 0.2);
|
|
206
205
|
transition: all cubic-bezier(0.3, 1.05, 0.4, 1.05) $pi-animation-duration;
|
|
207
206
|
}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
>
|
|
26
26
|
<!-- slot slot-scoped只支持app,h5,微信小程序平台 -->
|
|
27
27
|
<!-- <template slot="item" slot-scope="{ item }">{{ item.tag }}</template> -->
|
|
28
|
-
<slot name="item" :item="item" :active="activeIndex === index">
|
|
28
|
+
<slot name="item" :item="item" :index="index" :active="activeIndex === index">
|
|
29
29
|
{{ item[displayField] }}
|
|
30
30
|
</slot>
|
|
31
31
|
</view>
|
|
@@ -333,7 +333,6 @@ export default {
|
|
|
333
333
|
if (srollWrapRect) {
|
|
334
334
|
this.tabsWidth = srollWrapRect.width
|
|
335
335
|
}
|
|
336
|
-
console.warn('this.tabsWidth', this.tabsWidth)
|
|
337
336
|
this.tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
|
|
338
337
|
console.log(TAG, '计算.pi-tab布局', this.tabRects)
|
|
339
338
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2021-08-13 11:31:57
|
|
4
|
-
* @LastEditTime: 2021-11-11
|
|
4
|
+
* @LastEditTime: 2021-11-17 11:30:50
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 图片上传组件
|
|
7
|
-
* @FilePath: /piui-
|
|
7
|
+
* @FilePath: /piui-awesome/src/piui/components/pi-upload-img/index.vue
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
10
|
<template>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
/>
|
|
28
28
|
</view>
|
|
29
29
|
<!-- 上传框 -->
|
|
30
|
-
<view v-if="
|
|
30
|
+
<view v-if="getUploadMaxCount">
|
|
31
31
|
<view :style="[getUploadBtnStyle]" class="pi-flex-column-center" @tap="handleChooseImage">
|
|
32
32
|
<slot name="uploadBtn">
|
|
33
33
|
<!-- 添加按钮 -->
|
|
@@ -46,13 +46,38 @@
|
|
|
46
46
|
<view v-if="uploadText" class="pi-mg-top-6 pi-fz-24 pi-light-gray">{{ uploadText }}</view>
|
|
47
47
|
</view>
|
|
48
48
|
</view>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
<!-- 剪裁弹窗 -->
|
|
50
|
+
<pi-mask v-model="showCrop" :mask-closeable="false" background="rgba(0, 0, 0, .9)">
|
|
51
|
+
<view class="pi-abso-full pi-flex-column">
|
|
52
|
+
<view class="pi-flex-sub">
|
|
53
|
+
<pi-img-cropper
|
|
54
|
+
:custom-style="getCropOption.customStyle"
|
|
55
|
+
:custom-class="getCropOption.customClass"
|
|
56
|
+
:src="cropPic"
|
|
57
|
+
:file-type="getCropOption.fileType"
|
|
58
|
+
:quality="getCropOption.quality"
|
|
59
|
+
:crop-size="getCropOption.cropSize"
|
|
60
|
+
:min-crop-size="getCropOption.minCropSize"
|
|
61
|
+
:boundary-detect="getCropOption.boundaryDetect"
|
|
62
|
+
:keep-crop-ratio="getCropOption.keepCropRatio"
|
|
63
|
+
:disable-rotate="getCropOption.disableRotate"
|
|
64
|
+
:canvas-zoom="getCropOption.canvasZoom"
|
|
65
|
+
:mask-background="getCropMaskBackground"
|
|
66
|
+
@cropped="handleCrop"
|
|
67
|
+
/>
|
|
53
68
|
</view>
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
<pi-bottom-bar
|
|
70
|
+
border-top="none"
|
|
71
|
+
:background="getCropMaskBackground"
|
|
72
|
+
:safe-area-bg-color="getCropMaskBackground"
|
|
73
|
+
>
|
|
74
|
+
<view class="pi-justify-between pi-align-center pi-pd-tb-32 pi-pd-lr-24 pi-fz-32">
|
|
75
|
+
<view class="pi-white" @tap="handleCancelCrop">取消</view>
|
|
76
|
+
<view class="pi-primary" @tap="handleCompelteCrop">完成</view>
|
|
77
|
+
</view>
|
|
78
|
+
</pi-bottom-bar>
|
|
79
|
+
</view>
|
|
80
|
+
</pi-mask>
|
|
56
81
|
</view>
|
|
57
82
|
</template>
|
|
58
83
|
|
|
@@ -214,11 +239,18 @@ export default {
|
|
|
214
239
|
return uploadImg.chooseImageOpts
|
|
215
240
|
}
|
|
216
241
|
},
|
|
217
|
-
//
|
|
218
|
-
|
|
219
|
-
type:
|
|
242
|
+
// 当maxCount设置为1的时候,可开启裁剪
|
|
243
|
+
crop: {
|
|
244
|
+
type: Boolean,
|
|
220
245
|
// `false`
|
|
221
|
-
default: uploadImg.
|
|
246
|
+
default: uploadImg.crop
|
|
247
|
+
},
|
|
248
|
+
// 裁剪参数
|
|
249
|
+
cropOption: {
|
|
250
|
+
type: Object,
|
|
251
|
+
default() {
|
|
252
|
+
return uploadImg.cropOption
|
|
253
|
+
}
|
|
222
254
|
},
|
|
223
255
|
// 上传成功解析对象方法
|
|
224
256
|
parseResultFn: {
|
|
@@ -240,6 +272,16 @@ export default {
|
|
|
240
272
|
}
|
|
241
273
|
}
|
|
242
274
|
},
|
|
275
|
+
// 文件上传时的钩子
|
|
276
|
+
onProgress: {
|
|
277
|
+
type: [Object, Function],
|
|
278
|
+
default() {
|
|
279
|
+
return {
|
|
280
|
+
[PI_DEFAULT_FN_FLAG]: true,
|
|
281
|
+
fn: uploadImg.onProgress
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
243
285
|
// 删除之前的钩子
|
|
244
286
|
beforeRemove: {
|
|
245
287
|
type: [Object, Function],
|
|
@@ -253,8 +295,9 @@ export default {
|
|
|
253
295
|
},
|
|
254
296
|
data() {
|
|
255
297
|
return {
|
|
256
|
-
showCrop: false,
|
|
257
|
-
cropPic: ''
|
|
298
|
+
showCrop: false, // 是否显示裁剪工具
|
|
299
|
+
cropPic: '', // 需要剪裁的图片
|
|
300
|
+
cropedPic: '' // 剪裁后的图片
|
|
258
301
|
}
|
|
259
302
|
},
|
|
260
303
|
computed: {
|
|
@@ -279,9 +322,15 @@ export default {
|
|
|
279
322
|
arrayMerge: (target, source) => source
|
|
280
323
|
})
|
|
281
324
|
},
|
|
282
|
-
|
|
325
|
+
getUploadMaxCount() {
|
|
283
326
|
const maxCount = parseInt(this.maxCount, 10)
|
|
284
327
|
return maxCount - this.getImgs.length
|
|
328
|
+
},
|
|
329
|
+
getCropMaskBackground() {
|
|
330
|
+
return 'rgba(0, 0, 0, .3)'
|
|
331
|
+
},
|
|
332
|
+
getCropOption() {
|
|
333
|
+
return this.$pi.lang.mergeDeep(uploadImg.cropOption, this.cropOption)
|
|
285
334
|
}
|
|
286
335
|
},
|
|
287
336
|
methods: {
|
|
@@ -323,20 +372,30 @@ export default {
|
|
|
323
372
|
}
|
|
324
373
|
})
|
|
325
374
|
},
|
|
326
|
-
handleCrop(res) {
|
|
327
|
-
this.showCrop = false
|
|
328
|
-
this.cropPic = ''
|
|
329
|
-
this.handleUpload([res.img])
|
|
330
|
-
},
|
|
331
375
|
async handleUpload(paths) {
|
|
332
376
|
const beforeUpload = this.beforeUpload[PI_DEFAULT_FN_FLAG]
|
|
333
377
|
? this.beforeUpload.fn
|
|
334
378
|
: this.beforeUpload
|
|
379
|
+
const onProgress = this.onProgress[PI_DEFAULT_FN_FLAG] ? this.onProgress.fn : this.onProgress
|
|
335
380
|
const parseResultFn = this.parseResultFn[PI_DEFAULT_FN_FLAG]
|
|
336
381
|
? this.parseResultFn.fn
|
|
337
382
|
: this.parseResultFn
|
|
338
383
|
try {
|
|
339
384
|
for await (const filePath of paths) {
|
|
385
|
+
// ---------- 上传之前的钩子 ----------
|
|
386
|
+
|
|
387
|
+
let beforeUploadResult = true
|
|
388
|
+
if (this.$pi.lang.isFunction(beforeUpload)) {
|
|
389
|
+
console.log(TAG, '调用文件上传前钩子')
|
|
390
|
+
beforeUploadResult = await beforeUpload(filePath)
|
|
391
|
+
}
|
|
392
|
+
if (!beforeUploadResult) {
|
|
393
|
+
console.log(TAG, '文件上传前钩子返回false,跳过上传')
|
|
394
|
+
continue
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ---------- 上传文件 ----------
|
|
398
|
+
|
|
340
399
|
let uploadResult = null
|
|
341
400
|
const params = {
|
|
342
401
|
url: this.action,
|
|
@@ -345,17 +404,17 @@ export default {
|
|
|
345
404
|
formData: this.formData,
|
|
346
405
|
header: this.headers
|
|
347
406
|
}
|
|
348
|
-
|
|
349
|
-
if (this.$pi.lang.isFunction(beforeUpload)) {
|
|
407
|
+
if (this.$pi.lang.isFunction(onProgress)) {
|
|
350
408
|
console.log(TAG, '使用自定义上传函数')
|
|
351
409
|
// 上传之前的钩子, 如果定义了则使用钩子上传文件
|
|
352
|
-
uploadResult = await
|
|
410
|
+
uploadResult = await onProgress(params)
|
|
353
411
|
} else {
|
|
354
|
-
// eslint-disable-next-line no-undef
|
|
355
412
|
const [, uploadFileResult] = await uni.uploadFile(params)
|
|
356
413
|
uploadResult = uploadFileResult
|
|
357
414
|
}
|
|
358
415
|
|
|
416
|
+
// ---------- 解析上传结果 ----------
|
|
417
|
+
|
|
359
418
|
const item = await parseResultFn(uploadResult)
|
|
360
419
|
if (item) {
|
|
361
420
|
this.isValString ? (this.val = item) : this.val.push(item)
|
|
@@ -366,10 +425,25 @@ export default {
|
|
|
366
425
|
this.$emit('fail', e)
|
|
367
426
|
}
|
|
368
427
|
},
|
|
428
|
+
handleCrop(res) {
|
|
429
|
+
console.log(TAG, '处理剪裁')
|
|
430
|
+
this.cropedPic = res.img
|
|
431
|
+
},
|
|
432
|
+
handleCancelCrop() {
|
|
433
|
+
console.log(TAG, '取消剪裁')
|
|
434
|
+
this.showCrop = false
|
|
435
|
+
this.cropPic = ''
|
|
436
|
+
},
|
|
437
|
+
handleCompelteCrop() {
|
|
438
|
+
console.log(TAG, '完成剪裁')
|
|
439
|
+
this.showCrop = false
|
|
440
|
+
this.handleUpload([this.cropedPic])
|
|
441
|
+
},
|
|
369
442
|
async handleChooseImage() {
|
|
370
|
-
if (this.disabled || !this.
|
|
443
|
+
if (this.disabled || !this.getUploadMaxCount) return
|
|
371
444
|
// 检查上传地址
|
|
372
|
-
|
|
445
|
+
const onProgress = this.onProgress[PI_DEFAULT_FN_FLAG] ? this.onProgress.fn : this.onProgress
|
|
446
|
+
if (!onProgress && !this.action) {
|
|
373
447
|
this.$toast('请配置上传地址')
|
|
374
448
|
return
|
|
375
449
|
}
|
|
@@ -378,9 +452,8 @@ export default {
|
|
|
378
452
|
}
|
|
379
453
|
const { sizeType, extension, sourceType, crop } = this.getChooseImageOpts
|
|
380
454
|
try {
|
|
381
|
-
// eslint-disable-next-line no-undef
|
|
382
455
|
const [, result] = await uni.chooseImage({
|
|
383
|
-
count: this.
|
|
456
|
+
count: this.getUploadMaxCount,
|
|
384
457
|
sizeType,
|
|
385
458
|
extension,
|
|
386
459
|
sourceType,
|
|
@@ -390,9 +463,8 @@ export default {
|
|
|
390
463
|
if (errMsg !== 'chooseImage:ok') {
|
|
391
464
|
throw new Error(errMsg)
|
|
392
465
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (this.maxCount === 1 && this.cropOpts && tempFilePaths.length === 1) {
|
|
466
|
+
if (this.getUploadMaxCount === 1 && this.crop && tempFilePaths.length === 1) {
|
|
467
|
+
// 单张图片设置了剪裁
|
|
396
468
|
this.showCrop = true
|
|
397
469
|
this.cropPic = tempFilePaths[0]
|
|
398
470
|
return
|
package/config/bottomBar.js
CHANGED
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
4
4
|
borderTop: '1px solid #e6e6e6', // 顶部边框样式,如需去掉,设置'none'
|
|
5
5
|
safeArea: true, // 是否开启安全区域
|
|
6
|
+
background: '#ffffff', // 背景
|
|
6
7
|
safeAreaBgColor: '#ffffff', // 安全区域背景颜色
|
|
7
8
|
height: '', // 建议传值,不传的时候,自动根据内容撑开
|
|
8
9
|
fixed: false, // 是否fixed定位
|
package/config/checkbox.js
CHANGED
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
name: '', // 标识符
|
|
5
5
|
shape: 'square', // 形状,可选值为 square round
|
|
6
6
|
borderRadius: 8, // 当shape为square的时候,设置圆角,单位rpx
|
|
7
|
-
border:
|
|
7
|
+
border: 2, // 边框大小,单位rpx
|
|
8
8
|
disabled: false, // 是否禁用复选框
|
|
9
9
|
readonly: false, // 是否只读模式
|
|
10
10
|
size: 40, // checkbox大小,单位rpx
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
percent:50, // 环形进度条,限制0-100之间,数字形式,默认值:50
|
|
3
|
+
bgColor:'#ffffff', // 环形进度区域背景色,字符串形式,默认值:'#ffffff'
|
|
4
|
+
inactiveColor: '#ececec', // 环形进度条底色,字符串形式,默认值:'#ececec'
|
|
5
|
+
activeColor: '#19be6b', // 环形进度条激活的颜色,字符串形式,默认值:'#19be6b'
|
|
6
|
+
borderWidth:14, //环形进度条的线条宽度,字符串/数字形式,默认值:14
|
|
7
|
+
width:200,//环形进度条整个圆的宽度,字符串/数字形式,默认值:200
|
|
8
|
+
duration: 1500, // 整个圆环执行至进度条所需的时间,单位ms,字符串/数字形式,默认值:1500
|
|
9
|
+
type:'',//环形进度条的主题
|
|
10
|
+
fontSize:'16px',//环形进度条中间显示文字的大小,字符串形式,默认值:'16px'
|
|
11
|
+
text:'',//环形进度条中间显示的文字,字符串形式,默认值:''
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
customClass: '', // 自定义样式类,字符串形式('')
|
|
3
|
+
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
4
|
+
startNum: 0, // 起始值
|
|
5
|
+
endNum: 0, // 终止值
|
|
6
|
+
duration: 2000, // 滚动到目标数值的动画持续时间,单位为毫秒(ms)
|
|
7
|
+
autoplay: true, // 是否自动播放
|
|
8
|
+
decimals: 0, // 要显示的小数位数
|
|
9
|
+
thousands: '', // 千位符分隔符,默认为空
|
|
10
|
+
isEase: true, // 是否在即将到达目标数值的时候,使用缓慢滚动的效果
|
|
11
|
+
fontColor: '#333333', // 字体颜色
|
|
12
|
+
fontSize: 38 // 字体大小,单位rpx
|
|
13
|
+
}
|