升级uni-ui到最新版本1.4.27

This commit is contained in:
RuoYi 2023-07-12 09:42:10 +08:00
parent 296b15acbe
commit c27a8aa129
70 changed files with 1900 additions and 1578 deletions

View File

@ -1,3 +1,5 @@
## 1.2.22023-01-28
- 修复 运行/打包 控制台警告问题
## 1.2.12022-09-05 ## 1.2.12022-09-05
- 修复 当 text 超过 max-num 时badge 的宽度计算是根据 text 的长度计算,更改为 css 计算实际展示宽度,详见:[https://ask.dcloud.net.cn/question/150473](https://ask.dcloud.net.cn/question/150473) - 修复 当 text 超过 max-num 时badge 的宽度计算是根据 text 的长度计算,更改为 css 计算实际展示宽度,详见:[https://ask.dcloud.net.cn/question/150473](https://ask.dcloud.net.cn/question/150473)
## 1.2.02021-11-19 ## 1.2.02021-11-19

View File

@ -192,11 +192,12 @@
display: flex; display: flex;
overflow: hidden; overflow: hidden;
box-sizing: border-box; box-sizing: border-box;
font-feature-settings: "tnum";
min-width: 20px;
/* #endif */ /* #endif */
justify-content: center; justify-content: center;
flex-direction: row; flex-direction: row;
height: 20px; height: 20px;
min-width: 20px;
padding: 0 4px; padding: 0 4px;
line-height: 18px; line-height: 18px;
color: #fff; color: #fff;
@ -206,7 +207,6 @@
border: 1px solid #fff; border: 1px solid #fff;
text-align: center; text-align: center;
font-family: 'Helvetica Neue', Helvetica, sans-serif; font-family: 'Helvetica Neue', Helvetica, sans-serif;
font-feature-settings: "tnum";
font-size: $bage-size; font-size: $bage-size;
/* #ifdef H5 */ /* #ifdef H5 */
z-index: 999; z-index: 999;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-badge", "id": "uni-badge",
"displayName": "uni-badge 数字角标", "displayName": "uni-badge 数字角标",
"version": "1.2.1", "version": "1.2.2",
"description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。", "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
"keywords": [ "keywords": [
"", "",

View File

@ -1,5 +1,5 @@
## 0.1.22022-06-08 ## 0.1.22022-06-08
- 修复 微信小程序 separator 不显示问题 - 修复 微信小程序 separator 不显示的Bug
## 0.1.12022-06-02 ## 0.1.12022-06-02
- 新增 支持 uni.scss 修改颜色 - 新增 支持 uni.scss 修改颜色
## 0.1.02022-04-21 ## 0.1.02022-04-21

View File

@ -1,17 +1,23 @@
## 1.4.102023-04-10
- 修复 某些情况 monthSwitch 未触发的Bug
## 1.4.92023-02-02
- 修复 某些情况切换月份错误的Bug
## 1.4.82023-01-30
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/161964)
## 1.4.72022-09-16 ## 1.4.72022-09-16
- 可以使用 uni-scss 控制主题色 - 优化 支持使用 uni-scss 控制主题色
## 1.4.62022-09-08 ## 1.4.62022-09-08
- fix: 表头年月切换导致改变当前日期为选择月1号且未触发change事件 - 修复 表头年月切换导致改变当前日期为选择月1号且未触发change事件的Bug
## 1.4.52022-02-25 ## 1.4.52022-02-25
- 修复 条件编译 nvue 不支持的 css 样式 - 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.42022-02-25 ## 1.4.42022-02-25
- 修复 条件编译 nvue 不支持的 css 样式 - 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.32021-09-22 ## 1.4.32021-09-22
- 修复 startDate、 endDate 属性失效的 bug - 修复 startDate、 endDate 属性失效的Bug
## 1.4.22021-08-24 ## 1.4.22021-08-24
- 新增 支持国际化 - 新增 支持国际化
## 1.4.12021-08-05 ## 1.4.12021-08-05
- 修复 弹出层被 tabbar 遮盖 bug - 修复 弹出层被 tabbar 遮盖的Bug
## 1.4.02021-07-30 ## 1.4.02021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) - 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.3.162021-05-12 ## 1.3.162021-05-12

View File

@ -51,11 +51,10 @@
</template> </template>
<script> <script>
import { import { initVueI18n } from '@dcloudio/uni-i18n'
initVueI18n import i18nMessages from './i18n/index.js'
} from '@dcloudio/uni-i18n' const { t } = initVueI18n(i18nMessages)
import messages from './i18n/index.js'
const { t } = initVueI18n(messages)
export default { export default {
emits:['change'], emits:['change'],
props: { props: {

View File

@ -20,7 +20,7 @@
<view class="uni-calendar__header-btn-box" @click.stop="next"> <view class="uni-calendar__header-btn-box" @click.stop="next">
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<text class="uni-calendar__backtoday" @click="backtoday">{{todayText}}</text> <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text>
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
@ -62,12 +62,12 @@
<script> <script>
import Calendar from './util.js'; import Calendar from './util.js';
import calendarItem from './uni-calendar-item.vue' import CalendarItem from './uni-calendar-item.vue'
import {
initVueI18n import { initVueI18n } from '@dcloudio/uni-i18n'
} from '@dcloudio/uni-i18n' import i18nMessages from './i18n/index.js'
import messages from './i18n/index.js' const { t } = initVueI18n(i18nMessages)
const { t } = initVueI18n(messages)
/** /**
* Calendar 日历 * Calendar 日历
* @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等 * @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等
@ -90,7 +90,7 @@
*/ */
export default { export default {
components: { components: {
calendarItem CalendarItem
}, },
emits:['close','confirm','change','monthSwitch'], emits:['close','confirm','change','monthSwitch'],
props: { props: {
@ -199,26 +199,26 @@
} }
}, },
created() { created() {
//
this.cale = new Calendar({ this.cale = new Calendar({
// date: new Date(),
selected: this.selected, selected: this.selected,
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
range: this.range, range: this.range,
}) })
//
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
// this.setDay
}, },
methods: { methods: {
// 穿 // 穿
clean() {}, clean() {},
bindDateChange(e) { bindDateChange(e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
console.log(this.cale.getDate(value));
this.setDate(value) this.setDate(value)
const { year,month } = this.cale.getDate(value)
this.$emit('monthSwitch', {
year,
month
})
}, },
/** /**
* 初始化日期显示 * 初始化日期显示
@ -323,11 +323,16 @@
/** /**
* 回到今天 * 回到今天
*/ */
backtoday() { backToday() {
console.log(this.cale.getDate(new Date()).fullDate); const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
let date = this.cale.getDate(new Date()).fullDate const date = this.cale.getDate(new Date())
// this.cale.setDate(date) const todayYearMonth = `${date.year}-${date.month}`
this.init(date)
if(nowYearMonth !== todayYearMonth) {
this.monthSwitch()
}
this.init(date.fullDate)
this.change() this.change()
}, },
/** /**
@ -446,7 +451,6 @@
.uni-calendar--fixed-width { .uni-calendar--fixed-width {
width: 50px; width: 50px;
// padding: 0 15px;
} }
.uni-calendar__backtoday { .uni-calendar__backtoday {

View File

@ -76,10 +76,20 @@ class Calendar {
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期 dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
break break
case 'month': case 'month':
if (dd.getDate() === 31) { if (dd.getDate() === 31 && AddDayCount>0) {
dd.setDate(dd.getDate() + AddDayCount) dd.setDate(dd.getDate() + AddDayCount)
} else { } else {
dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期 const preMonth = dd.getMonth()
dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
const nextMonth = dd.getMonth()
// 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
}
// 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
}
} }
break break
case 'year': case 'year':

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-calendar", "id": "uni-calendar",
"displayName": "uni-calendar 日历", "displayName": "uni-calendar 日历",
"version": "1.4.7", "version": "1.4.10",
"description": "日历组件", "description": "日历组件",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -77,7 +77,7 @@ export default {
### Calendar Props ### Calendar Props
| 属性名 | 类型 | 默认值| 说明 | | 属性名 | 类型 | 默认值| 说明 |
| | | | - | - | - | - |
| date | String |- | 自定义当前时间,默认为今天 | | date | String |- | 自定义当前时间,默认为今天 |
| lunar | Boolean | false | 显示农历 | | lunar | Boolean | false | 显示农历 |
| startDate | String |- | 日期选择范围-开始日期 | | startDate | String |- | 日期选择范围-开始日期 |
@ -91,7 +91,7 @@ export default {
### Calendar Events ### Calendar Events
| 事件名 | 说明 |返回值| | 事件名 | 说明 |返回值|
| | | | | - | - | - |
| open | 弹出日历组件,`insert :false` 时生效|- | | open | 弹出日历组件,`insert :false` 时生效|- |

View File

@ -21,7 +21,9 @@
</view> </view>
</view> </view>
<view class="uni-card__header-extra" @click="onClick('extra')"> <view class="uni-card__header-extra" @click="onClick('extra')">
<slot name="extra">
<text class="uni-card__header-extra-text">{{ extra }}</text> <text class="uni-card__header-extra-text">{{ extra }}</text>
</slot>
</view> </view>
</view> </view>
</slot> </slot>

View File

@ -5,23 +5,23 @@
</view> </view>
<view class="uni-combox__input-box"> <view class="uni-combox__input-box">
<input class="uni-combox__input" type="text" :placeholder="placeholder" <input class="uni-combox__input" type="text" :placeholder="placeholder"
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
@blur="onBlur" />
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector"> <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
</uni-icons> </uni-icons>
</view> </view>
<view class="uni-combox__selector" v-if="showSelector"> <view class="uni-combox__selector" v-if="showSelector">
<view class="uni-popper__arrow"></view> <view class="uni-popper__arrow"></view>
<scroll-view scroll-y="true" class="uni-combox__selector-scroll"> <scroll-view scroll-y="true" class="uni-combox__selector-scroll" @scroll="onScroll">
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0"> <view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
<text>{{emptyTips}}</text> <text>{{emptyTips}}</text>
</view> </view>
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" <view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" @click="onSelectorClick(index)">
@click="onSelectorClick(index)">
<text>{{item}}</text> <text>{{item}}</text>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 新增蒙层点击蒙层时关闭选项显示 -->
<view class="uni-combox__mask" v-show="showSelector" @click="showSelector = false"></view>
</view> </view>
</template> </template>
@ -83,7 +83,8 @@
data() { data() {
return { return {
showSelector: false, showSelector: false,
inputVal: '' inputVal: '',
blurTimer:null,
} }
}, },
computed: { computed: {
@ -94,6 +95,9 @@
return `width: ${this.labelWidth}` return `width: ${this.labelWidth}`
}, },
filterCandidates() { filterCandidates() {
if (this.inputVal !== 0 && !this.inputVal) {
return this.candidates
}
return this.candidates.filter((item) => { return this.candidates.filter((item) => {
return item.toString().indexOf(this.inputVal) > -1 return item.toString().indexOf(this.inputVal) > -1
}) })
@ -128,10 +132,16 @@
this.showSelector = true this.showSelector = true
}, },
onBlur() { onBlur() {
setTimeout(() => { this.blurTimer = setTimeout(() => {
this.showSelector = false this.showSelector = false
}, 153) }, 153)
}, },
onScroll(){ // blur
if(this.blurTimer) {
clearTimeout(this.blurTimer)
this.blurTimer = null
}
},
onSelectorClick(index) { onSelectorClick(index) {
this.inputVal = this.filterCandidates[index] this.inputVal = this.filterCandidates[index]
this.showSelector = false this.showSelector = false
@ -205,7 +215,7 @@
border: 1px solid #EBEEF5; border: 1px solid #EBEEF5;
border-radius: 6px; border-radius: 6px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 2; z-index: 3;
padding: 4px 0; padding: 4px 0;
} }
@ -272,4 +282,13 @@
.uni-combox__no-border { .uni-combox__no-border {
border: none; border: none;
} }
.uni-combox__mask {
width:100%;
height:100%;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
</style> </style>

View File

@ -86,6 +86,10 @@
timestamp: { timestamp: {
type: Number, type: Number,
default: 0 default: 0
},
zeroPad: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@ -199,18 +203,10 @@
} else { } else {
this.timeUp() this.timeUp()
} }
if (day < 10) { day = (day < 10 && this.zeroPad) ? `0${day}` : day
day = '0' + day hour = (hour < 10 && this.zeroPad) ? `0${hour}` : hour
} minute = (minute < 10 && this.zeroPad) ? `0${minute}` : minute
if (hour < 10) { second = (second < 10 && this.zeroPad) ? `0${second}` : second
hour = '0' + hour
}
if (minute < 10) {
minute = '0' + minute
}
if (second < 10) {
second = '0' + second
}
this.d = day this.d = day
this.h = hour this.h = hour
this.i = minute this.i = minute

View File

@ -1,3 +1,12 @@
## 1.1.22023-04-11
- 修复 更改 modelValue 报错的 bug
- 修复 v-for 未使用 key 值控制台 warning
## 1.1.12023-02-21
- 修复代码合并时引发 value 属性为空时不渲染数据的问题
## 1.1.02023-02-15
- 修复 localdata 不支持动态更新的bug
## 1.0.92023-02-15
- 修复 localdata 不支持动态更新的bug
## 1.0.82022-09-16 ## 1.0.82022-09-16
- 可以使用 uni-scss 控制主题色 - 可以使用 uni-scss 控制主题色
## 1.0.72022-07-06 ## 1.0.72022-07-06

View File

@ -75,7 +75,7 @@
*/ */
export default { export default {
name: 'UniDataPicker', name: 'UniDataPicker',
emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue'], emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue','inputclick'],
mixins: [dataPicker], mixins: [dataPicker],
components: { components: {
DataPickerView DataPickerView
@ -131,9 +131,16 @@
this.load(); this.load();
}) })
}, },
watch: {
localdata: {
handler() {
this.load()
},
deep: true
},
},
methods: { methods: {
clear() { clear() {
this.modelValue = null;
this._dispatchEvent([]); this._dispatchEvent([]);
}, },
onPropsChange() { onPropsChange() {
@ -148,10 +155,6 @@
return; return;
} }
if (!this.hasValue) {
return;
}
// //
if (this.isLocalData) { if (this.isLocalData) {
this.loadData(); this.loadData();
@ -184,6 +187,7 @@
}, },
handleInput() { handleInput() {
if (this.readonly) { if (this.readonly) {
this.$emit('inputclick')
return return
} }
this.show() this.show()

View File

@ -2,25 +2,27 @@
<view class="uni-data-pickerview"> <view class="uni-data-pickerview">
<scroll-view v-if="!isCloudDataList" class="selected-area" scroll-x="true"> <scroll-view v-if="!isCloudDataList" class="selected-area" scroll-x="true">
<view class="selected-list"> <view class="selected-list">
<template v-for="(item,index) in selected"> <view
<view class="selected-item" class="selected-item"
:class="{'selected-item-active':index==selectedIndex}" v-for="(item,index) in selected"
v-if="item.text" @click="handleSelect(index)"> :key="index"
<text>{{item.text}}</text> :class="{
'selected-item-active':index == selectedIndex
}"
@click="handleSelect(index)"
>
<text>{{item.text || ''}}</text>
</view> </view>
</template>
</view> </view>
</scroll-view> </scroll-view>
<view class="tab-c"> <view class="tab-c">
<template v-for="(child, i) in dataList"> <scroll-view class="list" :scroll-y="true">
<scroll-view class="list" :key="i" v-if="i==selectedIndex" :scroll-y="true"> <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in dataList[selectedIndex]" :key="j"
<view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child" @click="handleNodeClick(item, selectedIndex, j)">
@click="handleNodeClick(item, i, j)">
<text class="item-text">{{item[map.text]}}</text> <text class="item-text">{{item[map.text]}}</text>
<view class="check" v-if="selected.length > i && item[map.value] == selected[i].value"></view> <view class="check" v-if="selected.length > selectedIndex && item[map.value] == selected[selectedIndex].value"></view>
</view> </view>
</scroll-view> </scroll-view>
</template>
<view class="loading-cover" v-if="loading"> <view class="loading-cover" v-if="loading">
<uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more> <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-picker", "id": "uni-data-picker",
"displayName": "uni-data-picker 数据驱动的picker选择器", "displayName": "uni-data-picker 数据驱动的picker选择器",
"version": "1.0.8", "version": "1.1.2",
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景", "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,3 +1,16 @@
## 1.0.62023-04-12
- 修复 微信小程序点击时会改变背景颜色的 bug
## 1.0.52023-02-03
- 修复 禁用时会显示清空按钮
## 1.0.42023-02-02
- 优化 查询条件短期内多次变更只查询最后一次变更后的结果
- 调整 内部缓存键名调整为 uni-data-select-lastSelectedValue
## 1.0.32023-01-16
- 修复 不关联服务空间报错的问题
## 1.0.22023-01-14
- 新增 属性 `format` 可用于格式化显示选项内容
## 1.0.12022-12-06
- 修复 当where变化时数据不会自动更新的问题
## 0.1.92022-09-05 ## 0.1.92022-09-05
- 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框 - 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
## 0.1.82022-08-29 ## 0.1.82022-08-29

View File

@ -6,8 +6,12 @@
<view class="uni-select__input-box" @click="toggleSelector"> <view class="uni-select__input-box" @click="toggleSelector">
<view v-if="current" class="uni-select__input-text">{{current}}</view> <view v-if="current" class="uni-select__input-text">{{current}}</view>
<view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view> <view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view>
<uni-icons v-if="current && clear" type="clear" color="#c0c4cc" size="24" @click="clearVal" /> <view v-if="current && clear && !disabled" @click.stop="clearVal" >
<uni-icons v-else :type="showSelector? 'top' : 'bottom'" size="14" color="#999" /> <uni-icons type="clear" color="#c0c4cc" size="24"/>
</view>
<view v-else>
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" />
</view>
</view> </view>
<view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" /> <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
<view class="uni-select__selector" v-if="showSelector"> <view class="uni-select__selector" v-if="showSelector">
@ -16,10 +20,9 @@
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0"> <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
<text>{{emptyTips}}</text> <text>{{emptyTips}}</text>
</view> </view>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" <view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
:key="index" @click="change(item)"> @click="change(item)">
<text <text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
:class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -44,17 +47,8 @@
*/ */
export default { export default {
name: "uni-stat-select", name: "uni-data-select",
mixins: [uniCloud.mixinDatacom || {}], mixins: [uniCloud.mixinDatacom || {}],
data() {
return {
showSelector: false,
current: '',
mixinDatacomResData: [],
apps: [],
channels: []
};
},
props: { props: {
localdata: { localdata: {
type: Array, type: Array,
@ -93,12 +87,29 @@
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
} },
// field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
format: {
type: String,
default: ''
},
},
data() {
return {
showSelector: false,
current: '',
mixinDatacomResData: [],
apps: [],
channels: [],
cacheKey: "uni-data-select-lastSelectedValue",
};
}, },
created() { created() {
this.last = `${this.collection}_last_selected_option_value` this.debounceGet = this.debounce(() => {
this.query();
}, 300);
if (this.collection && !this.localdata.length) { if (this.collection && !this.localdata.length) {
this.mixinDatacomEasyGet() this.debounceGet();
} }
}, },
computed: { computed: {
@ -113,6 +124,14 @@
return placeholder ? return placeholder ?
common + placeholder : common + placeholder :
common common
},
valueCom(){
// #ifdef VUE3
return this.modelValue;
// #endif
// #ifndef VUE3
return this.value;
// #endif
} }
}, },
watch: { watch: {
@ -124,16 +143,9 @@
} }
} }
}, },
// #ifndef VUE3 valueCom(val, old) {
value() {
this.initDefVal() this.initDefVal()
}, },
// #endif
// #ifdef VUE3
modelValue() {
this.initDefVal()
},
// #endif
mixinDatacomResData: { mixinDatacomResData: {
immediate: true, immediate: true,
handler(val) { handler(val) {
@ -144,27 +156,46 @@
} }
}, },
methods: { methods: {
debounce(fn, time = 100){
let timer = null
return function(...args) {
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, args)
}, time)
}
},
//
query(){
this.mixinDatacomEasyGet();
},
//
onMixinDatacomPropsChange(){
if (this.collection) {
this.debounceGet();
}
},
initDefVal() { initDefVal() {
let defValue = '' let defValue = ''
if ((this.value || this.value === 0) && !this.isDisabled(this.value)) { if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
defValue = this.value defValue = this.valueCom
} else if ((this.modelValue || this.modelValue === 0) && !this.isDisabled(this.modelValue)) {
defValue = this.modelValue
} else { } else {
let strogeValue let strogeValue
if (this.collection) { if (this.collection) {
strogeValue = uni.getStorageSync(this.last) strogeValue = this.getCache()
} }
if (strogeValue || strogeValue === 0) { if (strogeValue || strogeValue === 0) {
defValue = strogeValue defValue = strogeValue
} else { } else {
let defItem = '' let defItem = ''
if (this.defItem > 0 && this.defItem < this.mixinDatacomResData.length) { if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value defItem = this.mixinDatacomResData[this.defItem - 1].value
} }
defValue = defItem defValue = defItem
} }
if (defValue || defValue === 0) {
this.emit(defValue) this.emit(defValue)
}
} }
const def = this.mixinDatacomResData.find(item => item.value === defValue) const def = this.mixinDatacomResData.find(item => item.value === defValue)
this.current = def ? this.formatItemName(def) : '' this.current = def ? this.formatItemName(def) : ''
@ -189,7 +220,7 @@
clearVal() { clearVal() {
this.emit('') this.emit('')
if (this.collection) { if (this.collection) {
uni.removeStorageSync(this.last) this.removeCache()
} }
}, },
change(item) { change(item) {
@ -200,14 +231,13 @@
} }
}, },
emit(val) { emit(val) {
this.$emit('change', val)
this.$emit('input', val) this.$emit('input', val)
this.$emit('update:modelValue', val) this.$emit('update:modelValue', val)
this.$emit('change', val)
if (this.collection) { if (this.collection) {
uni.setStorageSync(this.last, val) this.setCache(val);
} }
}, },
toggleSelector() { toggleSelector() {
if (this.disabled) { if (this.disabled) {
return return
@ -222,6 +252,16 @@
channel_code channel_code
} = item } = item
channel_code = channel_code ? `(${channel_code})` : '' channel_code = channel_code ? `(${channel_code})` : ''
if (this.format) {
//
let str = "";
str = this.format;
for (let key in item) {
str = str.replace(new RegExp(`{${key}}`,"g"),item[key]);
}
return str;
} else {
return this.collection.indexOf('app-list') > 0 ? return this.collection.indexOf('app-list') > 0 ?
`${text}(${value})` : `${text}(${value})` :
( (
@ -230,6 +270,32 @@
`未命名${channel_code}` `未命名${channel_code}`
) )
} }
},
//
getLoadData(){
return this.mixinDatacomResData;
},
// key
getCurrentCacheKey(){
return this.collection;
},
//
getCache(name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
return cacheData[name];
},
//
setCache(value, name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
cacheData[name] = value;
uni.setStorageSync(this.cacheKey, cacheData);
},
//
removeCache(name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
delete cacheData[name];
uni.setStorageSync(this.cacheKey, cacheData);
},
} }
} }
</script> </script>
@ -253,7 +319,9 @@
display: flex; display: flex;
align-items: center; align-items: center;
// padding: 15px; // padding: 15px;
/* #ifdef H5 */
cursor: pointer; cursor: pointer;
/* #endif */
width: 100%; width: 100%;
flex: 1; flex: 1;
box-sizing: border-box; box-sizing: border-box;
@ -357,6 +425,14 @@
/* #endif */ /* #endif */
} }
/* #ifdef H5 */
@media (min-width: 768px) {
.uni-select__selector-scroll {
max-height: 600px;
}
}
/* #endif */
.uni-select__selector-empty, .uni-select__selector-empty,
.uni-select__selector-item { .uni-select__selector-item {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -436,5 +512,6 @@
bottom: 0; bottom: 0;
right: 0; right: 0;
left: 0; left: 0;
z-index: 2;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-select", "id": "uni-data-select",
"displayName": "uni-data-select 下拉框选择器", "displayName": "uni-data-select 下拉框选择器",
"version": "0.1.9", "version": "1.0.6",
"description": "通过数据驱动的下拉框选择器", "description": "通过数据驱动的下拉框选择器",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,41 +1,71 @@
## 2.2.222023-03-30
- 修复 日历 picker 修改年月后自动选中当月1日 [详情](https://ask.dcloud.net.cn/question/165937)
- 修复 小程序端 低版本 ios NaN [详情](https://ask.dcloud.net.cn/question/162979)
## 2.2.212023-02-20
- 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362)
## 2.2.202023-02-17
- 优化 值为空依然选中当天问题
- 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间
- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
- 优化 字节小程序日期时间范围选择,底部日期换行问题
## 2.2.192023-02-09
- 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686)
## 2.2.182023-02-08
- 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684)
- 优化 PC端输入日期格式错误时返回当前日期时间
- 优化 PC端输入日期时间超出 start、end 限制的Bug
- 优化 移动端日期时间范围用法时间展示不完整问题
## 2.2.172023-02-04
- 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679)
- 修复 vue3 time-picker 无法显示绑定时分秒的Bug
## 2.2.162023-02-02
- 修复 字节小程序报错的Bug
## 2.2.152023-02-02
- 修复 某些情况切换月份错误的Bug
## 2.2.142023-01-30
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033)
## 2.2.132023-01-10
- 修复 多次加载组件造成内存占用的Bug
## 2.2.122022-12-01
- 修复 vue3 下 i18n 国际化初始值不正确的Bug
## 2.2.112022-09-19 ## 2.2.112022-09-19
- 修复,支付宝小程序样式错乱,[详情](https://github.com/dcloudio/uni-app/issues/3861) - 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861)
## 2.2.102022-09-19 ## 2.2.102022-09-19
- 修复,反向选择日期范围,日期显示异常,[详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false) - 修复 反向选择日期范围日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
## 2.2.92022-09-16 ## 2.2.92022-09-16
- 可以使用 uni-scss 控制主题色 - 可以使用 uni-scss 控制主题色
## 2.2.82022-09-08 ## 2.2.82022-09-08
- 修复 close事件无效的 bug - 修复 close事件无效的Bug
## 2.2.72022-09-05 ## 2.2.72022-09-05
- 修复 移动端 maskClick 无效的 bug详见:[https://ask.dcloud.net.cn/question/140824?item_id=209458&rf=false](https://ask.dcloud.net.cn/question/140824?item_id=209458&rf=false) - 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824)
## 2.2.62022-06-30 ## 2.2.62022-06-30
- 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致 - 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致
## 2.2.52022-06-24 ## 2.2.52022-06-24
- 修复 日历顶部年月及底部确认未国际化 bug - 修复 日历顶部年月及底部确认未国际化的Bug
## 2.2.42022-03-31 ## 2.2.42022-03-31
- 修复 Vue3 下动态赋值,单选类型未响应的 bug - 修复 Vue3 下动态赋值,单选类型未响应的Bug
## 2.2.32022-03-28 ## 2.2.32022-03-28
- 修复 Vue3 下动态赋值未响应的 bug - 修复 Vue3 下动态赋值未响应的Bug
## 2.2.22021-12-10 ## 2.2.22021-12-10
- 修复 clear-icon 属性在小程序平台不生效的 bug - 修复 clear-icon 属性在小程序平台不生效的Bug
## 2.2.12021-12-10 ## 2.2.12021-12-10
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的 bug - 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug
## 2.2.02021-11-19 ## 2.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 优化 组件UI并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) - 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
## 2.1.52021-11-09 ## 2.1.52021-11-09
- 新增 提供组件设计资源,组件样式调整 - 新增 提供组件设计资源,组件样式调整
## 2.1.42021-09-10 ## 2.1.42021-09-10
- 修复 hide-second 在移动端的 bug - 修复 hide-second 在移动端的Bug
- 修复 单选赋默认值时,赋值日期未高亮的 bug - 修复 单选赋默认值时,赋值日期未高亮的Bug
- 修复 赋默认值时,移动端未正确显示时间的 bug - 修复 赋默认值时,移动端未正确显示时间的Bug
## 2.1.32021-09-09 ## 2.1.32021-09-09
- 新增 hide-second 属性,支持只使用时分,隐藏秒 - 新增 hide-second 属性,支持只使用时分,隐藏秒
## 2.1.22021-09-03 ## 2.1.22021-09-03
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次 - 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法 - 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
- 优化 调整字号大小,美化日历界面 - 优化 调整字号大小,美化日历界面
- 修复 因国际化导致的 placeholder 失效的 bug - 修复 因国际化导致的 placeholder 失效的Bug
## 2.1.12021-08-24 ## 2.1.12021-08-24
- 新增 支持国际化 - 新增 支持国际化
- 优化 范围选择器在 pc 端过宽的问题 - 优化 范围选择器在 pc 端过宽的问题
@ -43,50 +73,50 @@
- 新增 适配 vue3 - 新增 适配 vue3
## 2.0.192021-08-09 ## 2.0.192021-08-09
- 新增 支持作为 uni-forms 子组件相关功能 - 新增 支持作为 uni-forms 子组件相关功能
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的 bug - 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug
## 2.0.182021-08-05 ## 2.0.182021-08-05
- 修复 type 属性动态赋值无效的 bug - 修复 type 属性动态赋值无效的Bug
- 修复 ‘确认’按钮被 tabbar 遮盖 bug - 修复 ‘确认’按钮被 tabbar 遮盖 bug
- 修复 组件未赋值时范围选左、右日历相同的 bug - 修复 组件未赋值时范围选左、右日历相同的Bug
## 2.0.172021-08-04 ## 2.0.172021-08-04
- 修复 范围选未正确显示当前值的 bug - 修复 范围选未正确显示当前值的Bug
- 修复 h5 平台(移动端)报错 'cale' of undefined 的 bug - 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug
## 2.0.162021-07-21 ## 2.0.162021-07-21
- 新增 return-type 属性支持返回 date 日期对象 - 新增 return-type 属性支持返回 date 日期对象
## 2.0.152021-07-14 ## 2.0.152021-07-14
- 修复 单选日期类型,初始赋值后不在当前日历的 bug - 修复 单选日期类型,初始赋值后不在当前日历的Bug
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效) - 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
- 优化 移动端移除显示框的清空按钮,无实际用途 - 优化 移动端移除显示框的清空按钮,无实际用途
## 2.0.142021-07-14 ## 2.0.142021-07-14
- 修复 组件赋值为空,界面未更新的 bug - 修复 组件赋值为空,界面未更新的Bug
- 修复 start 和 end 不能动态赋值的 bug - 修复 start 和 end 不能动态赋值的Bug
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的 bug - 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug
## 2.0.132021-07-08 ## 2.0.132021-07-08
- 修复 范围选择不能动态赋值的 bug - 修复 范围选择不能动态赋值的Bug
## 2.0.122021-07-08 ## 2.0.122021-07-08
- 修复 范围选择的初始时间在一个月内时造成无法选择的bug - 修复 范围选择的初始时间在一个月内时造成无法选择的bug
## 2.0.112021-07-08 ## 2.0.112021-07-08
- 优化 弹出层在超出视窗边缘定位不准确的问题 - 优化 弹出层在超出视窗边缘定位不准确的问题
## 2.0.102021-07-08 ## 2.0.102021-07-08
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的 bug - 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug
- 优化 弹出层在超出视窗边缘被遮盖的问题 - 优化 弹出层在超出视窗边缘被遮盖的问题
## 2.0.92021-07-07 ## 2.0.92021-07-07
- 新增 maskClick 事件 - 新增 maskClick 事件
- 修复 特殊情况日历 rpx 布局错误的 bugrpx -> px - 修复 特殊情况日历 rpx 布局错误的Bugrpx -> px
- 修复 范围选择时清空返回值不合理的bug['', ''] -> [] - 修复 范围选择时清空返回值不合理的bug['', ''] -> []
## 2.0.82021-07-07 ## 2.0.82021-07-07
- 新增 日期时间显示框支持插槽 - 新增 日期时间显示框支持插槽
## 2.0.72021-07-01 ## 2.0.72021-07-01
- 优化 添加 uni-icons 依赖 - 优化 添加 uni-icons 依赖
## 2.0.62021-05-22 ## 2.0.62021-05-22
- 修复 图标在小程序上不显示的 bug - 修复 图标在小程序上不显示的Bug
- 优化 重命名引用组件,避免潜在组件命名冲突 - 优化 重命名引用组件,避免潜在组件命名冲突
## 2.0.52021-05-20 ## 2.0.52021-05-20
- 优化 代码目录扁平化 - 优化 代码目录扁平化
## 2.0.42021-05-12 ## 2.0.42021-05-12
- 新增 组件示例地址 - 新增 组件示例地址
## 2.0.32021-05-10 ## 2.0.32021-05-10
- 修复 ios 下不识别 '-' 日期格式的 bug - 修复 ios 下不识别 '-' 日期格式的Bug
- 优化 pc 下弹出层添加边框和阴影 - 优化 pc 下弹出层添加边框和阴影
## 2.0.22021-05-08 ## 2.0.22021-05-08
- 修复 在 admin 中获取弹出层定位错误的bug - 修复 在 admin 中获取弹出层定位错误的bug
@ -97,7 +127,7 @@
> 注意此版本不向后兼容不再支持单独时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker > 注意此版本不向后兼容不再支持单独时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker
## 1.0.62021-03-18 ## 1.0.62021-03-18
- 新增 hide-second 属性,时间支持仅选择时、分 - 新增 hide-second 属性,时间支持仅选择时、分
- 修复 选择跟显示的日期不一样的 bug - 修复 选择跟显示的日期不一样的Bug
- 修复 chang事件触发2次的 bug - 修复 chang事件触发2次的Bug
- 修复 分、秒 end 范围错误的 bug - 修复 分、秒 end 范围错误的Bug
- 优化 更好的 nvue 适配 - 优化 更好的 nvue 适配

View File

@ -16,7 +16,7 @@
<text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text> <text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
<text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text> <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
</view> </view>
<view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view> <view :class="{'uni-calendar-item--today': weeks.isToday}"></view>
</view> </view>
</template> </template>
@ -41,10 +41,6 @@
return [] return []
} }
}, },
lunar: {
type: Boolean,
default: false
},
checkHover: { checkHover: {
type: Boolean, type: Boolean,
default: false default: false
@ -83,11 +79,6 @@
color: darken($color: $uni-primary, $amount: 40%); color: darken($color: $uni-primary, $amount: 40%);
} }
.uni-calendar-item__weeks-lunar-text {
font-size: 12px;
color: #333;
}
.uni-calendar-item__weeks-box-item { .uni-calendar-item__weeks-box-item {
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -116,7 +107,6 @@
} }
.uni-calendar-item__weeks-box .uni-calendar-item--disable { .uni-calendar-item__weeks-box .uni-calendar-item--disable {
// background-color: rgba(249, 249, 249, $uni-opacity-disabled);
cursor: default; cursor: default;
} }
@ -124,7 +114,7 @@
color: #D1D1D1; color: #D1D1D1;
} }
.uni-calendar-item--isDay { .uni-calendar-item--today {
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 17%; right: 17%;

View File

@ -1,31 +1,37 @@
<template> <template>
<view class="uni-calendar" @mouseleave="leaveCale"> <view class="uni-calendar" @mouseleave="leaveCale">
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" <view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
@click="clean();maskClick()"></view> @click="maskClick"></view>
<view v-if="insert || show" class="uni-calendar__content" <view v-if="insert || show" class="uni-calendar__content"
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}"> :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}"> <view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
<view v-if="left" class="uni-calendar__header-btn-box" @click.stop="pre">
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
<view class="uni-calendar__header-btn uni-calendar--left"></view> <view class="uni-calendar__header-btn uni-calendar--left"></view>
</view> </view>
<picker mode="date" :value="date" fields="month" @change="bindDateChange"> <picker mode="date" :value="date" fields="month" @change="bindDateChange">
<text <text
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text> class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
</picker> </picker>
<view v-if="right" class="uni-calendar__header-btn-box" @click.stop="next">
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<view v-if="!insert" class="dialog-close" @click="clean">
<view v-if="!insert" class="dialog-close" @click="close">
<view class="dialog-close-plus" data-id="close"></view> <view class="dialog-close-plus" data-id="close"></view>
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view> <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
</view> </view>
<!-- <text class="uni-calendar__backtoday" @click="backtoday">回到今天</text> -->
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
<view v-if="showMonth" class="uni-calendar__box-bg"> <view v-if="showMonth" class="uni-calendar__box-bg">
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text> <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view> </view>
<view class="uni-calendar__weeks" style="padding-bottom: 7px;"> <view class="uni-calendar__weeks" style="padding-bottom: 7px;">
<view class="uni-calendar__weeks-day"> <view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text> <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
@ -49,28 +55,30 @@
<text class="uni-calendar__weeks-day-text">{{SATText}}</text> <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view> </view>
</view> </view>
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex"> <view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex"> <view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate" :selected="selected" :checkHover="range" @change="choiceDate"
@handleMouse="handleMouse"> @handleMouse="handleMouse">
</calendar-item> </calendar-item>
</view> </view>
</view> </view>
</view> </view>
<view v-if="!insert && !range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"
<view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
style="padding: 0 80px;"> style="padding: 0 80px;">
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view> <view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
<time-picker type="time" :start="reactStartTime" :end="reactEndTime" v-model="time" <time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style"> :disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
<view v-if="!insert && range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"> <view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
<view class="uni-date-changed--time-start"> <view class="uni-date-changed--time-start">
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}} <view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
</view> </view>
<time-picker type="time" :start="reactStartTime" v-model="timeRange.startTime" :border="false" <time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style"> :hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
@ -79,15 +87,13 @@
</view> </view>
<view class="uni-date-changed--time-end"> <view class="uni-date-changed--time-end">
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view> <view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
<time-picker type="time" :end="reactEndTime" v-model="timeRange.endTime" :border="false" <time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style"> :hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
</view> </view>
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok"> <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
<!-- <view class="uni-calendar__header-btn-box">
<text class="uni-calendar__button-text uni-calendar--fixed-width">{{okText}}</text>
</view> -->
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view> <view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
</view> </view>
</view> </view>
@ -95,22 +101,19 @@
</template> </template>
<script> <script>
import Calendar from './util.js'; import { Calendar, getDate, getTime } from './util.js';
import calendarItem from './calendar-item.vue' import calendarItem from './calendar-item.vue'
import timePicker from './time-picker.vue' import timePicker from './time-picker.vue'
import {
initVueI18n import { initVueI18n } from '@dcloudio/uni-i18n'
} from '@dcloudio/uni-i18n' import i18nMessages from './i18n/index.js'
import messages from './i18n/index.js' const { t } = initVueI18n(i18nMessages)
const {
t
} = initVueI18n(messages)
/** /**
* Calendar 日历 * Calendar 日历
* @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等 * @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56 * @tutorial https://ext.dcloud.net.cn/plugin?id=56
* @property {String} date 自定义当前时间默认为今天 * @property {String} date 自定义当前时间默认为今天
* @property {Boolean} lunar 显示农历
* @property {String} startDate 日期选择范围-开始日期 * @property {String} startDate 日期选择范围-开始日期
* @property {String} endDate 日期选择范围-结束日期 * @property {String} endDate 日期选择范围-结束日期
* @property {Boolean} range 范围选择 * @property {Boolean} range 范围选择
@ -120,10 +123,11 @@
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容 * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
* @property {Array} selected 打点期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] * @property {Array} selected 打点期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
* @property {Boolean} showMonth 是否选择月份为背景 * @property {Boolean} showMonth 是否选择月份为背景
* @property {[String} defaultValue 选择器打开时默认显示的时间
* @event {Function} change 日期改变`insert :ture` 时生效 * @event {Function} change 日期改变`insert :ture` 时生效
* @event {Function} confirm 确认选择`insert :false` 时生效 * @event {Function} confirm 确认选择`insert :false` 时生效
* @event {Function} monthSwitch 切换月份时触发 * @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" /> * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/ */
export default { export default {
components: { components: {
@ -151,10 +155,6 @@
return [] return []
} }
}, },
lunar: {
type: Boolean,
default: false
},
startDate: { startDate: {
type: String, type: String,
default: '' default: ''
@ -163,11 +163,19 @@
type: String, type: String,
default: '' default: ''
}, },
startPlaceholder: {
type: String,
default: ''
},
endPlaceholder: {
type: String,
default: ''
},
range: { range: {
type: Boolean, type: Boolean,
default: false default: false
}, },
typeHasTime: { hasTime: {
type: Boolean, type: Boolean,
default: false default: false
}, },
@ -183,14 +191,6 @@
type: Boolean, type: Boolean,
default: true default: true
}, },
left: {
type: Boolean,
default: true
},
right: {
type: Boolean,
default: true
},
checkHover: { checkHover: {
type: Boolean, type: Boolean,
default: true default: true
@ -209,6 +209,10 @@
fulldate: '' fulldate: ''
} }
} }
},
defaultValue: {
type: [String, Object, Array],
default: ''
} }
}, },
data() { data() {
@ -216,7 +220,7 @@
show: false, show: false,
weeks: [], weeks: [],
calendar: {}, calendar: {},
nowDate: '', nowDate: {},
aniMaskShow: false, aniMaskShow: false,
firstEnter: true, firstEnter: true,
time: '', time: '',
@ -234,7 +238,7 @@
watch: { watch: {
date: { date: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
if (!this.range) { if (!this.range) {
this.tempSingleDate = newVal this.tempSingleDate = newVal
setTimeout(() => { setTimeout(() => {
@ -245,33 +249,44 @@
}, },
defTime: { defTime: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
if (!this.range) { if (!this.range) {
this.time = newVal this.time = newVal
} else { } else {
// console.log('-----', newVal);
this.timeRange.startTime = newVal.start this.timeRange.startTime = newVal.start
this.timeRange.endTime = newVal.end this.timeRange.endTime = newVal.end
} }
} }
}, },
startDate(val) { startDate(val) {
this.cale.resetSatrtDate(val) // watch created
if(!this.cale){
return
}
this.cale.setStartDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
endDate(val) { endDate(val) {
this.cale.resetEndDate(val) // watch created
if(!this.cale){
return
}
this.cale.setEndDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
selected(newVal) { selected(newVal) {
// watch created
if(!this.cale){
return
}
this.cale.setSelectInfo(this.nowDate.fullDate, newVal) this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
pleStatus: { pleStatus: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
const { const {
before, before,
after, after,
@ -294,11 +309,16 @@
this.cale.lastHover = false this.cale.lastHover = false
} }
} else { } else {
// watch created
if(!this.cale){
return
}
this.cale.setDefaultMultiple(before, after) this.cale.setDefaultMultiple(before, after)
if (which === 'left') { if (which === 'left' && before) {
this.setDate(before) this.setDate(before)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
} else { } else if(after) {
this.setDate(after) this.setDate(after)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
} }
@ -309,15 +329,13 @@
} }
}, },
computed: { computed: {
reactStartTime() { timepickerStartTime() {
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
const res = activeDate === this.startDate ? this.selectableTimes.start : '' return activeDate === this.startDate ? this.selectableTimes.start : ''
return res
}, },
reactEndTime() { timepickerEndTime() {
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
const res = activeDate === this.endDate ? this.selectableTimes.end : '' return activeDate === this.endDate ? this.selectableTimes.end : ''
return res
}, },
/** /**
* for i18n * for i18n
@ -368,17 +386,13 @@
created() { created() {
// //
this.cale = new Calendar({ this.cale = new Calendar({
// date: new Date(),
selected: this.selected, selected: this.selected,
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
range: this.range, range: this.range,
// multipleStatus: this.pleStatus
}) })
// //
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
// this.setDay
}, },
methods: { methods: {
leaveCale() { leaveCale() {
@ -407,14 +421,9 @@
const [yearB, monthB] = B.split('-') const [yearB, monthB] = B.split('-')
return yearA === yearB && monthA === monthB return yearA === yearB && monthA === monthB
}, },
// 穿
clean() {
this.close()
},
// //
maskClick() { maskClick() {
this.close()
this.$emit('maskClose') this.$emit('maskClose')
}, },
@ -433,33 +442,49 @@
this.tempSingleDate = '' this.tempSingleDate = ''
} }
this.calendar.fullDate = '' this.calendar.fullDate = ''
this.setDate() this.setDate(new Date())
}, },
bindDateChange(e) { bindDateChange(e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
this.init(value) this.setDate(value)
}, },
/** /**
* 初始化日期显示 * 初始化日期显示
* @param {Object} date * @param {Object} date
*/ */
init(date) { init(date) {
this.cale.setDate(date) // watch created
if(!this.cale){
return
}
this.cale.setDate(date || new Date())
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date) this.nowDate = this.cale.getInfo(date)
this.calendar = {...this.nowDate}
if(!date){
// date
this.calendar.fullDate = ''
if(this.defaultValue && !this.range){
//
const defaultDate = new Date(this.defaultValue)
const fullDate = getDate(defaultDate)
const year = defaultDate.getFullYear()
const month = defaultDate.getMonth()+1
const date = defaultDate.getDate()
const day = defaultDate.getDay()
this.calendar = {
fullDate,
year,
month,
date,
day
},
this.tempSingleDate = fullDate
this.time = getTime(defaultDate, this.hideSecond)
}
}
}, },
// choiceDate(weeks) {
// if (weeks.disable) return
// this.calendar = weeks
// //
// this.cale.setMultiple(this.calendar.fullDate, true)
// this.weeks = this.cale.weeks
// this.tempSingleDate = this.calendar.fullDate
// this.tempRange.before = this.cale.multipleStatus.before
// this.tempRange.after = this.cale.multipleStatus.after
// this.change()
// },
/** /**
* 打开日历弹窗 * 打开日历弹窗
*/ */
@ -467,7 +492,6 @@
// //
if (this.clearDate && !this.insert) { if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus() this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
} }
this.show = true this.show = true
@ -521,12 +545,20 @@
* @param {Object} name * @param {Object} name
*/ */
setEmit(name) { setEmit(name) {
if(!this.range){
if(!this.calendar.fullDate){
this.calendar = this.cale.getInfo(new Date())
this.tempSingleDate = this.calendar.fullDate
}
if(this.hasTime && !this.time) {
this.time = getTime(new Date(), this.hideSecond)
}
}
let { let {
year, year,
month, month,
date, date,
fullDate, fullDate,
lunar,
extraInfo extraInfo
} = this.calendar } = this.calendar
this.$emit(name, { this.$emit(name, {
@ -537,7 +569,6 @@
time: this.time, time: this.time,
timeRange: this.timeRange, timeRange: this.timeRange,
fulldate: fullDate, fulldate: fullDate,
lunar,
extraInfo: extraInfo || {} extraInfo: extraInfo || {}
}) })
}, },
@ -553,7 +584,6 @@
this.cale.setMultiple(this.calendar.fullDate, true) this.cale.setMultiple(this.calendar.fullDate, true)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.tempSingleDate = this.calendar.fullDate this.tempSingleDate = this.calendar.fullDate
const beforeStatus = this.cale.multipleStatus.before
const beforeDate = new Date(this.cale.multipleStatus.before).getTime() const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
const afterDate = new Date(this.cale.multipleStatus.after).getTime() const afterDate = new Date(this.cale.multipleStatus.after).getTime()
if (beforeDate > afterDate && afterDate) { if (beforeDate > afterDate && afterDate) {
@ -565,44 +595,15 @@
} }
this.change() this.change()
}, },
/** changeMonth(type) {
* 回到今天 let newDate
*/ if(type === 'pre') {
backtoday() { newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
let date = this.cale.getDate(new Date()).fullDate } else if(type === 'next') {
// this.cale.setDate(date) newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
this.init(date)
this.change()
},
/**
* 比较时间大小
*/
dateCompare(startDate, endDate) {
//
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
//
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
} }
},
/**
* 上个月
*/
pre() {
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate)
this.monthSwitch()
}, this.setDate(newDate)
/**
* 下个月
*/
next() {
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate)
this.monthSwitch() this.monthSwitch()
}, },
/** /**
@ -862,6 +863,9 @@
.uni-date-changed--time-date { .uni-date-changed--time-date {
color: #999; color: #999;
line-height: 50px; line-height: 50px;
/* #ifdef MP-TOUTIAO */
font-size: 16px;
/* #endif */
margin-right: 5px; margin-right: 5px;
// opacity: 0.6; // opacity: 0.6;
} }

View File

@ -1,7 +1,7 @@
{ {
"uni-datetime-picker.selectDate": "select date", "uni-datetime-picker.selectDate": "select date",
"uni-datetime-picker.selectTime": "select time", "uni-datetime-picker.selectTime": "select time",
"uni-datetime-picker.selectDateTime": "select datetime", "uni-datetime-picker.selectDateTime": "select date and time",
"uni-datetime-picker.startDate": "start date", "uni-datetime-picker.startDate": "start date",
"uni-datetime-picker.endDate": "end date", "uni-datetime-picker.endDate": "end date",
"uni-datetime-picker.startTime": "start time", "uni-datetime-picker.startTime": "start time",

View File

@ -1,45 +0,0 @@
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
// #endif

View File

@ -77,21 +77,14 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef H5 -->
<!-- <keypress v-if="visible" @esc="tiggerTimePicker" @enter="setTime" /> -->
<!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
// #ifdef H5 import { initVueI18n } from '@dcloudio/uni-i18n'
import keypress from './keypress' import i18nMessages from './i18n/index.js'
// #endif const { t } = initVueI18n(i18nMessages)
import { import { fixIosDateFormat } from './util'
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from './i18n/index.js'
const { t } = initVueI18n(messages)
/** /**
* DatetimePicker 时间选择器 * DatetimePicker 时间选择器
@ -108,11 +101,6 @@
export default { export default {
name: 'UniDatetimePicker', name: 'UniDatetimePicker',
components: {
// #ifdef H5
keypress
// #endif
},
data() { data() {
return { return {
indicatorStyle: `height: 50px;`, indicatorStyle: `height: 50px;`,
@ -187,9 +175,9 @@
watch: { watch: {
// #ifndef VUE3 // #ifndef VUE3
value: { value: {
handler(newVal, oldVal) { handler(newVal) {
if (newVal) { if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari this.parseValue(fixIosDateFormat(newVal))
this.initTime(false) this.initTime(false)
} else { } else {
this.time = '' this.time = ''
@ -201,9 +189,9 @@
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
modelValue: { modelValue: {
handler(newVal, oldVal) { handler(newVal) {
if (newVal) { if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari this.parseValue(fixIosDateFormat(newVal))
this.initTime(false) this.initTime(false)
} else { } else {
this.time = '' this.time = ''
@ -233,13 +221,13 @@
}, },
start: { start: {
handler(newVal) { handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'start') // iOSsafari this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
}, },
immediate: true immediate: true
}, },
end: { end: {
handler(newVal) { handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') // iOSsafari this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
}, },
immediate: true immediate: true
}, },
@ -543,7 +531,7 @@
const day = now.getDate() const day = now.getDate()
dateBase = year + '/' + month + '/' + day + ' ' dateBase = year + '/' + month + '/' + day + ' '
} }
if (Number(value) && typeof value !== NaN) { if (Number(value)) {
value = parseInt(value) value = parseInt(value)
dateBase = 0 dateBase = 0
} }
@ -614,7 +602,7 @@
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60 pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
return return
} }
if (Number(point) && Number(point) !== NaN) { if (Number(point)) {
point = parseInt(point) point = parseInt(point)
} }
// datetime end , // datetime end ,
@ -752,7 +740,7 @@
*/ */
initTimePicker() { initTimePicker() {
if (this.disabled) return if (this.disabled) return
const value = this.fixIosDateFormat(this.value) const value = fixIosDateFormat(this.time)
this.initPickerValue(value) this.initPickerValue(value)
this.visible = !this.visible this.visible = !this.visible
}, },

View File

@ -1,27 +1,24 @@
class Calendar { class Calendar {
constructor({ constructor({
date,
selected, selected,
startDate, startDate,
endDate, endDate,
range, range,
// multipleStatus
} = {}) { } = {}) {
// 当前日期 // 当前日期
this.date = this.getDate(new Date()) // 当前初入日期 this.date = this.getDateObj(new Date()) // 当前初入日期
// 打点信息 // 打点信息
this.selected = selected || []; this.selected = selected || [];
// 范围开始 // 起始时间
this.startDate = startDate this.startDate = startDate
// 范围结束 // 终止时间
this.endDate = endDate this.endDate = endDate
// 是否范围选择
this.range = range this.range = range
// 多选状态 // 多选状态
this.cleanMultipleStatus() this.cleanMultipleStatus()
// 每周日期 // 每周日期
this.weeks = {} this.weeks = {}
// this._getWeek(this.date.fullDate)
// this.multipleStatus = multipleStatus
this.lastHover = false this.lastHover = false
} }
/** /**
@ -29,8 +26,8 @@ class Calendar {
* @param {Object} date * @param {Object} date
*/ */
setDate(date) { setDate(date) {
this.selectDate = this.getDate(date) const selectDate = this.getDateObj(date)
this._getWeek(this.selectDate.fullDate) this.getWeeks(selectDate.fullDate)
} }
/** /**
@ -44,93 +41,82 @@ class Calendar {
} }
} }
/** setStartDate(startDate) {
* 重置开始日期
*/
resetSatrtDate(startDate) {
// 范围开始
this.startDate = startDate this.startDate = startDate
} }
/** setEndDate(endDate) {
* 重置结束日期
*/
resetEndDate(endDate) {
// 范围结束
this.endDate = endDate this.endDate = endDate
} }
getPreMonthObj(date){
date = fixIosDateFormat(date)
date = new Date(date)
const oldMonth = date.getMonth()
date.setMonth(oldMonth - 1)
const newMonth = date.getMonth()
if(oldMonth !== 0 && newMonth - oldMonth === 0){
date.setMonth(newMonth - 1)
}
return this.getDateObj(date)
}
getNextMonthObj(date){
date = fixIosDateFormat(date)
date = new Date(date)
const oldMonth = date.getMonth()
date.setMonth(oldMonth + 1)
const newMonth = date.getMonth()
if(newMonth - oldMonth > 1){
date.setMonth(newMonth - 1)
}
return this.getDateObj(date)
}
/** /**
* 获取任意时间 * 获取指定格式Date对象
*/ */
getDate(date, AddDayCount = 0, str = 'day') { getDateObj(date) {
if (!date) { date = fixIosDateFormat(date)
date = new Date() date = new Date(date)
}
if (typeof date !== 'object') {
date = date.replace(/-/g, '/')
}
const dd = new Date(date)
switch (str) {
case 'day':
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
break
case 'month':
if (dd.getDate() === 31) {
dd.setDate(dd.getDate() + AddDayCount)
} else {
dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期
}
break
case 'year':
dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
break
}
const y = dd.getFullYear()
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期不足10补0
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号不足10补0
return { return {
fullDate: y + '-' + m + '-' + d, fullDate: getDate(date),
year: y, year: date.getFullYear(),
month: m, month: addZero(date.getMonth() + 1),
date: d, date: addZero(date.getDate()),
day: dd.getDay() day: date.getDay()
} }
} }
/** /**
* 获取上月剩余天数 * 获取上一个月日期集合
*/ */
_getLastMonthDays(firstDay, full) { getPreMonthDays(amount, dateObj) {
let dateArr = [] const result = []
for (let i = firstDay; i > 0; i--) { for (let i = amount - 1; i >= 0; i--) {
const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate() const month = dateObj.month - 1
dateArr.push({ result.push({
date: beforeDate, date: new Date(dateObj.year, month, -i).getDate(),
month: full.month - 1, month,
disable: true disable: true
}) })
} }
return dateArr return result
} }
/** /**
* 获取本月天数 * 获取本月日期集合
*/ */
_currentMonthDys(dateData, full) { getCurrentMonthDays(amount, dateObj) {
let dateArr = [] const result = []
let fullDate = this.date.fullDate const fullDate = this.date.fullDate
for (let i = 1; i <= dateData; i++) { for (let i = 1; i <= amount; i++) {
let isinfo = false const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
let nowDate = full.year + '-' + (full.month < 10 ? const isToday = fullDate === currentDate
full.month : full.month) + '-' + (i < 10 ?
'0' + i : i)
// 是否今天
let isDay = fullDate === nowDate
// 获取打点信息 // 获取打点信息
let info = this.selected && this.selected.find((item) => { const info = this.selected && this.selected.find((item) => {
if (this.dateEqual(nowDate, item.date)) { if (this.dateEqual(currentDate, item.date)) {
return item return item
} }
}) })
@ -139,62 +125,52 @@ class Calendar {
let disableBefore = true let disableBefore = true
let disableAfter = true let disableAfter = true
if (this.startDate) { if (this.startDate) {
// let dateCompBefore = this.dateCompare(this.startDate, fullDate) disableBefore = dateCompare(this.startDate, currentDate)
// disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
disableBefore = this.dateCompare(this.startDate, nowDate)
} }
if (this.endDate) { if (this.endDate) {
// let dateCompAfter = this.dateCompare(fullDate, this.endDate) disableAfter = dateCompare(currentDate, this.endDate)
// disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
disableAfter = this.dateCompare(nowDate, this.endDate)
}
let multiples = this.multipleStatus.data
let checked = false
let multiplesStatus = -1
if (this.range) {
if (multiples) {
multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, nowDate)
})
}
if (multiplesStatus !== -1) {
checked = true
}
}
let data = {
fullDate: nowDate,
year: full.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after),
afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after),
month: full.month,
disable: !(disableBefore && disableAfter),
isDay,
userChecked: false
}
if (info) {
data.extraInfo = info
} }
dateArr.push(data) let multiples = this.multipleStatus.data
let multiplesStatus = -1
if (this.range && multiples) {
multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, currentDate)
})
} }
return dateArr const checked = multiplesStatus !== -1
result.push({
fullDate: currentDate,
year: dateObj.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
month: dateObj.month,
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)),
isToday,
userChecked: false,
extraInfo: info
})
}
return result
} }
/** /**
* 获取下月天数 * 获取下一个月日期集合
*/ */
_getNextMonthDays(surplus, full) { _getNextMonthDays(amount, dateObj) {
let dateArr = [] const result = []
for (let i = 1; i < surplus + 1; i++) { const month = dateObj.month + 1
dateArr.push({ for (let i = 1; i <= amount; i++) {
result.push({
date: i, date: i,
month: Number(full.month) + 1, month,
disable: true disable: true
}) })
} }
return dateArr return result
} }
/** /**
@ -205,58 +181,37 @@ class Calendar {
if (!date) { if (!date) {
date = new Date() date = new Date()
} }
const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
return dateInfo
}
/** return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
* 比较时间大小
*/
dateCompare(startDate, endDate) {
// 计算截止时间
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
// 计算详细项的截止时间
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
}
} }
/** /**
* 比较时间是否相等 * 比较时间是否相等
*/ */
dateEqual(before, after) { dateEqual(before, after) {
// 计算截止时间 before = new Date(fixIosDateFormat(before))
before = new Date(before.replace('-', '/').replace('-', '/')) after = new Date(fixIosDateFormat(after))
// 计算详细项的截止时间 return before.valueOf() === after.valueOf()
after = new Date(after.replace('-', '/').replace('-', '/'))
if (before.getTime() - after.getTime() === 0) {
return true
} else {
return false
}
} }
/** /**
* 比较真实起始日期 * 比较真实起始日期
*/ */
isLogicBefore(currentDay, before, after) { isLogicBefore(currentDate, before, after) {
let logicBefore = before let logicBefore = before
if (before && after) { if (before && after) {
logicBefore = this.dateCompare(before, after) ? before : after logicBefore = dateCompare(before, after) ? before : after
} }
return this.dateEqual(logicBefore, currentDay) return this.dateEqual(logicBefore, currentDate)
} }
isLogicAfter(currentDay, before, after) { isLogicAfter(currentDate, before, after) {
let logicAfter = after let logicAfter = after
if (before && after) { if (before && after) {
logicAfter = this.dateCompare(before, after) ? after : before logicAfter = dateCompare(before, after) ? after : before
} }
return this.dateEqual(logicAfter, currentDay) return this.dateEqual(logicAfter, currentDate)
} }
/** /**
@ -276,7 +231,7 @@ class Calendar {
var unixDe = de.getTime() - 24 * 60 * 60 * 1000 var unixDe = de.getTime() - 24 * 60 * 60 * 1000
for (var k = unixDb; k <= unixDe;) { for (var k = unixDb; k <= unixDe;) {
k = k + 24 * 60 * 60 * 1000 k = k + 24 * 60 * 60 * 1000
arr.push(this.getDate(new Date(parseInt(k))).fullDate) arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
} }
return arr return arr
} }
@ -285,11 +240,12 @@ class Calendar {
* 获取多选状态 * 获取多选状态
*/ */
setMultiple(fullDate) { setMultiple(fullDate) {
if (!this.range) return
let { let {
before, before,
after after
} = this.multipleStatus } = this.multipleStatus
if (!this.range) return
if (before && after) { if (before && after) {
if (!this.lastHover) { if (!this.lastHover) {
this.lastHover = true this.lastHover = true
@ -306,7 +262,7 @@ class Calendar {
this.lastHover = false this.lastHover = false
} else { } else {
this.multipleStatus.after = fullDate this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
.after); .after);
} else { } else {
@ -316,32 +272,28 @@ class Calendar {
this.lastHover = true this.lastHover = true
} }
} }
this._getWeek(fullDate) this.getWeeks(fullDate)
} }
/** /**
* 鼠标 hover 更新多选状态 * 鼠标 hover 更新多选状态
*/ */
setHoverMultiple(fullDate) { setHoverMultiple(fullDate) {
let { if (!this.range || this.lastHover) return
before,
after
} = this.multipleStatus
if (!this.range) return const { before } = this.multipleStatus
if (this.lastHover) return
if (!before) { if (!before) {
this.multipleStatus.before = fullDate this.multipleStatus.before = fullDate
} else { } else {
this.multipleStatus.after = fullDate this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
} else { } else {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
} }
} }
this._getWeek(fullDate) this.getWeeks(fullDate)
} }
/** /**
@ -351,12 +303,12 @@ class Calendar {
this.multipleStatus.before = before this.multipleStatus.before = before
this.multipleStatus.after = after this.multipleStatus.after = after
if (before && after) { if (before && after) {
if (this.dateCompare(before, after)) { if (dateCompare(before, after)) {
this.multipleStatus.data = this.geDateAll(before, after); this.multipleStatus.data = this.geDateAll(before, after);
this._getWeek(after) this.getWeeks(after)
} else { } else {
this.multipleStatus.data = this.geDateAll(after, before); this.multipleStatus.data = this.geDateAll(after, before);
this._getWeek(before) this.getWeeks(before)
} }
} }
} }
@ -365,46 +317,87 @@ class Calendar {
* 获取每周数据 * 获取每周数据
* @param {Object} dateData * @param {Object} dateData
*/ */
_getWeek(dateData) { getWeeks(dateData) {
const { const {
fullDate,
year, year,
month, month,
date, } = this.getDateObj(dateData)
day
} = this.getDate(dateData) const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
let firstDay = new Date(year, month - 1, 1).getDay() const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
let currentDay = new Date(year, month, 0).getDate()
let dates = { const currentMonthDayAmount = new Date(year, month, 0).getDate()
lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天 const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
nextMonthDays: [], // 下个月开始几天 const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
weeks: [] const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
const weeks = new Array(6)
for (let i = 0; i < calendarDays.length; i++) {
const index = Math.floor(i / 7)
if(!weeks[index]){
weeks[index] = new Array(7)
} }
let canlender = [] weeks[index][i % 7] = calendarDays[i]
const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
let weeks = {}
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for (let i = 0; i < canlender.length; i++) {
if (i % 7 === 0) {
weeks[parseInt(i / 7)] = new Array(7)
} }
weeks[parseInt(i / 7)][i % 7] = canlender[i]
} this.calendar = calendarDays
this.canlender = canlender
this.weeks = weeks this.weeks = weeks
} }
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
} }
function getDateTime(date, hideSecond){
return `${getDate(date)} ${getTime(date, hideSecond)}`
}
export default Calendar function getDate(date) {
date = fixIosDateFormat(date)
date = new Date(date)
const year = date.getFullYear()
const month = date.getMonth()+1
const day = date.getDate()
return `${year}-${addZero(month)}-${addZero(day)}`
}
function getTime(date, hideSecond){
date = fixIosDateFormat(date)
date = new Date(date)
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
}
function addZero(num) {
if(num < 10){
num = `0${num}`
}
return num
}
function getDefaultSecond(hideSecond) {
return hideSecond ? '00:00' : '00:00:00'
}
function dateCompare(startDate, endDate) {
startDate = new Date(fixIosDateFormat(startDate))
endDate = new Date(fixIosDateFormat(endDate))
return startDate <= endDate
}
function checkDate(date){
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
return date.match(dateReg)
}
const dateTimeReg = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( [0-5][0-9]:[0-5][0-9]:[0-5][0-9])?$/
function fixIosDateFormat(value) {
if (typeof value === 'string' && dateTimeReg.test(value)) {
value = value.replace(/-/g, '/')
}
return value
}
export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat}

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-datetime-picker", "id": "uni-datetime-picker",
"displayName": "uni-datetime-picker 日期选择器", "displayName": "uni-datetime-picker 日期选择器",
"version": "2.2.11", "version": "2.2.22",
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择", "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
"keywords": [ "keywords": [
"uni-datetime-picker", "uni-datetime-picker",

View File

@ -1,10 +1,21 @@
## 1.1.92023-04-11
- 修复 vue3 下 keyboardheightchange 事件报错的bug
## 1.1.82023-03-29
- 优化 trim 属性默认值
## 1.1.72023-03-29
- 新增 cursor-spacing 属性
## 1.1.62023-01-28
- 新增 keyboardheightchange 事件,可监听键盘高度变化
## 1.1.52022-11-29
- 优化 主题样式
## 1.1.42022-10-27
- 修复 props 中背景颜色无默认值的bug
## 1.1.02022-06-30 ## 1.1.02022-06-30
- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 - 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
- 新增 clear 事件,点击右侧叉号图标触发 - 新增 clear 事件,点击右侧叉号图标触发
- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 - 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 - 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
-
## 1.0.52022-06-07 ## 1.0.52022-06-07

View File

@ -1,24 +1,7 @@
<template> <template>
<view <view class="uni-easyinput" :class="{ 'uni-easyinput-error': msg }" :style="boxStyle">
class="uni-easyinput" <view class="uni-easyinput__content" :class="inputContentClass" :style="inputContentStyle">
:class="{ 'uni-easyinput-error': msg }" <uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" @click="onClickIcon('prefix')" size="22"></uni-icons>
:style="boxStyle"
>
<view
class="uni-easyinput__content"
:class="inputContentClass"
:style="inputContentStyle"
>
<slot name="prefixIcon">
<uni-icons
v-if="prefixIcon"
class="content-clear-icon"
:type="prefixIcon"
color="#c0c4cc"
@click="onClickIcon('prefix')"
size="22"
></uni-icons>
</slot>
<textarea <textarea
v-if="type === 'textarea'" v-if="type === 'textarea'"
class="uni-easyinput__content-textarea" class="uni-easyinput__content-textarea"
@ -32,10 +15,12 @@
:maxlength="inputMaxlength" :maxlength="inputMaxlength"
:focus="focused" :focus="focused"
:autoHeight="autoHeight" :autoHeight="autoHeight"
:cursor-spacing="cursorSpacing"
@input="onInput" @input="onInput"
@blur="_Blur" @blur="_Blur"
@focus="_Focus" @focus="_Focus"
@confirm="onConfirm" @confirm="onConfirm"
@keyboardheightchange="onkeyboardheightchange"
></textarea> ></textarea>
<input <input
v-else v-else
@ -52,10 +37,12 @@
:maxlength="inputMaxlength" :maxlength="inputMaxlength"
:focus="focused" :focus="focused"
:confirmType="confirmType" :confirmType="confirmType"
:cursor-spacing="cursorSpacing"
@focus="_Focus" @focus="_Focus"
@blur="_Blur" @blur="_Blur"
@input="onInput" @input="onInput"
@confirm="onConfirm" @confirm="onConfirm"
@keyboardheightchange="onkeyboardheightchange"
/> />
<template v-if="type === 'password' && passwordIcon"> <template v-if="type === 'password' && passwordIcon">
<!-- 开启密码时显示小眼睛 --> <!-- 开启密码时显示小眼睛 -->
@ -67,20 +54,10 @@
:size="22" :size="22"
:color="focusShow ? primaryColor : '#c0c4cc'" :color="focusShow ? primaryColor : '#c0c4cc'"
@click="onEyes" @click="onEyes"
>
</uni-icons>
</template>
<template v-else-if="suffixIcon || $slots.suffixIcon">
<slot name="suffixIcon">
<uni-icons
v-if="suffixIcon"
class="content-clear-icon"
:type="suffixIcon"
color="#c0c4cc"
@click="onClickIcon('suffix')"
size="22"
></uni-icons> ></uni-icons>
</slot> </template>
<template v-else-if="suffixIcon">
<uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" @click="onClickIcon('suffix')" size="22"></uni-icons>
</template> </template>
<template v-else> <template v-else>
<uni-icons <uni-icons
@ -124,6 +101,7 @@
* @property {String} suffixIcon 输入框尾部图标 * @property {String} suffixIcon 输入框尾部图标
* @property {String} primaryColor 设置主题色默认#2979ff * @property {String} primaryColor 设置主题色默认#2979ff
* @property {Boolean} trim 是否自动去除两端的空格 * @property {Boolean} trim 是否自动去除两端的空格
* @property {Boolean} cursorSpacing 指定光标与键盘的距离单位 px
* @value both 去除两端空格 * @value both 去除两端空格
* @value left 去除左侧空格 * @value left 去除左侧空格
* @value right 去除右侧空格 * @value right 去除右侧空格
@ -139,12 +117,10 @@
* @event {Function} blur 输入框失去焦点时触发 * @event {Function} blur 输入框失去焦点时触发
* @event {Function} confirm 点击完成按钮时触发 * @event {Function} confirm 点击完成按钮时触发
* @event {Function} iconClick 点击图标时触发 * @event {Function} iconClick 点击图标时触发
* @slot prefixIcon 输入框头部插槽
* @slot suffixIcon 输入框尾部插槽
* @example <uni-easyinput v-model="mobile"></uni-easyinput> * @example <uni-easyinput v-model="mobile"></uni-easyinput>
*/ */
function obj2strClass(obj) { function obj2strClass(obj) {
let classess = ""; let classess = '';
for (let key in obj) { for (let key in obj) {
const val = obj[key]; const val = obj[key];
if (val) { if (val) {
@ -155,7 +131,7 @@ function obj2strClass(obj) {
} }
function obj2strStyle(obj) { function obj2strStyle(obj) {
let style = ""; let style = '';
for (let key in obj) { for (let key in obj) {
const val = obj[key]; const val = obj[key];
style += `${key}:${val};`; style += `${key}:${val};`;
@ -163,35 +139,24 @@ function obj2strStyle(obj) {
return style; return style;
} }
export default { export default {
name: "uni-easyinput", name: 'uni-easyinput',
emits: [ emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm', 'clear', 'eyes', 'change', 'keyboardheightchange'],
"click",
"iconClick",
"update:modelValue",
"input",
"focus",
"blur",
"confirm",
"clear",
"eyes",
"change",
],
model: { model: {
prop: "modelValue", prop: 'modelValue',
event: "update:modelValue", event: 'update:modelValue'
}, },
options: { options: {
virtualHost: true, virtualHost: true
}, },
inject: { inject: {
form: { form: {
from: "uniForm", from: 'uniForm',
default: null, default: null
}, },
formItem: { formItem: {
from: "uniFormItem", from: 'uniFormItem',
default: null, default: null
}, }
}, },
props: { props: {
name: String, name: String,
@ -199,91 +164,97 @@ export default {
modelValue: [Number, String], modelValue: [Number, String],
type: { type: {
type: String, type: String,
default: "text", default: 'text'
}, },
clearable: { clearable: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
autoHeight: { autoHeight: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
placeholder: { placeholder: {
type: String, type: String,
default: " ", default: ' '
}, },
placeholderStyle: String, placeholderStyle: String,
focus: { focus: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
maxlength: { maxlength: {
type: [Number, String], type: [Number, String],
default: 140, default: 140
}, },
confirmType: { confirmType: {
type: String, type: String,
default: "done", default: 'done'
}, },
clearSize: { clearSize: {
type: [Number, String], type: [Number, String],
default: 24, default: 24
}, },
inputBorder: { inputBorder: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
prefixIcon: { prefixIcon: {
type: String, type: String,
default: "", default: ''
}, },
suffixIcon: { suffixIcon: {
type: String, type: String,
default: "", default: ''
}, },
trim: { trim: {
type: [Boolean, String], type: [Boolean, String],
default: true, default: false
},
cursorSpacing: {
type: Number,
default: 0
}, },
passwordIcon: { passwordIcon: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
primaryColor: { primaryColor: {
type: String, type: String,
default: "#2979ff", default: '#2979ff'
}, },
styles: { styles: {
type: Object, type: Object,
default() { default() {
return { return {
color: "#333", color: '#333',
disableColor: "#F7F6F6", backgroundColor: '#fff',
borderColor: "#e5e5e5", disableColor: '#F7F6F6',
borderColor: '#e5e5e5'
}; };
}, }
}, },
errorMessage: { errorMessage: {
type: [String, Boolean], type: [String, Boolean],
default: "", default: ''
}, }
}, },
data() { data() {
return { return {
focused: false, focused: false,
val: "", val: '',
showMsg: "", showMsg: '',
border: false, border: false,
isFirstBorder: false, isFirstBorder: false,
showClearIcon: false, showClearIcon: false,
showPassword: false, showPassword: false,
focusShow: false, focusShow: false,
localMsg: "", localMsg: '',
isEnter: false // 使
}; };
}, },
computed: { computed: {
@ -312,42 +283,34 @@ export default {
// style // style
boxStyle() { boxStyle() {
return `color:${ return `color:${this.inputBorder && this.msg ? '#e43d33' : this.styles.color};`;
this.inputBorder && this.msg ? "#e43d33" : this.styles.color
};`;
}, },
// input // input
inputContentClass() { inputContentClass() {
return obj2strClass({ return obj2strClass({
"is-input-border": this.inputBorder, 'is-input-border': this.inputBorder,
"is-input-error-border": this.inputBorder && this.msg, 'is-input-error-border': this.inputBorder && this.msg,
"is-textarea": this.type === "textarea", 'is-textarea': this.type === 'textarea',
"is-disabled": this.disabled, 'is-disabled': this.disabled,
'is-focused': this.focusShow
}); });
}, },
inputContentStyle() { inputContentStyle() {
const focusColor = this.focusShow const focusColor = this.focusShow ? this.primaryColor : this.styles.borderColor;
? this.primaryColor const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor;
: this.styles.borderColor;
const borderColor = this.inputBorder && this.msg ? "#dd524d" : focusColor;
return obj2strStyle({ return obj2strStyle({
"border-color": borderColor || "#e5e5e5", 'border-color': borderColor || '#e5e5e5',
"background-color": this.disabled 'background-color': this.disabled ? this.styles.disableColor : this.styles.backgroundColor
? this.styles.disableColor
: this.styles.backgroundColor,
}); });
}, },
// input // input
inputStyle() { inputStyle() {
const paddingRight = const paddingRight = this.type === 'password' || this.clearable || this.prefixIcon ? '' : '10px';
this.type === "password" || this.clearable || this.prefixIcon
? ""
: "10px";
return obj2strStyle({ return obj2strStyle({
"padding-right": paddingRight, 'padding-right': paddingRight,
"padding-left": this.prefixIcon ? "" : "10px", 'padding-left': this.prefixIcon ? '' : '10px'
}); });
}, }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
@ -361,13 +324,13 @@ export default {
this.focused = this.focus; this.focused = this.focus;
this.focusShow = this.focus; this.focusShow = this.focus;
}); });
}, }
}, },
created() { created() {
this.init(); this.init();
// TODO vue3 computed inject formItem.errMsg // TODO vue3 computed inject formItem.errMsg
if (this.form && this.formItem) { if (this.form && this.formItem) {
this.$watch("formItem.errMsg", (newVal) => { this.$watch('formItem.errMsg', newVal => {
this.localMsg = newVal; this.localMsg = newVal;
}); });
} }
@ -385,7 +348,7 @@ export default {
init() { init() {
if (this.value || this.value === 0) { if (this.value || this.value === 0) {
this.val = this.value; this.val = this.value;
} else if (this.modelValue || this.modelValue === 0) { } else if (this.modelValue || this.modelValue === 0 || this.modelValue === '') {
this.val = this.modelValue; this.val = this.modelValue;
} else { } else {
this.val = null; this.val = null;
@ -397,7 +360,7 @@ export default {
* @param {Object} type * @param {Object} type
*/ */
onClickIcon(type) { onClickIcon(type) {
this.$emit("iconClick", type); this.$emit('iconClick', type);
}, },
/** /**
@ -405,7 +368,7 @@ export default {
*/ */
onEyes() { onEyes() {
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
this.$emit("eyes", this.showPassword); this.$emit('eyes', this.showPassword);
}, },
/** /**
@ -416,19 +379,19 @@ export default {
let value = event.detail.value; let value = event.detail.value;
// //
if (this.trim) { if (this.trim) {
if (typeof this.trim === "boolean" && this.trim) { if (typeof this.trim === 'boolean' && this.trim) {
value = this.trimStr(value); value = this.trimStr(value);
} }
if (typeof this.trim === "string") { if (typeof this.trim === 'string') {
value = this.trimStr(value, this.trim); value = this.trimStr(value, this.trim);
} }
} }
if (this.errMsg) this.errMsg = ""; if (this.errMsg) this.errMsg = '';
this.val = value; this.val = value;
// TODO vue2 // TODO vue2
this.$emit("input", value); this.$emit('input', value);
// TODO  vue3 // TODO  vue3
this.$emit("update:modelValue", value); this.$emit('update:modelValue', value);
}, },
/** /**
@ -440,12 +403,12 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.focused = true; this.focused = true;
}); });
this.$emit("focus", null); this.$emit('focus', null);
}, },
_Focus(event) { _Focus(event) {
this.focusShow = true; this.focusShow = true;
this.$emit("focus", event); this.$emit('focus', event);
}, },
/** /**
@ -455,18 +418,20 @@ export default {
*/ */
onBlur() { onBlur() {
this.focused = false; this.focused = false;
this.$emit("focus", null); this.$emit('focus', null);
}, },
_Blur(event) { _Blur(event) {
let value = event.detail.value; let value = event.detail.value;
this.focusShow = false; this.focusShow = false;
this.$emit("blur", event); this.$emit('blur', event);
// eventstring // eventstring
this.$emit("change", this.val); if (this.isEnter === false) {
this.$emit('change', this.val);
}
// //
if (this.form && this.formItem) { if (this.form && this.formItem) {
const { validateTrigger } = this.form; const { validateTrigger } = this.form;
if (validateTrigger === "blur") { if (validateTrigger === 'blur') {
this.formItem.onFieldChange(); this.formItem.onFieldChange();
} }
} }
@ -477,8 +442,12 @@ export default {
* @param {Object} e * @param {Object} e
*/ */
onConfirm(e) { onConfirm(e) {
this.$emit("confirm", this.val); this.$emit('confirm', this.val);
this.$emit("change", this.val); this.isEnter = true;
this.$emit('change', this.val);
this.$nextTick(() => {
this.isEnter = false;
});
}, },
/** /**
@ -486,38 +455,47 @@ export default {
* @param {Object} event * @param {Object} event
*/ */
onClear(event) { onClear(event) {
this.val = ""; this.val = '';
// TODO vue2 // TODO vue2
this.$emit("input", ""); this.$emit('input', '');
// TODO vue2 // TODO vue2
// TODO  vue3 // TODO  vue3
this.$emit("update:modelValue", ""); this.$emit('update:modelValue', '');
// //
this.$emit("clear"); this.$emit('clear');
},
/**
* 键盘高度发生变化的时候触发此事件
* 兼容性微信小程序2.7.0+App 3.1.0+
* @param {Object} event
*/
onkeyboardheightchange(event) {
this.$emit("keyboardheightchange",event);
}, },
/** /**
* 去除空格 * 去除空格
*/ */
trimStr(str, pos = "both") { trimStr(str, pos = 'both') {
if (pos === "both") { if (pos === 'both') {
return str.trim(); return str.trim();
} else if (pos === "left") { } else if (pos === 'left') {
return str.trimLeft(); return str.trimLeft();
} else if (pos === "right") { } else if (pos === 'right') {
return str.trimRight(); return str.trimRight();
} else if (pos === "start") { } else if (pos === 'start') {
return str.trimStart(); return str.trimStart();
} else if (pos === "end") { } else if (pos === 'end') {
return str.trimEnd(); return str.trimEnd();
} else if (pos === "all") { } else if (pos === 'all') {
return str.replace(/\s+/g, ""); return str.replace(/\s+/g, '');
} else if (pos === "none") { } else if (pos === 'none') {
return str; return str;
} }
return str; return str;
}, }
}, }
}; };
</script> </script>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-easyinput", "id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框", "displayName": "uni-easyinput 增强输入框",
"version": "1.1.3", "version": "1.1.9",
"description": "Easyinput 组件是对原生input组件的增强", "description": "Easyinput 组件是对原生input组件的增强",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,3 +1,5 @@
## 1.2.52023-03-29
- 新增 pattern.icon 属性,可自定义图标
## 1.2.42022-09-07 ## 1.2.42022-09-07
小程序端由于 style 使用了对象导致报错,[详情](https://ask.dcloud.net.cn/question/152790?item_id=211778&rf=false) 小程序端由于 style 使用了对象导致报错,[详情](https://ask.dcloud.net.cn/question/152790?item_id=211778&rf=false)
## 1.2.32022-09-05 ## 1.2.32022-09-05

View File

@ -35,7 +35,7 @@
'uni-fab__circle--rightTop': rightTop, 'uni-fab__circle--rightTop': rightTop,
'uni-fab__content--other-platform': !isAndroidNvue 'uni-fab__content--other-platform': !isAndroidNvue
}" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor, 'bottom': nvueBottom }" @click="_onClick"> }" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor, 'bottom': nvueBottom }" @click="_onClick">
<uni-icons class="fab-circle-icon" type="plusempty" :color="styles.iconColor" size="32" <uni-icons class="fab-circle-icon" :type="styles.icon" :color="styles.iconColor" size="32"
:class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons> :class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons>
<!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> <!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view>
<view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> --> <view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> -->
@ -115,7 +115,8 @@
selectedColor: '#007AFF', selectedColor: '#007AFF',
backgroundColor: '#fff', backgroundColor: '#fff',
buttonColor: '#007AFF', buttonColor: '#007AFF',
iconColor: '#fff' iconColor: '#fff',
icon: 'plusempty'
} }
} }
}, },

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-fab", "id": "uni-fab",
"displayName": "uni-fab 悬浮按钮", "displayName": "uni-fab 悬浮按钮",
"version": "1.2.4", "version": "1.2.5",
"description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。", "description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,3 +1,7 @@
## 1.0.42023-03-29
- 修复 手动上传删除一个文件后不能再上传的bug
## 1.0.32022-12-19
- 新增 sourceType 属性, 可以自定义图片和视频选择的来源
## 1.0.22022-07-04 ## 1.0.22022-07-04
- 修复 在uni-forms下样式不生效的bug - 修复 在uni-forms下样式不生效的bug
## 1.0.12021-11-23 ## 1.0.12021-11-23

View File

@ -7,7 +7,7 @@ function chooseImage(opts) {
const { const {
count, count,
sizeType = ['original', 'compressed'], sizeType = ['original', 'compressed'],
sourceType = ['album', 'camera'], sourceType,
extension extension
} = opts } = opts
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -33,7 +33,7 @@ function chooseVideo(opts) {
camera, camera,
compressed, compressed,
maxDuration, maxDuration,
sourceType = ['album', 'camera'], sourceType,
extension extension
} = opts; } = opts;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -185,6 +185,12 @@
default () { default () {
return ['original', 'compressed'] return ['original', 'compressed']
} }
},
sourceType: {
type: Array,
default () {
return ['album', 'camera']
}
} }
}, },
data() { data() {
@ -349,6 +355,7 @@
type: this.fileMediatype, type: this.fileMediatype,
compressed: false, compressed: false,
sizeType: this.sizeType, sizeType: this.sizeType,
sourceType: this.sourceType,
// TODO video // TODO video
extension: _extname.length > 0 ? _extname : undefined, extension: _extname.length > 0 ? _extname : undefined,
count: this.limitLength - this.files.length, //9 count: this.limitLength - this.files.length, //9
@ -576,7 +583,11 @@
path: v.path, path: v.path,
size: v.size, size: v.size,
fileID:v.fileID, fileID:v.fileID,
url: v.url url: v.url,
// bug, #694
uuid: v.uuid,
status: v.status,
cloudPath: v.cloudPath
}) })
}) })
return newFilesData return newFilesData

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-file-picker", "id": "uni-file-picker",
"displayName": "uni-file-picker 文件选择上传", "displayName": "uni-file-picker 文件选择上传",
"version": "1.0.2", "version": "1.0.4",
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间", "description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,10 +17,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -37,7 +33,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss"], "dependencies": ["uni-scss"],

View File

@ -1,3 +1,5 @@
## 1.4.92023-02-10
- 修复 required 参数无法动态绑定
## 1.4.82022-08-23 ## 1.4.82022-08-23
- 优化 根据 rules 自动添加 required 的问题 - 优化 根据 rules 自动添加 required 的问题
## 1.4.72022-08-22 ## 1.4.72022-08-22

View File

@ -2,9 +2,9 @@
<view class="uni-forms-item" <view class="uni-forms-item"
:class="['is-direction-' + localLabelPos ,border?'uni-forms-item--border':'' ,border && isFirstBorder?'is-first-border':'']"> :class="['is-direction-' + localLabelPos ,border?'uni-forms-item--border':'' ,border && isFirstBorder?'is-first-border':'']">
<slot name="label"> <slot name="label">
<view class="uni-forms-item__label" :class="{'no-label':!label && !isRequired}" <view class="uni-forms-item__label" :class="{'no-label':!label && !required}"
:style="{width:localLabelWidth,justifyContent: localLabelAlign}"> :style="{width:localLabelWidth,justifyContent: localLabelAlign}">
<text v-if="isRequired" class="is-required">*</text> <text v-if="required" class="is-required">*</text>
<text>{{label}}</text> <text>{{label}}</text>
</view> </view>
</slot> </slot>
@ -126,7 +126,6 @@
data() { data() {
return { return {
errMsg: '', errMsg: '',
isRequired: false,
userRules: null, userRules: null,
localLabelAlign: 'left', localLabelAlign: 'left',
localLabelWidth: '65px', localLabelWidth: '65px',
@ -315,7 +314,6 @@
this.localLabelWidth = this._labelWidthUnit(labelWidth) this.localLabelWidth = this._labelWidthUnit(labelWidth)
// //
this.localLabelPos = this._labelPosition() this.localLabelPos = this._labelPosition()
this.isRequired = this.required
// form // form
this.form && type && childrens.push(this) this.form && type && childrens.push(this)
@ -351,8 +349,6 @@
this.validator = validator this.validator = validator
// //
this.itemSetValue(_getDataValue(this.name, localData)) this.itemSetValue(_getDataValue(this.name, localData))
this.isRequired = this._isRequired()
}, },
unInit() { unInit() {
if (this.form) { if (this.form) {

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-forms", "id": "uni-forms",
"displayName": "uni-forms 表单", "displayName": "uni-forms 表单",
"version": "1.4.8", "version": "1.4.9",
"description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据", "description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,3 +1,29 @@
## 1.2.142023-04-14
- 优化 uni-list-chat 具名插槽`header` 非app端套一层元素方便使用时通过外层元素定位实现样式修改
## 1.2.132023-03-03
- uni-list-chat 新增 支持具名插槽`header`
## 1.2.122023-02-01
- 新增 列表图标新增 customPrefix 属性 ,用法 [详见](https://uniapp.dcloud.net.cn/component/uniui/uni-icons.html#icons-props)
## 1.2.112023-01-31
- 修复 无反馈效果呈现的bug
## 1.2.92022-11-22
- 修复 uni-list-chat 在vue3下跳转报错的bug
## 1.2.82022-11-21
- 修复 uni-list-chat avatar属性 值为本地路径时错误的问题
## 1.2.72022-11-21
- 修复 uni-list-chat avatar属性 在腾讯云版uniCloud下错误的问题
## 1.2.62022-11-18
- 修复 uni-list-chat note属性 支持:“草稿”字样功能 文本少1位的问题
## 1.2.52022-11-15
- 修复 uni-list-item 的 customStyle 属性 padding值在 H5端 无效的bug
## 1.2.42022-11-15
- 修复 uni-list-item 的 customStyle 属性 padding值在nvuevue2下无效的bug
## 1.2.32022-11-14
- uni-list-chat 新增 avatar 支持 fileId
## 1.2.22022-11-11
- uni-list 新增属性 render-reverse 详情参考:[https://uniapp.dcloud.net.cn/component/list.html](https://uniapp.dcloud.net.cn/component/list.html)
- uni-list-chat note属性 支持:“草稿”字样 加红显示 详情参考uni-im[https://ext.dcloud.net.cn/plugin?name=uni-im](https://ext.dcloud.net.cn/plugin?name=uni-im)
- uni-list-item 新增属性 customStyle 支持设置padding、backgroundColor
## 1.2.12022-03-30 ## 1.2.12022-03-30
- 删除无用文件 - 删除无用文件
## 1.2.02021-11-23 ## 1.2.02021-11-23

View File

@ -7,7 +7,7 @@
<view class="uni-list-chat__container"> <view class="uni-list-chat__container">
<view class="uni-list-chat__header-warp"> <view class="uni-list-chat__header-warp">
<view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }"> <view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }">
<image class="uni-list-chat__header-image" :class="{ 'header--circle': avatarCircle }" :src="avatar" mode="aspectFill"></image> <image class="uni-list-chat__header-image" :class="{ 'header--circle': avatarCircle }" :src="avatarUrl" mode="aspectFill"></image>
</view> </view>
<!-- 头像组 --> <!-- 头像组 -->
<view v-else class="uni-list-chat__header"> <view v-else class="uni-list-chat__header">
@ -18,13 +18,23 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifndef APP -->
<view class="slot-header">
<!-- #endif -->
<slot name="header"></slot>
<!-- #ifndef APP -->
</view>
<!-- #endif -->
<view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]"> <view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]">
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text> <text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
</view> </view>
<view class="uni-list-chat__content"> <view class="uni-list-chat__content">
<view class="uni-list-chat__content-main"> <view class="uni-list-chat__content-main">
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text> <text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{ note }}</text> <view style="flex-direction: row;">
<text class="draft" v-if="isDraft">[草稿]</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{isDraft?note.slice(14):note}}</text>
</view>
</view> </view>
<view class="uni-list-chat__content-extra"> <view class="uni-list-chat__content-extra">
<slot> <slot>
@ -121,6 +131,9 @@
}, },
// inject: ['list'], // inject: ['list'],
computed: { computed: {
isDraft(){
return this.note.slice(0,14) == '[uni-im-draft]'
},
isSingle() { isSingle() {
if (this.badgeText === 'dot') { if (this.badgeText === 'dot') {
return 'uni-badge--dot'; return 'uni-badge--dot';
@ -146,12 +159,32 @@
} }
} }
}, },
watch: {
avatar:{
handler(avatar) {
if(avatar.substr(0,8) == 'cloud://'){
uniCloud.getTempFileURL({
fileList: [avatar]
}).then(res=>{
// console.log(res);
// uniCloud
let fileList = res.fileList || res.result.fileList
this.avatarUrl = fileList[0].tempFileURL
})
}else{
this.avatarUrl = avatar
}
},
immediate: true
}
},
data() { data() {
return { return {
isFirstChild: false, isFirstChild: false,
border: true, border: true,
// avatarList: 3, // avatarList: 3,
imageWidth: 50 imageWidth: 50,
avatarUrl:''
}; };
}, },
mounted() { mounted() {
@ -198,7 +231,7 @@
} }
}, },
pageApi(api) { pageApi(api) {
uni[api]({ let callback = {
url: this.to, url: this.to,
success: res => { success: res => {
this.$emit('click', { this.$emit('click', {
@ -209,9 +242,24 @@
this.$emit('click', { this.$emit('click', {
data: err data: err
}); });
console.error(err.errMsg);
} }
}); }
switch (api) {
case 'navigateTo':
uni.navigateTo(callback)
break
case 'redirectTo':
uni.redirectTo(callback)
break
case 'reLaunch':
uni.reLaunch(callback)
break
case 'switchTab':
uni.switchTab(callback)
break
default:
uni.navigateTo(callback)
}
} }
} }
}; };
@ -445,13 +493,20 @@
overflow: hidden; overflow: hidden;
} }
.uni-list-chat__content-note { .draft ,.uni-list-chat__content-note {
margin-top: 3px; margin-top: 3px;
color: $note-color; color: $note-color;
font-size: $note-size; font-size: $note-size;
font-weight: $title-weight; font-weight: $title-weight;
overflow: hidden; overflow: hidden;
} }
.draft{
color: #eb3a41;
/* #ifndef APP-NVUE */
flex-shrink: 0;
/* #endif */
padding-right: 3px;
}
.uni-list-chat__content-extra { .uni-list-chat__content-extra {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */

View File

@ -1,21 +1,21 @@
<template> <template>
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<cell> <cell :keep-scroll-position="keepScrollPosition">
<!-- #endif --> <!-- #endif -->
<view :class="{ 'uni-list-item--disabled': disabled }" :style="{'background-color':customStyle.backgroundColor}"
<view :class="{ 'uni-list-item--disabled': disabled }"
:hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'" :hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
class="uni-list-item" @click="onClick"> class="uni-list-item" @click="onClick">
<view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view> <view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view>
<view class="uni-list-item__container" <view class="uni-list-item__container"
:class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }"> :class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column'}"
:style="{paddingTop:padding.top,paddingLeft:padding.left,paddingRight:padding.right,paddingBottom:padding.bottom}">
<slot name="header"> <slot name="header">
<view class="uni-list-item__header"> <view class="uni-list-item__header">
<view v-if="thumb" class="uni-list-item__icon"> <view v-if="thumb" class="uni-list-item__icon">
<image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" /> <image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" />
</view> </view>
<view v-else-if="showExtraIcon" class="uni-list-item__icon"> <view v-else-if="showExtraIcon" class="uni-list-item__icon">
<uni-icons :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" /> <uni-icons :customPrefix="extraIcon.customPrefix" :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" />
</view> </view>
</view> </view>
</slot> </slot>
@ -167,19 +167,75 @@
return { return {
type: '', type: '',
color: '#000000', color: '#000000',
size: 20 size: 20,
customPrefix: ''
}; };
} }
}, },
border: { border: {
type: Boolean, type: Boolean,
default: true default: true
},
customStyle: {
type: Object,
default () {
return {
padding: '',
backgroundColor: '#FFFFFF'
}
}
},
keepScrollPosition: {
type: Boolean,
default: false
}
},
watch: {
'customStyle.padding': {
handler(padding) {
if(typeof padding == 'number'){
padding += ''
}
let paddingArr = padding.split(' ')
if (paddingArr.length === 1) {
const allPadding = paddingArr[0]
this.padding = {
"top": allPadding,
"right": allPadding,
"bottom": allPadding,
"left": allPadding
}
} else if (paddingArr.length === 2) {
const [verticalPadding, horizontalPadding] = paddingArr;
this.padding = {
"top": verticalPadding,
"right": horizontalPadding,
"bottom": verticalPadding,
"left": horizontalPadding
}
} else if (paddingArr.length === 4) {
const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
this.padding = {
"top": topPadding,
"right": rightPadding,
"bottom": bottomPadding,
"left": leftPadding
}
}
},
immediate: true
} }
}, },
// inject: ['list'], // inject: ['list'],
data() { data() {
return { return {
isFirstChild: false isFirstChild: false,
padding: {
top: "",
right: "",
bottom: "",
left: ""
}
}; };
}, },
mounted() { mounted() {
@ -275,6 +331,7 @@
$uni-bg-color-hover:#f1f1f1; $uni-bg-color-hover:#f1f1f1;
$uni-text-color-grey:#999; $uni-text-color-grey:#999;
$list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg; $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg;
.uni-list-item { .uni-list-item {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -289,12 +346,15 @@
cursor: pointer; cursor: pointer;
/* #endif */ /* #endif */
} }
.uni-list-item--disabled { .uni-list-item--disabled {
opacity: 0.3; opacity: 0.3;
} }
.uni-list-item--hover { .uni-list-item--hover {
background-color: $uni-bg-color-hover; background-color: $uni-bg-color-hover !important;
} }
.uni-list-item__container { .uni-list-item__container {
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -307,9 +367,11 @@
overflow: hidden; overflow: hidden;
// align-items: center; // align-items: center;
} }
.container--right { .container--right {
padding-right: 0; padding-right: 0;
} }
// .border--left { // .border--left {
// margin-left: $uni-spacing-row-lg; // margin-left: $uni-spacing-row-lg;
// } // }
@ -324,6 +386,7 @@
border-top-width: 0.5px; border-top-width: 0.5px;
/* #endif */ /* #endif */
} }
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
.uni-list--border:after { .uni-list--border:after {
position: absolute; position: absolute;
@ -336,6 +399,7 @@
transform: scaleY(0.5); transform: scaleY(0.5);
background-color: $uni-border-color; background-color: $uni-border-color;
} }
/* #endif */ /* #endif */
.uni-list-item__content { .uni-list-item__content {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -349,20 +413,24 @@
justify-content: space-between; justify-content: space-between;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__content--center { .uni-list-item__content--center {
justify-content: center; justify-content: center;
} }
.uni-list-item__content-title { .uni-list-item__content-title {
font-size: $uni-font-size-base; font-size: $uni-font-size-base;
color: #3b4144; color: #3b4144;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__content-note { .uni-list-item__content-note {
margin-top: 6rpx; margin-top: 6rpx;
color: $uni-text-color-grey; color: $uni-text-color-grey;
font-size: $uni-font-size-sm; font-size: $uni-font-size-sm;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__extra { .uni-list-item__extra {
// width: 25%; // width: 25%;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -372,6 +440,7 @@
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
} }
.uni-list-item__header { .uni-list-item__header {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -379,12 +448,14 @@
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
.uni-list-item__icon { .uni-list-item__icon {
margin-right: 18rpx; margin-right: 18rpx;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.uni-list-item__icon-img { .uni-list-item__icon-img {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: block; display: block;
@ -393,6 +464,7 @@
width: $uni-img-size-base; width: $uni-img-size-base;
margin-right: 10px; margin-right: 10px;
} }
.uni-icon-wrapper { .uni-icon-wrapper {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -400,33 +472,40 @@
align-items: center; align-items: center;
padding: 0 10px; padding: 0 10px;
} }
.flex--direction { .flex--direction {
flex-direction: column; flex-direction: column;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
align-items: initial; align-items: initial;
/* #endif */ /* #endif */
} }
.flex--justify { .flex--justify {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
justify-content: initial; justify-content: initial;
/* #endif */ /* #endif */
} }
.uni-list--lg { .uni-list--lg {
height: $uni-img-size-lg; height: $uni-img-size-lg;
width: $uni-img-size-lg; width: $uni-img-size-lg;
} }
.uni-list--base { .uni-list--base {
height: $uni-img-size-base; height: $uni-img-size-base;
width: $uni-img-size-base; width: $uni-img-size-base;
} }
.uni-list--sm { .uni-list--sm {
height: $uni-img-size-sm; height: $uni-img-size-sm;
width: $uni-img-size-sm; width: $uni-img-size-sm;
} }
.uni-list-item__extra-text { .uni-list-item__extra-text {
color: $uni-text-color-grey; color: $uni-text-color-grey;
font-size: $uni-font-size-sm; font-size: $uni-font-size-sm;
} }
.uni-ellipsis-1 { .uni-ellipsis-1 {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
overflow: hidden; overflow: hidden;
@ -438,6 +517,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
/* #endif */ /* #endif */
} }
.uni-ellipsis-2 { .uni-ellipsis-2 {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
overflow: hidden; overflow: hidden;

View File

@ -7,7 +7,10 @@
</view> </view>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list> <list :bounce="false" :scrollable="true" show-scrollbar :render-reverse="renderReverse" @scroll="scroll" class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop"
loadmoreoffset="15">
<slot />
</list>
<!-- #endif --> <!-- #endif -->
</template> </template>
@ -26,6 +29,10 @@ export default {
} }
}, },
props: { props: {
stackFromEnd:{
type: Boolean,
default:false
},
enableBackToTop: { enableBackToTop: {
type: [Boolean, String], type: [Boolean, String],
default: false default: false
@ -37,6 +44,10 @@ export default {
border: { border: {
type: Boolean, type: Boolean,
default: true default: true
},
renderReverse:{
type: Boolean,
default: false
} }
}, },
// provide() { // provide() {
@ -50,6 +61,9 @@ export default {
methods: { methods: {
loadMore(e) { loadMore(e) {
this.$emit('scrolltolower'); this.$emit('scrolltolower');
},
scroll(e) {
this.$emit('scroll', e);
} }
} }
}; };
@ -57,6 +71,7 @@ export default {
<style lang="scss"> <style lang="scss">
$uni-bg-color:#ffffff; $uni-bg-color:#ffffff;
$uni-border-color:#e5e5e5; $uni-border-color:#e5e5e5;
.uni-list { .uni-list {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-list", "id": "uni-list",
"displayName": "uni-list 列表", "displayName": "uni-list 列表",
"version": "1.2.1", "version": "1.2.14",
"description": "List 组件 ,帮助使用者快速构建列表。", "description": "List 组件 ,帮助使用者快速构建列表。",
"keywords": [ "keywords": [
"", "",
@ -19,10 +19,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -39,7 +35,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,7 @@
## 1.3.112023-03-29
- 修复 自定义状态栏高度闪动BUG
## 1.3.102023-03-29
- 修复 暗黑模式下边线颜色错误的bug
## 1.3.92022-10-13 ## 1.3.92022-10-13
- 修复 条件编译错误的bug - 修复 条件编译错误的bug
## 1.3.82022-10-12 ## 1.3.82022-10-12

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}"> <view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}">
<view class="uni-navbar__content" :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }" <view class="uni-navbar__content" :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }"
:style="{ 'background-color': themeBgColor }" > :style="{ 'background-color': themeBgColor, 'border-bottom-color':themeColor }" >
<status-bar v-if="statusBar" /> <status-bar v-if="statusBar" />
<view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}" <view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}"
class="uni-navbar__header"> class="uni-navbar__header">

View File

@ -9,11 +9,8 @@
name: 'UniStatusBar', name: 'UniStatusBar',
data() { data() {
return { return {
statusBarHeight: 20 statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px'
} }
},
mounted() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
} }
} }
</script> </script>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-nav-bar", "id": "uni-nav-bar",
"displayName": "uni-nav-bar 自定义导航栏", "displayName": "uni-nav-bar 自定义导航栏",
"version": "1.3.9", "version": "1.3.11",
"description": "自定义导航栏组件,主要用于头部导航。", "description": "自定义导航栏组件,主要用于头部导航。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@ -1,3 +1,11 @@
## 1.8.32023-04-17
- 修复 uni-popup 重复打开时的 bug
## 1.8.22023-02-02
- uni-popup-dialog 组件新增 inputType 属性
## 1.8.12022-12-01
- 修复 nvue 下 v-show 报错
## 1.8.02022-11-29
- 优化 主题样式
## 1.7.92022-04-02 ## 1.7.92022-04-02
- 修复 弹出层内部无法滚动的bug - 修复 弹出层内部无法滚动的bug
## 1.7.82022-03-28 ## 1.7.82022-03-28

View File

@ -10,7 +10,7 @@
</view> </view>
<view v-else class="uni-dialog-content"> <view v-else class="uni-dialog-content">
<slot> <slot>
<input class="uni-dialog-input" v-model="val" type="text" :placeholder="placeholderText" :focus="focus" > <input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText" :focus="focus" >
</slot> </slot>
</view> </view>
<view class="uni-dialog-button-group"> <view class="uni-dialog-button-group">
@ -57,6 +57,10 @@
mixins: [popup], mixins: [popup],
emits:['confirm','close'], emits:['confirm','close'],
props: { props: {
inputType:{
type: String,
default: 'text'
},
value: { value: {
type: [String, Number], type: [String, Number],
default: '' default: ''

View File

@ -1,10 +1,10 @@
<template> <template>
<view v-if="showPopup||onceRender" v-show="showPopup" class="uni-popup" :class="[popupstyle, isDesktop ? 'fixforpc-z-index' : '']"> <view v-if="showPopup" class="uni-popup" :class="[popupstyle, isDesktop ? 'fixforpc-z-index' : '']">
<view @touchstart="touchstart"> <view @touchstart="touchstart">
<uni-transition key="1" v-if="maskShow" name="mask" mode-class="fade" :styles="maskClass" <uni-transition key="1" v-if="maskShow" name="mask" mode-class="fade" :styles="maskClass"
:duration="duration" :show="showTrans" @click="onTap" /> :duration="duration" :show="showTrans" @click="onTap" />
<uni-transition key="2" :mode-class="ani" name="content" :styles="transClass" :duration="duration" <uni-transition key="2" :mode-class="ani" name="content" :styles="transClass" :duration="duration"
:show="showTrans" @click="onTap" :once-render="onceRender"> :show="showTrans" @click="onTap">
<view class="uni-popup__wrapper" :style="{ backgroundColor: bg }" :class="[popupstyle]" @click="clear"> <view class="uni-popup__wrapper" :style="{ backgroundColor: bg }" :class="[popupstyle]" @click="clear">
<slot /> <slot />
</view> </view>
@ -86,11 +86,6 @@
type: String, type: String,
default: 'rgba(0, 0, 0, 0.4)' default: 'rgba(0, 0, 0, 0.4)'
}, },
// 使v-showPop
onceRender:{
type:Boolean,
default:false
},
}, },
watch: { watch: {
@ -274,8 +269,7 @@
open(direction) { open(direction) {
// fix by mehaotian // fix by mehaotian
if (this.showPopup) { if (this.showPopup) {
clearTimeout(this.timer) return
this.showPopup = false
} }
let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share'] let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share']
if (!(direction && innerType.indexOf(direction) !== -1)) { if (!(direction && innerType.indexOf(direction) !== -1)) {

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-popup", "id": "uni-popup",
"displayName": "uni-popup 弹出层", "displayName": "uni-popup 弹出层",
"version": "1.7.9", "version": "1.8.3",
"description": " Popup 组件,提供常用的弹层", "description": " Popup 组件,提供常用的弹层",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -258,20 +258,21 @@
* 获取星星个数 * 获取星星个数
*/ */
_getRateCount(clientX) { _getRateCount(clientX) {
this._getSize() const _this = this;
const size = Number(this.size) this._getSize(function() {
const size = Number(_this.size)
if (isNaN(size)) { if (isNaN(size)) {
return new Error('size 属性只能设置为数字') return new Error('size 属性只能设置为数字')
} }
const rateMoveRange = clientX - this._rateBoxLeft const rateMoveRange = clientX - _this._rateBoxLeft
let index = parseInt(rateMoveRange / (size + this.marginNumber)) let index = parseInt(rateMoveRange / (size + _this.marginNumber))
index = index < 0 ? 0 : index; index = index < 0 ? 0 : index;
index = index > this.max ? this.max : index; index = index > _this.max ? _this.max : index;
const range = parseInt(rateMoveRange - (size + this.marginNumber) * index); const range = parseInt(rateMoveRange - (size + _this.marginNumber) * index);
let value = 0; let value = 0;
if (this._oldValue === index && !this.PC) return; if (_this._oldValue === index && !_this.PC) return;
this._oldValue = index; _this._oldValue = index;
if (this.allowHalf) { if (_this.allowHalf) {
if (range > (size / 2)) { if (range > (size / 2)) {
value = index + 1 value = index + 1
} else { } else {
@ -281,9 +282,10 @@
value = index + 1 value = index + 1
} }
value = Math.max(0.5, Math.min(value, this.max)) value = Math.max(0.5, Math.min(value, _this.max))
this.valueSync = value _this.valueSync = value
this._onChange() _this._onChange()
})
}, },
/** /**
@ -300,7 +302,7 @@
/** /**
* 获取星星距离屏幕左侧距离 * 获取星星距离屏幕左侧距离
*/ */
_getSize() { _getSize(fn) {
// #ifndef APP-NVUE // #ifndef APP-NVUE
uni.createSelectorQuery() uni.createSelectorQuery()
.in(this) .in(this)
@ -309,6 +311,7 @@
.exec(ret => { .exec(ret => {
if (ret) { if (ret) {
this._rateBoxLeft = ret[0].left this._rateBoxLeft = ret[0].left
fn && fn()
} }
}) })
// #endif // #endif
@ -317,6 +320,7 @@
const size = ret.size const size = ret.size
if (size) { if (size) {
this._rateBoxLeft = size.left this._rateBoxLeft = size.left
fn && fn()
} }
}) })
// #endif // #endif

View File

@ -5,7 +5,7 @@
index === currentIndex&&styleType === 'button' ? 'segmented-control__item--button--active': '', index === currentIndex&&styleType === 'button' ? 'segmented-control__item--button--active': '',
index === 0&&styleType === 'button' ? 'segmented-control__item--button--first': '', index === 0&&styleType === 'button' ? 'segmented-control__item--button--first': '',
index === values.length - 1&&styleType === 'button' ? 'segmented-control__item--button--last': '' ]" :key="index" index === values.length - 1&&styleType === 'button' ? 'segmented-control__item--button--last': '' ]" :key="index"
:style="{ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',borderColor: index === currentIndex&&styleType === 'text'||styleType === 'button'?activeColor:'transparent' }" :style="{ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',borderColor: index === currentIndex&&(styleType === 'text'||styleType === 'button')?activeColor:'#d9d9d9' }"
class="segmented-control__item" @click="_onClick(index)"> class="segmented-control__item" @click="_onClick(index)">
<view> <view>
<text :style="{color: <text :style="{color:

View File

@ -1,3 +1,5 @@
## 1.3.82023-04-13
- 修复`uni-swipe-action`和`uni-swipe-action-item`不同时使用导致 closeOther 方法报错的 bug
## 1.3.72022-06-06 ## 1.3.72022-06-06
- 修复 vue3 下使用组件不能正常运行的Bug - 修复 vue3 下使用组件不能正常运行的Bug
## 1.3.62022-05-31 ## 1.3.62022-05-31

View File

@ -31,7 +31,7 @@ bindIngXMixins = {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -74,7 +74,7 @@ bindIngXMixins = {
// 每次只触发一次,避免多次监听造成闪烁 // 每次只触发一次,避免多次监听造成闪烁
if (this.stop) return if (this.stop) return
this.stop = true this.stop = true
if (this.autoClose) { if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
} }

View File

@ -21,7 +21,7 @@ export default {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -65,7 +65,9 @@ export default {
touchstart(e) { touchstart(e) {
this.transition = false this.transition = false
this.isclose = true this.isclose = true
this.autoClose && this.swipeaction.closeOther(this) if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this)
}
}, },
touchmove(e) {}, touchmove(e) {},
touchend(e) { touchend(e) {

View File

@ -36,7 +36,7 @@ otherMixins = {
}, },
mounted() { mounted() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
this.init() this.init()
@ -53,8 +53,9 @@ otherMixins = {
}, },
closeSwipe(e) { closeSwipe(e) {
if (!this.autoClose) return if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
}
}, },
appTouchStart(e) { appTouchStart(e) {
const { const {

View File

@ -21,7 +21,7 @@ mpMixins = {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -31,8 +31,9 @@ mpMixins = {
methods: { methods: {
// wxs 中调用 // wxs 中调用
closeSwipe(e) { closeSwipe(e) {
if (!this.autoClose) return if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
}
}, },
change(e) { change(e) {

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-swipe-action", "id": "uni-swipe-action",
"displayName": "uni-swipe-action 滑动操作", "displayName": "uni-swipe-action 滑动操作",
"version": "1.3.7", "version": "1.3.8",
"description": "SwipeAction 滑动操作操作组件", "description": "SwipeAction 滑动操作操作组件",
"keywords": [ "keywords": [
"", "",

View File

@ -1,3 +1,7 @@
## 1.2.32023-03-28
- 修复 在vue3模式下可能会出现错误的问题
## 1.2.22022-11-29
- 优化 主题样式
## 1.2.12022-06-06 ## 1.2.12022-06-06
- 修复 微信小程序存在无使用组件的问题 - 修复 微信小程序存在无使用组件的问题
## 1.2.02021-11-19 ## 1.2.02021-11-19

View File

@ -3,9 +3,9 @@
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<table class="uni-table" border="0" cellpadding="0" cellspacing="0" :class="{ 'table--stripe': stripe }" :style="{ 'min-width': minWidth + 'px' }"> <table class="uni-table" border="0" cellpadding="0" cellspacing="0" :class="{ 'table--stripe': stripe }" :style="{ 'min-width': minWidth + 'px' }">
<slot></slot> <slot></slot>
<view v-if="noData" class="uni-table-loading"> <tr v-if="noData" class="uni-table-loading">
<view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view> <td class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</td>
</view> </tr>
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view> <view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
</table> </table>
<!-- #endif --> <!-- #endif -->

View File

@ -112,6 +112,12 @@
value: 'value' value: 'value'
} }
} }
},
filterDefaultValue: {
type: [Array,String],
default () {
return ""
}
} }
}, },
computed: { computed: {
@ -157,7 +163,7 @@
enabled: true, enabled: true,
isOpened: false, isOpened: false,
dataList: [], dataList: [],
filterValue: '', filterValue: this.filterDefaultValue,
checkedValues: [], checkedValues: [],
gtValue: '', gtValue: '',
ltValue: '', ltValue: '',
@ -286,6 +292,8 @@
</script> </script>
<style lang="scss"> <style lang="scss">
$uni-primary: #1890ff !default;
.flex-r { .flex-r {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -315,8 +323,8 @@
} }
.icon-select.active { .icon-select.active {
background-color: #1890ff; background-color: $uni-primary;
border-top-color: #1890ff; border-top-color: $uni-primary;
} }
.icon-search { .icon-search {
@ -343,11 +351,11 @@
} }
.icon-search.active .icon-search-0 { .icon-search.active .icon-search-0 {
border-color: #1890ff; border-color: $uni-primary;
} }
.icon-search.active .icon-search-1 { .icon-search.active .icon-search-1 {
background-color: #1890ff; background-color: $uni-primary;
} }
.icon-calendar { .icon-calendar {
@ -387,14 +395,14 @@
} }
.icon-calendar.active { .icon-calendar.active {
color: #1890ff; color: $uni-primary;
} }
.icon-calendar.active .icon-calendar-0, .icon-calendar.active .icon-calendar-0,
.icon-calendar.active .icon-calendar-1, .icon-calendar.active .icon-calendar-1,
.icon-calendar.active .icon-calendar-0:before, .icon-calendar.active .icon-calendar-0:before,
.icon-calendar.active .icon-calendar-0:after { .icon-calendar.active .icon-calendar-0:after {
background-color: #1890ff; background-color: $uni-primary;
} }
.uni-filter-dropdown { .uni-filter-dropdown {
@ -497,7 +505,7 @@
} }
.btn-submit { .btn-submit {
background-color: #1890ff; background-color: $uni-primary;
color: #ffffff; color: #ffffff;
} }
</style> </style>

View File

@ -9,7 +9,7 @@
<text class="arrow down" :class="{ active: descending }" @click.stop="descendingFn"></text> <text class="arrow down" :class="{ active: descending }" @click.stop="descendingFn"></text>
</view> </view>
</view> </view>
<dropdown v-if="filterType || filterData.length" :filterData="filterData" :filterType="filterType" @change="ondropdown"></dropdown> <dropdown v-if="filterType || filterData.length" :filterDefaultValue="filterDefaultValue" :filterData="filterData" :filterType="filterType" @change="ondropdown"></dropdown>
</view> </view>
</th> </th>
<!-- #endif --> <!-- #endif -->
@ -79,6 +79,12 @@ export default {
default () { default () {
return [] return []
} }
},
filterDefaultValue: {
type: [Array,String],
default () {
return ""
}
} }
}, },
data() { data() {
@ -200,6 +206,7 @@ export default {
<style lang="scss"> <style lang="scss">
$border-color: #ebeef5; $border-color: #ebeef5;
$uni-primary: #007aff !default;
.uni-table-th { .uni-table-th {
padding: 12px 10px; padding: 12px 10px;
@ -254,7 +261,7 @@ $border-color: #ebeef5;
} }
&.active { &.active {
::after { ::after {
background-color: #007aff; background-color: $uni-primary;
} }
} }
} }
@ -271,7 +278,7 @@ $border-color: #ebeef5;
} }
&.active { &.active {
::after { ::after {
background-color: #007aff; background-color: $uni-primary;
} }
} }
} }

View File

@ -77,7 +77,7 @@
</script> </script>
<style lang="scss"> <style lang="scss">
$checked-color: #007aff; $uni-primary: #007aff !default;
$border-color: #DCDFE6; $border-color: #DCDFE6;
$disable:0.4; $disable:0.4;
@ -125,8 +125,8 @@
} }
&.checkbox--indeterminate { &.checkbox--indeterminate {
border-color: $checked-color; border-color: $uni-primary;
background-color: $checked-color; background-color: $uni-primary;
.checkbox__inner-icon { .checkbox__inner-icon {
position: absolute; position: absolute;
@ -147,7 +147,7 @@
} }
} }
&:hover{ &:hover{
border-color: $checked-color; border-color: $uni-primary;
} }
// //
&.is-disable { &.is-disable {
@ -160,8 +160,8 @@
// //
&.is-checked { &.is-checked {
border-color: $checked-color; border-color: $uni-primary;
background-color: $checked-color; background-color: $uni-primary;
.checkbox__inner-icon { .checkbox__inner-icon {
opacity: 1; opacity: 1;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-table", "id": "uni-table",
"displayName": "uni-table 表格", "displayName": "uni-table 表格",
"version": "1.2.1", "version": "1.2.3",
"description": "表格组件,多用于展示多条结构类似的数据,如", "description": "表格组件,多用于展示多条结构类似的数据,如",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,10 +17,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -37,7 +33,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss","uni-datetime-picker"], "dependencies": ["uni-scss","uni-datetime-picker"],

View File

@ -10,7 +10,10 @@ const nvueAnimation = uni.requireNativePlugin('animation')
class MPAnimation { class MPAnimation {
constructor(options, _this) { constructor(options, _this) {
this.options = options this.options = options
this.animation = uni.createAnimation(options) // 在iOS10+QQ小程序平台下传给原生的对象一定是个普通对象而不是Proxy对象否则会报parameter should be Object instead of ProxyObject的错误
this.animation = uni.createAnimation({
...options
})
this.currentStepAnimates = {} this.currentStepAnimates = {}
this.next = 0 this.next = 0
this.$ = _this this.$ = _this