sadais-piui 1.1.0 → 1.2.1

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 (41) hide show
  1. package/CHANGELOG.md +482 -240
  2. package/README.md +27 -17
  3. package/components/pi-bottom-bar/index.vue +11 -2
  4. package/components/pi-calendar-panel/index.vue +10 -4
  5. package/components/pi-checkbox-group/index.vue +5 -0
  6. package/components/pi-circle-progress/index.vue +196 -173
  7. package/components/pi-count-up/index.vue +209 -0
  8. package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
  9. package/components/pi-dropdown/index.vue +316 -0
  10. package/components/pi-dropdown-item/index.vue +233 -0
  11. package/components/pi-form-item/index.vue +13 -1
  12. package/components/pi-img-cropper/canvas.js +112 -0
  13. package/components/pi-img-cropper/index.vue +357 -0
  14. package/components/pi-img-cropper/touch.js +163 -0
  15. package/components/pi-img-cropper/vector.js +35 -0
  16. package/components/pi-input/index.vue +9 -2
  17. package/components/pi-line/index.vue +78 -0
  18. package/components/pi-notify/index.vue +239 -0
  19. package/components/pi-popup/index.vue +1 -3
  20. package/components/pi-radio/index.vue +1 -1
  21. package/components/pi-select/index.vue +16 -6
  22. package/components/pi-steps/index.vue +299 -0
  23. package/components/pi-switch/index.vue +2 -3
  24. package/components/pi-tabs/index.vue +1 -1
  25. package/components/pi-upload-img/index.vue +145 -40
  26. package/config/bottomBar.js +1 -0
  27. package/config/checkbox.js +1 -1
  28. package/config/circleProgress.js +13 -0
  29. package/config/countUp.js +13 -0
  30. package/config/dropdown.js +21 -0
  31. package/config/dropdownItem.js +26 -0
  32. package/config/form.js +3 -3
  33. package/config/imgCropper.js +26 -0
  34. package/config/line.js +8 -0
  35. package/config/notify.js +13 -0
  36. package/config/steps.js +19 -0
  37. package/config/{upload-img.js → uploadImg.js} +5 -1
  38. package/index.js +2 -2
  39. package/package.json +3 -3
  40. package/scss/common.scss +4 -0
  41. package/scss/variable.scss +1 -1
package/README.md CHANGED
@@ -18,26 +18,29 @@ PiUI是基于uniapp,高质量UI移动组件库,基于 `vue.js` 语法,可
18
18
  * 按需引入
19
19
  * 支持主题定制
20
20
 
21
- ## Table of Contents
21
+ ## Website 网站
22
22
 
