b228b822 by 华明祺

no message

1 parent 158b63b8
Showing 209 changed files with 4917 additions and 1 deletions
1 .DS_Store 1 .DS_Store
2 node_modules/ 2 node_modules/
3 uni_modules/
4 unpackage/ 3 unpackage/
5 4
6 package-lock.json 5 package-lock.json
......
1 ## 1.2.0(2021-11-19)
2 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
3 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge)
4 ## 1.1.7(2021-11-08)
5 - 优化 升级ui
6 - 修改 size 属性默认值调整为 small
7 - 修改 type 属性,默认值调整为 error,info 替换 default
8 ## 1.1.6(2021-09-22)
9 - 修复 在字节小程序上样式不生效的 bug
10 ## 1.1.5(2021-07-30)
11 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
12 ## 1.1.4(2021-07-29)
13 - 修复 去掉 nvue 不支持css 的 align-self 属性,nvue 下不暂支持 absolute 属性
14 ## 1.1.3(2021-06-24)
15 - 优化 示例项目
16 ## 1.1.1(2021-05-12)
17 - 新增 组件示例地址
18 ## 1.1.0(2021-05-12)
19 - 新增 uni-badge 的 absolute 属性,支持定位
20 - 新增 uni-badge 的 offset 属性,支持定位偏移
21 - 新增 uni-badge 的 is-dot 属性,支持仅显示有一个小点
22 - 新增 uni-badge 的 max-num 属性,支持自定义封顶的数字值,超过 99 显示99+
23 - 优化 uni-badge 属性 custom-style, 支持以对象形式自定义样式
24 ## 1.0.7(2021-05-07)
25 - 修复 uni-badge 在 App 端,数字小于10时不是圆形的bug
26 - 修复 uni-badge 在父元素不是 flex 布局时,宽度缩小的bug
27 - 新增 uni-badge 属性 custom-style, 支持自定义样式
28 ## 1.0.6(2021-02-04)
29 - 调整为uni_modules目录规范
1 <template>
2 <view class="uni-badge--x">
3 <slot />
4 <text v-if="text" :class="classNames" :style="[badgeWidth, positionStyle, customStyle, dotStyle]"
5 class="uni-badge" @click="onClick()">{{displayValue}}</text>
6 </view>
7 </template>
8
9 <script>
10 /**
11 * Badge 数字角标
12 * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
13 * @tutorial https://ext.dcloud.net.cn/plugin?id=21
14 * @property {String} text 角标内容
15 * @property {String} size = [normal|small] 角标内容
16 * @property {String} type = [info|primary|success|warning|error] 颜色类型
17 * @value info 灰色
18 * @value primary 蓝色
19 * @value success 绿色
20 * @value warning 黄色
21 * @value error 红色
22 * @property {String} inverted = [true|false] 是否无需背景颜色
23 * @property {Number} maxNum 展示封顶的数字值,超过 99 显示 99+
24 * @property {String} absolute = [rightTop|rightBottom|leftBottom|leftTop] 开启绝对定位, 角标将定位到其包裹的标签的四角上
25 * @value rightTop 右上
26 * @value rightBottom 右下
27 * @value leftTop 左上
28 * @value leftBottom 左下
29 * @property {Array[number]} offset 距定位角中心点的偏移量,只有存在 absolute 属性时有效,例如:[-10, -10] 表示向外偏移 10px,[10, 10] 表示向 absolute 指定的内偏移 10px
30 * @property {String} isDot = [true|false] 是否显示为一个小点
31 * @event {Function} click 点击 Badge 触发事件
32 * @example <uni-badge text="1"></uni-badge>
33 */
34
35 export default {
36 name: 'UniBadge',
37 emits: ['click'],
38 props: {
39 type: {
40 type: String,
41 default: 'error'
42 },
43 inverted: {
44 type: Boolean,
45 default: false
46 },
47 isDot: {
48 type: Boolean,
49 default: false
50 },
51 maxNum: {
52 type: Number,
53 default: 99
54 },
55 absolute: {
56 type: String,
57 default: ''
58 },
59 offset: {
60 type: Array,
61 default () {
62 return [0, 0]
63 }
64 },
65 text: {
66 type: [String, Number],
67 default: ''
68 },
69 size: {
70 type: String,
71 default: 'small'
72 },
73 customStyle: {
74 type: Object,
75 default () {
76 return {}
77 }
78 }
79 },
80 data() {
81 return {};
82 },
83 computed: {
84 width() {
85 return String(this.text).length * 8 + 12
86 },
87 classNames() {
88 const {
89 inverted,
90 type,
91 size,
92 absolute
93 } = this
94 return [
95 inverted ? 'uni-badge--' + type + '-inverted' : '',
96 'uni-badge--' + type,
97 'uni-badge--' + size,
98 absolute ? 'uni-badge--absolute' : ''
99 ].join(' ')
100 },
101 positionStyle() {
102 if (!this.absolute) return {}
103 let w = this.width / 2,
104 h = 10
105 if (this.isDot) {
106 w = 5
107 h = 5
108 }
109 const x = `${- w + this.offset[0]}px`
110 const y = `${- h + this.offset[1]}px`
111
112 const whiteList = {
113 rightTop: {
114 right: x,
115 top: y
116 },
117 rightBottom: {
118 right: x,
119 bottom: y
120 },
121 leftBottom: {
122 left: x,
123 bottom: y
124 },
125 leftTop: {
126 left: x,
127 top: y
128 }
129 }
130 const match = whiteList[this.absolute]
131 return match ? match : whiteList['rightTop']
132 },
133 badgeWidth() {
134 return {
135 width: `${this.width}px`
136 }
137 },
138 dotStyle() {
139 if (!this.isDot) return {}
140 return {
141 width: '10px',
142 height: '10px',
143 borderRadius: '10px'
144 }
145 },
146 displayValue() {
147 const {
148 isDot,
149 text,
150 maxNum
151 } = this
152 return isDot ? '' : (Number(text) > maxNum ? `${maxNum}+` : text)
153 }
154 },
155 methods: {
156 onClick() {
157 this.$emit('click');
158 }
159 }
160 };
161 </script>
162
163 <style lang="scss" scoped>
164 $uni-primary: #2979ff !default;
165 $uni-success: #4cd964 !default;
166 $uni-warning: #f0ad4e !default;
167 $uni-error: #dd524d !default;
168 $uni-info: #909399 !default;
169
170
171 $bage-size: 12px;
172 $bage-small: scale(0.8);
173
174 .uni-badge--x {
175 /* #ifdef APP-NVUE */
176 // align-self: flex-start;
177 /* #endif */
178 /* #ifndef APP-NVUE */
179 display: inline-block;
180 /* #endif */
181 position: relative;
182 }
183
184 .uni-badge--absolute {
185 position: absolute;
186 }
187
188 .uni-badge--small {
189 transform: $bage-small;
190 transform-origin: center center;
191 }
192
193 .uni-badge {
194 /* #ifndef APP-NVUE */
195 display: flex;
196 overflow: hidden;
197 box-sizing: border-box;
198 /* #endif */
199 justify-content: center;
200 flex-direction: row;
201 height: 20px;
202 line-height: 18px;
203 color: #fff;
204 border-radius: 100px;
205 background-color: $uni-info;
206 background-color: transparent;
207 border: 1px solid #fff;
208 text-align: center;
209 font-family: 'Helvetica Neue', Helvetica, sans-serif;
210 font-size: $bage-size;
211 /* #ifdef H5 */
212 z-index: 999;
213 cursor: pointer;
214 /* #endif */
215
216 &--info {
217 color: #fff;
218 background-color: $uni-info;
219 }
220
221 &--primary {
222 background-color: $uni-primary;
223 }
224
225 &--success {
226 background-color: $uni-success;
227 }
228
229 &--warning {
230 background-color: $uni-warning;
231 }
232
233 &--error {
234 background-color: $uni-error;
235 }
236
237 &--inverted {
238 padding: 0 5px 0 0;
239 color: $uni-info;
240 }
241
242 &--info-inverted {
243 color: $uni-info;
244 background-color: transparent;
245 }
246
247 &--primary-inverted {
248 color: $uni-primary;
249 background-color: transparent;
250 }
251
252 &--success-inverted {
253 color: $uni-success;
254 background-color: transparent;
255 }
256
257 &--warning-inverted {
258 color: $uni-warning;
259 background-color: transparent;
260 }
261
262 &--error-inverted {
263 color: $uni-error;
264 background-color: transparent;
265 }
266
267 }
268 </style>
1 {
2 "id": "uni-badge",
3 "displayName": "uni-badge 数字角标",
4 "version": "1.2.0",
5 "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
6 "keywords": [
7 "",
8 "badge",
9 "uni-ui",
10 "uniui",
11 "数字角标",
12 "徽章"
13 ],
14 "repository": "https://github.com/dcloudio/uni-ui",
15 "engines": {
16 "HBuilderX": ""
17 },
18 "directories": {
19 "example": "../../temps/example_temps"
20 },
21 "dcloudext": {
22 "category": [
23 "前端组件",
24 "通用组件"
25 ],
26 "sale": {
27 "regular": {
28 "price": "0.00"
29 },
30 "sourcecode": {
31 "price": "0.00"
32 }
33 },
34 "contact": {
35 "qq": ""
36 },
37 "declaration": {
38 "ads": "无",
39 "data": "无",
40 "permissions": "无"
41 },
42 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
43 },
44 "uni_modules": {
45 "dependencies": [],
46 "encrypt": [],
47 "platforms": {
48 "cloud": {
49 "tcb": "y",
50 "aliyun": "y"
51 },
52 "client": {
53 "App": {
54 "app-vue": "y",
55 "app-nvue": "y"
56 },
57 "H5-mobile": {
58 "Safari": "y",
59 "Android Browser": "y",
60 "微信浏览器(Android)": "y",
61 "QQ浏览器(Android)": "y"
62 },
63 "H5-pc": {
64 "Chrome": "y",
65 "IE": "y",
66 "Edge": "y",
67 "Firefox": "y",
68 "Safari": "y"
69 },
70 "小程序": {
71 "微信": "y",
72 "阿里": "y",
73 "百度": "y",
74 "字节跳动": "y",
75 "QQ": "y"
76 },
77 "快应用": {
78 "华为": "y",
79 "联盟": "y"
80 },
81 "Vue": {
82 "vue2": "y",
83 "vue3": "y"
84 }
85 }
86 }
87 }
88 }
...\ No newline at end of file ...\ No newline at end of file
1 ## Badge 数字角标
2 > **组件名:uni-badge**
3 > 代码块: `uBadge`
4
5 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景,
6
7 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-badge)
8 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
9
10
1 ## 1.4.7(2022-09-16)
2 - 可以使用 uni-scss 控制主题色
3 ## 1.4.6(2022-09-08)
4 - fix: 表头年月切换,导致改变当前日期为选择月1号,且未触发change事件
5 ## 1.4.5(2022-02-25)
6 - 修复 条件编译 nvue 不支持的 css 样式
7 ## 1.4.4(2022-02-25)
8 - 修复 条件编译 nvue 不支持的 css 样式
9 ## 1.4.3(2021-09-22)
10 - 修复 startDate、 endDate 属性失效的 bug
11 ## 1.4.2(2021-08-24)
12 - 新增 支持国际化
13 ## 1.4.1(2021-08-05)
14 - 修复 弹出层被 tabbar 遮盖 bug
15 ## 1.4.0(2021-07-30)
16 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
17 ## 1.3.16(2021-05-12)
18 - 新增 组件示例地址
19 ## 1.3.15(2021-02-04)
20 - 调整为uni_modules目录规范
1 {
2 "uni-calender.ok": "ok",
3 "uni-calender.cancel": "cancel",
4 "uni-calender.today": "today",
5 "uni-calender.MON": "MON",
6 "uni-calender.TUE": "TUE",
7 "uni-calender.WED": "WED",
8 "uni-calender.THU": "THU",
9 "uni-calender.FRI": "FRI",
10 "uni-calender.SAT": "SAT",
11 "uni-calender.SUN": "SUN"
12 }
1 import en from './en.json'
2 import zhHans from './zh-Hans.json'
3 import zhHant from './zh-Hant.json'
4 export default {
5 en,
6 'zh-Hans': zhHans,
7 'zh-Hant': zhHant
8 }
1 {
2 "uni-calender.ok": "确定",
3 "uni-calender.cancel": "取消",
4 "uni-calender.today": "今日",
5 "uni-calender.SUN": "日",
6 "uni-calender.MON": "一",
7 "uni-calender.TUE": "二",
8 "uni-calender.WED": "三",
9 "uni-calender.THU": "四",
10 "uni-calender.FRI": "五",
11 "uni-calender.SAT": "六"
12 }
1 {
2 "uni-calender.ok": "確定",
3 "uni-calender.cancel": "取消",
4 "uni-calender.today": "今日",
5 "uni-calender.SUN": "日",
6 "uni-calender.MON": "一",
7 "uni-calender.TUE": "二",
8 "uni-calender.WED": "三",
9 "uni-calender.THU": "四",
10 "uni-calender.FRI": "五",
11 "uni-calender.SAT": "六"
12 }
1 <template>
2 <view class="uni-calendar-item__weeks-box" :class="{
3 'uni-calendar-item--disable':weeks.disable,
4 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
5 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
6 'uni-calendar-item--before-checked':weeks.beforeMultiple,
7 'uni-calendar-item--multiple': weeks.multiple,
8 'uni-calendar-item--after-checked':weeks.afterMultiple,
9 }"
10 @click="choiceDate(weeks)">
11 <view class="uni-calendar-item__weeks-box-item">
12 <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
13 <text class="uni-calendar-item__weeks-box-text" :class="{
14 'uni-calendar-item--isDay-text': weeks.isDay,
15 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
16 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
17 'uni-calendar-item--before-checked':weeks.beforeMultiple,
18 'uni-calendar-item--multiple': weeks.multiple,
19 'uni-calendar-item--after-checked':weeks.afterMultiple,
20 'uni-calendar-item--disable':weeks.disable,
21 }">{{weeks.date}}</text>
22 <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
23 'uni-calendar-item--isDay-text':weeks.isDay,
24 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
25 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
26 'uni-calendar-item--before-checked':weeks.beforeMultiple,
27 'uni-calendar-item--multiple': weeks.multiple,
28 'uni-calendar-item--after-checked':weeks.afterMultiple,
29 }">{{todayText}}</text>
30 <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
31 'uni-calendar-item--isDay-text':weeks.isDay,
32 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
33 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
34 'uni-calendar-item--before-checked':weeks.beforeMultiple,
35 'uni-calendar-item--multiple': weeks.multiple,
36 'uni-calendar-item--after-checked':weeks.afterMultiple,
37 'uni-calendar-item--disable':weeks.disable,
38 }">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
39 <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
40 'uni-calendar-item--extra':weeks.extraInfo.info,
41 'uni-calendar-item--isDay-text':weeks.isDay,
42 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
43 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
44 'uni-calendar-item--before-checked':weeks.beforeMultiple,
45 'uni-calendar-item--multiple': weeks.multiple,
46 'uni-calendar-item--after-checked':weeks.afterMultiple,
47 'uni-calendar-item--disable':weeks.disable,
48 }">{{weeks.extraInfo.info}}</text>
49 </view>
50 </view>
51 </template>
52
53 <script>
54 import {
55 initVueI18n
56 } from '@dcloudio/uni-i18n'
57 import messages from './i18n/index.js'
58 const { t } = initVueI18n(messages)
59 export default {
60 emits:['change'],
61 props: {
62 weeks: {
63 type: Object,
64 default () {
65 return {}
66 }
67 },
68 calendar: {
69 type: Object,
70 default: () => {
71 return {}
72 }
73 },
74 selected: {
75 type: Array,
76 default: () => {
77 return []
78 }
79 },
80 lunar: {
81 type: Boolean,
82 default: false
83 }
84 },
85 computed: {
86 todayText() {
87 return t("uni-calender.today")
88 },
89 },
90 methods: {
91 choiceDate(weeks) {
92 this.$emit('change', weeks)
93 }
94 }
95 }
96 </script>
97
98 <style lang="scss" scoped>
99 $uni-font-size-base:14px;
100 $uni-text-color:#333;
101 $uni-font-size-sm:12px;
102 $uni-color-error: #e43d33;
103 $uni-opacity-disabled: 0.3;
104 $uni-text-color-disable:#c0c0c0;
105 $uni-primary: #2979ff !default;
106 .uni-calendar-item__weeks-box {
107 flex: 1;
108 /* #ifndef APP-NVUE */
109 display: flex;
110 /* #endif */
111 flex-direction: column;
112 justify-content: center;
113 align-items: center;
114 }
115
116 .uni-calendar-item__weeks-box-text {
117 font-size: $uni-font-size-base;
118 color: $uni-text-color;
119 }
120
121 .uni-calendar-item__weeks-lunar-text {
122 font-size: $uni-font-size-sm;
123 color: $uni-text-color;
124 }
125
126 .uni-calendar-item__weeks-box-item {
127 position: relative;
128 /* #ifndef APP-NVUE */
129 display: flex;
130 /* #endif */
131 flex-direction: column;
132 justify-content: center;
133 align-items: center;
134 width: 100rpx;
135 height: 100rpx;
136 }
137
138 .uni-calendar-item__weeks-box-circle {
139 position: absolute;
140 top: 5px;
141 right: 5px;
142 width: 8px;
143 height: 8px;
144 border-radius: 8px;
145 background-color: $uni-color-error;
146
147 }
148
149 .uni-calendar-item--disable {
150 background-color: rgba(249, 249, 249, $uni-opacity-disabled);
151 color: $uni-text-color-disable;
152 }
153
154 .uni-calendar-item--isDay-text {
155 color: $uni-primary;
156 }
157
158 .uni-calendar-item--isDay {
159 background-color: $uni-primary;
160 opacity: 0.8;
161 color: #fff;
162 }
163
164 .uni-calendar-item--extra {
165 color: $uni-color-error;
166 opacity: 0.8;
167 }
168
169 .uni-calendar-item--checked {
170 background-color: $uni-primary;
171 color: #fff;
172 opacity: 0.8;
173 }
174
175 .uni-calendar-item--multiple {
176 background-color: $uni-primary;
177 color: #fff;
178 opacity: 0.8;
179 }
180 .uni-calendar-item--before-checked {
181 background-color: #ff5a5f;
182 color: #fff;
183 }
184 .uni-calendar-item--after-checked {
185 background-color: #ff5a5f;
186 color: #fff;
187 }
188 </style>
1 import CALENDAR from './calendar.js'
2
3 class Calendar {
4 constructor({
5 date,
6 selected,
7 startDate,
8 endDate,
9 range
10 } = {}) {
11 // 当前日期
12 this.date = this.getDate(new Date()) // 当前初入日期
13 // 打点信息
14 this.selected = selected || [];
15 // 范围开始
16 this.startDate = startDate
17 // 范围结束
18 this.endDate = endDate
19 this.range = range
20 // 多选状态
21 this.cleanMultipleStatus()
22 // 每周日期
23 this.weeks = {}
24 // this._getWeek(this.date.fullDate)
25 }
26 /**
27 * 设置日期
28 * @param {Object} date
29 */
30 setDate(date) {
31 this.selectDate = this.getDate(date)
32 this._getWeek(this.selectDate.fullDate)
33 }
34
35 /**
36 * 清理多选状态
37 */
38 cleanMultipleStatus() {
39 this.multipleStatus = {
40 before: '',
41 after: '',
42 data: []
43 }
44 }
45
46 /**
47 * 重置开始日期
48 */
49 resetSatrtDate(startDate) {
50 // 范围开始
51 this.startDate = startDate
52
53 }
54
55 /**
56 * 重置结束日期
57 */
58 resetEndDate(endDate) {
59 // 范围结束
60 this.endDate = endDate
61 }
62
63 /**
64 * 获取任意时间
65 */
66 getDate(date, AddDayCount = 0, str = 'day') {
67 if (!date) {
68 date = new Date()
69 }
70 if (typeof date !== 'object') {
71 date = date.replace(/-/g, '/')
72 }
73 const dd = new Date(date)
74 switch (str) {
75 case 'day':
76 dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
77 break
78 case 'month':
79 if (dd.getDate() === 31) {
80 dd.setDate(dd.getDate() + AddDayCount)
81 } else {
82 dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期
83 }
84 break
85 case 'year':
86 dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
87 break
88 }
89 const y = dd.getFullYear()
90 const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
91 const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
92 return {
93 fullDate: y + '-' + m + '-' + d,
94 year: y,
95 month: m,
96 date: d,
97 day: dd.getDay()
98 }
99 }
100
101
102 /**
103 * 获取上月剩余天数
104 */
105 _getLastMonthDays(firstDay, full) {
106 let dateArr = []
107 for (let i = firstDay; i > 0; i--) {
108 const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
109 dateArr.push({
110 date: beforeDate,
111 month: full.month - 1,
112 lunar: this.getlunar(full.year, full.month - 1, beforeDate),
113 disable: true
114 })
115 }
116 return dateArr
117 }
118 /**
119 * 获取本月天数
120 */
121 _currentMonthDys(dateData, full) {
122 let dateArr = []
123 let fullDate = this.date.fullDate
124 for (let i = 1; i <= dateData; i++) {
125 let nowDate = full.year + '-' + (full.month < 10 ?
126 full.month : full.month) + '-' + (i < 10 ?
127 '0' + i : i)
128 // 是否今天
129 let isDay = fullDate === nowDate
130 // 获取打点信息
131 let info = this.selected && this.selected.find((item) => {
132 if (this.dateEqual(nowDate, item.date)) {
133 return item
134 }
135 })
136
137 // 日期禁用
138 let disableBefore = true
139 let disableAfter = true
140 if (this.startDate) {
141 // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
142 // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
143 disableBefore = this.dateCompare(this.startDate, nowDate)
144 }
145
146 if (this.endDate) {
147 // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
148 // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
149 disableAfter = this.dateCompare(nowDate, this.endDate)
150 }
151 let multiples = this.multipleStatus.data
152 let checked = false
153 let multiplesStatus = -1
154 if (this.range) {
155 if (multiples) {
156 multiplesStatus = multiples.findIndex((item) => {
157 return this.dateEqual(item, nowDate)
158 })
159 }
160 if (multiplesStatus !== -1) {
161 checked = true
162 }
163 }
164 let data = {
165 fullDate: nowDate,
166 year: full.year,
167 date: i,
168 multiple: this.range ? checked : false,
169 beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
170 afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
171 month: full.month,
172 lunar: this.getlunar(full.year, full.month, i),
173 disable: !(disableBefore && disableAfter),
174 isDay
175 }
176 if (info) {
177 data.extraInfo = info
178 }
179
180 dateArr.push(data)
181 }
182 return dateArr
183 }
184 /**
185 * 获取下月天数
186 */
187 _getNextMonthDays(surplus, full) {
188 let dateArr = []
189 for (let i = 1; i < surplus + 1; i++) {
190 dateArr.push({
191 date: i,
192 month: Number(full.month) + 1,
193 lunar: this.getlunar(full.year, Number(full.month) + 1, i),
194 disable: true
195 })
196 }
197 return dateArr
198 }
199
200 /**
201 * 获取当前日期详情
202 * @param {Object} date
203 */
204 getInfo(date) {
205 if (!date) {
206 date = new Date()
207 }
208 const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
209 return dateInfo
210 }
211
212 /**
213 * 比较时间大小
214 */
215 dateCompare(startDate, endDate) {
216 // 计算截止时间
217 startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
218 // 计算详细项的截止时间
219 endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
220 if (startDate <= endDate) {
221 return true
222 } else {
223 return false
224 }
225 }
226
227 /**
228 * 比较时间是否相等
229 */
230 dateEqual(before, after) {
231 // 计算截止时间
232 before = new Date(before.replace('-', '/').replace('-', '/'))
233 // 计算详细项的截止时间
234 after = new Date(after.replace('-', '/').replace('-', '/'))
235 if (before.getTime() - after.getTime() === 0) {
236 return true
237 } else {
238 return false
239 }
240 }
241
242
243 /**
244 * 获取日期范围内所有日期
245 * @param {Object} begin
246 * @param {Object} end
247 */
248 geDateAll(begin, end) {
249 var arr = []
250 var ab = begin.split('-')
251 var ae = end.split('-')
252 var db = new Date()
253 db.setFullYear(ab[0], ab[1] - 1, ab[2])
254 var de = new Date()
255 de.setFullYear(ae[0], ae[1] - 1, ae[2])
256 var unixDb = db.getTime() - 24 * 60 * 60 * 1000
257 var unixDe = de.getTime() - 24 * 60 * 60 * 1000
258 for (var k = unixDb; k <= unixDe;) {
259 k = k + 24 * 60 * 60 * 1000
260 arr.push(this.getDate(new Date(parseInt(k))).fullDate)
261 }
262 return arr
263 }
264 /**
265 * 计算阴历日期显示
266 */
267 getlunar(year, month, date) {
268 return CALENDAR.solar2lunar(year, month, date)
269 }
270 /**
271 * 设置打点
272 */
273 setSelectInfo(data, value) {
274 this.selected = value
275 this._getWeek(data)
276 }
277
278 /**
279 * 获取多选状态
280 */
281 setMultiple(fullDate) {
282 let {
283 before,
284 after
285 } = this.multipleStatus
286
287 if (!this.range) return
288 if (before && after) {
289 this.multipleStatus.before = ''
290 this.multipleStatus.after = ''
291 this.multipleStatus.data = []
292 } else {
293 if (!before) {
294 this.multipleStatus.before = fullDate
295 } else {
296 this.multipleStatus.after = fullDate
297 if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
298 this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
299 } else {
300 this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
301 }
302 }
303 }
304 this._getWeek(fullDate)
305 }
306
307 /**
308 * 获取每周数据
309 * @param {Object} dateData
310 */
311 _getWeek(dateData) {
312 const {
313 year,
314 month
315 } = this.getDate(dateData)
316 let firstDay = new Date(year, month - 1, 1).getDay()
317 let currentDay = new Date(year, month, 0).getDate()
318 let dates = {
319 lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
320 currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
321 nextMonthDays: [], // 下个月开始几天
322 weeks: []
323 }
324 let canlender = []
325 const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
326 dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
327 canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
328 let weeks = {}
329 // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
330 for (let i = 0; i < canlender.length; i++) {
331 if (i % 7 === 0) {
332 weeks[parseInt(i / 7)] = new Array(7)
333 }
334 weeks[parseInt(i / 7)][i % 7] = canlender[i]
335 }
336 this.canlender = canlender
337 this.weeks = weeks
338 }
339
340 //静态方法
341 // static init(date) {
342 // if (!this.instance) {
343 // this.instance = new Calendar(date);
344 // }
345 // return this.instance;
346 // }
347 }
348
349
350 export default Calendar
1 {
2 "id": "uni-calendar",
3 "displayName": "uni-calendar 日历",
4 "version": "1.4.7",
5 "description": "日历组件",
6 "keywords": [
7 "uni-ui",
8 "uniui",
9 "日历",
10 "",
11 "打卡",
12 "日历选择"
13 ],
14 "repository": "https://github.com/dcloudio/uni-ui",
15 "engines": {
16 "HBuilderX": ""
17 },
18 "directories": {
19 "example": "../../temps/example_temps"
20 },
21 "dcloudext": {
22 "sale": {
23 "regular": {
24 "price": "0.00"
25 },
26 "sourcecode": {
27 "price": "0.00"
28 }
29 },
30 "contact": {
31 "qq": ""
32 },
33 "declaration": {
34 "ads": "无",
35 "data": "无",
36 "permissions": "无"
37 },
38 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
39 "type": "component-vue"
40 },
41 "uni_modules": {
42 "dependencies": [],
43 "encrypt": [],
44 "platforms": {
45 "cloud": {
46 "tcb": "y",
47 "aliyun": "y"
48 },
49 "client": {
50 "App": {
51 "app-vue": "y",
52 "app-nvue": "y"
53 },
54 "H5-mobile": {
55 "Safari": "y",
56 "Android Browser": "y",
57 "微信浏览器(Android)": "y",
58 "QQ浏览器(Android)": "y"
59 },
60 "H5-pc": {
61 "Chrome": "y",
62 "IE": "y",
63 "Edge": "y",
64 "Firefox": "y",
65 "Safari": "y"
66 },
67 "小程序": {
68 "微信": "y",
69 "阿里": "y",
70 "百度": "y",
71 "字节跳动": "y",
72 "QQ": "y"
73 },
74 "快应用": {
75 "华为": "u",
76 "联盟": "u"
77 },
78 "Vue": {
79 "vue2": "y",
80 "vue3": "y"
81 }
82 }
83 }
84 }
85 }
...\ No newline at end of file ...\ No newline at end of file
1
2
3 ## Calendar 日历
4 > **组件名:uni-calendar**
5 > 代码块: `uCalendar`
6
7
8 日历组件
9
10 > **注意事项**
11 > 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
12 > - 本组件农历转换使用的js是 [@1900-2100区间内的公历、农历互转](https://github.com/jjonline/calendar.js)
13 > - 仅支持自定义组件模式
14 > - `date`属性传入的应该是一个 String ,如: 2019-06-27 ,而不是 new Date()
15 > - 通过 `insert` 属性来确定当前的事件是 @change 还是 @confirm 。理应合并为一个事件,但是为了区分模式,现使用两个事件,这里需要注意
16 > - 弹窗模式下无法阻止后面的元素滚动,如有需要阻止,请在弹窗弹出后,手动设置滚动元素为不可滚动
17
18
19 ### 安装方式
20
21 本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。
22
23 如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
24
25 ### 基本用法
26
27 在 ``template`` 中使用组件
28
29 ```html
30 <view>
31 <uni-calendar
32 :insert="true"
33 :lunar="true"
34 :start-date="'2019-3-2'"
35 :end-date="'2019-5-20'"
36 @change="change"
37 />
38 </view>
39 ```
40
41 ### 通过方法打开日历
42
43 需要设置 `insert` 为 `false`
44
45 ```html
46 <view>
47 <uni-calendar
48 ref="calendar"
49 :insert="false"
50 @confirm="confirm"
51 />
52 <button @click="open">打开日历</button>
53 </view>
54 ```
55
56 ```javascript
57
58 export default {
59 data() {
60 return {};
61 },
62 methods: {
63 open(){
64 this.$refs.calendar.open();
65 },
66 confirm(e) {
67 console.log(e);
68 }
69 }
70 };
71
72 ```
73
74
75 ## API
76
77 ### Calendar Props
78
79 | 属性名 | 类型 | 默认值| 说明 |
80 | | |
81 | date | String |- | 自定义当前时间,默认为今天 |
82 | lunar | Boolean | false | 显示农历 |
83 | startDate | String |- | 日期选择范围-开始日期 |
84 | endDate | String |- | 日期选择范围-结束日期 |
85 | range | Boolean | false | 范围选择 |
86 | insert | Boolean | false | 插入模式,可选值,ture:插入模式;false:弹窗模式;默认为插入模式 |
87 |clearDate |Boolean |true |弹窗模式是否清空上次选择内容 |
88 | selected | Array |- | 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] |
89 |showMonth | Boolean | true | 是否显示月份为背景 |
90
91 ### Calendar Events
92
93 | 事件名 | 说明 |返回值|
94 | | | |
95 | open | 弹出日历组件,`insert :false` 时生效|- |
96
97
98
99
100
101 ## 组件示例
102
103 点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar](https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar)
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.3.1(2021-12-20)
2 - 修复 在vue页面下略缩图显示不正常的bug
3 ## 1.3.0(2021-11-19)
4 - 重构插槽的用法 ,header 替换为 title
5 - 新增 actions 插槽
6 - 新增 cover 封面图属性和插槽
7 - 新增 padding 内容默认内边距离
8 - 新增 margin 卡片默认外边距离
9 - 新增 spacing 卡片默认内边距
10 - 新增 shadow 卡片阴影属性
11 - 取消 mode 属性,可使用组合插槽代替
12 - 取消 note 属性 ,使用actions插槽代替
13 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
14 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-card](https://uniapp.dcloud.io/component/uniui/uni-card)
15 ## 1.2.1(2021-07-30)
16 - 优化 vue3下事件警告的问题
17 ## 1.2.0(2021-07-13)
18 - 组件兼容 vue3,如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
19 ## 1.1.8(2021-07-01)
20 - 优化 图文卡片无图片加载时,提供占位图标
21 - 新增 header 插槽,自定义卡片头部( 图文卡片 mode="style" 时,不支持)
22 - 修复 thumbnail 不存在仍然占位的 bug
23 ## 1.1.7(2021-05-12)
24 - 新增 组件示例地址
25 ## 1.1.6(2021-02-04)
26 - 调整为uni_modules目录规范
1 <template>
2 <view class="uni-card" :class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow,'uni-card--border':border}"
3 :style="{'margin':isFull?0:margin,'padding':spacing,'box-shadow':isShadow?shadow:''}">
4 <!-- 封面 -->
5 <slot name="cover">
6 <view v-if="cover" class="uni-card__cover">
7 <image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image>
8 </view>
9 </slot>
10 <slot name="title">
11 <view v-if="title || extra" class="uni-card__header">
12 <!-- 卡片标题 -->
13 <view class="uni-card__header-box" @click="onClick('title')">
14 <view v-if="thumbnail" class="uni-card__header-avatar">
15 <image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" />
16 </view>
17 <view class="uni-card__header-content">
18 <text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text>
19 <text v-if="title&&subTitle"
20 class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }}</text>
21 </view>
22 </view>
23 <view class="uni-card__header-extra" @click="onClick('extra')">
24 <text class="uni-card__header-extra-text">{{ extra }}</text>
25 </view>
26 </view>
27 </slot>
28 <!-- 卡片内容 -->
29 <view class="uni-card__content" :style="{padding:padding}" @click="onClick('content')">
30 <slot></slot>
31 </view>
32 <view class="uni-card__actions" @click="onClick('actions')">
33 <slot name="actions"></slot>
34 </view>
35 </view>
36 </template>
37
38 <script>
39 /**
40 * Card 卡片
41 * @description 卡片视图组件
42 * @tutorial https://ext.dcloud.net.cn/plugin?id=22
43 * @property {String} title 标题文字
44 * @property {String} subTitle 副标题
45 * @property {Number} padding 内容内边距
46 * @property {Number} margin 卡片外边距
47 * @property {Number} spacing 卡片内边距
48 * @property {String} extra 标题额外信息
49 * @property {String} cover 封面图(本地路径需要引入)
50 * @property {String} thumbnail 标题左侧缩略图
51 * @property {Boolean} is-full = [true | false] 卡片内容是否通栏,为 true 时将去除padding值
52 * @property {Boolean} is-shadow = [true | false] 卡片内容是否开启阴影
53 * @property {String} shadow 卡片阴影
54 * @property {Boolean} border 卡片边框
55 * @event {Function} click 点击 Card 触发事件
56 */
57 export default {
58 name: 'UniCard',
59 emits: ['click'],
60 props: {
61 title: {
62 type: String,
63 default: ''
64 },
65 subTitle: {
66 type: String,
67 default: ''
68 },
69 padding: {
70 type: String,
71 default: '10px'
72 },
73 margin: {
74 type: String,
75 default: '15px'
76 },
77 spacing: {
78 type: String,
79 default: '0 10px'
80 },
81 extra: {
82 type: String,
83 default: ''
84 },
85 cover: {
86 type: String,
87 default: ''
88 },
89 thumbnail: {
90 type: String,
91 default: ''
92 },
93 isFull: {
94 // 内容区域是否通栏
95 type: Boolean,
96 default: false
97 },
98 isShadow: {
99 // 是否开启阴影
100 type: Boolean,
101 default: true
102 },
103 shadow: {
104 type: String,
105 default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)'
106 },
107 border: {
108 type: Boolean,
109 default: true
110 }
111 },
112 methods: {
113 onClick(type) {
114 this.$emit('click', type)
115 }
116 }
117 }
118 </script>
119
120 <style lang="scss">
121 $uni-border-3: #EBEEF5 !default;
122 $uni-shadow-base:0 0px 6px 1px rgba($color: #a5a5a5, $alpha: 0.2) !default;
123 $uni-main-color: #3a3a3a !default;
124 $uni-base-color: #6a6a6a !default;
125 $uni-secondary-color: #909399 !default;
126 $uni-spacing-sm: 8px !default;
127 $uni-border-color:$uni-border-3;
128 $uni-shadow: $uni-shadow-base;
129 $uni-card-title: 15px;
130 $uni-cart-title-color:$uni-main-color;
131 $uni-card-subtitle: 12px;
132 $uni-cart-subtitle-color:$uni-secondary-color;
133 $uni-card-spacing: 10px;
134 $uni-card-content-color: $uni-base-color;
135
136 .uni-card {
137 margin: $uni-card-spacing;
138 padding: 0 $uni-spacing-sm;
139 border-radius: 4px;
140 overflow: hidden;
141 font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
142 background-color: #fff;
143 flex: 1;
144
145 .uni-card__cover {
146 position: relative;
147 margin-top: $uni-card-spacing;
148 flex-direction: row;
149 overflow: hidden;
150 border-radius: 4px;
151 .uni-card__cover-image {
152 flex: 1;
153 // width: 100%;
154 /* #ifndef APP-PLUS */
155 vertical-align: middle;
156 /* #endif */
157 }
158 }
159
160 .uni-card__header {
161 display: flex;
162 border-bottom: 1px $uni-border-color solid;
163 flex-direction: row;
164 align-items: center;
165 padding: $uni-card-spacing;
166 overflow: hidden;
167
168 .uni-card__header-box {
169 /* #ifndef APP-NVUE */
170 display: flex;
171 /* #endif */
172 flex: 1;
173 flex-direction: row;
174 align-items: center;
175 overflow: hidden;
176 }
177
178 .uni-card__header-avatar {
179 width: 40px;
180 height: 40px;
181 overflow: hidden;
182 border-radius: 5px;
183 margin-right: $uni-card-spacing;
184 .uni-card__header-avatar-image {
185 flex: 1;
186 width: 40px;
187 height: 40px;
188 }
189 }
190
191 .uni-card__header-content {
192 /* #ifndef APP-NVUE */
193 display: flex;
194 /* #endif */
195 flex-direction: column;
196 justify-content: center;
197 flex: 1;
198 // height: 40px;
199 overflow: hidden;
200
201 .uni-card__header-content-title {
202 font-size: $uni-card-title;
203 color: $uni-cart-title-color;
204 // line-height: 22px;
205 }
206
207 .uni-card__header-content-subtitle {
208 font-size: $uni-card-subtitle;
209 margin-top: 5px;
210 color: $uni-cart-subtitle-color;
211 }
212 }
213
214 .uni-card__header-extra {
215 line-height: 12px;
216
217 .uni-card__header-extra-text {
218 font-size: 12px;
219 color: $uni-cart-subtitle-color;
220 }
221 }
222 }
223
224 .uni-card__content {
225 padding: $uni-card-spacing;
226 font-size: 14px;
227 color: $uni-card-content-color;
228 line-height: 22px;
229 }
230
231 .uni-card__actions {
232 font-size: 12px;
233 }
234 }
235
236 .uni-card--border {
237 border: 1px solid $uni-border-color;
238 }
239
240 .uni-card--shadow {
241 position: relative;
242 /* #ifndef APP-NVUE */
243 box-shadow: $uni-shadow;
244 /* #endif */
245 }
246
247 .uni-card--full {
248 margin: 0;
249 border-left-width: 0;
250 border-left-width: 0;
251 border-radius: 0;
252 }
253
254 /* #ifndef APP-NVUE */
255 .uni-card--full:after {
256 border-radius: 0;
257 }
258
259 /* #endif */
260 .uni-ellipsis {
261 /* #ifndef APP-NVUE */
262 overflow: hidden;
263 white-space: nowrap;
264 text-overflow: ellipsis;
265 /* #endif */
266 /* #ifdef APP-NVUE */
267 lines: 1;
268 /* #endif */
269 }
270 </style>
1 {
2 "id": "uni-card",
3 "displayName": "uni-card 卡片",
4 "version": "1.3.1",
5 "description": "Card 组件,提供常见的卡片样式。",
6 "keywords": [
7 "uni-ui",
8 "uniui",
9 "card",
10 "",
11 "卡片"
12 ],
13 "repository": "https://github.com/dcloudio/uni-ui",
14 "engines": {
15 "HBuilderX": ""
16 },
17 "directories": {
18 "example": "../../temps/example_temps"
19 },
20 "dcloudext": {
21 "category": [
22 "前端组件",
23 "通用组件"
24 ],
25 "sale": {
26 "regular": {
27 "price": "0.00"
28 },
29 "sourcecode": {
30 "price": "0.00"
31 }
32 },
33 "contact": {
34 "qq": ""
35 },
36 "declaration": {
37 "ads": "无",
38 "data": "无",
39 "permissions": "无"
40 },
41 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
42 },
43 "uni_modules": {
44 "dependencies": [
45 "uni-icons",
46 "uni-scss"
47 ],
48 "encrypt": [],
49 "platforms": {
50 "cloud": {
51 "tcb": "y",
52 "aliyun": "y"
53 },
54 "client": {
55 "App": {
56 "app-vue": "y",
57 "app-nvue": "y"
58 },
59 "H5-mobile": {
60 "Safari": "y",
61 "Android Browser": "y",
62 "微信浏览器(Android)": "y",
63 "QQ浏览器(Android)": "y"
64 },
65 "H5-pc": {
66 "Chrome": "y",
67 "IE": "y",
68 "Edge": "y",
69 "Firefox": "y",
70 "Safari": "y"
71 },
72 "小程序": {
73 "微信": "y",
74 "阿里": "y",
75 "百度": "y",
76 "字节跳动": "y",
77 "QQ": "y"
78 },
79 "快应用": {
80 "华为": "u",
81 "联盟": "u"
82 },
83 "Vue": {
84 "vue2": "y",
85 "vue3": "y"
86 }
87 }
88 }
89 }
90 }
1
2
3 ## Card 卡片
4 > **组件名:uni-card**
5 > 代码块: `uCard`
6
7 卡片视图组件。
8
9 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-card)
10 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
11
12
1 ## 1.4.3(2022-01-25)
2 - 修复 初始化的时候 ,open 属性失效的bug
3 ## 1.4.2(2022-01-21)
4 - 修复 微信小程序resize后组件收起的bug
5 ## 1.4.1(2021-11-22)
6 - 修复 vue3中个别scss变量无法找到的问题
7 ## 1.4.0(2021-11-19)
8 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
9 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-collapse](https://uniapp.dcloud.io/component/uniui/uni-collapse)
10 ## 1.3.3(2021-08-17)
11 - 优化 show-arrow 属性默认为true
12 ## 1.3.2(2021-08-17)
13 - 新增 show-arrow 属性,控制是否显示右侧箭头
14 ## 1.3.1(2021-07-30)
15 - 优化 vue3下小程序事件警告的问题
16 ## 1.3.0(2021-07-30)
17 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
18 ## 1.2.2(2021-07-21)
19 - 修复 由1.2.0版本引起的 change 事件返回 undefined 的Bug
20 ## 1.2.1(2021-07-21)
21 - 优化 组件示例
22 ## 1.2.0(2021-07-21)
23 - 新增 组件折叠动画
24 - 新增 value\v-model 属性 ,动态修改面板折叠状态
25 - 新增 title 插槽 ,可定义面板标题
26 - 新增 border 属性 ,显示隐藏面板内容分隔线
27 - 新增 title-border 属性 ,显示隐藏面板标题分隔线
28 - 修复 resize 方法失效的Bug
29 - 修复 change 事件返回参数不正确的Bug
30 - 优化 H5、App 平台自动更具内容更新高度,无需调用 reszie() 方法
31 ## 1.1.7(2021-05-12)
32 - 新增 组件示例地址
33 ## 1.1.6(2021-02-05)
34 - 优化 组件引用关系,通过uni_modules引用组件
35 ## 1.1.5(2021-02-05)
36 - 调整为uni_modules目录规范
...\ No newline at end of file ...\ No newline at end of file
1 <template>
2 <view class="uni-collapse-item">
3 <!-- onClick(!isOpen) -->
4 <view @click="onClick(!isOpen)" class="uni-collapse-item__title"
5 :class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}">
6 <view class="uni-collapse-item__title-wrap">
7 <slot name="title">
8 <view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}">
9 <image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
10 <text class="uni-collapse-item__title-text">{{ title }}</text>
11 </view>
12 </slot>
13 </view>
14 <view v-if="showArrow"
15 :class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
16 class="uni-collapse-item__title-arrow">
17 <uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="bottom" />
18 </view>
19 </view>
20 <view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}"
21 :style="{height: (isOpen?height:0) +'px'}">
22 <view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content"
23 :class="{open:isheight,'uni-collapse-item--border':border&&isOpen}">
24 <slot></slot>
25 </view>
26 </view>
27
28 </view>
29 </template>
30
31 <script>
32 // #ifdef APP-NVUE
33 const dom = weex.requireModule('dom')
34 // #endif
35 /**
36 * CollapseItem 折叠面板子组件
37 * @description 折叠面板子组件
38 * @property {String} title 标题文字
39 * @property {String} thumb 标题左侧缩略图
40 * @property {String} name 唯一标志符
41 * @property {Boolean} open = [true|false] 是否展开组件
42 * @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
43 * @property {Boolean} border = [true|false] 是否显示分隔线
44 * @property {Boolean} disabled = [true|false] 是否展开面板
45 * @property {Boolean} showAnimation = [true|false] 开启动画
46 * @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
47 */
48 export default {
49 name: 'uniCollapseItem',
50 props: {
51 // 列表标题
52 title: {
53 type: String,
54 default: ''
55 },
56 name: {
57 type: [Number, String],
58 default: ''
59 },
60 // 是否禁用
61 disabled: {
62 type: Boolean,
63 default: false
64 },
65 // #ifdef APP-PLUS
66 // 是否显示动画,app 端默认不开启动画,卡顿严重
67 showAnimation: {
68 type: Boolean,
69 default: false
70 },
71 // #endif
72 // #ifndef APP-PLUS
73 // 是否显示动画
74 showAnimation: {
75 type: Boolean,
76 default: true
77 },
78 // #endif
79 // 是否展开
80 open: {
81 type: Boolean,
82 default: false
83 },
84 // 缩略图
85 thumb: {
86 type: String,
87 default: ''
88 },
89 // 标题分隔线显示类型
90 titleBorder: {
91 type: String,
92 default: 'auto'
93 },
94 border: {
95 type: Boolean,
96 default: true
97 },
98 showArrow: {
99 type: Boolean,
100 default: true
101 }
102 },
103 data() {
104 // TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
105 const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
106 return {
107 isOpen: false,
108 isheight: null,
109 height: 0,
110 elId,
111 nameSync: 0
112 }
113 },
114 watch: {
115 open(val) {
116 this.isOpen = val
117 this.onClick(val, 'init')
118 }
119 },
120 updated(e) {
121 this.$nextTick(() => {
122 this.init(true)
123 })
124 },
125 created() {
126 this.collapse = this.getCollapse()
127 this.oldHeight = 0
128 this.onClick(this.open, 'init')
129 },
130 // #ifndef VUE3
131 // TODO vue2
132 destroyed() {
133 if (this.__isUnmounted) return
134 this.uninstall()
135 },
136 // #endif
137 // #ifdef VUE3
138 // TODO vue3
139 unmounted() {
140 this.__isUnmounted = true
141 this.uninstall()
142 },
143 // #endif
144 mounted() {
145 if (!this.collapse) return
146 if (this.name !== '') {
147 this.nameSync = this.name
148 } else {
149 this.nameSync = this.collapse.childrens.length + ''
150 }
151 if (this.collapse.names.indexOf(this.nameSync) === -1) {
152 this.collapse.names.push(this.nameSync)
153 } else {
154 console.warn(`name 值 ${this.nameSync} 重复`);
155 }
156 if (this.collapse.childrens.indexOf(this) === -1) {
157 this.collapse.childrens.push(this)
158 }
159 this.init()
160 },
161 methods: {
162 init(type) {
163 // #ifndef APP-NVUE
164 this.getCollapseHeight(type)
165 // #endif
166 // #ifdef APP-NVUE
167 this.getNvueHwight(type)
168 // #endif
169 },
170 uninstall() {
171 if (this.collapse) {
172 this.collapse.childrens.forEach((item, index) => {
173 if (item === this) {
174 this.collapse.childrens.splice(index, 1)
175 }
176 })
177 this.collapse.names.forEach((item, index) => {
178 if (item === this.nameSync) {
179 this.collapse.names.splice(index, 1)
180 }
181 })
182 }
183 },
184 onClick(isOpen, type) {
185 if (this.disabled) return
186 this.isOpen = isOpen
187 if (this.isOpen && this.collapse) {
188 this.collapse.setAccordion(this)
189 }
190 if (type !== 'init') {
191 this.collapse.onChange(isOpen, this)
192 }
193 },
194 getCollapseHeight(type, index = 0) {
195 const views = uni.createSelectorQuery().in(this)
196 views
197 .select(`#${this.elId}`)
198 .fields({
199 size: true
200 }, data => {
201 // TODO 百度中可能获取不到节点信息 ,需要循环获取
202 if (index >= 10) return
203 if (!data) {
204 index++
205 this.getCollapseHeight(false, index)
206 return
207 }
208 // #ifdef APP-NVUE
209 this.height = data.height + 1
210 // #endif
211 // #ifndef APP-NVUE
212 this.height = data.height
213 // #endif
214 this.isheight = true
215 if (type) return
216 this.onClick(this.isOpen, 'init')
217 })
218 .exec()
219 },
220 getNvueHwight(type) {
221 const result = dom.getComponentRect(this.$refs['collapse--hook'], option => {
222 if (option && option.result && option.size) {
223 // #ifdef APP-NVUE
224 this.height = option.size.height + 1
225 // #endif
226 // #ifndef APP-NVUE
227 this.height = option.size.height
228 // #endif
229 this.isheight = true
230 if (type) return
231 this.onClick(this.open, 'init')
232 }
233 })
234 },
235 /**
236 * 获取父元素实例
237 */
238 getCollapse(name = 'uniCollapse') {
239 let parent = this.$parent;
240 let parentName = parent.$options.name;
241 while (parentName !== name) {
242 parent = parent.$parent;
243 if (!parent) return false;
244 parentName = parent.$options.name;
245 }
246 return parent;
247 }
248 }
249 }
250 </script>
251
252 <style lang="scss">
253 .uni-collapse-item {
254 /* #ifndef APP-NVUE */
255 box-sizing: border-box;
256
257 /* #endif */
258 &__title {
259 /* #ifndef APP-NVUE */
260 display: flex;
261 width: 100%;
262 box-sizing: border-box;
263 /* #endif */
264 flex-direction: row;
265 align-items: center;
266 transition: border-bottom-color .3s;
267
268 // transition-property: border-bottom-color;
269 // transition-duration: 5s;
270 &-wrap {
271 width: 100%;
272 flex: 1;
273
274 }
275
276 &-box {
277 padding: 0 15px;
278 /* #ifndef APP-NVUE */
279 display: flex;
280 width: 100%;
281 box-sizing: border-box;
282 /* #endif */
283 flex-direction: row;
284 justify-content: space-between;
285 align-items: center;
286 height: 48px;
287 line-height: 48px;
288 background-color: #fff;
289 color: #303133;
290 font-size: 13px;
291 font-weight: 500;
292 /* #ifdef H5 */
293 cursor: pointer;
294 outline: none;
295
296 /* #endif */
297 &.is-disabled {
298 .uni-collapse-item__title-text {
299 color: #999;
300 }
301 }
302
303 }
304
305 &.uni-collapse-item-border {
306 border-bottom: 1px solid #ebeef5;
307 }
308
309 &.is-open {
310 border-bottom-color: transparent;
311 }
312
313 &-img {
314 height: 22px;
315 width: 22px;
316 margin-right: 10px;
317 }
318
319 &-text {
320 flex: 1;
321 font-size: 14px;
322 /* #ifndef APP-NVUE */
323 white-space: nowrap;
324 color: inherit;
325 /* #endif */
326 /* #ifdef APP-NVUE */
327 lines: 1;
328 /* #endif */
329 overflow: hidden;
330 text-overflow: ellipsis;
331 }
332
333 &-arrow {
334 /* #ifndef APP-NVUE */
335 display: flex;
336 box-sizing: border-box;
337 /* #endif */
338 align-items: center;
339 justify-content: center;
340 width: 20px;
341 height: 20px;
342 margin-right: 10px;
343 transform: rotate(0deg);
344
345 &-active {
346 transform: rotate(-180deg);
347 }
348 }
349
350
351 }
352
353 &__wrap {
354 /* #ifndef APP-NVUE */
355 will-change: height;
356 box-sizing: border-box;
357 /* #endif */
358 background-color: #fff;
359 overflow: hidden;
360 position: relative;
361 height: 0;
362
363 &.is--transition {
364 // transition: all 0.3s;
365 transition-property: height, border-bottom-width;
366 transition-duration: 0.3s;
367 /* #ifndef APP-NVUE */
368 will-change: height;
369 /* #endif */
370 }
371
372
373
374 &-content {
375 position: absolute;
376 font-size: 13px;
377 color: #303133;
378 // transition: height 0.3s;
379 border-bottom-color: transparent;
380 border-bottom-style: solid;
381 border-bottom-width: 0;
382
383 &.uni-collapse-item--border {
384 border-bottom-width: 1px;
385 border-bottom-color: red;
386 border-bottom-color: #ebeef5;
387 }
388
389 &.open {
390 position: relative;
391 }
392 }
393 }
394
395 &--animation {
396 transition-property: transform;
397 transition-duration: 0.3s;
398 transition-timing-function: ease;
399 }
400
401 }
402 </style>
1 <template>
2 <view class="uni-collapse">
3 <slot />
4 </view>
5 </template>
6 <script>
7 /**
8 * Collapse 折叠面板
9 * @description 展示可以折叠 / 展开的内容区域
10 * @tutorial https://ext.dcloud.net.cn/plugin?id=23
11 * @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
12 * @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
13 * @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
14 */
15 export default {
16 name: 'uniCollapse',
17 emits:['change','activeItem','input','update:modelValue'],
18 props: {
19 value: {
20 type: [String, Array],
21 default: ''
22 },
23 modelValue: {
24 type: [String, Array],
25 default: ''
26 },
27 accordion: {
28 // 是否开启手风琴效果
29 type: [Boolean, String],
30 default: false
31 },
32 },
33 data() {
34 return {}
35 },
36 computed: {
37 // TODO 兼容 vue2 和 vue3
38 dataValue() {
39 let value = (typeof this.value === 'string' && this.value === '') ||
40 (Array.isArray(this.value) && this.value.length === 0)
41 let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') ||
42 (Array.isArray(this.modelValue) && this.modelValue.length === 0)
43 if (value) {
44 return this.modelValue
45 }
46 if (modelValue) {
47 return this.value
48 }
49
50 return this.value
51 }
52 },
53 watch: {
54 dataValue(val) {
55 this.setOpen(val)
56 }
57 },
58 created() {
59 this.childrens = []
60 this.names = []
61 },
62 mounted() {
63 this.$nextTick(()=>{
64 this.setOpen(this.dataValue)
65 })
66 },
67 methods: {
68 setOpen(val) {
69 let str = typeof val === 'string'
70 let arr = Array.isArray(val)
71 this.childrens.forEach((vm, index) => {
72 if (str) {
73 if (val === vm.nameSync) {
74 if (!this.accordion) {
75 console.warn('accordion 属性为 false ,v-model 类型应该为 array')
76 return
77 }
78 vm.isOpen = true
79 }
80 }
81 if (arr) {
82 val.forEach(v => {
83 if (v === vm.nameSync) {
84 if (this.accordion) {
85 console.warn('accordion 属性为 true ,v-model 类型应该为 string')
86 return
87 }
88 vm.isOpen = true
89 }
90 })
91 }
92 })
93 this.emit(val)
94 },
95 setAccordion(self) {
96 if (!this.accordion) return
97 this.childrens.forEach((vm, index) => {
98 if (self !== vm) {
99 vm.isOpen = false
100 }
101 })
102 },
103 resize() {
104 this.childrens.forEach((vm, index) => {
105 // #ifndef APP-NVUE
106 vm.getCollapseHeight()
107 // #endif
108 // #ifdef APP-NVUE
109 vm.getNvueHwight()
110 // #endif
111 })
112 },
113 onChange(isOpen, self) {
114 let activeItem = []
115
116 if (this.accordion) {
117 activeItem = isOpen ? self.nameSync : ''
118 } else {
119 this.childrens.forEach((vm, index) => {
120 if (vm.isOpen) {
121 activeItem.push(vm.nameSync)
122 }
123 })
124 }
125 this.$emit('change', activeItem)
126 this.emit(activeItem)
127 },
128 emit(val){
129 this.$emit('input', val)
130 this.$emit('update:modelValue', val)
131 }
132 }
133 }
134 </script>
135 <style lang="scss" >
136 .uni-collapse {
137 /* #ifndef APP-NVUE */
138 width: 100%;
139 display: flex;
140 /* #endif */
141 /* #ifdef APP-NVUE */
142 flex: 1;
143 /* #endif */
144 flex-direction: column;
145 background-color: #fff;
146 }
147 </style>
1 {
2 "id": "uni-collapse",
3 "displayName": "uni-collapse 折叠面板",
4 "version": "1.4.3",
5 "description": "Collapse 组件,可以折叠 / 展开的内容区域。",
6 "keywords": [
7 "uni-ui",
8 "折叠",
9 "折叠面板",
10 "手风琴"
11 ],
12 "repository": "https://github.com/dcloudio/uni-ui",
13 "engines": {
14 "HBuilderX": ""
15 },
16 "directories": {
17 "example": "../../temps/example_temps"
18 },
19 "dcloudext": {
20 "category": [
21 "前端组件",
22 "通用组件"
23 ],
24 "sale": {
25 "regular": {
26 "price": "0.00"
27 },
28 "sourcecode": {
29 "price": "0.00"
30 }
31 },
32 "contact": {
33 "qq": ""
34 },
35 "declaration": {
36 "ads": "无",
37 "data": "无",
38 "permissions": "无"
39 },
40 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
41 },
42 "uni_modules": {
43 "dependencies": [
44 "uni-scss",
45 "uni-icons"
46 ],
47 "encrypt": [],
48 "platforms": {
49 "cloud": {
50 "tcb": "y",
51 "aliyun": "y"
52 },
53 "client": {
54 "App": {
55 "app-vue": "y",
56 "app-nvue": "y"
57 },
58 "H5-mobile": {
59 "Safari": "y",
60 "Android Browser": "y",
61 "微信浏览器(Android)": "y",
62 "QQ浏览器(Android)": "y"
63 },
64 "H5-pc": {
65 "Chrome": "y",
66 "IE": "y",
67 "Edge": "y",
68 "Firefox": "y",
69 "Safari": "y"
70 },
71 "小程序": {
72 "微信": "y",
73 "阿里": "y",
74 "百度": "y",
75 "字节跳动": "y",
76 "QQ": "y"
77 },
78 "快应用": {
79 "华为": "u",
80 "联盟": "u"
81 },
82 "Vue": {
83 "vue2": "y",
84 "vue3": "y"
85 }
86 }
87 }
88 }
89 }
1
2
3 ## Collapse 折叠面板
4 > **组件名:uni-collapse**
5 > 代码块: `uCollapse`
6 > 关联组件:`uni-collapse-item`、`uni-icons`。
7
8
9 折叠面板用来折叠/显示过长的内容或者是列表。通常是在多内容分类项使用,折叠不重要的内容,显示重要内容。点击可以展开折叠部分。
10
11 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-collapse)
12 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.2.2(2022-01-19)
2 - 修复 在微信小程序中样式不生效的bug
3 ## 1.2.1(2022-01-18)
4 - 新增 update 方法 ,在动态更新时间后,刷新组件
5 ## 1.2.0(2021-11-19)
6 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
7 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-countdown](https://uniapp.dcloud.io/component/uniui/uni-countdown)
8 ## 1.1.3(2021-10-18)
9 - 重构
10 - 新增 font-size 支持自定义字体大小
11 ## 1.1.2(2021-08-24)
12 - 新增 支持国际化
13 ## 1.1.1(2021-07-30)
14 - 优化 vue3下小程序事件警告的问题
15 ## 1.1.0(2021-07-30)
16 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
17 ## 1.0.5(2021-06-18)
18 - 修复 uni-countdown 重复赋值跳两秒的 bug
19 ## 1.0.4(2021-05-12)
20 - 新增 组件示例地址
21 ## 1.0.3(2021-05-08)
22 - 修复 uni-countdown 不能控制倒计时的 bug
23 ## 1.0.2(2021-02-04)
24 - 调整为uni_modules目录规范
1 {
2 "uni-countdown.day": "day",
3 "uni-countdown.h": "h",
4 "uni-countdown.m": "m",
5 "uni-countdown.s": "s"
6 }
1 import en from './en.json'
2 import zhHans from './zh-Hans.json'
3 import zhHant from './zh-Hant.json'
4 export default {
5 en,
6 'zh-Hans': zhHans,
7 'zh-Hant': zhHant
8 }
1 {
2 "uni-countdown.day": "天",
3 "uni-countdown.h": "时",
4 "uni-countdown.m": "分",
5 "uni-countdown.s": "秒"
6 }
1 {
2 "uni-countdown.day": "天",
3 "uni-countdown.h": "時",
4 "uni-countdown.m": "分",
5 "uni-countdown.s": "秒"
6 }
1 <template>
2 <view class="uni-countdown">
3 <text v-if="showDay" :style="[timeStyle]" class="uni-countdown__number">{{ d }}</text>
4 <text v-if="showDay" :style="[splitorStyle]" class="uni-countdown__splitor">{{dayText}}</text>
5 <text v-if="showHour" :style="[timeStyle]" class="uni-countdown__number">{{ h }}</text>
6 <text v-if="showHour" :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : hourText }}</text>
7 <text v-if="showMin" :style="[timeStyle]" class="uni-countdown__number">{{ i }}</text>
8 <text v-if="showMin" :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : minuteText }}</text>
9 <text :style="[timeStyle]" class="uni-countdown__number">{{ s }}</text>
10 <text v-if="!showColon" :style="[splitorStyle]" class="uni-countdown__splitor">{{secondText}}</text>
11 </view>
12 </template>
13 <script>
14 import {
15 initVueI18n
16 } from '@dcloudio/uni-i18n'
17 import messages from './i18n/index.js'
18 const {
19 t
20 } = initVueI18n(messages)
21 /**
22 * Countdown 倒计时
23 * @description 倒计时组件
24 * @tutorial https://ext.dcloud.net.cn/plugin?id=25
25 * @property {String} backgroundColor 背景色
26 * @property {String} color 文字颜色
27 * @property {Number} day 天数
28 * @property {Number} hour 小时
29 * @property {Number} minute 分钟
30 * @property {Number} second 秒
31 * @property {Number} timestamp 时间戳
32 * @property {Boolean} showDay = [true|false] 是否显示天数
33 * @property {Boolean} show-colon = [true|false] 是否以冒号为分隔符
34 * @property {String} splitorColor 分割符号颜色
35 * @event {Function} timeup 倒计时时间到触发事件
36 * @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown>
37 */
38 export default {
39 name: 'UniCountdown',
40 emits: ['timeup'],
41 props: {
42 showDay: {
43 type: Boolean,
44 default: true
45 },
46 showHour: {
47 type: Boolean,
48 default: true
49 },
50 showMin: {
51 type: Boolean,
52 default: true
53 },
54 showColon: {
55 type: Boolean,
56 default: true
57 },
58 start: {
59 type: Boolean,
60 default: true
61 },
62 backgroundColor: {
63 type: String,
64 default: ''
65 },
66 color: {
67 type: String,
68 default: '#333'
69 },
70 fontSize: {
71 type: Number,
72 default: 14
73 },
74 splitorColor: {
75 type: String,
76 default: '#333'
77 },
78 day: {
79 type: Number,
80 default: 0
81 },
82 hour: {
83 type: Number,
84 default: 0
85 },
86 minute: {
87 type: Number,
88 default: 0
89 },
90 second: {
91 type: Number,
92 default: 0
93 },
94 timestamp: {
95 type: Number,
96 default: 0
97 }
98 },
99 data() {
100 return {
101 timer: null,
102 syncFlag: false,
103 d: '00',
104 h: '00',
105 i: '00',
106 s: '00',
107 leftTime: 0,
108 seconds: 0
109 }
110 },
111 computed: {
112 dayText() {
113 return t("uni-countdown.day")
114 },
115 hourText(val) {
116 return t("uni-countdown.h")
117 },
118 minuteText(val) {
119 return t("uni-countdown.m")
120 },
121 secondText(val) {
122 return t("uni-countdown.s")
123 },
124 timeStyle() {
125 const {
126 color,
127 backgroundColor,
128 fontSize
129 } = this
130 return {
131 color,
132 backgroundColor,
133 fontSize: `${fontSize}px`,
134 width: `${fontSize * 22 / 14}px`, // 按字体大小为 14px 时的比例缩放
135 lineHeight: `${fontSize * 20 / 14}px`,
136 borderRadius: `${fontSize * 3 / 14}px`,
137 }
138 },
139 splitorStyle() {
140 const { splitorColor, fontSize, backgroundColor } = this
141 return {
142 color: splitorColor,
143 fontSize: `${fontSize * 12 / 14}px`,
144 margin: backgroundColor ? `${fontSize * 4 / 14}px` : ''
145 }
146 }
147 },
148 watch: {
149 day(val) {
150 this.changeFlag()
151 },
152 hour(val) {
153 this.changeFlag()
154 },
155 minute(val) {
156 this.changeFlag()
157 },
158 second(val) {
159 this.changeFlag()
160 },
161 start: {
162 immediate: true,
163 handler(newVal, oldVal) {
164 if (newVal) {
165 this.startData();
166 } else {
167 if (!oldVal) return
168 clearInterval(this.timer)
169 }
170 }
171
172 }
173 },
174 created: function(e) {
175 this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
176 this.countDown()
177 },
178 // #ifndef VUE3
179 destroyed() {
180 clearInterval(this.timer)
181 },
182 // #endif
183 // #ifdef VUE3
184 unmounted() {
185 clearInterval(this.timer)
186 },
187 // #endif
188 methods: {
189 toSeconds(timestamp, day, hours, minutes, seconds) {
190 if (timestamp) {
191 return timestamp - parseInt(new Date().getTime() / 1000, 10)
192 }
193 return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds
194 },
195 timeUp() {
196 clearInterval(this.timer)
197 this.$emit('timeup')
198 },
199 countDown() {
200 let seconds = this.seconds
201 let [day, hour, minute, second] = [0, 0, 0, 0]
202 if (seconds > 0) {
203 day = Math.floor(seconds / (60 * 60 * 24))
204 hour = Math.floor(seconds / (60 * 60)) - (day * 24)
205 minute = Math.floor(seconds / 60) - (day * 24 * 60) - (hour * 60)
206 second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
207 } else {
208 this.timeUp()
209 }
210 if (day < 10) {
211 day = '0' + day
212 }
213 if (hour < 10) {
214 hour = '0' + hour
215 }
216 if (minute < 10) {
217 minute = '0' + minute
218 }
219 if (second < 10) {
220 second = '0' + second
221 }
222 this.d = day
223 this.h = hour
224 this.i = minute
225 this.s = second
226 },
227 startData() {
228 this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
229 if (this.seconds <= 0) {
230 this.seconds = this.toSeconds(0, 0, 0, 0, 0)
231 this.countDown()
232 return
233 }
234 clearInterval(this.timer)
235 this.countDown()
236 this.timer = setInterval(() => {
237 this.seconds--
238 if (this.seconds < 0) {
239 this.timeUp()
240 return
241 }
242 this.countDown()
243 }, 1000)
244 },
245 update(){
246 this.startData();
247 },
248 changeFlag() {
249 if (!this.syncFlag) {
250 this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
251 this.startData();
252 this.syncFlag = true;
253 }
254 }
255 }
256 }
257 </script>
258 <style lang="scss" scoped>
259 $font-size: 14px;
260
261 .uni-countdown {
262 display: flex;
263 flex-direction: row;
264 justify-content: flex-start;
265 align-items: center;
266
267 &__splitor {
268 margin: 0 2px;
269 font-size: $font-size;
270 color: #333;
271 }
272
273 &__number {
274 border-radius: 3px;
275 text-align: center;
276 font-size: $font-size;
277 }
278 }
279 </style>
1 {
2 "id": "uni-countdown",
3 "displayName": "uni-countdown 倒计时",
4 "version": "1.2.2",
5 "description": "CountDown 倒计时组件",
6 "keywords": [
7 "uni-ui",
8 "uniui",
9 "countdown",
10 "倒计时"
11 ],
12 "repository": "https://github.com/dcloudio/uni-ui",
13 "engines": {
14 "HBuilderX": ""
15 },
16 "directories": {
17 "example": "../../temps/example_temps"
18 },
19 "dcloudext": {
20 "category": [
21 "前端组件",
22 "通用组件"
23 ],
24 "sale": {
25 "regular": {
26 "price": "0.00"
27 },
28 "sourcecode": {
29 "price": "0.00"
30 }
31 },
32 "contact": {
33 "qq": ""
34 },
35 "declaration": {
36 "ads": "无",
37 "data": "无",
38 "permissions": "无"
39 },
40 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
41 },
42 "uni_modules": {
43 "dependencies": ["uni-scss"],
44 "encrypt": [],
45 "platforms": {
46 "cloud": {
47 "tcb": "y",
48 "aliyun": "y"
49 },
50 "client": {
51 "App": {
52 "app-vue": "y",
53 "app-nvue": "y"
54 },
55 "H5-mobile": {
56 "Safari": "y",
57 "Android Browser": "y",
58 "微信浏览器(Android)": "y",
59 "QQ浏览器(Android)": "y"
60 },
61 "H5-pc": {
62 "Chrome": "y",
63 "IE": "y",
64 "Edge": "y",
65 "Firefox": "y",
66 "Safari": "y"
67 },
68 "小程序": {
69 "微信": "y",
70 "阿里": "y",
71 "百度": "y",
72 "字节跳动": "y",
73 "QQ": "y"
74 },
75 "快应用": {
76 "华为": "u",
77 "联盟": "u"
78 },
79 "Vue": {
80 "vue2": "y",
81 "vue3": "y"
82 }
83 }
84 }
85 }
86 }
...\ No newline at end of file ...\ No newline at end of file
1
2
3 ## CountDown 倒计时
4 > **组件名:uni-countdown**
5 > 代码块: `uCountDown`
6
7 倒计时组件。
8
9 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-countdown)
10 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.0.3(2022-09-16)
2 - 可以使用 uni-scss 控制主题色
3 ## 1.0.2(2022-06-30)
4 - 优化 在 uni-forms 中的依赖注入方式
5 ## 1.0.1(2022-02-07)
6 - 修复 multiple 为 true 时,v-model 的值为 null 报错的 bug
7 ## 1.0.0(2021-11-19)
8 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
9 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-checkbox](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox)
10 ## 0.2.5(2021-08-23)
11 - 修复 在uni-forms中 modelValue 中不存在当前字段,当前字段必填写也不参与校验的问题
12 ## 0.2.4(2021-08-17)
13 - 修复 单选 list 模式下 ,icon 为 left 时,选中图标不显示的问题
14 ## 0.2.3(2021-08-11)
15 - 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
16 ## 0.2.2(2021-07-30)
17 - 优化 在uni-forms组件,与label不对齐的问题
18 ## 0.2.1(2021-07-27)
19 - 修复 单选默认值为0不能选中的Bug
20 ## 0.2.0(2021-07-13)
21 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
22 ## 0.1.11(2021-07-06)
23 - 优化 删除无用日志
24 ## 0.1.10(2021-07-05)
25 - 修复 由 0.1.9 引起的非 nvue 端图标不显示的问题
26 ## 0.1.9(2021-07-05)
27 - 修复 nvue 黑框样式问题
28 ## 0.1.8(2021-06-28)
29 - 修复 selectedTextColor 属性不生效的Bug
30 ## 0.1.7(2021-06-02)
31 - 新增 map 属性,可以方便映射text/value属性
32 ## 0.1.6(2021-05-26)
33 - 修复 不关联服务空间的情况下组件报错的Bug
34 ## 0.1.5(2021-05-12)
35 - 新增 组件示例地址
36 ## 0.1.4(2021-04-09)
37 - 修复 nvue 下无法选中的问题
38 ## 0.1.3(2021-03-22)
39 - 新增 disabled属性
40 ## 0.1.2(2021-02-24)
41 - 优化 默认颜色显示
42 ## 0.1.1(2021-02-24)
43 - 新增 支持nvue
44 ## 0.1.0(2021-02-18)
45 - “暂无数据”显示居中
1 {
2 "id": "uni-data-checkbox",
3 "displayName": "uni-data-checkbox 数据选择器",
4 "version": "1.0.3",
5 "description": "通过数据驱动的单选框和复选框",
6 "keywords": [
7 "uni-ui",
8 "checkbox",
9 "单选",
10 "多选",
11 "单选多选"
12 ],
13 "repository": "https://github.com/dcloudio/uni-ui",
14 "engines": {
15 "HBuilderX": "^3.1.1"
16 },
17 "directories": {
18 "example": "../../temps/example_temps"
19 },
20 "dcloudext": {
21 "sale": {
22 "regular": {
23 "price": "0.00"
24 },
25 "sourcecode": {
26 "price": "0.00"
27 }
28 },
29 "contact": {
30 "qq": ""
31 },
32 "declaration": {
33 "ads": "无",
34 "data": "无",
35 "permissions": "无"
36 },
37 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
38 "type": "component-vue"
39 },
40 "uni_modules": {
41 "dependencies": ["uni-load-more","uni-scss"],
42 "encrypt": [],
43 "platforms": {
44 "cloud": {
45 "tcb": "y",
46 "aliyun": "y"
47 },
48 "client": {
49 "App": {
50 "app-vue": "y",
51 "app-nvue": "y"
52 },
53 "H5-mobile": {
54 "Safari": "y",
55 "Android Browser": "y",
56 "微信浏览器(Android)": "y",
57 "QQ浏览器(Android)": "y"
58 },
59 "H5-pc": {
60 "Chrome": "y",
61 "IE": "y",
62 "Edge": "y",
63 "Firefox": "y",
64 "Safari": "y"
65 },
66 "小程序": {
67 "微信": "y",
68 "阿里": "y",
69 "百度": "y",
70 "字节跳动": "y",
71 "QQ": "y"
72 },
73 "快应用": {
74 "华为": "u",
75 "联盟": "u"
76 },
77 "Vue": {
78 "vue2": "y",
79 "vue3": "y"
80 }
81 }
82 }
83 }
84 }
1
2
3 ## DataCheckbox 数据驱动的单选复选框
4 > **组件名:uni-data-checkbox**
5 > 代码块: `uDataCheckbox`
6
7
8 本组件是基于uni-app基础组件checkbox的封装。本组件要解决问题包括:
9
10 1. 数据绑定型组件:给本组件绑定一个data,会自动渲染一组候选内容。再以往,开发者需要编写不少代码实现类似功能
11 2. 自动的表单校验:组件绑定了data,且符合[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)组件的表单校验规范,搭配使用会自动实现表单校验
12 3. 本组件合并了单选多选
13 4. 本组件有若干风格选择,如普通的单选多选框、并列button风格、tag风格。开发者可以快速选择需要的风格。但作为一个封装组件,样式代码虽然不用自己写了,却会牺牲一定的样式自定义性
14
15 在uniCloud开发中,`DB Schema`中配置了enum枚举等类型后,在web控制台的[自动生成表单](https://uniapp.dcloud.io/uniCloud/schema?id=autocode)功能中,会自动生成``uni-data-checkbox``组件并绑定好data
16
17 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox)
18 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.0.4(2022-04-19)
2 - 修复 字节小程序 本地数据无法选择下一级的Bug
3 ## 1.0.3(2022-02-25)
4 - 修复 nvue 不支持的 v-show 的 bug
5 ## 1.0.2(2022-02-25)
6 - 修复 条件编译 nvue 不支持的 css 样式
7 ## 1.0.1(2021-11-23)
8 - 修复 由上个版本引发的map、v-model等属性不生效的bug
9 ## 1.0.0(2021-11-19)
10 - 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
11 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
12 ## 0.4.9(2021-10-28)
13 - 修复 VUE2 v-model 概率无效的 bug
14 ## 0.4.8(2021-10-27)
15 - 修复 v-model 概率无效的 bug
16 ## 0.4.7(2021-10-25)
17 - 新增 属性 spaceInfo 服务空间配置 HBuilderX 3.2.11+
18 - 修复 树型 uniCloud 数据类型为 int 时报错的 bug
19 ## 0.4.6(2021-10-19)
20 - 修复 非 VUE3 v-model 为 0 时无法选中的 bug
21 ## 0.4.5(2021-09-26)
22 - 新增 清除已选项的功能(通过 clearIcon 属性配置是否显示按钮),同时提供 clear 方法以供调用,二者等效
23 - 修复 readonly 为 true 时报错的 bug
24 ## 0.4.4(2021-09-26)
25 - 修复 上一版本造成的 map 属性失效的 bug
26 - 新增 ellipsis 属性,支持配置 tab 选项长度过长时是否自动省略
27 ## 0.4.3(2021-09-24)
28 - 修复 某些情况下级联未触发的 bug
29 ## 0.4.2(2021-09-23)
30 - 新增 提供 show 和 hide 方法,开发者可以通过 ref 调用
31 - 新增 选项内容过长自动添加省略号
32 ## 0.4.1(2021-09-15)
33 - 新增 map 属性 字段映射,将 text/value 映射到数据中的其他字段
34 ## 0.4.0(2021-07-13)
35 - 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
36 ## 0.3.5(2021-06-04)
37 - 修复 无法加载云端数据的问题
38 ## 0.3.4(2021-05-28)
39 - 修复 v-model 无效问题
40 - 修复 loaddata 为空数据组时加载时间过长问题
41 - 修复 上个版本引出的本地数据无法选择带有 children 的 2 级节点
42 ## 0.3.3(2021-05-12)
43 - 新增 组件示例地址
44 ## 0.3.2(2021-04-22)
45 - 修复 非树形数据有 where 属性查询报错的问题
46 ## 0.3.1(2021-04-15)
47 - 修复 本地数据概率无法回显时问题
48 ## 0.3.0(2021-04-07)
49 - 新增 支持云端非树形表结构数据
50 - 修复 根节点 parent_field 字段等于 null 时选择界面错乱问题
51 ## 0.2.0(2021-03-15)
52 - 修复 nodeclick、popupopened、popupclosed 事件无法触发的问题
53 ## 0.1.9(2021-03-09)
54 - 修复 微信小程序某些情况下无法选择的问题
55 ## 0.1.8(2021-02-05)
56 - 优化 部分样式在 nvue 上的兼容表现
57 ## 0.1.7(2021-02-05)
58 - 调整为 uni_modules 目录规范
1 // #ifdef H5
2 export default {
3 name: 'Keypress',
4 props: {
5 disable: {
6 type: Boolean,
7 default: false
8 }
9 },
10 mounted () {
11 const keyNames = {
12 esc: ['Esc', 'Escape'],
13 tab: 'Tab',
14 enter: 'Enter',
15 space: [' ', 'Spacebar'],
16 up: ['Up', 'ArrowUp'],
17 left: ['Left', 'ArrowLeft'],
18 right: ['Right', 'ArrowRight'],
19 down: ['Down', 'ArrowDown'],
20 delete: ['Backspace', 'Delete', 'Del']
21 }
22 const listener = ($event) => {
23 if (this.disable) {
24 return
25 }
26 const keyName = Object.keys(keyNames).find(key => {
27 const keyName = $event.key
28 const value = keyNames[key]
29 return value === keyName || (Array.isArray(value) && value.includes(keyName))
30 })
31 if (keyName) {
32 // 避免和其他按键事件冲突
33 setTimeout(() => {
34 this.$emit(keyName, {})
35 }, 0)
36 }
37 }
38 document.addEventListener('keyup', listener)
39 this.$once('hook:beforeDestroy', () => {
40 document.removeEventListener('keyup', listener)
41 })
42 },
43 render: () => {}
44 }
45 // #endif
1 <template>
2 <view class="uni-data-pickerview">
3 <scroll-view class="selected-area" scroll-x="true" scroll-y="false" :show-scrollbar="false">
4 <view class="selected-list">
5 <template v-for="(item,index) in selected">
6 <view class="selected-item"
7 :class="{'selected-item-active':index==selectedIndex, 'selected-item-text-overflow': ellipsis}"
8 :key="index" v-if="item.text" @click="handleSelect(index)">
9 <text class="">{{item.text}}</text>
10 </view>
11 </template>
12 </view>
13 </scroll-view>
14 <view class="tab-c">
15 <template v-for="(child, i) in dataList">
16 <scroll-view class="list" :key="i" v-if="i==selectedIndex" :scroll-y="true">
17 <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child" :key="j"
18 @click="handleNodeClick(item, i, j)">
19 <text class="item-text item-text-overflow">{{item[map.text]}}</text>
20 <view class="check" v-if="selected.length > i && item[map.value] == selected[i].value"></view>
21 </view>
22 </scroll-view>
23 </template>
24
25 <view class="loading-cover" v-if="loading">
26 <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
27 </view>
28 <view class="error-message" v-if="errorMessage">
29 <text class="error-text">{{errorMessage}}</text>
30 </view>
31 </view>
32 </view>
33 </template>
34
35 <script>
36 import dataPicker from "./uni-data-picker.js"
37
38 /**
39 * DataPickerview
40 * @description uni-data-pickerview
41 * @tutorial https://ext.dcloud.net.cn/plugin?id=3796
42 * @property {Array} localdata 本地数据,参考
43 * @property {Boolean} step-searh = [true|false] 是否分布查询
44 * @value true 启用分布查询,仅查询当前选中节点
45 * @value false 关闭分布查询,一次查询出所有数据
46 * @property {String|DBFieldString} self-field 分布查询当前字段名称
47 * @property {String|DBFieldString} parent-field 分布查询父字段名称
48 * @property {String|DBCollectionString} collection 表名
49 * @property {String|DBFieldString} field 查询字段,多个字段用 `,` 分割
50 * @property {String} orderby 排序字段及正序倒叙设置
51 * @property {String|JQLString} where 查询条件
52 */
53 export default {
54 name: 'UniDataPickerView',
55 emits: ['nodeclick', 'change', 'datachange', 'update:modelValue'],
56 mixins: [dataPicker],
57 props: {
58 managedMode: {
59 type: Boolean,
60 default: false
61 },
62 ellipsis: {
63 type: Boolean,
64 default: true
65 }
66 },
67 data() {
68 return {}
69 },
70 created() {
71 if (this.managedMode) {
72 return
73 }
74
75 this.$nextTick(() => {
76 this.load()
77 })
78 },
79 methods: {
80 onPropsChange() {
81 this._treeData = []
82 this.selectedIndex = 0
83 this.load()
84 },
85 load() {
86 if (this.isLocaldata) {
87 this.loadData()
88 } else if (this.dataValue.length) {
89 this.getTreePath((res) => {
90 this.loadData()
91 })
92 }
93 },
94 handleSelect(index) {
95 this.selectedIndex = index
96 },
97 handleNodeClick(item, i, j) {
98 if (item.disable) {
99 return
100 }
101 const node = this.dataList[i][j]
102 const text = node[this.map.text]
103 const value = node[this.map.value]
104 if (i < this.selected.length - 1) {
105 this.selected.splice(i, this.selected.length - i)
106 this.selected.push({
107 text,
108 value
109 })
110 } else if (i === this.selected.length - 1) {
111 this.selected.splice(i, 1, {
112 text,
113 value
114 })
115 }
116
117 if (node.isleaf) {
118 this.onSelectedChange(node, node.isleaf)
119 return
120 }
121
122 const {
123 isleaf,
124 hasNodes
125 } = this._updateBindData()
126
127 if (!this._isTreeView() && !hasNodes) {
128 this.onSelectedChange(node, true)
129 return
130 }
131
132 if (this.isLocaldata && (!hasNodes || isleaf)) {
133 this.onSelectedChange(node, true)
134 return
135 }
136
137 if (!isleaf && !hasNodes) {
138 this._loadNodeData((data) => {
139 if (!data.length) {
140 node.isleaf = true
141 } else {
142 this._treeData.push(...data)
143 this._updateBindData(node)
144 }
145 this.onSelectedChange(node, node.isleaf)
146 }, this._nodeWhere())
147 return
148 }
149
150 this.onSelectedChange(node, false)
151 },
152 updateData(data) {
153 this._treeData = data.treeData
154 this.selected = data.selected
155 if (!this._treeData.length) {
156 this.loadData()
157 } else {
158 //this.selected = data.selected
159 this._updateBindData()
160 }
161 },
162 onDataChange() {
163 this.$emit('datachange')
164 },
165 onSelectedChange(node, isleaf) {
166 if (isleaf) {
167 this._dispatchEvent()
168 }
169
170 if (node) {
171 this.$emit('nodeclick', node)
172 }
173 },
174 _dispatchEvent() {
175 this.$emit('change', this.selected.slice(0))
176 }
177 }
178 }
179 </script>
180 <style >
181 .uni-data-pickerview {
182 flex: 1;
183 /* #ifndef APP-NVUE */
184 display: flex;
185 /* #endif */
186 flex-direction: column;
187 overflow: hidden;
188 height: 100%;
189 }
190
191 .error-text {
192 color: #DD524D;
193 }
194
195 .loading-cover {
196 position: absolute;
197 left: 0;
198 top: 0;
199 right: 0;
200 bottom: 0;
201 background-color: rgba(255, 255, 255, .5);
202 /* #ifndef APP-NVUE */
203 display: flex;
204 /* #endif */
205 flex-direction: column;
206 align-items: center;
207 z-index: 1001;
208 }
209
210 .load-more {
211 /* #ifndef APP-NVUE */
212 margin: auto;
213 /* #endif */
214 }
215
216 .error-message {
217 background-color: #fff;
218 position: absolute;
219 left: 0;
220 top: 0;
221 right: 0;
222 bottom: 0;
223 padding: 15px;
224 opacity: .9;
225 z-index: 102;
226 }
227
228 /* #ifdef APP-NVUE */
229 .selected-area {
230 width: 750rpx;
231 }
232
233 /* #endif */
234
235 .selected-list {
236 /* #ifndef APP-NVUE */
237 display: flex;
238 /* #endif */
239 flex-direction: row;
240 flex-wrap: nowrap;
241 padding: 0 5px;
242 border-bottom: 1px solid #f8f8f8;
243 }
244
245 .selected-item {
246 margin-left: 10px;
247 margin-right: 10px;
248 padding: 12px 0;
249 text-align: center;
250 /* #ifndef APP-NVUE */
251 white-space: nowrap;
252 /* #endif */
253 }
254
255 .selected-item-text-overflow {
256 width: 168px;
257 /* fix nvue */
258 overflow: hidden;
259 /* #ifndef APP-NVUE */
260 width: 6em;
261 white-space: nowrap;
262 text-overflow: ellipsis;
263 -o-text-overflow: ellipsis;
264 /* #endif */
265 }
266
267 .selected-item-active {
268 border-bottom: 2px solid #00C176;
269 }
270
271 .selected-item-text {
272 color: #00C176;
273 }
274
275 .tab-c {
276 position: relative;
277 flex: 1;
278 /* #ifndef APP-NVUE */
279 display: flex;
280 /* #endif */
281 flex-direction: row;
282 overflow: hidden;
283 }
284
285 .list {
286 flex: 1;
287 }
288
289 .item {
290 padding: 12px 15px;
291 /* border-bottom: 1px solid #f0f0f0; */
292 /* #ifndef APP-NVUE */
293 display: flex;
294 /* #endif */
295 flex-direction: row;
296 justify-content: space-between;
297 }
298
299 .is-disabled {
300 opacity: .5;
301 }
302
303 .item-text {
304 /* flex: 1; */
305 color: #333333;
306 }
307
308 .item-text-overflow {
309 width: 280px;
310 /* fix nvue */
311 overflow: hidden;
312 /* #ifndef APP-NVUE */
313 width: 20em;
314 white-space: nowrap;
315 text-overflow: ellipsis;
316 -o-text-overflow: ellipsis;
317 /* #endif */
318 }
319
320 .check {
321 margin-right: 5px;
322 border: 2px solid #00C176;
323 border-left: 0;
324 border-top: 0;
325 height: 12px;
326 width: 6px;
327 transform-origin: center;
328 /* #ifndef APP-NVUE */
329 transition: all 0.3s;
330 /* #endif */
331 transform: rotate(45deg);
332 }
333 </style>
1 {
2 "id": "uni-data-picker",
3 "displayName": "uni-data-picker 数据驱动的picker选择器",
4 "version": "1.0.4",
5 "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
6 "keywords": [
7 "uni-ui",
8 "uniui",
9 "picker",
10 "级联",
11 "省市区",
12 ""
13 ],
14 "repository": "https://github.com/dcloudio/uni-ui",
15 "engines": {
16 "HBuilderX": ""
17 },
18 "directories": {
19 "example": "../../temps/example_temps"
20 },
21 "dcloudext": {
22 "category": [
23 "前端组件",
24 "通用组件"
25 ],
26 "sale": {
27 "regular": {
28 "price": "0.00"
29 },
30 "sourcecode": {
31 "price": "0.00"
32 }
33 },
34 "contact": {
35 "qq": ""
36 },
37 "declaration": {
38 "ads": "无",
39 "data": "无",
40 "permissions": "无"
41 },
42 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
43 },
44 "uni_modules": {
45 "dependencies": [
46 "uni-load-more",
47 "uni-icons",
48 "uni-scss"
49 ],
50 "encrypt": [],
51 "platforms": {
52 "cloud": {
53 "tcb": "y",
54 "aliyun": "y"
55 },
56 "client": {
57 "App": {
58 "app-vue": "y",
59 "app-nvue": "y"
60 },
61 "H5-mobile": {
62 "Safari": "y",
63 "Android Browser": "y",
64 "微信浏览器(Android)": "y",
65 "QQ浏览器(Android)": "y"
66 },
67 "H5-pc": {
68 "Chrome": "y",
69 "IE": "y",
70 "Edge": "y",
71 "Firefox": "y",
72 "Safari": "y"
73 },
74 "小程序": {
75 "微信": "y",
76 "阿里": "y",
77 "百度": "y",
78 "字节跳动": "y",
79 "QQ": "y"
80 },
81 "快应用": {
82 "华为": "u",
83 "联盟": "u"
84 },
85 "Vue": {
86 "vue2": "y",
87 "vue3": "y"
88 }
89 }
90 }
91 }
92 }
...\ No newline at end of file ...\ No newline at end of file
1 ## DataPicker 级联选择
2 > **组件名:uni-data-picker**
3 > 代码块: `uDataPicker`
4 > 关联组件:`uni-data-pickerview`、`uni-load-more`。
5
6
7 `<uni-data-picker>` 是一个选择类[datacom组件](https://uniapp.dcloud.net.cn/component/datacom)。
8
9 支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
10
11 候选数据支持一次性加载完毕,也支持懒加载,比如示例图中,选择了“北京”后,动态加载北京的区县数据。
12
13 `<uni-data-picker>` 组件尤其适用于地址选择、分类选择等选择类。
14
15 `<uni-data-picker>` 支持本地数据、云端静态数据(json),uniCloud云数据库数据。
16
17 `<uni-data-picker>` 可以通过JQL直连uniCloud云数据库,配套[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema),可在schema2code中自动生成前端页面,还支持服务器端校验。
18
19 在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
20
21 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
22 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.0.5(2023-02-03)
2 - 修复 禁用时会显示清空按钮
3 ## 1.0.4(2023-02-02)
4 - 优化 查询条件短期内多次变更只查询最后一次变更后的结果
5 - 调整 内部缓存键名调整为 uni-data-select-lastSelectedValue
6 ## 1.0.3(2023-01-16)
7 - 修复 不关联服务空间报错的问题
8 ## 1.0.2(2023-01-14)
9 - 新增 属性 `format` 可用于格式化显示选项内容
10 ## 1.0.1(2022-12-06)
11 - 修复 当where变化时,数据不会自动更新的问题
12 ## 0.1.9(2022-09-05)
13 - 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
14 ## 0.1.8(2022-08-29)
15 - 修复 点击的位置不准确
16 ## 0.1.7(2022-08-12)
17 - 新增 支持 disabled 属性
18 ## 0.1.6(2022-07-06)
19 - 修复 pc端宽度异常的bug
20 ## 0.1.5
21 - 修复 pc端宽度异常的bug
22 ## 0.1.4(2022-07-05)
23 - 优化 显示样式
24 ## 0.1.3(2022-06-02)
25 - 修复 localdata 赋值不生效的 bug
26 - 新增 支持 uni.scss 修改颜色
27 - 新增 支持选项禁用(数据选项设置 disabled: true 即禁用)
28 ## 0.1.2(2022-05-08)
29 - 修复 当 value 为 0 时选择不生效的 bug
30 ## 0.1.1(2022-05-07)
31 - 新增 记住上次的选项(仅 collection 存在时有效)
32 ## 0.1.0(2022-04-22)
33 - 初始化
1 {
2 "id": "uni-data-select",
3 "displayName": "uni-data-select 下拉框选择器",
4 "version": "1.0.5",
5 "description": "通过数据驱动的下拉框选择器",
6 "keywords": [
7 "uni-ui",
8 "select",
9 "uni-data-select",
10 "下拉框",
11 "下拉选"
12 ],
13 "repository": "https://github.com/dcloudio/uni-ui",
14 "engines": {
15 "HBuilderX": "^3.1.1"
16 },
17 "directories": {
18 "example": "../../temps/example_temps"
19 },
20 "dcloudext": {
21 "sale": {
22 "regular": {
23 "price": "0.00"
24 },
25 "sourcecode": {
26 "price": "0.00"
27 }
28 },
29 "contact": {
30 "qq": ""
31 },
32 "declaration": {
33 "ads": "无",
34 "data": "无",
35 "permissions": "无"
36 },
37 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
38 "type": "component-vue"
39 },
40 "uni_modules": {
41 "dependencies": ["uni-load-more"],
42 "encrypt": [],
43 "platforms": {
44 "cloud": {
45 "tcb": "y",
46 "aliyun": "y"
47 },
48 "client": {
49 "App": {
50 "app-vue": "u",
51 "app-nvue": "n"
52 },
53 "H5-mobile": {
54 "Safari": "y",
55 "Android Browser": "y",
56 "微信浏览器(Android)": "y",
57 "QQ浏览器(Android)": "y"
58 },
59 "H5-pc": {
60 "Chrome": "y",
61 "IE": "y",
62 "Edge": "y",
63 "Firefox": "y",
64 "Safari": "y"
65 },
66 "小程序": {
67 "微信": "y",
68 "阿里": "u",
69 "百度": "u",
70 "字节跳动": "u",
71 "QQ": "u",
72 "京东": "u"
73 },
74 "快应用": {
75 "华为": "u",
76 "联盟": "u"
77 },
78 "Vue": {
79 "vue2": "y",
80 "vue3": "y"
81 }
82 }
83 }
84 }
85 }
1 ## DataSelect 下拉框选择器
2 > **组件名:uni-data-select**
3 > 代码块: `uDataSelect`
4
5 当选项过多时,使用下拉菜单展示并选择内容
6
7 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select)
8 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
1 ## 2.2.21(2023-02-20)
2 - 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362)
3 ## 2.2.20(2023-02-17)
4 - 优化 值为空依然选中当天问题
5 - 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间
6 - 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
7 - 优化 字节小程序日期时间范围选择,底部日期换行问题
8 ## 2.2.19(2023-02-09)
9 - 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686)
10 ## 2.2.18(2023-02-08)
11 - 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684)
12 - 优化 PC端输入日期格式错误时返回当前日期时间
13 - 优化 PC端输入日期时间超出 start、end 限制的Bug
14 - 优化 移动端日期时间范围用法时间展示不完整问题
15 ## 2.2.17(2023-02-04)
16 - 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679)
17 - 修复 vue3 time-picker 无法显示绑定时分秒的Bug
18 ## 2.2.16(2023-02-02)
19 - 修复 字节小程序报错的Bug
20 ## 2.2.15(2023-02-02)
21 - 修复 某些情况切换月份错误的Bug
22 ## 2.2.14(2023-01-30)
23 - 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033)
24 ## 2.2.13(2023-01-10)
25 - 修复 多次加载组件造成内存占用的Bug
26 ## 2.2.12(2022-12-01)
27 - 修复 vue3 下 i18n 国际化初始值不正确的Bug
28 ## 2.2.11(2022-09-19)
29 - 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861)
30 ## 2.2.10(2022-09-19)
31 - 修复 反向选择日期范围,日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
32 ## 2.2.9(2022-09-16)
33 - 可以使用 uni-scss 控制主题色
34 ## 2.2.8(2022-09-08)
35 - 修复 close事件无效的Bug
36 ## 2.2.7(2022-09-05)
37 - 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824)
38 ## 2.2.6(2022-06-30)
39 - 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致
40 ## 2.2.5(2022-06-24)
41 - 修复 日历顶部年月及底部确认未国际化的Bug
42 ## 2.2.4(2022-03-31)
43 - 修复 Vue3 下动态赋值,单选类型未响应的Bug
44 ## 2.2.3(2022-03-28)
45 - 修复 Vue3 下动态赋值未响应的Bug
46 ## 2.2.2(2021-12-10)
47 - 修复 clear-icon 属性在小程序平台不生效的Bug
48 ## 2.2.1(2021-12-10)
49 - 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug
50 ## 2.2.0(2021-11-19)
51 - 优化 组件UI,并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource)
52 - 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
53 ## 2.1.5(2021-11-09)
54 - 新增 提供组件设计资源,组件样式调整
55 ## 2.1.4(2021-09-10)
56 - 修复 hide-second 在移动端的Bug
57 - 修复 单选赋默认值时,赋值日期未高亮的Bug
58 - 修复 赋默认值时,移动端未正确显示时间的Bug
59 ## 2.1.3(2021-09-09)
60 - 新增 hide-second 属性,支持只使用时分,隐藏秒
61 ## 2.1.2(2021-09-03)
62 - 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
63 - 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
64 - 优化 调整字号大小,美化日历界面
65 - 修复 因国际化导致的 placeholder 失效的Bug
66 ## 2.1.1(2021-08-24)
67 - 新增 支持国际化
68 - 优化 范围选择器在 pc 端过宽的问题
69 ## 2.1.0(2021-08-09)
70 - 新增 适配 vue3
71 ## 2.0.19(2021-08-09)
72 - 新增 支持作为 uni-forms 子组件相关功能
73 - 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug
74 ## 2.0.18(2021-08-05)
75 - 修复 type 属性动态赋值无效的Bug
76 - 修复 ‘确认’按钮被 tabbar 遮盖 bug
77 - 修复 组件未赋值时范围选左、右日历相同的Bug
78 ## 2.0.17(2021-08-04)
79 - 修复 范围选未正确显示当前值的Bug
80 - 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug
81 ## 2.0.16(2021-07-21)
82 - 新增 return-type 属性支持返回 date 日期对象
83 ## 2.0.15(2021-07-14)
84 - 修复 单选日期类型,初始赋值后不在当前日历的Bug
85 - 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
86 - 优化 移动端移除显示框的清空按钮,无实际用途
87 ## 2.0.14(2021-07-14)
88 - 修复 组件赋值为空,界面未更新的Bug
89 - 修复 start 和 end 不能动态赋值的Bug
90 - 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug
91 ## 2.0.13(2021-07-08)
92 - 修复 范围选择不能动态赋值的Bug
93 ## 2.0.12(2021-07-08)
94 - 修复 范围选择的初始时间在一个月内时,造成无法选择的bug
95 ## 2.0.11(2021-07-08)
96 - 优化 弹出层在超出视窗边缘定位不准确的问题
97 ## 2.0.10(2021-07-08)
98 - 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug
99 - 优化 弹出层在超出视窗边缘被遮盖的问题
100 ## 2.0.9(2021-07-07)
101 - 新增 maskClick 事件
102 - 修复 特殊情况日历 rpx 布局错误的Bug,rpx -> px
103 - 修复 范围选择时清空返回值不合理的bug,['', ''] -> []
104 ## 2.0.8(2021-07-07)
105 - 新增 日期时间显示框支持插槽
106 ## 2.0.7(2021-07-01)
107 - 优化 添加 uni-icons 依赖
108 ## 2.0.6(2021-05-22)
109 - 修复 图标在小程序上不显示的Bug
110 - 优化 重命名引用组件,避免潜在组件命名冲突
111 ## 2.0.5(2021-05-20)
112 - 优化 代码目录扁平化
113 ## 2.0.4(2021-05-12)
114 - 新增 组件示例地址
115 ## 2.0.3(2021-05-10)
116 - 修复 ios 下不识别 '-' 日期格式的Bug
117 - 优化 pc 下弹出层添加边框和阴影
118 ## 2.0.2(2021-05-08)
119 - 修复 在 admin 中获取弹出层定位错误的bug
120 ## 2.0.1(2021-05-08)
121 - 修复 type 属性向下兼容,默认值从 date 变更为 datetime
122 ## 2.0.0(2021-04-30)
123 - 支持日历形式的日期+时间的范围选择
124 > 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)
125 ## 1.0.6(2021-03-18)
126 - 新增 hide-second 属性,时间支持仅选择时、分
127 - 修复 选择跟显示的日期不一样的Bug
128 - 修复 chang事件触发2次的Bug
129 - 修复 分、秒 end 范围错误的Bug
130 - 优化 更好的 nvue 适配
1 <template>
2 <view class="uni-calendar-item__weeks-box" :class="{
3 'uni-calendar-item--disable':weeks.disable,
4 'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
5 'uni-calendar-item--multiple': weeks.multiple,
6 'uni-calendar-item--after-checked-x':weeks.afterMultiple,
7 }" @click="choiceDate(weeks)" @mouseenter="handleMousemove(weeks)">
8 <view class="uni-calendar-item__weeks-box-item" :class="{
9 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
10 'uni-calendar-item--checked-range-text': checkHover,
11 'uni-calendar-item--before-checked':weeks.beforeMultiple,
12 'uni-calendar-item--multiple': weeks.multiple,
13 'uni-calendar-item--after-checked':weeks.afterMultiple,
14 'uni-calendar-item--disable':weeks.disable,
15 }">
16 <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
17 <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
18 </view>
19 <view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view>
20 </view>
21 </template>
22
23 <script>
24 export default {
25 props: {
26 weeks: {
27 type: Object,
28 default () {
29 return {}
30 }
31 },
32 calendar: {
33 type: Object,
34 default: () => {
35 return {}
36 }
37 },
38 selected: {
39 type: Array,
40 default: () => {
41 return []
42 }
43 },
44 lunar: {
45 type: Boolean,
46 default: false
47 },
48 checkHover: {
49 type: Boolean,
50 default: false
51 }
52 },
53 methods: {
54 choiceDate(weeks) {
55 this.$emit('change', weeks)
56 },
57 handleMousemove(weeks) {
58 this.$emit('handleMouse', weeks)
59 }
60 }
61 }
62 </script>
63
64 <style lang="scss" >
65 $uni-primary: #007aff !default;
66
67 .uni-calendar-item__weeks-box {
68 flex: 1;
69 /* #ifndef APP-NVUE */
70 display: flex;
71 /* #endif */
72 flex-direction: column;
73 justify-content: center;
74 align-items: center;
75 margin: 1px 0;
76 position: relative;
77 }
78
79 .uni-calendar-item__weeks-box-text {
80 font-size: 14px;
81 // font-family: Lato-Bold, Lato;
82 font-weight: bold;
83 color: darken($color: $uni-primary, $amount: 40%);
84 }
85
86 .uni-calendar-item__weeks-lunar-text {
87 font-size: 12px;
88 color: #333;
89 }
90
91 .uni-calendar-item__weeks-box-item {
92 position: relative;
93 /* #ifndef APP-NVUE */
94 display: flex;
95 /* #endif */
96 flex-direction: column;
97 justify-content: center;
98 align-items: center;
99 width: 40px;
100 height: 40px;
101 /* #ifdef H5 */
102 cursor: pointer;
103 /* #endif */
104 }
105
106
107 .uni-calendar-item__weeks-box-circle {
108 position: absolute;
109 top: 5px;
110 right: 5px;
111 width: 8px;
112 height: 8px;
113 border-radius: 8px;
114 background-color: #dd524d;
115
116 }
117
118 .uni-calendar-item__weeks-box .uni-calendar-item--disable {
119 cursor: default;
120 }
121
122 .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
123 color: #D1D1D1;
124 }
125
126 .uni-calendar-item--isDay {
127 position: absolute;
128 top: 10px;
129 right: 17%;
130 background-color: #dd524d;
131 width:6px;
132 height: 6px;
133 border-radius: 50%;
134 }
135
136 .uni-calendar-item--extra {
137 color: #dd524d;
138 opacity: 0.8;
139 }
140
141 .uni-calendar-item__weeks-box .uni-calendar-item--checked {
142 background-color: $uni-primary;
143 border-radius: 50%;
144 box-sizing: border-box;
145 border: 3px solid #fff;
146 }
147
148 .uni-calendar-item--checked .uni-calendar-item--checked-text {
149 color: #fff;
150 }
151
152 .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
153 color: #333;
154 }
155
156 .uni-calendar-item--multiple {
157 background-color: #F6F7FC;
158 // color: #fff;
159 }
160
161 .uni-calendar-item--multiple .uni-calendar-item--before-checked,
162 .uni-calendar-item--multiple .uni-calendar-item--after-checked {
163 background-color: $uni-primary;
164 border-radius: 50%;
165 box-sizing: border-box;
166 border: 3px solid #F6F7FC;
167 }
168
169 .uni-calendar-item--before-checked .uni-calendar-item--checked-text,
170 .uni-calendar-item--after-checked .uni-calendar-item--checked-text {
171 color: #fff;
172 }
173
174 .uni-calendar-item--before-checked-x {
175 border-top-left-radius: 50px;
176 border-bottom-left-radius: 50px;
177 box-sizing: border-box;
178 background-color: #F6F7FC;
179 }
180
181 .uni-calendar-item--after-checked-x {
182 border-top-right-radius: 50px;
183 border-bottom-right-radius: 50px;
184 background-color: #F6F7FC;
185 }
186 </style>
1 {
2 "uni-datetime-picker.selectDate": "select date",
3 "uni-datetime-picker.selectTime": "select time",
4 "uni-datetime-picker.selectDateTime": "select datetime",
5 "uni-datetime-picker.startDate": "start date",
6 "uni-datetime-picker.endDate": "end date",
7 "uni-datetime-picker.startTime": "start time",
8 "uni-datetime-picker.endTime": "end time",
9 "uni-datetime-picker.ok": "ok",
10 "uni-datetime-picker.clear": "clear",
11 "uni-datetime-picker.cancel": "cancel",
12 "uni-datetime-picker.year": "-",
13 "uni-datetime-picker.month": "",
14 "uni-calender.MON": "MON",
15 "uni-calender.TUE": "TUE",
16 "uni-calender.WED": "WED",
17 "uni-calender.THU": "THU",
18 "uni-calender.FRI": "FRI",
19 "uni-calender.SAT": "SAT",
20 "uni-calender.SUN": "SUN",
21 "uni-calender.confirm": "confirm"
22 }
1 import en from './en.json'
2 import zhHans from './zh-Hans.json'
3 import zhHant from './zh-Hant.json'
4 export default {
5 en,
6 'zh-Hans': zhHans,
7 'zh-Hant': zhHant
8 }
1 {
2 "uni-datetime-picker.selectDate": "选择日期",
3 "uni-datetime-picker.selectTime": "选择时间",
4 "uni-datetime-picker.selectDateTime": "选择日期时间",
5 "uni-datetime-picker.startDate": "开始日期",
6 "uni-datetime-picker.endDate": "结束日期",
7 "uni-datetime-picker.startTime": "开始时间",
8 "uni-datetime-picker.endTime": "结束时间",
9 "uni-datetime-picker.ok": "确定",
10 "uni-datetime-picker.clear": "清除",
11 "uni-datetime-picker.cancel": "取消",
12 "uni-datetime-picker.year": "年",
13 "uni-datetime-picker.month": "月",
14 "uni-calender.SUN": "日",
15 "uni-calender.MON": "一",
16 "uni-calender.TUE": "二",
17 "uni-calender.WED": "三",
18 "uni-calender.THU": "四",
19 "uni-calender.FRI": "五",
20 "uni-calender.SAT": "六",
21 "uni-calender.confirm": "确认"
22 }
...\ No newline at end of file ...\ No newline at end of file
1 {
2 "uni-datetime-picker.selectDate": "選擇日期",
3 "uni-datetime-picker.selectTime": "選擇時間",
4 "uni-datetime-picker.selectDateTime": "選擇日期時間",
5 "uni-datetime-picker.startDate": "開始日期",
6 "uni-datetime-picker.endDate": "結束日期",
7 "uni-datetime-picker.startTime": "開始时间",
8 "uni-datetime-picker.endTime": "結束时间",
9 "uni-datetime-picker.ok": "確定",
10 "uni-datetime-picker.clear": "清除",
11 "uni-datetime-picker.cancel": "取消",
12 "uni-datetime-picker.year": "年",
13 "uni-datetime-picker.month": "月",
14 "uni-calender.SUN": "日",
15 "uni-calender.MON": "一",
16 "uni-calender.TUE": "二",
17 "uni-calender.WED": "三",
18 "uni-calender.THU": "四",
19 "uni-calender.FRI": "五",
20 "uni-calender.SAT": "六",
21 "uni-calender.confirm": "確認"
22 }
...\ No newline at end of file ...\ No newline at end of file
1 // #ifdef H5
2 export default {
3 name: 'Keypress',
4 props: {
5 disable: {
6 type: Boolean,
7 default: false
8 }
9 },
10 mounted () {
11 const keyNames = {
12 esc: ['Esc', 'Escape'],
13 tab: 'Tab',
14 enter: 'Enter',
15 space: [' ', 'Spacebar'],
16 up: ['Up', 'ArrowUp'],
17 left: ['Left', 'ArrowLeft'],
18 right: ['Right', 'ArrowRight'],
19 down: ['Down', 'ArrowDown'],
20 delete: ['Backspace', 'Delete', 'Del']
21 }
22 const listener = ($event) => {
23 if (this.disable) {
24 return
25 }
26 const keyName = Object.keys(keyNames).find(key => {
27 const keyName = $event.key
28 const value = keyNames[key]
29 return value === keyName || (Array.isArray(value) && value.includes(keyName))
30 })
31 if (keyName) {
32 // 避免和其他按键事件冲突
33 setTimeout(() => {
34 this.$emit(keyName, {})
35 }, 0)
36 }
37 }
38 document.addEventListener('keyup', listener)
39 this.$once('hook:beforeDestroy', () => {
40 document.removeEventListener('keyup', listener)
41 })
42 },
43 render: () => {}
44 }
45 // #endif
...\ No newline at end of file ...\ No newline at end of file
1 {
2 "id": "uni-datetime-picker",
3 "displayName": "uni-datetime-picker 日期选择器",
4 "version": "2.2.21",
5 "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
6 "keywords": [
7 "uni-datetime-picker",
8 "uni-ui",
9 "uniui",
10 "日期时间选择器",
11 "日期时间"
12 ],
13 "repository": "https://github.com/dcloudio/uni-ui",
14 "engines": {
15 "HBuilderX": ""
16 },
17 "directories": {
18 "example": "../../temps/example_temps"
19 },
20 "dcloudext": {
21 "sale": {
22 "regular": {
23 "price": "0.00"
24 },
25 "sourcecode": {
26 "price": "0.00"
27 }
28 },
29 "contact": {
30 "qq": ""
31 },
32 "declaration": {
33 "ads": "无",
34 "data": "无",
35 "permissions": "无"
36 },
37 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
38 "type": "component-vue"
39 },
40 "uni_modules": {
41 "dependencies": [
42 "uni-scss",
43 "uni-icons"
44 ],
45 "encrypt": [],
46 "platforms": {
47 "cloud": {
48 "tcb": "y",
49 "aliyun": "y"
50 },
51 "client": {
52 "App": {
53 "app-vue": "y",
54 "app-nvue": "n"
55 },
56 "H5-mobile": {
57 "Safari": "y",
58 "Android Browser": "y",
59 "微信浏览器(Android)": "y",
60 "QQ浏览器(Android)": "y"
61 },
62 "H5-pc": {
63 "Chrome": "y",
64 "IE": "y",
65 "Edge": "y",
66 "Firefox": "y",
67 "Safari": "y"
68 },
69 "小程序": {
70 "微信": "y",
71 "阿里": "y",
72 "百度": "y",
73 "字节跳动": "y",
74 "QQ": "y"
75 },
76 "快应用": {
77 "华为": "u",
78 "联盟": "u"
79 },
80 "Vue": {
81 "vue2": "y",
82 "vue3": "y"
83 }
84 }
85 }
86 }
87 }
1
2
3 > `重要通知:组件升级更新 2.0.0 后,支持日期+时间范围选择,组件 ui 将使用日历选择日期,ui 变化较大,同时支持 PC 和 移动端。此版本不向后兼容,不再支持单独的时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)。若仍需使用旧版本,可在插件市场下载*非uni_modules版本*,旧版本将不再维护`
4
5 ## DatetimePicker 时间选择器
6
7 > **组件名:uni-datetime-picker**
8 > 代码块: `uDatetimePicker`
9
10
11 该组件的优势是,支持**时间戳**输入和输出(起始时间、终止时间也支持时间戳),可**同时选择**日期和时间。
12
13 若只是需要单独选择日期和时间,不需要时间戳输入和输出,可使用原生的 picker 组件。
14
15 **_点击 picker 默认值规则:_**
16
17 - 若设置初始值 value, 会显示在 picker 显示框中
18 - 若无初始值 value,则初始值 value 为当前本地时间 Date.now(), 但不会显示在 picker 显示框中
19
20 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
21 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.1.5(2022-11-29)
2 - 优化 主题样式
3 ## 1.1.4(2022-10-27)
4 - 修复 props 中背景颜色无默认值的bug
5 ## 1.1.0(2022-06-30)
6
7 - 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
8 - 新增 clear 事件,点击右侧叉号图标触发
9 - 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
10 - 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
11
12 ## 1.0.5(2022-06-07)
13
14 - 优化 clearable 显示策略
15
16 ## 1.0.4(2022-06-07)
17
18 - 优化 clearable 显示策略
19
20 ## 1.0.3(2022-05-20)
21
22 - 修复 关闭图标某些情况下无法取消的 bug
23
24 ## 1.0.2(2022-04-12)
25
26 - 修复 默认值不生效的 bug
27
28 ## 1.0.1(2022-04-02)
29
30 - 修复 value 不能为 0 的 bug
31
32 ## 1.0.0(2021-11-19)
33
34 - 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
35 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
36
37 ## 0.1.4(2021-08-20)
38
39 - 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
40
41 ## 0.1.3(2021-08-11)
42
43 - 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
44
45 ## 0.1.2(2021-07-30)
46
47 - 优化 vue3 下事件警告的问题
48
49 ## 0.1.1
50
51 - 优化 errorMessage 属性支持 Boolean 类型
52
53 ## 0.1.0(2021-07-13)
54
55 - 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
56
57 ## 0.0.16(2021-06-29)
58
59 - 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
60
61 ## 0.0.15(2021-06-21)
62
63 - 修复 passwordIcon 属性拼写错误的 bug
64
65 ## 0.0.14(2021-06-18)
66
67 - 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
68 - 修复 confirmType 属性不生效的问题
69
70 ## 0.0.13(2021-06-04)
71
72 - 修复 disabled 状态可清出内容的 bug
73
74 ## 0.0.12(2021-05-12)
75
76 - 新增 组件示例地址
77
78 ## 0.0.11(2021-05-07)
79
80 - 修复 input-border 属性不生效的问题
81
82 ## 0.0.10(2021-04-30)
83
84 - 修复 ios 遮挡文字、显示一半的问题
85
86 ## 0.0.9(2021-02-05)
87
88 - 调整为 uni_modules 目录规范
89 - 优化 兼容 nvue 页面
1 /**
2 * @desc 函数防抖
3 * @param func 目标函数
4 * @param wait 延迟执行毫秒数
5 * @param immediate true - 立即执行, false - 延迟执行
6 */
7 export const debounce = function(func, wait = 1000, immediate = true) {
8 let timer;
9 console.log(1);
10 return function() {
11 console.log(123);
12 let context = this,
13 args = arguments;
14 if (timer) clearTimeout(timer);
15 if (immediate) {
16 let callNow = !timer;
17 timer = setTimeout(() => {
18 timer = null;
19 }, wait);
20 if (callNow) func.apply(context, args);
21 } else {
22 timer = setTimeout(() => {
23 func.apply(context, args);
24 }, wait)
25 }
26 }
27 }
28 /**
29 * @desc 函数节流
30 * @param func 函数
31 * @param wait 延迟执行毫秒数
32 * @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发
33 */
34 export const throttle = (func, wait = 1000, type = 1) => {
35 let previous = 0;
36 let timeout;
37 return function() {
38 let context = this;
39 let args = arguments;
40 if (type === 1) {
41 let now = Date.now();
42
43 if (now - previous > wait) {
44 func.apply(context, args);
45 previous = now;
46 }
47 } else if (type === 2) {
48 if (!timeout) {
49 timeout = setTimeout(() => {
50 timeout = null;
51 func.apply(context, args)
52 }, wait)
53 }
54 }
55 }
56 }
1 {
2 "id": "uni-easyinput",
3 "displayName": "uni-easyinput 增强输入框",
4 "version": "1.1.5",
5 "description": "Easyinput 组件是对原生input组件的增强",
6 "keywords": [
7 "uni-ui",
8 "uniui",
9 "input",
10 "uni-easyinput",
11 "输入框"
12 ],
13 "repository": "https://github.com/dcloudio/uni-ui",
14 "engines": {
15 "HBuilderX": ""
16 },
17 "directories": {
18 "example": "../../temps/example_temps"
19 },
20 "dcloudext": {
21 "sale": {
22 "regular": {
23 "price": "0.00"
24 },
25 "sourcecode": {
26 "price": "0.00"
27 }
28 },
29 "contact": {
30 "qq": ""
31 },
32 "declaration": {
33 "ads": "无",
34 "data": "无",
35 "permissions": "无"
36 },
37 "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
38 "type": "component-vue"
39 },
40 "uni_modules": {
41 "dependencies": [
42 "uni-scss",
43 "uni-icons"
44 ],
45 "encrypt": [],
46 "platforms": {
47 "cloud": {
48 "tcb": "y",
49 "aliyun": "y"
50 },
51 "client": {
52 "App": {
53 "app-vue": "y",
54 "app-nvue": "y"
55 },
56 "H5-mobile": {
57 "Safari": "y",
58 "Android Browser": "y",
59 "微信浏览器(Android)": "y",
60 "QQ浏览器(Android)": "y"
61 },
62 "H5-pc": {
63 "Chrome": "y",
64 "IE": "y",
65 "Edge": "y",
66 "Firefox": "y",
67 "Safari": "y"
68 },
69 "小程序": {
70 "微信": "y",
71 "阿里": "y",
72 "百度": "y",
73 "字节跳动": "y",
74 "QQ": "y"
75 },
76 "快应用": {
77 "华为": "u",
78 "联盟": "u"
79 },
80 "Vue": {
81 "vue2": "y",
82 "vue3": "y"
83 }
84 }
85 }
86 }
87 }
...\ No newline at end of file ...\ No newline at end of file
1
2
3 ### Easyinput 增强输入框
4 > **组件名:uni-easyinput**
5 > 代码块: `uEasyinput`
6
7
8 easyinput 组件是对原生input组件的增强 ,是专门为配合表单组件[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)而设计的,easyinput 内置了边框,图标等,同时包含 input 所有功能
9
10 ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
11 #### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...\ No newline at end of file ...\ No newline at end of file
1 ## 1.0.3(2022-12-21)
2 - 新增 sourceType 属性, 可以自定义图片和视频选择的来源
3 ## 1.0.2(2022-07-04)
4 - 修复 在uni-forms下样式不生效的bug
5 ## 1.0.1(2021-11-23)
6 - 修复 参数为对象的情况下,url在某些情况显示错误的bug
7 ## 1.0.0(2021-11-19)
8 - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
9 - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-file-picker](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
10 ## 0.2.16(2021-11-08)
11 - 修复 传入空对象 ,显示错误的Bug
12 ## 0.2.15(2021-08-30)
13 - 修复 return-type="object" 时且存在v-model时,无法删除文件的Bug
14 ## 0.2.14(2021-08-23)
15 - 新增 参数中返回 fileID 字段
16 ## 0.2.13(2021-08-23)
17 - 修复 腾讯云传入fileID 不能回显的bug
18 - 修复 选择图片后,不能放大的问题
19 ## 0.2.12(2021-08-17)
20 - 修复 由于 0.2.11 版本引起的不能回显图片的Bug
21 ## 0.2.11(2021-08-16)
22 - 新增 clearFiles(index) 方法,可以手动删除指定文件
23 - 修复 v-model 值设为 null 报错的Bug
24 ## 0.2.10(2021-08-13)
25 - 修复 return-type="object" 时,无法删除文件的Bug
26 ## 0.2.9(2021-08-03)
27 - 修复 auto-upload 属性失效的Bug
28 ## 0.2.8(2021-07-31)
29 - 修复 fileExtname属性不指定值报错的Bug
30 ## 0.2.7(2021-07-31)
31 - 修复 在某种场景下图片不回显的Bug
32 ## 0.2.6(2021-07-30)
33 - 修复 return-type为object下,返回值不正确的Bug
34 ## 0.2.5(2021-07-30)
35 - 修复(重要) H5 平台下如果和uni-forms组件一同使用导致页面卡死的问题
36 ## 0.2.3(2021-07-28)
37 - 优化 调整示例代码
38 ## 0.2.2(2021-07-27)
39 - 修复 vue3 下赋值错误的Bug
40 - 优化 h5平台下上传文件导致页面卡死的问题
41 ## 0.2.0(2021-07-13)
42 - 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
43 ## 0.1.1(2021-07-02)
44 - 修复 sourceType 缺少默认值导致 ios 无法选择文件
45 ## 0.1.0(2021-06-30)
46 - 优化 解耦与uniCloud的强绑定关系 ,如不绑定服务空间,默认autoUpload为false且不可更改
47 ## 0.0.11(2021-06-30)
48 - 修复 由 0.0.10 版本引发的 returnType 属性失效的问题
49 ## 0.0.10(2021-06-29)
50 - 优化 文件上传后进度条消失时机
51 ## 0.0.9(2021-06-29)
52 - 修复 在uni-forms 中,删除文件 ,获取的值不对的Bug
53 ## 0.0.8(2021-06-15)
54 - 修复 删除文件时无法触发 v-model 的Bug
55 ## 0.0.7(2021-05-12)
56 - 新增 组件示例地址
57 ## 0.0.6(2021-04-09)
58 - 修复 选择的文件非 file-extname 字段指定的扩展名报错的Bug
59 ## 0.0.5(2021-04-09)
60 - 优化 更新组件示例
61 ## 0.0.4(2021-04-09)
62 - 优化 file-extname 字段支持字符串写法,多个扩展名需要用逗号分隔
63 ## 0.0.3(2021-02-05)
64 - 调整为uni_modules目录规范
65 - 修复 微信小程序不指定 fileExtname 属性选择失败的Bug
1 'use strict';
2
3 const ERR_MSG_OK = 'chooseAndUploadFile:ok';
4 const ERR_MSG_FAIL = 'chooseAndUploadFile:fail';
5
6 function chooseImage(opts) {
7 const {
8 count,
9 sizeType = ['original', 'compressed'],
10 sourceType,
11 extension
12 } = opts
13 return new Promise((resolve, reject) => {
14 uni.chooseImage({
15 count,
16 sizeType,
17 sourceType,
18 extension,
19 success(res) {
20 resolve(normalizeChooseAndUploadFileRes(res, 'image'));
21 },
22 fail(res) {
23 reject({
24 errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
25 });
26 },
27 });
28 });
29 }
30
31 function chooseVideo(opts) {
32 const {
33 camera,
34 compressed,
35 maxDuration,
36 sourceType,
37 extension
38 } = opts;
39 return new Promise((resolve, reject) => {
40 uni.chooseVideo({
41 camera,
42 compressed,
43 maxDuration,
44 sourceType,
45 extension,
46 success(res) {
47 const {
48 tempFilePath,
49 duration,
50 size,
51 height,
52 width
53 } = res;
54 resolve(normalizeChooseAndUploadFileRes({
55 errMsg: 'chooseVideo:ok',
56 tempFilePaths: [tempFilePath],
57 tempFiles: [
58 {
59 name: (res.tempFile && res.tempFile.name) || '',
60 path: tempFilePath,
61 size,
62 type: (res.tempFile && res.tempFile.type) || '',
63 width,
64 height,
65 duration,
66 fileType: 'video',
67 cloudPath: '',
68 }, ],
69 }, 'video'));
70 },
71 fail(res) {
72 reject({
73 errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL),
74 });
75 },
76 });
77 });
78 }
79
80 function chooseAll(opts) {
81 const {
82 count,
83 extension
84 } = opts;
85 return new Promise((resolve, reject) => {
86 let chooseFile = uni.chooseFile;
87 if (typeof wx !== 'undefined' &&
88 typeof wx.chooseMessageFile === 'function') {
89 chooseFile = wx.chooseMessageFile;
90 }
91 if (typeof chooseFile !== 'function') {
92 return reject({
93 errMsg: ERR_MSG_FAIL + ' 请指定 type 类型,该平台仅支持选择 image 或 video。',
94 });
95 }
96 chooseFile({
97 type: 'all',
98 count,
99 extension,
100 success(res) {
101 resolve(normalizeChooseAndUploadFileRes(res));
102 },
103 fail(res) {
104 reject({
105 errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL),
106 });
107 },
108 });
109 });
110 }
111
112 function normalizeChooseAndUploadFileRes(res, fileType) {
113 res.tempFiles.forEach((item, index) => {
114 if (!item.name) {
115 item.name = item.path.substring(item.path.lastIndexOf('/') + 1);
116 }
117 if (fileType) {
118 item.fileType = fileType;
119 }
120 item.cloudPath =
121 Date.now() + '_' + index + item.name.substring(item.name.lastIndexOf('.'));
122 });
123 if (!res.tempFilePaths) {
124 res.tempFilePaths = res.tempFiles.map((file) => file.path);
125 }
126 return res;
127 }
128
129 function uploadCloudFiles(files, max = 5, onUploadProgress) {
130 files = JSON.parse(JSON.stringify(files))
131 const len = files.length
132 let count = 0
133 let self = this
134 return new Promise(resolve => {
135 while (count < max) {
136 next()
137 }
138
139 function next() {
140 let cur = count++
141 if (cur >= len) {
142 !files.find(item => !item.url && !item.errMsg) && resolve(files)
143 return
144 }
145 const fileItem = files[cur]
146 const index = self.files.findIndex(v => v.uuid === fileItem.uuid)
147 fileItem.url = ''
148 delete fileItem.errMsg
149
150 uniCloud
151 .uploadFile({
152 filePath: fileItem.path,
153 cloudPath: fileItem.cloudPath,
154 fileType: fileItem.fileType,
155 onUploadProgress: res => {
156 res.index = index
157 onUploadProgress && onUploadProgress(res)
158 }
159 })
160 .then(res => {
161 fileItem.url = res.fileID
162 fileItem.index = index
163 if (cur < len) {
164 next()
165 }
166 })
167 .catch(res => {
168 fileItem.errMsg = res.errMsg || res.message
169 fileItem.index = index
170 if (cur < len) {
171 next()
172 }
173 })
174 }
175 })
176 }
177
178
179
180
181
182 function uploadFiles(choosePromise, {
183 onChooseFile,
184 onUploadProgress
185 }) {
186 return choosePromise
187 .then((res) => {
188 if (onChooseFile) {
189 const customChooseRes = onChooseFile(res);
190 if (typeof customChooseRes !== 'undefined') {
191 return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === 'undefined' ?
192 res : chooseRes);
193 }
194 }
195 return res;
196 })
197 .then((res) => {
198 if (res === false) {
199 return {
200 errMsg: ERR_MSG_OK,
201 tempFilePaths: [],
202 tempFiles: [],
203 };
204 }
205 return res
206 })
207 }
208
209 function chooseAndUploadFile(opts = {
210 type: 'all'
211 }) {
212 if (opts.type === 'image') {
213 return uploadFiles(chooseImage(opts), opts);
214 }
215 else if (opts.type === 'video') {
216 return uploadFiles(chooseVideo(opts), opts);
217 }
218 return uploadFiles(chooseAll(opts), opts);
219 }
220
221 export {
222 chooseAndUploadFile,
223 uploadCloudFiles
224 };
1 <template>
2 <view class="uni-file-picker__files">
3 <view v-if="!readonly" class="files-button" @click="choose">
4 <slot></slot>
5 </view>
6 <!-- :class="{'is-text-box':showType === 'list'}" -->
7 <view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
8 <!-- ,'is-list-card':showType === 'list-card' -->
9
10 <view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
11 'files-border':index !== 0 && styles.dividline}"
12 :style="index !== 0 && styles.dividline &&borderLineStyle">
13 <view class="uni-file-picker__item">
14 <!-- :class="{'is-text-image':showType === 'list'}" -->
15 <!-- <view class="files__image is-text-image">
16 <image class="header-image" :src="item.logo" mode="aspectFit"></image>
17 </view> -->
18 <view class="files__name">{{item.name}}</view>
19 <view v-if="delIcon&&!readonly" class="icon-del-box icon-files" @click="delFile(index)">
20 <view class="icon-del icon-files"></view>
21 <view class="icon-del rotate"></view>
22 </view>
23 </view>
24 <view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
25 <progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
26 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
27 </view>
28 <view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
29 点击重试
30 </view>
31 </view>
32
33 </view>
34 </view>
35 </template>
36
37 <script>
38 export default {
39 name: "uploadFile",
40 emits:['uploadFiles','choose','delFile'],
41 props: {
42 filesList: {
43 type: Array,
44 default () {
45 return []
46 }
47 },
48 delIcon: {
49 type: Boolean,
50 default: true
51 },
52 limit: {
53 type: [Number, String],
54 default: 9
55 },
56 showType: {
57 type: String,
58 default: ''
59 },
60 listStyles: {
61 type: Object,
62 default () {
63 return {
64 // 是否显示边框
65 border: true,
66 // 是否显示分隔线
67 dividline: true,
68 // 线条样式
69 borderStyle: {}
70 }
71 }
72 },
73 readonly:{
74 type:Boolean,
75 default:false
76 }
77 },
78 computed: {
79 list() {
80 let files = []
81 this.filesList.forEach(v => {
82 files.push(v)
83 })
84 return files
85 },
86 styles() {
87 let styles = {
88 border: true,
89 dividline: true,
90 'border-style': {}
91 }
92 return Object.assign(styles, this.listStyles)
93 },
94 borderStyle() {
95 let {
96 borderStyle,
97 border
98 } = this.styles
99 let obj = {}
100 if (!border) {
101 obj.border = 'none'
102 } else {
103 let width = (borderStyle && borderStyle.width) || 1
104 width = this.value2px(width)
105 let radius = (borderStyle && borderStyle.radius) || 5
106 radius = this.value2px(radius)
107 obj = {
108 'border-width': width,
109 'border-style': (borderStyle && borderStyle.style) || 'solid',
110 'border-color': (borderStyle && borderStyle.color) || '#eee',
111 'border-radius': radius
112 }
113 }
114 let classles = ''
115 for (let i in obj) {
116 classles += `${i}:${obj[i]};`
117 }
118 return classles
119 },
120 borderLineStyle() {
121 let obj = {}
122 let {
123 borderStyle
124 } = this.styles
125 if (borderStyle && borderStyle.color) {
126 obj['border-color'] = borderStyle.color
127 }
128 if (borderStyle && borderStyle.width) {
129 let width = borderStyle && borderStyle.width || 1
130 let style = borderStyle && borderStyle.style || 0
131 if (typeof width === 'number') {
132 width += 'px'
133 } else {
134 width = width.indexOf('px') ? width : width + 'px'
135 }
136 obj['border-width'] = width
137
138 if (typeof style === 'number') {
139 style += 'px'
140 } else {
141 style = style.indexOf('px') ? style : style + 'px'
142 }
143 obj['border-top-style'] = style
144 }
145 let classles = ''
146 for (let i in obj) {
147 classles += `${i}:${obj[i]};`
148 }
149 return classles
150 }
151 },
152
153 methods: {
154 uploadFiles(item, index) {
155 this.$emit("uploadFiles", {
156 item,
157 index
158 })
159 },
160 choose() {
161 this.$emit("choose")
162 },
163 delFile(index) {
164 this.$emit('delFile', index)
165 },
166 value2px(value) {
167 if (typeof value === 'number') {
168 value += 'px'
169 } else {
170 value = value.indexOf('px') !== -1 ? value : value + 'px'
171 }
172 return value
173 }
174 }
175 }
176 </script>
177
178 <style lang="scss">
179 .uni-file-picker__files {
180 /* #ifndef APP-NVUE */
181 display: flex;
182 /* #endif */
183 flex-direction: column;
184 justify-content: flex-start;
185 }
186
187 .files-button {
188 // border: 1px red solid;
189 }
190
191 .uni-file-picker__lists {
192 position: relative;
193 margin-top: 5px;
194 overflow: hidden;
195 }
196
197 .file-picker__mask {
198 /* #ifndef APP-NVUE */
199 display: flex;
200 /* #endif */
201 justify-content: center;
202 align-items: center;
203 position: absolute;
204 right: 0;
205 top: 0;
206 bottom: 0;
207 left: 0;
208 color: #fff;
209 font-size: 14px;
210 background-color: rgba(0, 0, 0, 0.4);
211 }
212
213 .uni-file-picker__lists-box {
214 position: relative;
215 }
216
217 .uni-file-picker__item {
218 /* #ifndef APP-NVUE */
219 display: flex;
220 /* #endif */
221 align-items: center;
222 padding: 8px 10px;
223 padding-right: 5px;
224 padding-left: 10px;
225 }
226
227 .files-border {
228 border-top: 1px #eee solid;
229 }
230
231 .files__name {
232 flex: 1;
233 font-size: 14px;
234 color: #666;
235 margin-right: 25px;
236 /* #ifndef APP-NVUE */
237 word-break: break-all;
238 word-wrap: break-word;
239 /* #endif */
240 }
241
242 .icon-files {
243 /* #ifndef APP-NVUE */
244 position: static;
245 background-color: initial;
246 /* #endif */
247 }
248
249 // .icon-files .icon-del {
250 // background-color: #333;
251 // width: 12px;
252 // height: 1px;
253 // }
254
255
256 .is-list-card {
257 border: 1px #eee solid;
258 margin-bottom: 5px;
259 border-radius: 5px;
260 box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1);
261 padding: 5px;
262 }
263
264 .files__image {
265 width: 40px;
266 height: 40px;
267 margin-right: 10px;
268 }
269
270 .header-image {
271 width: 100%;
272 height: 100%;
273 }
274
275 .is-text-box {
276 border: 1px #eee solid;
277 border-radius: 5px;
278 }
279
280 .is-text-image {
281 width: 25px;
282 height: 25px;
283 margin-left: 5px;
284 }
285
286 .rotate {
287 position: absolute;
288 transform: rotate(90deg);
289 }
290
291 .icon-del-box {
292 /* #ifndef APP-NVUE */
293 display: flex;
294 margin: auto 0;
295 /* #endif */
296 align-items: center;
297 justify-content: center;
298 position: absolute;
299 top: 0px;
300 bottom: 0;
301 right: 5px;
302 height: 26px;
303 width: 26px;
304 // border-radius: 50%;
305 // background-color: rgba(0, 0, 0, 0.5);
306 z-index: 2;
307 transform: rotate(-45deg);
308 }
309
310 .icon-del {
311 width: 15px;
312 height: 1px;
313 background-color: #333;
314 // border-radius: 1px;
315 }
316
317 /* #ifdef H5 */
318 @media all and (min-width: 768px) {
319 .uni-file-picker__files {
320 max-width: 375px;
321 }
322 }
323
324 /* #endif */
325 </style>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!