sadais-piui 1.0.182 → 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/README.md +27 -17
- package/components/pi-bottom-bar/index.vue +11 -2
- package/components/pi-calendar-panel/index.vue +10 -4
- package/components/pi-checkbox-group/index.vue +5 -0
- package/components/pi-circle-progress/index.vue +196 -173
- package/components/pi-count-up/index.vue +209 -0
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
- package/components/pi-dropdown/index.vue +316 -0
- package/components/pi-dropdown-item/index.vue +233 -0
- package/components/pi-form-item/index.vue +13 -1
- package/components/pi-img-cropper/canvas.js +112 -0
- package/components/pi-img-cropper/index.vue +357 -0
- package/components/pi-img-cropper/touch.js +163 -0
- package/components/pi-img-cropper/vector.js +35 -0
- package/components/pi-input/index.vue +9 -2
- package/components/pi-line/index.vue +78 -0
- package/components/pi-notify/index.vue +239 -0
- package/components/pi-popup/index.vue +1 -3
- package/components/pi-select/index.vue +5 -5
- package/components/pi-steps/index.vue +299 -0
- package/components/pi-switch/index.vue +2 -3
- package/components/pi-tabs/index.vue +1 -1
- package/components/pi-upload-img/index.vue +145 -40
- 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 +21 -0
- package/config/dropdownItem.js +26 -0
- package/config/form.js +3 -3
- package/config/imgCropper.js +26 -0
- package/config/line.js +8 -0
- package/config/notify.js +13 -0
- package/config/steps.js +19 -0
- package/config/{upload-img.js → uploadImg.js} +5 -1
- package/index.js +2 -2
- package/package.json +3 -3
- package/scss/common.scss +4 -0
- package/scss/variable.scss +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view v-if="show" scroll-y class="pi-dropdown-item pi-w-100P">
|
|
3
|
+
<slot>
|
|
4
|
+
<view
|
|
5
|
+
v-for="item in options"
|
|
6
|
+
:key="item[getKeyField]"
|
|
7
|
+
class="item-wrap pi-pd-tb-24 pi-pd-lr-32 pi-w-100P pi-justify-between pi-align-center"
|
|
8
|
+
:class="[customClass, item[getDisabledField] ? 'disabled' : '']"
|
|
9
|
+
:style="[customStyle, getItemStyle]"
|
|
10
|
+
@tap="handleSelectItem(item)"
|
|
11
|
+
>
|
|
12
|
+
<view>
|
|
13
|
+
{{ item[getDisplayField] }}
|
|
14
|
+
</view>
|
|
15
|
+
<!-- 如果配置了图片地址,使用图片 -->
|
|
16
|
+
<pi-img
|
|
17
|
+
v-if="getSelectedImg.src && item.id === val"
|
|
18
|
+
:src="getSelectedImg.src"
|
|
19
|
+
:mode="getSelectedImg.mode"
|
|
20
|
+
:width="getSelectedImg.width"
|
|
21
|
+
:height="getSelectedImg.height"
|
|
22
|
+
:dot="getSelectedImg.dot"
|
|
23
|
+
:dot-radius="getSelectedImg.dotRadius"
|
|
24
|
+
:badge="getSelectedImg.badge"
|
|
25
|
+
:shape="getSelectedImg.shape"
|
|
26
|
+
:border-radius="getSelectedImg.borderRadius"
|
|
27
|
+
:show-loading="getSelectedImg.showLoading"
|
|
28
|
+
:loading-color="getSelectedImg.loadingColor"
|
|
29
|
+
:loading-type="getSelectedImg.loadingType"
|
|
30
|
+
:loading-size="getSelectedImg.loadingSize"
|
|
31
|
+
:show-error="getSelectedImg.showError"
|
|
32
|
+
:webp="getSelectedImg.webp"
|
|
33
|
+
custom-class="pi-mg-left-24"
|
|
34
|
+
/>
|
|
35
|
+
<!-- 默认使用复选框 -->
|
|
36
|
+
<pi-checkbox
|
|
37
|
+
v-if="!getSelectedImg.src"
|
|
38
|
+
readonly
|
|
39
|
+
:value="item.id === val"
|
|
40
|
+
:name="getSelectedCheckbox.name"
|
|
41
|
+
:shape="getSelectedCheckbox.shape"
|
|
42
|
+
:border-radius="getSelectedCheckbox.borderRadius"
|
|
43
|
+
:border="getSelectedCheckbox.border"
|
|
44
|
+
:disabled="getSelectedCheckbox.disabled"
|
|
45
|
+
:size="getSelectedCheckbox.size"
|
|
46
|
+
:icon-size="getSelectedCheckbox.iconSize"
|
|
47
|
+
:active-color="getSelectedCheckbox.activeColor"
|
|
48
|
+
:active-mode="getSelectedCheckbox.activeMode"
|
|
49
|
+
custom-class="pi-mg-left-24"
|
|
50
|
+
/>
|
|
51
|
+
</view>
|
|
52
|
+
</slot>
|
|
53
|
+
</scroll-view>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
import ValueSync from '../../mixin/value-sync'
|
|
58
|
+
import { childInit } from '../../mixin/props-sync'
|
|
59
|
+
import { getConfig } from '../../config'
|
|
60
|
+
|
|
61
|
+
const { dropdownItem } = getConfig()
|
|
62
|
+
const extendPiDropDown = childInit('PiDropdown')
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
name: 'PiDropdownItem',
|
|
66
|
+
mixins: [ValueSync, extendPiDropDown], // 注入value与val,进行双向绑定、混入自定义样式customStyle和customClass
|
|
67
|
+
props: {
|
|
68
|
+
// 初始值
|
|
69
|
+
value: {
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
// 自定义样式,对象形式
|
|
73
|
+
customStyle: {
|
|
74
|
+
type: Object,
|
|
75
|
+
default() {
|
|
76
|
+
// {}
|
|
77
|
+
return dropdownItem.customStyle
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
// 自定义样式类,字符串形式
|
|
81
|
+
customClass: {
|
|
82
|
+
type: String,
|
|
83
|
+
default() {
|
|
84
|
+
// ''
|
|
85
|
+
return dropdownItem.customClass
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
// 是否显示菜单
|
|
89
|
+
showIcon: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: dropdownItem.showIcon
|
|
92
|
+
},
|
|
93
|
+
// 菜单图标配置
|
|
94
|
+
iconOption: {
|
|
95
|
+
type: Object,
|
|
96
|
+
default() {
|
|
97
|
+
return dropdownItem.iconOption
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
// 菜单标题
|
|
101
|
+
title: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: dropdownItem.title
|
|
104
|
+
},
|
|
105
|
+
// 是否禁用
|
|
106
|
+
disabled: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: dropdownItem.disabled
|
|
109
|
+
},
|
|
110
|
+
// 选项列表,默认
|
|
111
|
+
options: {
|
|
112
|
+
type: Array,
|
|
113
|
+
default() {
|
|
114
|
+
return dropdownItem.options
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// 行高 值为数字,则单位默认rpx
|
|
118
|
+
itemHeight: {
|
|
119
|
+
type: [String, Number],
|
|
120
|
+
// 110
|
|
121
|
+
default: dropdownItem.itemHeight
|
|
122
|
+
},
|
|
123
|
+
// 选项id字段
|
|
124
|
+
keyField: {
|
|
125
|
+
type: String,
|
|
126
|
+
// `id`
|
|
127
|
+
default: dropdownItem.keyField
|
|
128
|
+
},
|
|
129
|
+
// 选项显示字段
|
|
130
|
+
displayField: {
|
|
131
|
+
type: String,
|
|
132
|
+
// `text`
|
|
133
|
+
default: dropdownItem.displayField
|
|
134
|
+
},
|
|
135
|
+
// 选项禁用字段,默认为disabled
|
|
136
|
+
disabledField: {
|
|
137
|
+
type: String,
|
|
138
|
+
// `text`
|
|
139
|
+
default: dropdownItem.disabledField
|
|
140
|
+
},
|
|
141
|
+
// 选中图标的配置
|
|
142
|
+
selectedImg: {
|
|
143
|
+
type: Object,
|
|
144
|
+
default() {
|
|
145
|
+
// 参照img
|
|
146
|
+
return dropdownItem.selectedImg
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
// 选中checkbox配置
|
|
150
|
+
selectedCheckbox: {
|
|
151
|
+
type: Object,
|
|
152
|
+
default() {
|
|
153
|
+
// 参照checkbox
|
|
154
|
+
return dropdownItem.selectedCheckbox
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
data() {
|
|
159
|
+
return {
|
|
160
|
+
show: false // 显示当前Item组件
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
computed: {
|
|
164
|
+
getIconOption() {
|
|
165
|
+
return this.$pi.lang.mergeDeep(dropdownItem.iconOption, this.iconOption)
|
|
166
|
+
},
|
|
167
|
+
getItemHeight() {
|
|
168
|
+
return this.inheritProps.itemHeight !== null ? this.inheritProps.itemHeight : this.itemHeight
|
|
169
|
+
},
|
|
170
|
+
getKeyField() {
|
|
171
|
+
return this.inheritProps.keyField !== null ? this.inheritProps.keyField : this.keyField
|
|
172
|
+
},
|
|
173
|
+
getDisplayField() {
|
|
174
|
+
return this.inheritProps.displayField !== null
|
|
175
|
+
? this.inheritProps.displayField
|
|
176
|
+
: this.displayField
|
|
177
|
+
},
|
|
178
|
+
getDisabledField() {
|
|
179
|
+
return this.inheritProps.disabledField !== null
|
|
180
|
+
? this.inheritProps.disabledField
|
|
181
|
+
: this.disabledField
|
|
182
|
+
},
|
|
183
|
+
getSelectedImg() {
|
|
184
|
+
const selectedImg = this.inheritProps.selectedImg || dropdownItem.selectedImg
|
|
185
|
+
return this.$pi.lang.mergeDeep(selectedImg, this.selectedImg)
|
|
186
|
+
},
|
|
187
|
+
getSelectedCheckbox() {
|
|
188
|
+
const selectedCheckbox = this.inheritProps.selectedCheckbox || dropdownItem.selectedCheckbox
|
|
189
|
+
return this.$pi.lang.mergeDeep(selectedCheckbox, this.selectedCheckbox)
|
|
190
|
+
},
|
|
191
|
+
getItemStyle() {
|
|
192
|
+
return {
|
|
193
|
+
height: this.$pi.common.addUnit(this.getItemHeight)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
methods: {
|
|
198
|
+
emitChange(val) {
|
|
199
|
+
this.val = val
|
|
200
|
+
this.handleEmitChange()
|
|
201
|
+
},
|
|
202
|
+
handleSelectItem(item) {
|
|
203
|
+
if (item[this.getDisabledField]) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
this.emitChange(item.id)
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
this._parent.submit()
|
|
209
|
+
}, 300) // 延迟 可见按钮点击动画
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
</script>
|
|
214
|
+
|
|
215
|
+
<style lang="scss" scoped>
|
|
216
|
+
@import '../../scss/mixin.scss';
|
|
217
|
+
|
|
218
|
+
.pi-dropdown-item {
|
|
219
|
+
max-height: 600rpx;
|
|
220
|
+
.item-wrap {
|
|
221
|
+
&:not(:last-child) {
|
|
222
|
+
@include pi-border;
|
|
223
|
+
&::after {
|
|
224
|
+
border: 0 solid $pi-list-border-color;
|
|
225
|
+
border-bottom-width: $pi-list-border-width;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
&.disabled {
|
|
229
|
+
opacity: $pi-disabled-opacity;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
</style>
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
<view
|
|
3
3
|
class="pi-form-item"
|
|
4
4
|
:style="[customStyle, itemStyle]"
|
|
5
|
-
:class="[
|
|
5
|
+
:class="[
|
|
6
|
+
{ disabled: getDisabled },
|
|
7
|
+
{ border: getBorder },
|
|
8
|
+
{ 'pi-align-center': !getWrap },
|
|
9
|
+
customClass
|
|
10
|
+
]"
|
|
6
11
|
@tap.stop="handleItemClick"
|
|
7
12
|
>
|
|
8
13
|
<!-- 表单标题 -->
|
|
@@ -263,6 +268,9 @@ export default {
|
|
|
263
268
|
getColon() {
|
|
264
269
|
return this.inheritProps.colon !== null ? this.inheritProps.colon : this.colon
|
|
265
270
|
},
|
|
271
|
+
getDisabled() {
|
|
272
|
+
return this.inheritProps.disabled !== null ? this.inheritProps.disabled : this.disabled
|
|
273
|
+
},
|
|
266
274
|
getLabelAlign() {
|
|
267
275
|
return this.inheritProps.labelAlign !== null ? this.inheritProps.labelAlign : this.labelAlign
|
|
268
276
|
},
|
|
@@ -430,6 +438,10 @@ export default {
|
|
|
430
438
|
.pi-form-item {
|
|
431
439
|
overflow: hidden;
|
|
432
440
|
font-size: $pi-form-size;
|
|
441
|
+
&.disabled {
|
|
442
|
+
pointer-events: none;
|
|
443
|
+
opacity: $pi-disabled-opacity;
|
|
444
|
+
}
|
|
433
445
|
&.border {
|
|
434
446
|
@include pi-border;
|
|
435
447
|
&::after {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
canvasId: ''
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
created() {
|
|
8
|
+
this.canvasId = this.generateCanvasId()
|
|
9
|
+
},
|
|
10
|
+
computed: {
|
|
11
|
+
canvasStyle() {
|
|
12
|
+
const w = this.crop.width * this.canvasZoom
|
|
13
|
+
const h = this.crop.height * this.canvasZoom
|
|
14
|
+
return {
|
|
15
|
+
width: `${w}px`,
|
|
16
|
+
height: `${h}px`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
methods: {
|
|
21
|
+
// this method copy from: https://github.com/prianyu/uniapp-nice-cropper/blob/master/src/cropper.js
|
|
22
|
+
generateCanvasId() {
|
|
23
|
+
const seeds = 'abcdefghijklmnopqrstuvwxyz'
|
|
24
|
+
const arr = seeds
|
|
25
|
+
.split('')
|
|
26
|
+
.concat(seeds.toUpperCase().split(''))
|
|
27
|
+
.concat('0123456789'.split(''))
|
|
28
|
+
let m = arr.length
|
|
29
|
+
let i
|
|
30
|
+
while (m) {
|
|
31
|
+
i = Math.floor(Math.random() * m--)
|
|
32
|
+
const temp = arr[m]
|
|
33
|
+
arr[m] = arr[i]
|
|
34
|
+
arr[i] = temp
|
|
35
|
+
}
|
|
36
|
+
return arr.slice(0, 16).join('')
|
|
37
|
+
},
|
|
38
|
+
draw() {
|
|
39
|
+
// #ifdef MP-ALIPAY
|
|
40
|
+
const ctx = uni.createCanvasContext(this.canvasId)
|
|
41
|
+
// #endif
|
|
42
|
+
// #ifndef MP-ALIPAY
|
|
43
|
+
const ctx = uni.createCanvasContext(this.canvasId, this)
|
|
44
|
+
// #endif
|
|
45
|
+
ctx.save()
|
|
46
|
+
// 填充裁剪窗口
|
|
47
|
+
ctx.setFillStyle('#ffffff')
|
|
48
|
+
// 绘制之前
|
|
49
|
+
// @arg ctx 结构: {ctx: canvas实例, width, height}
|
|
50
|
+
this.$emit('beforeDraw', {
|
|
51
|
+
ctx,
|
|
52
|
+
width: this.crop.width,
|
|
53
|
+
height: this.crop.height
|
|
54
|
+
})
|
|
55
|
+
ctx.fillRect(
|
|
56
|
+
0,
|
|
57
|
+
0,
|
|
58
|
+
this.crop.width * this.canvasZoom,
|
|
59
|
+
this.crop.height * this.canvasZoom
|
|
60
|
+
)
|
|
61
|
+
// 将画布的坐标原点 移动到裁剪窗口左上角对应的那个像素点的位置
|
|
62
|
+
ctx.translate(
|
|
63
|
+
(this.img.width * 0.5 + this.img.transform.x - this.crop.left) *
|
|
64
|
+
this.canvasZoom,
|
|
65
|
+
(this.img.height * 0.5 + this.img.transform.y - this.crop.top) *
|
|
66
|
+
this.canvasZoom
|
|
67
|
+
)
|
|
68
|
+
// 旋转图片
|
|
69
|
+
ctx.rotate((this.img.transform.rotate * Math.PI) / 180)
|
|
70
|
+
// 将坐标原点移动回左上角
|
|
71
|
+
ctx.translate(
|
|
72
|
+
-this.img.width * 0.5 * this.img.transform.scale * this.canvasZoom,
|
|
73
|
+
-this.img.height * 0.5 * this.img.transform.scale * this.canvasZoom
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
ctx.drawImage(
|
|
77
|
+
this.img.path,
|
|
78
|
+
0,
|
|
79
|
+
0,
|
|
80
|
+
this.img.width * this.img.transform.scale * this.canvasZoom,
|
|
81
|
+
this.img.height * this.canvasZoom * this.img.transform.scale
|
|
82
|
+
)
|
|
83
|
+
// 绘制完裁剪图片之后
|
|
84
|
+
// @arg ctx 结构: {ctx: canvas实例, width, height}
|
|
85
|
+
ctx.restore()
|
|
86
|
+
this.$emit('afterDraw', {
|
|
87
|
+
ctx,
|
|
88
|
+
width: this.crop.width * this.canvasZoom,
|
|
89
|
+
height: this.crop.height * this.canvasZoom
|
|
90
|
+
})
|
|
91
|
+
ctx.draw(false, () => {
|
|
92
|
+
uni.canvasToTempFilePath(
|
|
93
|
+
{
|
|
94
|
+
canvasId: this.canvasId,
|
|
95
|
+
quality: this.quality,
|
|
96
|
+
fileType: this.fileTpe,
|
|
97
|
+
success: (res) => {
|
|
98
|
+
// 裁剪成功
|
|
99
|
+
// @arg 参数1 结构:{ img: 本地路径 or base64(h5端), width, height }
|
|
100
|
+
this.$emit('cropped', {
|
|
101
|
+
img: res.tempFilePath,
|
|
102
|
+
width: this.crop.width * this.canvasZoom,
|
|
103
|
+
height: this.crop.height * this.canvasZoom
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
this
|
|
108
|
+
)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|