23
- - [Website](#website)
24
- - [Background](#background)
25
- - [Install](#install)
26
- - [Usage](#usage)
27
- - [Maintainers](#maintainers)
28
- - [Contributing](#contributing)
29
- - [License](#license)
23
+ [官方文档:https://piui.sadais.com/](https://piui.sadais.com/)
30
24
 
31
- ## Website
32
- [官方文档](http://piui.sadais.com/)
25
+ [GITHUB仓库:https://github.com/sadais-org/piui](https://github.com/sadais-org/piui)
33
26
 
34
- ## Background
27
+ [GITEE仓库:https://gitee.com/org-sadais/piui](https://gitee.com/org-sadais/piui)
35
28
 
36
- 大多数团队使用[uni-app](https://uniapp.dcloud.io/)方案,是为了跨平台,在跨平台的基础上,uniapp提供的vue语法(不完全支持),能比原生的写法(小程序原生语法作为对比)提高30%的效率,但是仅仅使用uniapp提供的基础组件,是远远支撑不了现代移动端的业务复杂度。
29
+ `欢迎大家star和fork,你的支持是我们持续更新的动力!`
30
+
31
+ `扫码体验[piui]小程序`
32
+
33
+ ![](https://sadais-oss.oss-cn-hangzhou.aliyuncs.com/piui/qrcode.jpeg)
34
+
35
+ ## Background 背景
36
+
37
+ uniapp提供的vue语法(不完全支持),能比原生的写法(小程序原生语法作为对比)提高30%的效率。
38
+
39
+ 但是仅仅使用uniapp提供的基础组件,是远远支撑不了现代移动端的业务复杂度。
37
40
 
38
41
  借助`piui`的能力,可以让您基于uniapp,再增加至少50%的效率提升。
39
42
 
40
- ## Install
43
+ ## Install 安装
41
44
 
42
45
  ### 使用脚手架【推荐】
43
46
  基于`vue-cli`脚手架创建,更加通用的`vue`项目配置,接入更加快捷,可以做到零配置直接运行,其中引入了`sadais-core`
@@ -120,15 +123,15 @@ Vue.use(piui, piuiConfig);
120
123
  }
121
124
  ```
122
125
 
123
- ## Usage
126
+ ## Usage 使用方法
124
127
 
125
128
  配置easycom规则后,自动按需引入
126
129
 
127
- ## Maintainers
130
+ ## Maintainers 成员
128
131
 
129
132
  [@zhangzhenfei](https://github.com/zhangzhenfei)
130
133
 
131
- ## Contributing
134
+ ## Contributing 贡献
132
135
 
133
136
  PRs accepted.
134
137
 
@@ -139,7 +142,7 @@ issue 仅用于提交 Bug 或 Feature 相关的内容,其它内容可能会被
139
142
 
140
143
  在提交 issue 之前,请搜索相关内容是否已被提出。
141
144
 
142
- 请说明 Muse UI 和 Vue 的版本号,并提供操作系统和浏览器信息。推荐使用 生成在线 demo,这能够更直观地重现问题。
145
+ 请说明 PiUI 和 Vue 的版本号,并提供操作系统和浏览器信息。推荐使用 生成在线 demo,这能够更直观地重现问题。
143
146
 
144
147
  ## Pull Request 规范
145
148
  请先 fork 一份到自己的项目下,不要直接在仓库下建分支。
@@ -155,3 +158,10 @@ commit 信息要以[组件名]: 描述信息 的形式填写,例如 [Navbar]:
155
158
  ## License
156
159
 
157
160
  MIT © 2021 zhangzhenfei
161
+
162
+ ## 微信群
163
+
164
+ 请扫码添加[piui客服小助手]邀请进群
165
+
166
+ ![](https://sadais-oss.oss-cn-hangzhou.aliyuncs.com/piui/WechatIMG17.jpeg)
167
+
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <view>
3
- <view class="pi-bottom-bar" :style="[{ borderTop: borderTop }]" :class="[{ fixed: fixed }]">
3
+ <view
4
+ class="pi-bottom-bar"
5
+ :style="[{ borderTop: borderTop, background: background }]"
6
+ :class="[{ fixed: fixed }]"
7
+ >
4
8
  <!-- 默认插槽 -->
5
9
  <view
6
10
  class="pi-w-100P"
@@ -63,6 +67,12 @@ export default {
63
67
  return bottomBar.safeArea
64
68
  }
65
69
  },
70
+ // 背景
71
+ background: {
72
+ type: String,
73
+ // '#ffffff'
74
+ default: bottomBar.background
75
+ },
66
76
  // 安全区域背景颜色
67
77
  safeAreaBgColor: {
68
78
  type: String,
@@ -114,7 +124,6 @@ export default {
114
124
  <style lang="scss" scoped>
115
125
  .pi-bottom-bar {
116
126
  width: 100%;
117
- background: #ffffff;
118
127
  &.fixed {
119
128
  position: fixed;
120
129
  right: 0;
@@ -225,6 +225,12 @@ export default {
225
225
  getMaxDate() {
226
226
  return this.minDate ? this.$pi.date.parseDate(this.maxDate) : ''
227
227
  },
228
+ isMinYear() {
229
+ return this.year === parseInt(this.minYear, 10)
230
+ },
231
+ isMaxYear() {
232
+ return this.year === parseInt(this.maxYear, 10)
233
+ },
228
234
  // 总天数
229
235
  days() {
230
236
  const days = []
@@ -367,11 +373,11 @@ export default {
367
373
  },
368
374
  handleChangeMonth(change) {
369
375
  const month = this.month + change
370
- if (month > 12) {
376
+ if (month > 12 && !this.isMaxYear) {
371
377
  // 下一年
372
378
  this.year = this.year + 1
373
379
  this.month = 1
374
- } else if (month < 1) {
380
+ } else if (month < 1 && !this.isMinYear) {
375
381
  // 上一年
376
382
  this.year = this.year - 1
377
383
  this.month = 12
@@ -380,8 +386,8 @@ export default {
380
386
  }
381
387
  },
382
388
  handleChangeYear(change) {
383
- if (change > 0 && this.year === parseInt(this.maxYear, 10)) return
384
- if (change < 0 && this.year === parseInt(this.minYear, 10)) return
389
+ if (change > 0 && this.isMaxYear) return
390
+ if (change < 0 && this.isMinYear) return
385
391
  this.year = this.year + change
386
392
  },
387
393
  handleBackToday() {
@@ -137,6 +137,11 @@ export default {
137
137
  handler(value) {
138
138
  this.handleValChange()
139
139
  }
140
+ },
141
+ value: {
142
+ handler(val) {
143
+ console.warn('val', val)
144
+ }
140
145
  }
141
146
  },
142
147
  methods: {
@@ -1,201 +1,224 @@
1
1
  <!--
2
2
  * @Author: zhouxianpan
3
3
  * @Date: 2021-09-06 10:07:33
4
- * @LastEditTime: 2021-09-06 11:27:56
5
- * @LastEditors: zhouxianpan
4
+ * @LastEditTime: 2021-11-23 16:45:30
5
+ * @LastEditors: zhangzhenfei
6
6
  * @Description:
7
- * @FilePath: \pi-ui\piui\components\pi-circle-progress\index.vue
7
+ * @FilePath: \piui-awesome\src\piui\components\pi-circle-progress\index.vue
8
8
  -->
9
9
  <template>
10
- <view>
11
- <canvas :id="elBgId" class="pi-canvas-bg"></canvas>
12
- <canvas :id="elId" class="pi-canvas"></canvas>
13
- </view>
10
+ <view
11
+ class="circle-progress"
12
+ :style="{
13
+ width: widthPx + 'px',
14
+ height: widthPx + 'px',
15
+ backgroundColor: bgColor
16
+ }"
17
+ >
18
+ <canvas
19
+ :id="elBgId"
20
+ :canvas-id="elBgId"
21
+ class="pi-canvas-bg"
22
+ :style="{
23
+ width: widthPx + 'px',
24
+ height: widthPx + 'px'
25
+ }"
26
+ />
27
+ <canvas
28
+ :id="elId"
29
+ :canvas-id="elId"
30
+ class="pi-canvas"
31
+ :style="{
32
+ width: widthPx + 'px',
33
+ height: widthPx + 'px'
34
+ }"
35
+ />
36
+ </view>
14
37
  </template>
38
+ <script>
39
+ import { getConfig } from '../../config'
40
+ const { circleProgress } = getConfig()
15
41
 
16
- <script >
17
42
  export default {
43
+ name: 'PiCircleProgress',
18
44
  props: {
19
- // 进度 默认50%
45
+ // 圆环进度百分比值
20
46
  percent: {
21
- type:number,
22
- default() {
23
- return 50
24
- },
25
- // 动画时间 默认1秒
26
- duration: {
27
- type:number,
28
- default() {
29
- return 1000
47
+ type: Number,
48
+ default: circleProgress.percent,
49
+ // 限制值在0到100之间
50
+ validator: val => {
51
+ return val >= 0 && val <= 100
30
52
  }
31
53
  },
32
- // 圆的半径
33
- radius : {
34
- type:number,
35
- default() {
36
- return 100
37
- }
54
+ // 整个圆环进度区域的背景色
55
+ bgColor: {
56
+ type: String,
57
+ default: circleProgress.bgColor
38
58
  },
39
- // 环形进度的width
40
- lineWidth : {
41
- type:number,
42
- default() {
43
- return 10
44
- }
59
+ // 底部圆环的颜色(灰色的圆环)
60
+ inactiveColor: {
61
+ type: String,
62
+ default: circleProgress.inactiveColor
45
63
  },
46
- // 进度条的底色
47
- strokeStyle: {
48
- type:string,
49
- default(){
50
- return '#40E0D0'
51
- }
64
+ // 圆环激活部分的颜色
65
+ activeColor: {
66
+ type: String,
67
+ default: circleProgress.activeColor
52
68
  },
53
- // 激活进度条的底色
54
- circleColor: {
55
- type:string,
56
- default(){
57
- return '#FFFF00'
58
- }
69
+ // 圆环线条的宽度,单位rpx
70
+ borderWidth: {
71
+ type: [Number, String],
72
+ default: circleProgress.borderWidth
59
73
  },
60
- // 进度条的形态
61
- lineCap : {
62
- type:string,
63
- default(){
64
- return 'round'
65
- }
74
+ // 整个圆形的宽度,单位rpx
75
+ width: {
76
+ type: [Number, String],
77
+ default: circleProgress.width
66
78
  },
67
- // 中间显示的文字
68
- text: {
69
- type:string,
70
- default(){
71
- return '文字显示'
72
- }
79
+ // 整个圆环执行一圈的时间,单位ms
80
+ duration: {
81
+ type: [Number, String],
82
+ default: circleProgress.duration
73
83
  },
74
- // 显示字体颜色
75
- fontColor : {
76
- type:string,
77
- default(){
78
- return '#000000'
79
- }
84
+ // 主题类型
85
+ type: {
86
+ type: String,
87
+ default: circleProgress.type
80
88
  },
81
- // 显示字体大小
82
- fontSize : {
83
- type:number,
84
- default(){
85
- return 28
86
- }
89
+
90
+ // 字体大小
91
+ fontSize: {
92
+ type: String,
93
+ default: circleProgress.fontSize
87
94
  },
95
+ // 显示的文字 默认为空
96
+ text: {
97
+ type: String,
98
+ default: circleProgress.text
99
+ }
88
100
  },
89
101
  data() {
90
- return {
102
+ return {
103
+ elBgId: 'pCircleProgressBgId', // 微信小程序中不能使用this.$pi形式动态生成id值,否则会报错
104
+ elId: 'pCircleProgressElId',
105
+ elBgId: this.$pi.guid(), // 支付宝等小程序 动态生产ID
106
+ elId: this.$pi.guid(),
91
107
  progressContext: null,
92
- //开始的角度
93
- startAngle: -Math.PI / 2,
94
- newVal: 0,
95
- oldVal: 0,
96
- }
97
- },
98
- mounted() {
99
- setTimeout(() => {
100
- // 背景圆
101
- this.drawProgressBg()
102
- // 进度圆
103
- this.drawCircleByProgress(this.percent)
104
- }, 50)
105
- },
106
- watch: {
107
- // 深度监听进度
108
- percent: {
109
- handler(newVal, oldVal) {
110
- console.log(newVal);
111
- console.log(oldVal);
112
- if (newVal > 100) newVal = 100;
113
- if (newVal < 0) oldVal = 0
114
- this.newVal = newVal
115
- this.oldVal = oldVal
116
- this.drawCircleByProgress(oldVal)
117
- },
118
- deep: true
119
- }
120
- },
121
- computed: {
122
- // 圆的实际半径 =半径+环形进度条的宽度
123
- moveWith() {
124
- return this.radius + this.lineWidth
125
- },
126
-
127
- },
128
- created() {
129
- this.newVal = this.percent
130
- this.oldVal = 0
131
- console.log(-Math.PI / 2);
132
-
133
- },
134
- methods: {
135
-
136
- drawProgressBg() {
137
- let canvas = document.getElementById(this.elBgId)
138
- // 宽高
139
- canvas.width = this.moveWith * 2
140
- canvas.height = this.moveWith * 2
141
- let ctx = canvas.getContext('2d')
142
- ctx.beginPath();
143
- // X,Y轴中心点+半径+起始方向+结束 +是否顺逆
144
- ctx.arc(this.moveWith, this.moveWith, this.radius, 0, Math.PI * 2, false);
145
- ctx.lineWidth = this.lineWidth;
146
- ctx.strokeStyle = this.strokeStyle;
147
- // 文字
148
- ctx.font = 'bold ' + this.fontSize + 'px' + ' Arial'
149
- ctx.fillStyle = this.fontColor;
150
- ctx.textAlign = 'center';
151
- ctx.textBaseline = 'middle';
152
- ctx.fillText(this.text, this.moveWith, this.moveWith, this.radius);
153
- ctx.stroke();
154
- ctx.closePath();
155
-
156
- },
157
- // 激活部分
158
- drawCircleByProgress(progress) {
159
- let canvas = document.getElementById(this.elId)
160
- canvas.width = this.moveWith * 2
161
- canvas.height = this.moveWith * 2
162
- let ctx = canvas.getContext('2d')
163
- let endAngel = ((2 * Math.PI) / 100) * progress + this.startAngle
164
- ctx.beginPath()
165
- ctx.lineWidth = this.lineWidth;
166
- ctx.strokeStyle = this.circleColor;
167
- ctx.lineCap = this.lineCap
168
- ctx.arc(this.moveWith, this.moveWith, this.radius, this.startAngle, endAngel, false);
169
- ctx.stroke();
170
- ctx.closePath();
171
- // 实际时间
172
- let time = Math.floor(this.duration / 100)
173
- if (this.newVal > this.oldVal) {
174
-
175
- progress++;
176
-
177
- if (progress > this.newVal) return;
178
- } else {
179
-
180
- progress--;
181
- if (progress < this.newVal) return;
182
- }
183
- // 动画
184
- setTimeout(() => {
185
- // 定时器 进度条有动画效果
186
- this.drawCircleByProgress(progress);
187
- }, time);
188
- }
189
- }
108
+ // 开始的角度
109
+ widthPx: uni.upx2px(this.width), // 转成px后的整个组件的背景宽度
110
+ borderWidthPx: uni.upx2px(this.borderWidth), // 转成px后的圆环的宽度
111
+ startAngle: -Math.PI / 2, // canvas画圆的起始角度,默认为3点钟方向,定位到12点钟方向
112
+ newPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
113
+ oldPercent: 0 // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
114
+ }
115
+ },
116
+ computed: {
117
+ // 有type主题时,优先起作用
118
+ circleColor() {
119
+ if (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0)
120
+ return this.$u.color[this.type]
121
+ else return this.activeColor
190
122
  }
123
+ },
124
+ watch: {
125
+ // 深度监听进度
126
+ percent(nVal, oVal = 0) {
127
+ if (nVal > 100) nVal = 100
128
+ if (nVal < 0) oVal = 0
129
+ // 此值其实等于this.percent,命名一个新值
130
+ this.newPercent = nVal
131
+ this.oldPercent = oVal
132
+ setTimeout(() => {
133
+ // 无论是百分比值增加还是减少,需要操作还是原来的旧的百分比值
134
+ // 将此值减少或者新增到新的百分比值
135
+ this.drawCircleByProgress(oVal)
136
+ }, 50)
137
+ }
138
+ },
139
+ mounted() {
140
+ // 背景圆
141
+ this.drawProgressBg()
142
+ setTimeout(() => {
143
+ // 进度圆
144
+ this.drawCircleByProgress(this.percent)
145
+ }, 500)
146
+ },
147
+ created() {
148
+ this.newPercent = this.percent
149
+ this.oldPercent = 0
150
+ },
151
+ methods: {
152
+ drawProgressBg() {
153
+ console.log(this)
154
+ let ctx = uni.createCanvasContext(this.elBgId, this)
155
+ ctx.setLineWidth(this.borderWidthPx) // 设置圆环宽度
156
+ ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
157
+ ctx.beginPath() // 开描绘路径
158
+ // 设置一个原点(110,110),半径为100的圆的路径到当前路径
159
+ let radius = this.widthPx / 2
160
+ // 用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
161
+ ctx.arc(radius, radius, radius - this.borderWidthPx, 0, 2 * Math.PI, false)
162
+ ctx.stroke() // 对路径进行描绘
163
+ ctx.draw()
164
+ },
165
+ // 激活部分
166
+ drawCircleByProgress(progress) {
167
+ // 第一次操作进度环时将上下文保存到了this.data中,直接使用即可
168
+ let ctx = this.progressContext
169
+ if (!ctx) {
170
+ ctx = uni.createCanvasContext(this.elId, this)
171
+ this.progressContext = ctx
172
+ }
173
+ // 表示进度的两端为圆形
174
+ ctx.setLineCap('round')
175
+ // 设置线条的宽度和颜色
176
+ ctx.setLineWidth(this.borderWidthPx)
177
+ ctx.setStrokeStyle(this.circleColor)
178
+ // 将总过渡时间除以100,得出每修改百分之一进度所需的时间
179
+ let time = Math.floor(this.duration / 100)
180
+ // 结束角的计算依据为:将2π分为100份,乘以当前的进度值,得出终止点的弧度值,加起始角,为整个圆从默认的
181
+ // 3点钟方向开始画图,转为更好理解的12点钟方向开始作图,这需要起始角和终止角同时加上this.startAngle值
182
+ let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
183
+ ctx.beginPath()
184
+ // 半径为整个canvas宽度的一半
185
+ let radius = this.widthPx / 2
186
+ ctx.arc(radius, radius, radius - this.borderWidthPx, this.startAngle, endAngle, false)
187
+ ctx.textAlign = 'center'
188
+ ctx.font = this.fontSize + ' Arial'
189
+ ctx.fillText(this.text, radius, radius)
190
+ ctx.stroke()
191
+ ctx.draw()
192
+ // 如果变更后新值大于旧值,意味着增大了百分比
193
+ if (this.newPercent > this.oldPercent) {
194
+ // 每次递增百分之一
195
+ progress++
196
+ // 如果新增后的值,大于需要设置的值百分比值,停止继续增加
197
+ if (progress > this.newPercent) return
198
+ } else {
199
+ // 同理于上面
200
+ progress--
201
+ if (progress < this.newPercent) return
202
+ }
203
+ setTimeout(() => {
204
+ // 定时器,每次操作间隔为time值,为了让进度条有动画效果
205
+ this.drawCircleByProgress(progress)
206
+ }, time)
207
+ }
208
+ }
209
+ }
191
210
  </script>
192
211
  <style scoped lang="scss">
212
+ .circle-progress {
213
+ position: relative;
214
+ display: inline-flex;
215
+ align-items: center;
216
+ justify-content: center;
217
+ }
193
218
  .pi-canvas-bg {
194
- position: absolute;
195
- }
196
-
197
- .pi-canvas {
198
- position: absolute;
199
- }
200
-
201
- </style>
219
+ position: absolute;
220
+ }
221
+ .pi-canvas {
222
+ position: absolute;
223
+ }
224
+ </style>