升级uni-ui到最新版本1.4.23

This commit is contained in:
RuoYi 2022-12-28 10:03:07 +08:00
parent 9bca5bebd5
commit 55fb5c5f61
52 changed files with 2907 additions and 2542 deletions

View File

@ -1,6 +1,7 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
baseUrl: 'http://localhost:8080', baseUrl: 'https://vue.ruoyi.vip/prod-api',
// baseUrl: 'http://localhost:8080',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@ -1,3 +1,5 @@
## 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)
## 1.2.02021-11-19 ## 1.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/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge)

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="uni-badge--x"> <view class="uni-badge--x">
<slot /> <slot />
<text v-if="text" :class="classNames" :style="[badgeWidth, positionStyle, customStyle, dotStyle]" <text v-if="text" :class="classNames" :style="[positionStyle, customStyle, dotStyle]"
class="uni-badge" @click="onClick()">{{displayValue}}</text> class="uni-badge" @click="onClick()">{{displayValue}}</text>
</view> </view>
</template> </template>
@ -130,16 +130,13 @@
const match = whiteList[this.absolute] const match = whiteList[this.absolute]
return match ? match : whiteList['rightTop'] return match ? match : whiteList['rightTop']
}, },
badgeWidth() {
return {
width: `${this.width}px`
}
},
dotStyle() { dotStyle() {
if (!this.isDot) return {} if (!this.isDot) return {}
return { return {
width: '10px', width: '10px',
minWidth: '0',
height: '10px', height: '10px',
padding: '0',
borderRadius: '10px' borderRadius: '10px'
} }
}, },
@ -199,6 +196,8 @@
justify-content: center; justify-content: center;
flex-direction: row; flex-direction: row;
height: 20px; height: 20px;
min-width: 20px;
padding: 0 4px;
line-height: 18px; line-height: 18px;
color: #fff; color: #fff;
border-radius: 100px; border-radius: 100px;
@ -207,6 +206,7 @@
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.0", "version": "1.2.1",
"description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。", "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
"keywords": [ "keywords": [
"", "",
@ -18,11 +18,7 @@
"directories": { "directories": {
"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": ["uni-scss"], "dependencies": ["uni-scss"],

View File

@ -1,3 +1,7 @@
## 1.4.72022-09-16
- 可以使用 uni-scss 控制主题色
## 1.4.62022-09-08
- fix: 表头年月切换导致改变当前日期为选择月1号且未触发change事件
## 1.4.52022-02-25 ## 1.4.52022-02-25
- 修复 条件编译 nvue 不支持的 css 样式 - 修复 条件编译 nvue 不支持的 css 样式
## 1.4.42022-02-25 ## 1.4.42022-02-25

View File

@ -102,7 +102,7 @@
$uni-color-error: #e43d33; $uni-color-error: #e43d33;
$uni-opacity-disabled: 0.3; $uni-opacity-disabled: 0.3;
$uni-text-color-disable:#c0c0c0; $uni-text-color-disable:#c0c0c0;
$uni-color-primary: #2979ff; $uni-primary: #2979ff !default;
.uni-calendar-item__weeks-box { .uni-calendar-item__weeks-box {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -152,11 +152,11 @@
} }
.uni-calendar-item--isDay-text { .uni-calendar-item--isDay-text {
color: $uni-color-primary; color: $uni-primary;
} }
.uni-calendar-item--isDay { .uni-calendar-item--isDay {
background-color: $uni-color-primary; background-color: $uni-primary;
opacity: 0.8; opacity: 0.8;
color: #fff; color: #fff;
} }
@ -167,13 +167,13 @@
} }
.uni-calendar-item--checked { .uni-calendar-item--checked {
background-color: $uni-color-primary; background-color: $uni-primary;
color: #fff; color: #fff;
opacity: 0.8; opacity: 0.8;
} }
.uni-calendar-item--multiple { .uni-calendar-item--multiple {
background-color: $uni-color-primary; background-color: $uni-primary;
color: #fff; color: #fff;
opacity: 0.8; opacity: 0.8;
} }

View File

@ -218,7 +218,7 @@
bindDateChange(e) { bindDateChange(e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
console.log(this.cale.getDate(value)); console.log(this.cale.getDate(value));
this.init(value) this.setDate(value)
}, },
/** /**
* 初始化日期显示 * 初始化日期显示

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-calendar", "id": "uni-calendar",
"displayName": "uni-calendar 日历", "displayName": "uni-calendar 日历",
"version": "1.4.5", "version": "1.4.7",
"description": "日历组件", "description": "日历组件",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,11 +18,7 @@
"directories": { "directories": {
"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,5 @@
## 1.0.32022-09-16
- 可以使用 uni-scss 控制主题色
## 1.0.22022-06-30 ## 1.0.22022-06-30
- 优化 在 uni-forms 中的依赖注入方式 - 优化 在 uni-forms 中的依赖注入方式
## 1.0.12022-02-07 ## 1.0.12022-02-07

View File

@ -383,12 +383,14 @@
*/ */
setStyleBackgroud(item) { setStyleBackgroud(item) {
let styles = {} let styles = {}
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
if (this.mode !== 'list') { if (this.selectedColor) {
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' if (this.mode !== 'list') {
} styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
if (this.mode === 'tag') { }
styles['background-color'] = item.selected? selectedColor:'#f5f5f5' if (this.mode === 'tag') {
styles['background-color'] = item.selected? selectedColor:'#f5f5f5'
}
} }
let classles = '' let classles = ''
for (let i in styles) { for (let i in styles) {
@ -398,16 +400,17 @@
}, },
setStyleIcon(item) { setStyleIcon(item) {
let styles = {} let styles = {}
let classles = '' let classles = ''
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' if (this.selectedColor) {
styles['background-color'] = item.selected?selectedColor:'#fff' let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' styles['background-color'] = item.selected?selectedColor:'#fff'
styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
if(!item.selected && item.disabled){
styles['background-color'] = '#F2F6FC' if(!item.selected && item.disabled){
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' styles['background-color'] = '#F2F6FC'
styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
}
} }
for (let i in styles) { for (let i in styles) {
classles += `${i}:${styles[i]};` classles += `${i}:${styles[i]};`
} }
@ -415,17 +418,18 @@
}, },
setStyleIconText(item) { setStyleIconText(item) {
let styles = {} let styles = {}
let classles = '' let classles = ''
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' if (this.selectedColor) {
if (this.mode === 'tag') { let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666' if (this.mode === 'tag') {
} else { styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666'
styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:selectedColor):'#666' } else {
styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:selectedColor):'#666'
}
if(!item.selected && item.disabled){
styles.color = '#999'
}
} }
if(!item.selected && item.disabled){
styles.color = '#999'
}
for (let i in styles) { for (let i in styles) {
classles += `${i}:${styles[i]};` classles += `${i}:${styles[i]};`
} }
@ -448,7 +452,7 @@
</script> </script>
<style lang="scss"> <style lang="scss">
$checked-color: #2979ff; $uni-primary: #2979ff !default;
$border-color: #DCDFE6; $border-color: #DCDFE6;
$disable:0.4; $disable:0.4;
@ -614,8 +618,8 @@
// //
&.is-checked { &.is-checked {
.checkbox__inner { .checkbox__inner {
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;
@ -623,14 +627,14 @@
} }
} }
.radio__inner { .radio__inner {
border-color: $checked-color; border-color: $uni-primary;
.radio__inner-icon { .radio__inner-icon {
opacity: 1; opacity: 1;
background-color: $checked-color; background-color: $uni-primary;
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
// //
&.is-disable { &.is-disable {
@ -683,10 +687,10 @@
} }
&.is-checked { &.is-checked {
border-color: $checked-color; border-color: $uni-primary;
.checkbox__inner { .checkbox__inner {
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;
transform: rotate(45deg); transform: rotate(45deg);
@ -694,16 +698,16 @@
} }
.radio__inner { .radio__inner {
border-color: $checked-color; border-color: $uni-primary;
.radio__inner-icon { .radio__inner-icon {
opacity: 1; opacity: 1;
background-color: $checked-color; background-color: $uni-primary;
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
// //
@ -735,8 +739,8 @@
} }
&.is-checked { &.is-checked {
background-color: $checked-color; background-color: $uni-primary;
border-color: $checked-color; border-color: $uni-primary;
.checklist-text { .checklist-text {
color: #fff; color: #fff;
@ -775,8 +779,8 @@
&.is-checked { &.is-checked {
.checkbox__inner { .checkbox__inner {
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;
@ -789,13 +793,13 @@
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
.checklist-content { .checklist-content {
.checkobx__list { .checkobx__list {
opacity: 1; opacity: 1;
border-color: $checked-color; border-color: $uni-primary;
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-checkbox", "id": "uni-data-checkbox",
"displayName": "uni-data-checkbox 数据选择器", "displayName": "uni-data-checkbox 数据选择器",
"version": "1.0.2", "version": "1.0.3",
"description": "通过数据驱动的单选框和复选框", "description": "通过数据驱动的单选框和复选框",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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": ["uni-load-more","uni-scss"], "dependencies": ["uni-load-more","uni-scss"],

View File

@ -1,3 +1,5 @@
## 1.0.82022-09-16
- 可以使用 uni-scss 控制主题色
## 1.0.72022-07-06 ## 1.0.72022-07-06
- 优化 pc端图标位置不正确的问题 - 优化 pc端图标位置不正确的问题
## 1.0.62022-07-05 ## 1.0.62022-07-05

View File

@ -42,7 +42,7 @@ export default {
}, },
pageSize: { pageSize: {
type: Number, type: Number,
default: 20 default: 500
}, },
getcount: { getcount: {
type: [Boolean, String], type: [Boolean, String],
@ -94,7 +94,7 @@ export default {
}, },
map: { map: {
type: Object, type: Object,
default() { default () {
return { return {
text: "text", text: "text",
value: "value" value: "value"
@ -122,19 +122,22 @@ export default {
} }
}, },
computed: { computed: {
isLocaldata() { isLocalData() {
return !this.collection.length return !this.collection.length;
}, },
postField() { isCloudData() {
let fields = [this.field]; return this.collection.length > 0;
if (this.parentField) { },
fields.push(`${this.parentField} as parent_value`); isCloudDataList() {
} return (this.isCloudData && (!this.parentField && !this.selfField));
return fields.join(','); },
isCloudDataTree() {
return (this.isCloudData && this.parentField && this.selfField);
}, },
dataValue() { dataValue() {
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined) let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
return isModelValue ? this.modelValue : this.value this.modelValue !== undefined);
return isModelValue ? this.modelValue : this.value;
}, },
hasValue() { hasValue() {
if (typeof this.dataValue === 'number') { if (typeof this.dataValue === 'number') {
@ -183,8 +186,169 @@ export default {
}, },
methods: { methods: {
onPropsChange() { onPropsChange() {
this._treeData = [] this._treeData = [];
}, },
// 填充 pickview 数据
async loadData() {
if (this.isLocalData) {
this.loadLocalData();
} else if (this.isCloudDataList) {
this.loadCloudDataList();
} else if (this.isCloudDataTree) {
this.loadCloudDataTree();
}
},
// 加载本地数据
async loadLocalData() {
this._treeData = [];
this._extractTree(this.localdata, this._treeData);
let inputValue = this.dataValue;
if (inputValue === undefined) {
return;
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1];
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value];
}
}
this.selected = this._findNodePath(inputValue, this.localdata);
},
// 加载 Cloud 数据 (单列)
async loadCloudDataList() {
if (this.loading) {
return;
}
this.loading = true;
try {
let response = await this.getCommand();
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (树形)
async loadCloudDataTree() {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataTreeWhere()
};
if (this.gettree) {
commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
}
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (节点)
async loadCloudDataNode(callback) {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataNodeWhere()
};
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
callback(responseData);
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 回显 Cloud 数据
getCloudDataValue() {
if (this.isCloudDataList) {
return this.getCloudDataListValue();
}
if (this.isCloudDataTree) {
return this.getCloudDataTreeValue();
}
},
// 回显 Cloud 数据 (单列)
getCloudDataListValue() {
// 根据 field's as value标识匹配 where 条件
let where = [];
let whereField = this._getForeignKeyByField();
if (whereField) {
where.push(`${whereField} == '${this.dataValue}'`)
}
where = where.join(' || ');
if (this.where) {
where = `(${this.where}) && (${where})`
}
return this.getCommand({
field: this._cloudDataPostField(),
where
}).then((res) => {
this.selected = res.result.data;
return res.result.data;
});
},
// 回显 Cloud 数据 (树形)
getCloudDataTreeValue() {
return this.getCommand({
field: this._cloudDataPostField(),
getTreePath: {
startWith: `${this.selfField}=='${this.dataValue}'`
}
}).then((res) => {
let treePath = [];
this._extractTreePath(res.result.data, treePath);
this.selected = treePath;
return treePath;
});
},
getCommand(options = {}) { getCommand(options = {}) {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
let db = uniCloud.database(this.spaceInfo) let db = uniCloud.database(this.spaceInfo)
@ -229,125 +393,16 @@ export default {
return db return db
}, },
getNodeData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: this._pathWhere()
}).then((res) => {
this.loading = false
this.selected = res.result.data
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
getTreePath(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({ _cloudDataPostField() {
field: this.postField, let fields = [this.field];
getTreePath: { if (this.parentField) {
startWith: `${this.selfField}=='${this.dataValue}'` fields.push(`${this.parentField} as parent_value`);
} }
}).then((res) => { return fields.join(',');
this.loading = false
let treePath = []
this._extractTreePath(res.result.data, treePath)
this.selected = treePath
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
}, },
loadData() {
if (this.isLocaldata) {
this._processLocalData()
return
}
if (this.dataValue != null) { _cloudDataTreeWhere() {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
this._updateSelected()
})
return
}
if (this.stepSearh) {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
})
} else {
this._loadAllData((data) => {
this._treeData = []
this._extractTree(data, this._treeData, null)
this._updateBindData()
})
}
},
_loadAllData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
gettree: true,
startwith: `${this.selfField}=='${this.dataValue}'`
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_loadNodeData(callback, pw) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: pw || this._postWhere(),
pageSize: 500
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_pathWhere() {
let result = []
let where_field = this._getParentNameByField();
if (where_field) {
result.push(`${where_field} == '${this.dataValue}'`)
}
if (this.where) {
return `(${this.where}) && (${result.join(' || ')})`
}
return result.join(' || ')
},
_postWhere() {
let result = [] let result = []
let selected = this.selected let selected = this.selected
let parentField = this.parentField let parentField = this.parentField
@ -364,17 +419,35 @@ export default {
if (this.where) { if (this.where) {
where.push(`(${this.where})`) where.push(`(${this.where})`)
} }
if (result.length) { if (result.length) {
where.push(`(${result.join(' || ')})`) where.push(`(${result.join(' || ')})`)
} }
return where.join(' && ') return where.join(' && ')
}, },
_nodeWhere() {
let result = [] _cloudDataNodeWhere() {
let selected = this.selected let where = []
let selected = this.selected;
if (selected.length) { if (selected.length) {
result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`) where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
}
where = where.join(' || ');
if (this.where) {
return `(${this.where}) && (${where})`
}
return where
},
_getWhereByForeignKey() {
let result = []
let whereField = this._getForeignKeyByField();
if (whereField) {
result.push(`${whereField} == '${this.dataValue}'`)
} }
if (this.where) { if (this.where) {
@ -383,41 +456,23 @@ export default {
return result.join(' || ') return result.join(' || ')
}, },
_getParentNameByField() {
const fields = this.field.split(','); _getForeignKeyByField() {
let where_field = null; let fields = this.field.split(',');
let whereField = null;
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
const items = fields[i].split('as'); const items = fields[i].split('as');
if (items.length < 2) { if (items.length < 2) {
continue; continue;
} }
if (items[1].trim() === 'value') { if (items[1].trim() === 'value') {
where_field = items[0].trim(); whereField = items[0].trim();
break; break;
} }
} }
return where_field return whereField;
},
_isTreeView() {
return (this.parentField && this.selfField)
},
_updateSelected() {
var dl = this.dataList
var sl = this.selected
let textField = this.map.text
let valueField = this.map.value
for (var i = 0; i < sl.length; i++) {
var value = sl[i].value
var dl2 = dl[i]
for (var j = 0; j < dl2.length; j++) {
var item2 = dl2[j]
if (item2[valueField] === value) {
sl[i].text = item2[textField]
break
}
}
}
}, },
_updateBindData(node) { _updateBindData(node) {
const { const {
dataList, dataList,
@ -445,6 +500,25 @@ export default {
hasNodes hasNodes
} }
}, },
_updateSelected() {
let dl = this.dataList
let sl = this.selected
let textField = this.map.text
let valueField = this.map.value
for (let i = 0; i < sl.length; i++) {
let value = sl[i].value
let dl2 = dl[i]
for (let j = 0; j < dl2.length; j++) {
let item2 = dl2[j]
if (item2[valueField] === value) {
sl[i].text = item2[textField]
break
}
}
}
},
_filterData(data, paths) { _filterData(data, paths) {
let dataList = [] let dataList = []
let hasNodes = true let hasNodes = true
@ -453,8 +527,8 @@ export default {
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '') return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
})) }))
for (let i = 0; i < paths.length; i++) { for (let i = 0; i < paths.length; i++) {
var value = paths[i].value let value = paths[i].value
var nodes = data.filter((item) => { let nodes = data.filter((item) => {
return item.parent_value === value return item.parent_value === value
}) })
@ -470,6 +544,7 @@ export default {
hasNodes hasNodes
} }
}, },
_extractTree(nodes, result, parent_value) { _extractTree(nodes, result, parent_value) {
let list = result || [] let list = result || []
let valueField = this.map.value let valueField = this.map.value
@ -493,6 +568,7 @@ export default {
} }
} }
}, },
_extractTreePath(nodes, result) { _extractTreePath(nodes, result) {
let list = result || [] let list = result || []
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
@ -512,6 +588,7 @@ export default {
} }
} }
}, },
_findNodePath(key, nodes, path = []) { _findNodePath(key, nodes, path = []) {
let textField = this.map.text let textField = this.map.text
let valueField = this.map.value let valueField = this.map.value
@ -540,24 +617,6 @@ export default {
path.pop() path.pop()
} }
return [] return []
},
_processLocalData() {
this._treeData = []
this._extractTree(this.localdata, this._treeData)
var inputValue = this.dataValue
if (inputValue === undefined) {
return
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1]
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value]
}
}
this.selected = this._findNodePath(inputValue, this.localdata)
} }
} }
} }

View File

@ -1,183 +1,172 @@
<template> <template>
<view class="uni-data-pickerview"> <view class="uni-data-pickerview">
<scroll-view class="selected-area" scroll-x="true" scroll-y="false" :show-scrollbar="false"> <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"> <template v-for="(item,index) in selected">
<view class="selected-item" <view class="selected-item"
:class="{'selected-item-active':index==selectedIndex, 'selected-item-text-overflow': ellipsis}" :class="{'selected-item-active':index==selectedIndex}"
v-if="item.text" @click="handleSelect(index)"> v-if="item.text" @click="handleSelect(index)">
<text class="">{{item.text}}</text> <text>{{item.text}}</text>
</view> </view>
</template> </template>
</view> </view>
</scroll-view> </scroll-view>
<view class="tab-c"> <view class="tab-c">
<template v-for="(child, i) in dataList" > <template v-for="(child, i) in dataList">
<scroll-view class="list" :key="i" v-if="i==selectedIndex" :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 child" <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child"
@click="handleNodeClick(item, i, j)"> @click="handleNodeClick(item, i, j)">
<text class="item-text item-text-overflow">{{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 > i && item[map.value] == selected[i].value"></view>
</view> </view>
</scroll-view> </scroll-view>
</template> </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> </view>
<view class="error-message" v-if="errorMessage"> <view class="error-message" v-if="errorMessage">
<text class="error-text">{{errorMessage}}</text> <text class="error-text">{{errorMessage}}</text>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import dataPicker from "./uni-data-picker.js" import dataPicker from "./uni-data-picker.js"
/** /**
* DataPickerview * DataPickerview
* @description uni-data-pickerview * @description uni-data-pickerview
* @tutorial https://ext.dcloud.net.cn/plugin?id=3796 * @tutorial https://ext.dcloud.net.cn/plugin?id=3796
* @property {Array} localdata 本地数据参考 * @property {Array} localdata 本地数据参考
* @property {Boolean} step-searh = [true|false] 是否分布查询 * @property {Boolean} step-searh = [true|false] 是否分布查询
* @value true 启用分布查询仅查询当前选中节点 * @value true 启用分布查询仅查询当前选中节点
* @value false 关闭分布查询一次查询出所有数据 * @value false 关闭分布查询一次查询出所有数据
* @property {String|DBFieldString} self-field 分布查询当前字段名称 * @property {String|DBFieldString} self-field 分布查询当前字段名称
* @property {String|DBFieldString} parent-field 分布查询父字段名称 * @property {String|DBFieldString} parent-field 分布查询父字段名称
* @property {String|DBCollectionString} collection 表名 * @property {String|DBCollectionString} collection 表名
* @property {String|DBFieldString} field 查询字段多个字段用 `,` 分割 * @property {String|DBFieldString} field 查询字段多个字段用 `,` 分割
* @property {String} orderby 排序字段及正序倒叙设置 * @property {String} orderby 排序字段及正序倒叙设置
* @property {String|JQLString} where 查询条件 * @property {String|JQLString} where 查询条件
*/ */
export default { export default {
name: 'UniDataPickerView', name: 'UniDataPickerView',
emits: ['nodeclick', 'change', 'datachange', 'update:modelValue'], emits: ['nodeclick', 'change', 'datachange', 'update:modelValue'],
mixins: [dataPicker], mixins: [dataPicker],
props: { props: {
managedMode: { managedMode: {
type: Boolean, type: Boolean,
default: false default: false
}, },
ellipsis: { ellipsis: {
type: Boolean, type: Boolean,
default: true default: true
} }
}, },
data() { created() {
return {} if (!this.managedMode) {
}, this.$nextTick(() => {
created() { this.loadData();
if (this.managedMode) { })
return }
} },
methods: {
onPropsChange() {
this._treeData = [];
this.selectedIndex = 0;
this.$nextTick(() => {
this.loadData();
})
},
handleSelect(index) {
this.selectedIndex = index;
},
handleNodeClick(item, i, j) {
if (item.disable) {
return;
}
this.$nextTick(() => { const node = this.dataList[i][j];
this.load() const text = node[this.map.text];
}) const value = node[this.map.value];
},
methods: {
onPropsChange() {
this._treeData = []
this.selectedIndex = 0
this.load()
},
load() {
if (this.isLocaldata) {
this.loadData()
} else if (this.dataValue.length) {
this.getTreePath((res) => {
this.loadData()
})
}
},
handleSelect(index) {
this.selectedIndex = index
},
handleNodeClick(item, i, j) {
if (item.disable) {
return
}
const node = this.dataList[i][j]
const text = node[this.map.text]
const value = node[this.map.value]
if (i < this.selected.length - 1) {
this.selected.splice(i, this.selected.length - i)
this.selected.push({
text,
value
})
} else if (i === this.selected.length - 1) {
this.selected.splice(i, 1, {
text,
value
})
}
if (node.isleaf) { if (i < this.selected.length - 1) {
this.onSelectedChange(node, node.isleaf) this.selected.splice(i, this.selected.length - i)
return this.selected.push({
} text,
value
})
} else if (i === this.selected.length - 1) {
this.selected.splice(i, 1, {
text,
value
})
}
const { if (node.isleaf) {
isleaf, this.onSelectedChange(node, node.isleaf)
hasNodes return
} = this._updateBindData() }
if (!this._isTreeView() && !hasNodes) { const {
this.onSelectedChange(node, true) isleaf,
return hasNodes
} } = this._updateBindData()
if (this.isLocaldata && (!hasNodes || isleaf)) { //
this.onSelectedChange(node, true) if (this.isLocalData) {
return this.onSelectedChange(node, (!hasNodes || isleaf))
} } else if (this.isCloudDataList) { // Cloud ()
this.onSelectedChange(node, true)
} else if (this.isCloudDataTree) { // Cloud ()
if (isleaf) {
this.onSelectedChange(node, node.isleaf)
} else if (!hasNodes) { //
this.loadCloudDataNode((data) => {
if (!data.length) {
node.isleaf = true
} else {
this._treeData.push(...data)
this._updateBindData(node)
}
this.onSelectedChange(node, node.isleaf)
})
}
}
},
updateData(data) {
this._treeData = data.treeData
this.selected = data.selected
if (!this._treeData.length) {
this.loadData()
} else {
//this.selected = data.selected
this._updateBindData()
}
},
onDataChange() {
this.$emit('datachange');
},
onSelectedChange(node, isleaf) {
if (isleaf) {
this._dispatchEvent()
}
if (!isleaf && !hasNodes) { if (node) {
this._loadNodeData((data) => { this.$emit('nodeclick', node)
if (!data.length) { }
node.isleaf = true },
} else { _dispatchEvent() {
this._treeData.push(...data) this.$emit('change', this.selected.slice(0))
this._updateBindData(node) }
} }
this.onSelectedChange(node, node.isleaf) }
}, this._nodeWhere())
return
}
this.onSelectedChange(node, false)
},
updateData(data) {
this._treeData = data.treeData
this.selected = data.selected
if (!this._treeData.length) {
this.loadData()
} else {
//this.selected = data.selected
this._updateBindData()
}
},
onDataChange() {
this.$emit('datachange')
},
onSelectedChange(node, isleaf) {
if (isleaf) {
this._dispatchEvent()
}
if (node) {
this.$emit('nodeclick', node)
}
},
_dispatchEvent() {
this.$emit('change', this.selected.slice(0))
}
}
}
</script> </script>
<style >
<style lang="scss">
$uni-primary: #007aff !default;
.uni-data-pickerview { .uni-data-pickerview {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -188,138 +177,137 @@
height: 100%; height: 100%;
} }
.error-text { .error-text {
color: #DD524D; color: #DD524D;
} }
.loading-cover { .loading-cover {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: rgba(255, 255, 255, .5); background-color: rgba(255, 255, 255, .5);
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
z-index: 1001; z-index: 1001;
} }
.load-more { .load-more {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
margin: auto; margin: auto;
/* #endif */ /* #endif */
} }
.error-message { .error-message {
background-color: #fff; background-color: #fff;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
padding: 15px; padding: 15px;
opacity: .9; opacity: .9;
z-index: 102; z-index: 102;
} }
/* #ifdef APP-NVUE */ /* #ifdef APP-NVUE */
.selected-area { .selected-area {
width: 750rpx; width: 750rpx;
} }
/* #endif */
/* #endif */ .selected-list {
/* #ifndef APP-NVUE */
display: flex;
flex-wrap: nowrap;
/* #endif */
flex-direction: row;
padding: 0 5px;
border-bottom: 1px solid #f8f8f8;
}
.selected-list { .selected-item {
/* #ifndef APP-NVUE */ margin-left: 10px;
display: flex; margin-right: 10px;
/* #endif */ padding: 12px 0;
flex-direction: row; text-align: center;
flex-wrap: nowrap; /* #ifndef APP-NVUE */
padding: 0 5px; white-space: nowrap;
border-bottom: 1px solid #f8f8f8; /* #endif */
} }
.selected-item { .selected-item-text-overflow {
margin-left: 10px; width: 168px;
margin-right: 10px; /* fix nvue */
padding: 12px 0; overflow: hidden;
text-align: center; /* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */ width: 6em;
white-space: nowrap; white-space: nowrap;
/* #endif */ text-overflow: ellipsis;
} -o-text-overflow: ellipsis;
/* #endif */
.selected-item-text-overflow { }
width: 168px;
/* fix nvue */
overflow: hidden;
/* #ifndef APP-NVUE */
width: 6em;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
/* #endif */
}
.selected-item-active { .selected-item-active {
border-bottom: 2px solid #007aff; border-bottom: 2px solid $uni-primary;
} }
.selected-item-text { .selected-item-text {
color: #007aff; color: $uni-primary;
} }
.tab-c { .tab-c {
position: relative; position: relative;
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
overflow: hidden; overflow: hidden;
} }
.list { .list {
flex: 1; flex: 1;
} }
.item { .item {
padding: 12px 15px; padding: 12px 15px;
/* border-bottom: 1px solid #f0f0f0; */ /* border-bottom: 1px solid #f0f0f0; */
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
} }
.is-disabled { .is-disabled {
opacity: .5; opacity: .5;
} }
.item-text { .item-text {
/* flex: 1; */ /* flex: 1; */
color: #333333; color: #333333;
} }
.item-text-overflow { .item-text-overflow {
width: 280px; width: 280px;
/* fix nvue */ /* fix nvue */
overflow: hidden; overflow: hidden;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
width: 20em; width: 20em;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
-o-text-overflow: ellipsis; -o-text-overflow: ellipsis;
/* #endif */ /* #endif */
} }
.check { .check {
margin-right: 5px; margin-right: 5px;
border: 2px solid #007aff; border: 2px solid $uni-primary;
border-left: 0; border-left: 0;
border-top: 0; border-top: 0;
height: 12px; height: 12px;
@ -330,4 +318,4 @@
/* #endif */ /* #endif */
transform: rotate(45deg); transform: rotate(45deg);
} }
</style> </style>

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.7", "version": "1.0.8",
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景", "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,11 +18,7 @@
"directories": { "directories": {
"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": [
@ -56,7 +53,7 @@
"client": { "client": {
"App": { "App": {
"app-vue": "y", "app-vue": "y",
"app-nvue": "y" "app-nvue": "u"
}, },
"H5-mobile": { "H5-mobile": {
"Safari": "y", "Safari": "y",

View File

@ -1,3 +1,9 @@
## 0.1.92022-09-05
- 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
## 0.1.82022-08-29
- 修复 点击的位置不准确
## 0.1.72022-08-12
- 新增 支持 disabled 属性
## 0.1.62022-07-06 ## 0.1.62022-07-06
- 修复 pc端宽度异常的bug - 修复 pc端宽度异常的bug
## 0.1.5 ## 0.1.5

View File

@ -2,7 +2,7 @@
<view class="uni-stat__select"> <view class="uni-stat__select">
<span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span> <span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span>
<view class="uni-stat-box" :class="{'uni-stat__actived': current}"> <view class="uni-stat-box" :class="{'uni-stat__actived': current}">
<view class="uni-select"> <view class="uni-select" :class="{'uni-select--disabled':disabled}">
<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>
@ -39,6 +39,7 @@
* @property {Boolean} emptyText 没有数据时显示的文字 本地数据无效 * @property {Boolean} emptyText 没有数据时显示的文字 本地数据无效
* @property {String} label 左侧标题 * @property {String} label 左侧标题
* @property {String} placeholder 输入框的提示文字 * @property {String} placeholder 输入框的提示文字
* @property {Boolean} disabled 是否禁用
* @event {Function} change 选中发生变化触发 * @event {Function} change 选中发生变化触发
*/ */
@ -88,6 +89,10 @@
defItem: { defItem: {
type: Number, type: Number,
default: 0 default: 0
},
disabled: {
type: Boolean,
default: false
} }
}, },
created() { created() {
@ -204,6 +209,10 @@
}, },
toggleSelector() { toggleSelector() {
if(this.disabled){
return
}
this.showSelector = !this.showSelector this.showSelector = !this.showSelector
}, },
formatItemName(item) { formatItemName(item) {
@ -248,15 +257,15 @@
width: 100%; width: 100%;
flex: 1; flex: 1;
box-sizing: border-box; box-sizing: border-box;
} }
.uni-stat-box { .uni-stat-box {
width: 100%; width: 100%;
flex: 1; flex: 1;
} }
.uni-stat__actived { .uni-stat__actived {
width: 100%; width: 100%;
flex: 1; flex: 1;
// outline: 1px solid #2979ff; // outline: 1px solid #2979ff;
} }
@ -287,6 +296,11 @@
width: 100%; width: 100%;
flex: 1; flex: 1;
height: 35px; height: 35px;
&--disabled{
background-color: #f5f7fa;
cursor: not-allowed;
}
} }
.uni-select__label { .uni-select__label {
@ -298,7 +312,7 @@
} }
.uni-select__input-box { .uni-select__input-box {
// height: 35px; height: 35px;
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -332,7 +346,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;
} }
@ -423,4 +437,4 @@
right: 0; right: 0;
left: 0; left: 0;
} }
</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.6", "version": "0.1.9",
"description": "通过数据驱动的下拉框选择器", "description": "通过数据驱动的下拉框选择器",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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": ["uni-load-more"], "dependencies": ["uni-load-more"],

View File

@ -1,3 +1,13 @@
## 2.2.112022-09-19
- 修复,支付宝小程序样式错乱,[详情](https://github.com/dcloudio/uni-app/issues/3861)
## 2.2.102022-09-19
- 修复,反向选择日期范围,日期显示异常,[详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
## 2.2.92022-09-16
- 可以使用 uni-scss 控制主题色
## 2.2.82022-09-08
- 修复 close事件无效的 bug
## 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)
## 2.2.62022-06-30 ## 2.2.62022-06-30
- 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致 - 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致
## 2.2.52022-06-24 ## 2.2.52022-06-24

View File

@ -61,7 +61,9 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" >
$uni-primary: #007aff !default;
.uni-calendar-item__weeks-box { .uni-calendar-item__weeks-box {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -78,7 +80,7 @@
font-size: 14px; font-size: 14px;
// font-family: Lato-Bold, Lato; // font-family: Lato-Bold, Lato;
font-weight: bold; font-weight: bold;
color: #455997; color: darken($color: $uni-primary, $amount: 40%);
} }
.uni-calendar-item__weeks-lunar-text { .uni-calendar-item__weeks-lunar-text {
@ -138,7 +140,7 @@
} }
.uni-calendar-item__weeks-box .uni-calendar-item--checked { .uni-calendar-item__weeks-box .uni-calendar-item--checked {
background-color: #007aff; background-color: $uni-primary;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
border: 3px solid #fff; border: 3px solid #fff;
@ -159,7 +161,7 @@
.uni-calendar-item--multiple .uni-calendar-item--before-checked, .uni-calendar-item--multiple .uni-calendar-item--before-checked,
.uni-calendar-item--multiple .uni-calendar-item--after-checked { .uni-calendar-item--multiple .uni-calendar-item--after-checked {
background-color: #409eff; background-color: $uni-primary;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
border: 3px solid #F6F7FC; border: 3px solid #F6F7FC;

View File

@ -1,7 +1,7 @@
<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"></view> @click="clean();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}">
@ -73,8 +73,10 @@
<time-picker type="time" :start="reactStartTime" v-model="timeRange.startTime" :border="false" <time-picker type="time" :start="reactStartTime" 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 style="line-height: 50px;">
<uni-icons type="arrowthinright" color="#999"></uni-icons>
</view> </view>
<uni-icons type="arrowthinright" color="#999" style="line-height: 50px;"></uni-icons>
<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="reactEndTime" v-model="timeRange.endTime" :border="false"
@ -331,12 +333,12 @@
}, },
okText() { okText() {
return t("uni-datetime-picker.ok") return t("uni-datetime-picker.ok")
}, },
yearText() { yearText() {
return t("uni-datetime-picker.year") return t("uni-datetime-picker.year")
}, },
monthText() { monthText() {
return t("uni-datetime-picker.month") return t("uni-datetime-picker.month")
}, },
MONText() { MONText() {
return t("uni-calender.MON") return t("uni-calender.MON")
@ -411,6 +413,11 @@
this.close() this.close()
}, },
//
maskClick() {
this.$emit('maskClose')
},
clearCalender() { clearCalender() {
if (this.range) { if (this.range) {
this.timeRange.startTime = '' this.timeRange.startTime = ''
@ -538,16 +545,24 @@
* 选择天触发 * 选择天触发
* @param {Object} weeks * @param {Object} weeks
*/ */
choiceDate(weeks) { choiceDate(weeks) {
if (weeks.disable) return if (weeks.disable) return
this.calendar = weeks this.calendar = weeks
this.calendar.userChecked = true this.calendar.userChecked = true
// //
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
this.tempRange.before = this.cale.multipleStatus.before const beforeStatus = this.cale.multipleStatus.before
this.tempRange.after = this.cale.multipleStatus.after const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
if (beforeDate > afterDate && afterDate) {
this.tempRange.before = this.cale.multipleStatus.after
this.tempRange.after = this.cale.multipleStatus.before
} else {
this.tempRange.before = this.cale.multipleStatus.before
this.tempRange.after = this.cale.multipleStatus.after
}
this.change() this.change()
}, },
/** /**
@ -603,7 +618,9 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" >
$uni-primary: #007aff !default;
.uni-calendar { .uni-calendar {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -714,7 +731,7 @@
text-align: center; text-align: center;
width: 100px; width: 100px;
font-size: 14px; font-size: 14px;
color: #007aff; color: $uni-primary;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
letter-spacing: 3px; letter-spacing: 3px;
/* #endif */ /* #endif */
@ -893,7 +910,7 @@
border-radius: 100px; border-radius: 100px;
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
background-color: #007aff; background-color: $uni-primary;
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;
letter-spacing: 2px; letter-spacing: 2px;

View File

@ -185,18 +185,34 @@
} }
}, },
watch: { watch: {
// #ifndef VUE3
value: { value: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
if (newVal) { if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari
this.initTime(false) this.initTime(false)
} else { } else {
this.time = '' this.time = ''
this.parseValue(Date.now()) this.parseValue(Date.now())
} }
}, },
immediate: true immediate: true
}, },
// #endif
// #ifdef VUE3
modelValue: {
handler(newVal, oldVal) {
if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari
this.initTime(false)
} else {
this.time = ''
this.parseValue(Date.now())
}
},
immediate: true
},
// #endif
type: { type: {
handler(newValue) { handler(newValue) {
if (newValue === 'date') { if (newValue === 'date') {
@ -539,8 +555,8 @@
* @param {Object} defaultTime * @param {Object} defaultTime
*/ */
parseValue(value) { parseValue(value) {
if (!value) { if (!value) {
return return
} }
if (this.type === 'time' && typeof value === "string") { if (this.type === 'time' && typeof value === "string") {
this.parseTimeType(value) this.parseTimeType(value)
@ -770,7 +786,9 @@
} }
</script> </script>
<style> <style lang="scss">
$uni-primary: #007aff !default;
.uni-datetime-picker { .uni-datetime-picker {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
/* width: 100%; */ /* width: 100%; */
@ -804,7 +822,7 @@
.uni-datetime-picker-btn-text { .uni-datetime-picker-btn-text {
font-size: 14px; font-size: 14px;
color: #007AFF; color: $uni-primary;
} }
.uni-datetime-picker-btn-group { .uni-datetime-picker-btn-group {
@ -889,6 +907,7 @@
.uni-datetime-picker-text { .uni-datetime-picker-text {
font-size: 14px; font-size: 14px;
line-height: 50px
} }
.uni-datetime-picker-sign { .uni-datetime-picker-sign {

View File

@ -91,7 +91,7 @@
<calendar v-show="isPhone" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime" <calendar v-show="isPhone" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime"
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime" :start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime"
:pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false" :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false"
:hideSecond="hideSecond" @confirm="mobileChange" /> :hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" />
</view> </view>
</template> </template>
<script> <script>
@ -126,23 +126,23 @@
} = initVueI18n(messages) } = initVueI18n(messages)
export default { export default {
name: 'UniDatetimePicker', name: 'UniDatetimePicker',
options: { options: {
virtualHost: true virtualHost: true
}, },
components: { components: {
calendar, calendar,
timePicker timePicker
}, },
inject: { inject: {
form: { form: {
from: 'uniForm', from: 'uniForm',
default: null default: null
}, },
formItem: { formItem: {
from: 'uniFormItem', from: 'uniFormItem',
default: null default: null
}, },
}, },
data() { data() {
return { return {
@ -399,10 +399,10 @@
} }
}, },
created() { created() {
// 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
// }) // })
// } // }
}, },
mounted() { mounted() {
@ -515,7 +515,8 @@
close() { close() {
setTimeout(() => { setTimeout(() => {
this.popup = false this.popup = false
this.$emit('maskClick', this.value) this.$emit('maskClick', this.value)
this.$refs.mobile.close()
}, 20) }, 20)
}, },
setEmit(value) { setEmit(value) {
@ -541,7 +542,7 @@
} }
} }
} }
this.$emit('change', value) this.$emit('change', value)
this.$emit('input', value) this.$emit('input', value)
@ -706,15 +707,15 @@
} else { } else {
this.$refs.pcSingle && this.$refs.pcSingle.clearCalender() this.$refs.pcSingle && this.$refs.pcSingle.clearCalender()
} }
if (needEmit) { if (needEmit) {
// //
// if(this.form && this.formItem){ // if(this.form && this.formItem){
// const { // const {
// validateTrigger // validateTrigger
// } = this.form // } = this.form
// if (validateTrigger === 'blur') { // if (validateTrigger === 'blur') {
// this.formItem.onFieldChange() // this.formItem.onFieldChange()
// } // }
// } // }
this.$emit('change', '') this.$emit('change', '')
this.$emit('input', '') this.$emit('input', '')
@ -782,12 +783,14 @@
} }
</script> </script>
<style> <style lang="scss">
.uni-date { $uni-primary: #007aff !default;
/* #ifndef APP-NVUE */
width: 100%; .uni-date {
/* #endif */ /* #ifndef APP-NVUE */
flex: 1; width: 100%;
/* #endif */
flex: 1;
} }
.uni-date-x { .uni-date-x {
display: flex; display: flex;
@ -798,8 +801,8 @@
border-radius: 4px; border-radius: 4px;
background-color: #fff; background-color: #fff;
color: #666; color: #666;
font-size: 14px; font-size: 14px;
flex: 1; flex: 1;
} }
.uni-date-x--border { .uni-date-x--border {
@ -808,15 +811,15 @@
border: 1px solid #e5e5e5; border: 1px solid #e5e5e5;
} }
.uni-date-editor--x { .uni-date-editor--x {
display: flex; display: flex;
align-items: center; align-items: center;
position: relative; position: relative;
} }
.uni-date-editor--x .uni-date__icon-clear { .uni-date-editor--x .uni-date__icon-clear {
padding: 0 5px; padding: 0 5px;
display: flex; display: flex;
align-items: center; align-items: center;
/* #ifdef H5 */ /* #ifdef H5 */
cursor: pointer; cursor: pointer;
@ -825,14 +828,14 @@
.uni-date__x-input { .uni-date__x-input {
padding: 0 8px; padding: 0 8px;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
width: auto; width: auto;
/* #endif */ /* #endif */
position: relative; position: relative;
overflow: hidden; overflow: hidden;
flex: 1; flex: 1;
line-height: 1; line-height: 1;
font-size: 14px; font-size: 14px;
height: 35px; height: 35px;
} }
@ -941,14 +944,14 @@
} }
.popup-x-footer text:hover { .popup-x-footer text:hover {
color: #007aff; color: $uni-primary;
cursor: pointer; cursor: pointer;
opacity: 0.8; opacity: 0.8;
} }
.popup-x-footer .confirm { .popup-x-footer .confirm {
margin-left: 20px; margin-left: 20px;
color: #007aff; color: $uni-primary;
} }
.uni-date-changed { .uni-date-changed {
@ -1009,4 +1012,4 @@
border-top-width: 0; border-top-width: 0;
border-bottom-color: #fff; border-bottom-color: #fff;
} }
</style> </style>

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.6", "version": "2.2.11",
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择", "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
"keywords": [ "keywords": [
"uni-datetime-picker", "uni-datetime-picker",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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

@ -1,47 +1,86 @@
## 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
- 优化 clearable 显示策略 - 优化 clearable 显示策略
## 1.0.42022-06-07 ## 1.0.42022-06-07
- 优化 clearable 显示策略 - 优化 clearable 显示策略
## 1.0.32022-05-20 ## 1.0.32022-05-20
- 修复 关闭图标某些情况下无法取消的bug
- 修复 关闭图标某些情况下无法取消的 bug
## 1.0.22022-04-12 ## 1.0.22022-04-12
- 修复 默认值不生效的bug
- 修复 默认值不生效的 bug
## 1.0.12022-04-02 ## 1.0.12022-04-02
- 修复 value不能为0的bug
- 修复 value 不能为 0 的 bug
## 1.0.02021-11-19 ## 1.0.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/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
## 0.1.42021-08-20 ## 0.1.42021-08-20
- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug - 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
## 0.1.32021-08-11 ## 0.1.32021-08-11
- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 - 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
## 0.1.22021-07-30 ## 0.1.22021-07-30
- 优化 vue3下事件警告的问题
- 优化 vue3 下事件警告的问题
## 0.1.1 ## 0.1.1
- 优化 errorMessage 属性支持 Boolean 类型 - 优化 errorMessage 属性支持 Boolean 类型
## 0.1.02021-07-13 ## 0.1.02021-07-13
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
- 组件兼容 vue3如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 0.0.162021-06-29 ## 0.0.162021-06-29
- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug - 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
## 0.0.152021-06-21 ## 0.0.152021-06-21
- 修复 passwordIcon 属性拼写错误的 bug - 修复 passwordIcon 属性拼写错误的 bug
## 0.0.142021-06-18 ## 0.0.142021-06-18
- 新增 passwordIcon 属性当type=password时是否显示小眼睛图标
- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
- 修复 confirmType 属性不生效的问题 - 修复 confirmType 属性不生效的问题
## 0.0.132021-06-04 ## 0.0.132021-06-04
- 修复 disabled 状态可清出内容的 bug - 修复 disabled 状态可清出内容的 bug
## 0.0.122021-05-12 ## 0.0.122021-05-12
- 新增 组件示例地址 - 新增 组件示例地址
## 0.0.112021-05-07 ## 0.0.112021-05-07
- 修复 input-border 属性不生效的问题 - 修复 input-border 属性不生效的问题
## 0.0.102021-04-30 ## 0.0.102021-04-30
- 修复 ios 遮挡文字、显示一半的问题 - 修复 ios 遮挡文字、显示一半的问题
## 0.0.92021-02-05 ## 0.0.92021-02-05
- 调整为uni_modules目录规范
- 调整为 uni_modules 目录规范
- 优化 兼容 nvue 页面 - 优化 兼容 nvue 页面

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-easyinput", "id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框", "displayName": "uni-easyinput 增强输入框",
"version": "1.1.0", "version": "1.1.3",
"description": "Easyinput 组件是对原生input组件的增强", "description": "Easyinput 组件是对原生input组件的增强",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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

@ -1,3 +1,7 @@
## 1.2.42022-09-07
小程序端由于 style 使用了对象导致报错,[详情](https://ask.dcloud.net.cn/question/152790?item_id=211778&rf=false)
## 1.2.32022-09-05
- 修复 nvue 环境下,具有 tabBar 时fab 组件下部位置无法正常获取 --window-bottom 的bug详见[https://ask.dcloud.net.cn/question/110638?notification_id=826310](https://ask.dcloud.net.cn/question/110638?notification_id=826310)
## 1.2.22021-12-29 ## 1.2.22021-12-29
- 更新 组件依赖 - 更新 组件依赖
## 1.2.12021-11-19 ## 1.2.12021-11-19

View File

@ -5,7 +5,9 @@
'uni-fab--rightBottom': rightBottom, 'uni-fab--rightBottom': rightBottom,
'uni-fab--leftTop': leftTop, 'uni-fab--leftTop': leftTop,
'uni-fab--rightTop': rightTop 'uni-fab--rightTop': rightTop
}" class="uni-fab"> }" class="uni-fab"
:style="nvueBottom"
>
<view :class="{ <view :class="{
'uni-fab__content--left': horizontal === 'left', 'uni-fab__content--left': horizontal === 'left',
'uni-fab__content--right': horizontal === 'right', 'uni-fab__content--right': horizontal === 'right',
@ -32,7 +34,7 @@
'uni-fab__circle--leftTop': leftTop, 'uni-fab__circle--leftTop': leftTop,
'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 }" @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="plusempty" :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>
@ -158,6 +160,16 @@
}, },
horizontalRight() { horizontalRight() {
return this.getPosition(2, 'horizontal', 'right') return this.getPosition(2, 'horizontal', 'right')
},
// nvue bottom
nvueBottom() {
const safeBottom = uni.getSystemInfoSync().windowBottom;
// #ifdef APP-NVUE
return 30 + safeBottom
// #endif
// #ifndef APP-NVUE
return 30
// #endif
} }
}, },
watch: { watch: {
@ -194,6 +206,9 @@
* 按钮点击事件 * 按钮点击事件
*/ */
_onItemClick(index, item) { _onItemClick(index, item) {
if (!this.isShow) {
return
}
this.$emit('trigger', { this.$emit('trigger', {
index, index,
item item

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-fab", "id": "uni-fab",
"displayName": "uni-fab 悬浮按钮", "displayName": "uni-fab 悬浮按钮",
"version": "1.2.2", "version": "1.2.4",
"description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。", "description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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": ["uni-scss","uni-icons"], "dependencies": ["uni-scss","uni-icons"],

View File

@ -1,3 +1,7 @@
## 1.4.82022-08-23
- 优化 根据 rules 自动添加 required 的问题
## 1.4.72022-08-22
- 修复 item 未设置 require 属性rules 设置 require 后,星号也显示的 bug详见[https://ask.dcloud.net.cn/question/151540](https://ask.dcloud.net.cn/question/151540)
## 1.4.62022-07-13 ## 1.4.62022-07-13
- 修复 model 需要校验的值没有声明对应字段时导致第一次不触发校验的bug - 修复 model 需要校验的值没有声明对应字段时导致第一次不触发校验的bug
## 1.4.52022-07-05 ## 1.4.52022-07-05

View File

@ -181,7 +181,7 @@
(value, oldVal) => { (value, oldVal) => {
const isEqual = this.form._isEqual(value, oldVal) const isEqual = this.form._isEqual(value, oldVal)
// //
// TODO oldVal = undefined , // TODO oldVal = undefined ,
// fix by mehaotian && oldVal !== undefined formData // fix by mehaotian && oldVal !== undefined formData
if (!isEqual) { if (!isEqual) {
const val = this.itemSetValue(value) const val = this.itemSetValue(value)
@ -386,10 +386,14 @@
}, },
// //
_isRequired() { _isRequired() {
if (this.form) { // TODO
return this.required || this.form._isRequiredField(this.itemRules.rules || []) // if (this.form) {
} // if (this.form._isRequiredField(this.itemRules.rules || []) && this.required) {
// return true
// }
// return false
// }
return this.required return this.required
}, },
@ -479,7 +483,7 @@
height: 36px; height: 36px;
padding: 0 12px 0 0; padding: 0 12px 0 0;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
vertical-align: middle; vertical-align: middle;
flex-shrink: 0; flex-shrink: 0;
/* #endif */ /* #endif */
@ -624,4 +628,4 @@
border-width: 0; border-width: 0;
/* #endif */ /* #endif */
} }
</style> </style>

View File

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

@ -1,3 +1,9 @@
## 1.3.92022-10-13
- 修复 条件编译错误的bug
## 1.3.82022-10-12
- 修复 nvue 环境 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.72022-08-11
- 修复 nvue 环境下 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.62022-06-30 ## 1.3.62022-06-30
- 修复 组件示例中插槽用法无法显示内容的bug - 修复 组件示例中插槽用法无法显示内容的bug
## 1.3.52022-05-24 ## 1.3.52022-05-24

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="uni-navbar" :class="{'uni-dark':dark}"> <view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}">
<view :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 }" class="uni-navbar__content"> :style="{ 'background-color': themeBgColor }" >
<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">
@ -37,11 +37,13 @@
</slot> </slot>
</view> </view>
</view> </view>
</view> </view>
<!-- #ifndef APP-NVUE -->
<view class="uni-navbar__placeholder" v-if="fixed"> <view class="uni-navbar__placeholder" v-if="fixed">
<status-bar v-if="statusBar" /> <status-bar v-if="statusBar" />
<view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" /> <view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" />
</view> </view>
<!-- #endif -->
</view> </view>
</template> </template>
@ -50,6 +52,8 @@
const getVal = (val) => typeof val === 'number' ? val + 'px' : val; const getVal = (val) => typeof val === 'number' ? val + 'px' : val;
/** /**
*
*
* NavBar 自定义导航栏 * NavBar 自定义导航栏
* @description 导航栏组件主要用于头部导航 * @description 导航栏组件主要用于头部导航
* @tutorial https://ext.dcloud.net.cn/plugin?id=52 * @tutorial https://ext.dcloud.net.cn/plugin?id=52
@ -196,6 +200,11 @@
<style lang="scss" scoped> <style lang="scss" scoped>
$nav-height: 44px; $nav-height: 44px;
.uni-nvue-fixed {
/* #ifdef APP-NVUE */
position: sticky;
/* #endif */
}
.uni-navbar { .uni-navbar {
// box-sizing: border-box; // box-sizing: border-box;
} }

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.6", "version": "1.3.9",
"description": "自定义导航栏组件,主要用于头部导航。", "description": "自定义导航栏组件,主要用于头部导航。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -16,11 +16,7 @@
"directories": { "directories": {
"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": [ "dependencies": [

View File

@ -1,3 +1,5 @@
## 1.2.12022-09-05
- 新增 属性 fontSize可修改文字大小。
## 1.2.02021-11-19 ## 1.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/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-notice-bar](https://uniapp.dcloud.io/component/uniui/uni-notice-bar) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-notice-bar](https://uniapp.dcloud.io/component/uniui/uni-notice-bar)

View File

@ -1,24 +1,47 @@
<template> <template>
<view v-if="show" class="uni-noticebar" :style="{ backgroundColor: backgroundColor }" @click="onClick"> <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
<uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound" <uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound"
:color="color" size="22" /> :color="color" :size="fontSize * 1.5" />
<view ref="textBox" class="uni-noticebar__content-wrapper" <view ref="textBox" class="uni-noticebar__content-wrapper"
:class="{'uni-noticebar__content-wrapper--scrollable':scrollable, 'uni-noticebar__content-wrapper--single':!scrollable && (single || moreText)}"> :class="{
'uni-noticebar__content-wrapper--scrollable': scrollable,
'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText)
}"
:style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
>
<view :id="elIdBox" class="uni-noticebar__content" <view :id="elIdBox" class="uni-noticebar__content"
:class="{'uni-noticebar__content--scrollable':scrollable, 'uni-noticebar__content--single':!scrollable && (single || moreText)}"> :class="{
<text :id="elId" ref="animationEle" class="uni-noticebar__content-text" 'uni-noticebar__content--scrollable': scrollable,
:class="{'uni-noticebar__content-text--scrollable':scrollable,'uni-noticebar__content-text--single':!scrollable && (single || showGetMore)}" 'uni-noticebar__content--single': !scrollable && (single || moreText)
:style="{color:color, width:wrapWidth+'px', 'animationDuration': animationDuration, '-webkit-animationDuration': animationDuration ,animationPlayState: webviewHide?'paused':animationPlayState,'-webkit-animationPlayState':webviewHide?'paused':animationPlayState, animationDelay: animationDelay, '-webkit-animationDelay':animationDelay}">{{text}}</text> }"
>
<text :id="elId" ref="animationEle" class="uni-noticebar__content-text"
:class="{
'uni-noticebar__content-text--scrollable': scrollable,
'uni-noticebar__content-text--single': !scrollable && (single || showGetMore)
}"
:style="{
color: color,
fontSize: fontSize + 'px',
lineHeight: fontSize * 1.5 + 'px',
width: wrapWidth + 'px',
'animationDuration': animationDuration,
'-webkit-animationDuration': animationDuration,
animationPlayState: webviewHide ? 'paused' : animationPlayState,
'-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
animationDelay: animationDelay,
'-webkit-animationDelay': animationDelay
}"
>{{text}}</text>
</view> </view>
</view> </view>
<view v-if="showGetMore === true || showGetMore === 'true'" class="uni-noticebar__more uni-cursor-point" <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point"
@click="clickMore"> @click="clickMore">
<text v-if="moreText.length > 0" :style="{ color: moreColor }" class="uni-noticebar__more-text">{{ moreText }}</text> <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
<uni-icons v-else type="right" :color="moreColor" size="16" /> <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
</view> </view>
<view class="uni-noticebar-close uni-cursor-point" v-if="(showClose === true || showClose === 'true') && (showGetMore === false || showGetMore === 'false')"> <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
<uni-icons <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
type="closeempty" :color="color" size="16" @click="close" />
</view> </view>
</view> </view>
</template> </template>
@ -74,6 +97,10 @@
type: String, type: String,
default: '#FF9A43' default: '#FF9A43'
}, },
fontSize: {
type: Number,
default: 14
},
moreColor: { moreColor: {
type: String, type: String,
default: '#FF9A43' default: '#FF9A43'
@ -123,6 +150,15 @@
animationDelay: '0s' animationDelay: '0s'
} }
}, },
computed: {
isShowGetMore() {
return this.showGetMore === true || this.showGetMore === 'true'
},
isShowClose() {
return (this.showClose === true || this.showClose === 'true')
&& (this.showGetMore === false || this.showGetMore === 'false')
}
},
mounted() { mounted() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
var pages = getCurrentPages(); var pages = getCurrentPages();
@ -262,7 +298,7 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" scoped>
.uni-noticebar { .uni-noticebar {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -310,7 +346,6 @@
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
.uni-noticebar__content-wrapper--scrollable { .uni-noticebar__content-wrapper--scrollable {
position: relative; position: relative;
height: 18px;
} }
/* #endif */ /* #endif */
@ -383,10 +418,6 @@
padding-left: 5px; padding-left: 5px;
} }
.uni-noticebar__more-text {
font-size: 14px;
}
@keyframes notice { @keyframes notice {
100% { 100% {
transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0);

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-notice-bar", "id": "uni-notice-bar",
"displayName": "uni-notice-bar 通告栏", "displayName": "uni-notice-bar 通告栏",
"version": "1.2.0", "version": "1.2.1",
"description": "NoticeBar 通告栏组件,常用于展示公告信息,可设为滚动公告", "description": "NoticeBar 通告栏组件,常用于展示公告信息,可设为滚动公告",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,11 +17,7 @@
"directories": { "directories": {
"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

@ -1,3 +1,10 @@
## 1.2.42022-09-19
- 修复,未对主题色设置默认色,导致未引入 uni-scss 变量文件报错。
- 修复,未对移动端当前页文字做主题色适配。
## 1.2.32022-09-15
- 修复未使用 uni-scss 主题色的 bug。
## 1.2.22022-07-06
- 修复 es 语言 i18n 错误
## 1.2.12021-11-22 ## 1.2.12021-11-22
- 修复 vue3中某些scss变量无法找到的问题 - 修复 vue3中某些scss变量无法找到的问题
## 1.2.02021-11-19 ## 1.2.02021-11-19

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "prev", "uni-pagination.prevText": "prev",
"uni-pagination.nextText": "next" "uni-pagination.nextText": "next",
"uni-pagination.piecePerPage": "piece/page"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "anterior", "uni-pagination.prevText": "anterior",
"uni-pagination.nextText": "próxima" "uni-pagination.nextText": "prxima",
"uni-pagination.piecePerPage": "Art¨ªculo/P¨¢gina"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "précédente", "uni-pagination.prevText": "précédente",
"uni-pagination.nextText": "suivante" "uni-pagination.nextText": "suivante",
"uni-pagination.piecePerPage": "Articles/Pages"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "上一页", "uni-pagination.prevText": "上一页",
"uni-pagination.nextText": "下一页" "uni-pagination.nextText": "下一页",
"uni-pagination.piecePerPage": "条/页"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "上一頁", "uni-pagination.prevText": "上一頁",
"uni-pagination.nextText": "下一頁" "uni-pagination.nextText": "下一頁",
"uni-pagination.piecePerPage": "條/頁"
} }

View File

@ -1,5 +1,15 @@
<template> <template>
<view class="uni-pagination"> <view class="uni-pagination">
<!-- #ifndef MP -->
<picker v-if="showPageSize === true || showPageSize === 'true'" class="select-picker" mode="selector"
:value="pageSizeIndex" :range="pageSizeRange" @change="pickerChange" @cancel="pickerClick"
@click.native="pickerClick">
<button type="default" size="mini" :plain="true">
<text>{{pageSizeRange[pageSizeIndex]}} {{piecePerPage}}</text>
<uni-icons class="select-picker-icon" type="arrowdown" size="12" color="#999"></uni-icons>
</button>
</picker>
<!-- #endif -->
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<view class="uni-pagination__total is-phone-hide"> {{ total }} </view> <view class="uni-pagination__total is-phone-hide"> {{ total }} </view>
<!-- #endif --> <!-- #endif -->
@ -16,8 +26,7 @@
</view> </view>
<view class="uni-pagination__num uni-pagination__num-flex-none"> <view class="uni-pagination__num uni-pagination__num-flex-none">
<view class="uni-pagination__num-current"> <view class="uni-pagination__num-current">
<text class="uni-pagination__num-current-text is-pc-hide" <text class="uni-pagination__num-current-text is-pc-hide current-index-text">{{ currentIndex }}</text>
style="color:#409EFF">{{ currentIndex }}</text>
<text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text> <text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text>
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }" <view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }"
@ -49,11 +58,15 @@
* @tutorial https://ext.dcloud.net.cn/plugin?id=32 * @tutorial https://ext.dcloud.net.cn/plugin?id=32
* @property {String} prevText 左侧按钮文字 * @property {String} prevText 左侧按钮文字
* @property {String} nextText 右侧按钮文字 * @property {String} nextText 右侧按钮文字
* @property {String} piecePerPageText /页文字
* @property {Number} current 当前页 * @property {Number} current 当前页
* @property {Number} total 数据总量 * @property {Number} total 数据总量
* @property {Number} pageSize 每页数据量 * @property {Number} pageSize 每页数据量
* @property {Number} showIcon = [true|false] 是否以 icon 形式展示按钮 * @property {Boolean} showIcon = [true|false] 是否以 icon 形式展示按钮
* @property {Boolean} showPageSize = [true|false] 是否展示每页条数
* @property {Array} pageSizeRange = [20, 50, 100, 500] 每页条数选框
* @event {Function} change 点击页码按钮时触发 ,e={type,current} current为当前页type值为next/prev表示点击的是上一页还是下一个 * @event {Function} change 点击页码按钮时触发 ,e={type,current} current为当前页type值为next/prev表示点击的是上一页还是下一个
* * @event {Function} pageSizeChange 当前每页条数改变时触发 ,e={pageSize} pageSize 为当前所选的每页条数
*/ */
import { import {
@ -65,7 +78,7 @@
} = initVueI18n(messages) } = initVueI18n(messages)
export default { export default {
name: 'UniPagination', name: 'UniPagination',
emits: ['update:modelValue', 'input', 'change'], emits: ['update:modelValue', 'input', 'change', 'pageSizeChange'],
props: { props: {
value: { value: {
type: [Number, String], type: [Number, String],
@ -81,6 +94,9 @@
nextText: { nextText: {
type: String, type: String,
}, },
piecePerPageText: {
type: String
},
current: { current: {
type: [Number, String], type: [Number, String],
default: 1 default: 1
@ -100,18 +116,32 @@
type: [Boolean, String], type: [Boolean, String],
default: false default: false
}, },
showPageSize: {
// icon
type: [Boolean, String],
default: false
},
pagerCount: { pagerCount: {
type: Number, type: Number,
default: 7 default: 7
},
pageSizeRange: {
type: Array,
default: () => [20, 50, 100, 500]
} }
}, },
data() { data() {
return { return {
pageSizeIndex: 0,
currentIndex: 1, currentIndex: 1,
paperData: [] paperData: [],
pickerShow: false
} }
}, },
computed: { computed: {
piecePerPage() {
return this.piecePerPageText || t('uni-pagination.piecePerPage')
},
prevPageText() { prevPageText() {
return this.prevText || t('uni-pagination.prevText') return this.prevText || t('uni-pagination.prevText')
}, },
@ -199,9 +229,31 @@
this.currentIndex = val this.currentIndex = val
} }
} }
},
pageSizeIndex(val) {
this.$emit('pageSizeChange', this.pageSizeRange[val])
} }
}, },
methods: { methods: {
pickerChange(e) {
this.pageSizeIndex = e.detail.value
this.pickerClick()
},
pickerClick() {
// #ifdef H5
const body = document.querySelector('body')
if (!body) return
const className = 'uni-pagination-picker-show'
this.pickerShow = !this.pickerShow
if (this.pickerShow) {
body.classList.add(className)
} else {
setTimeout(() => body.classList.remove(className), 300)
}
// #endif
},
// //
selectPage(e, index) { selectPage(e, index) {
if (parseInt(e)) { if (parseInt(e)) {
@ -256,8 +308,8 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" scoped>
$uni-primary: #2979ff; $uni-primary: #2979ff !default;
.uni-pagination { .uni-pagination {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -350,6 +402,10 @@
.uni-pagination__num-current-text { .uni-pagination__num-current-text {
font-size: 15px; font-size: 15px;
}
.current-index-text{
color: $uni-primary;
} }
.uni-pagination--enabled { .uni-pagination--enabled {
@ -406,4 +462,4 @@
} }
/* #endif */ /* #endif */
</style> </style>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-pagination", "id": "uni-pagination",
"displayName": "uni-pagination 分页器", "displayName": "uni-pagination 分页器",
"version": "1.2.1", "version": "1.2.4",
"description": "Pagination 分页器组件,用于展示页码、请求数据等。", "description": "Pagination 分页器组件,用于展示页码、请求数据等。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -16,11 +16,7 @@
"directories": { "directories": {
"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-icons"], "dependencies": ["uni-scss","uni-icons"],

View File

@ -9,5 +9,3 @@
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-pagination) ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-pagination)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839 #### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@ -1,474 +1,479 @@
<template> <template>
<view v-if="showPopup" class="uni-popup" :class="[popupstyle, isDesktop ? 'fixforpc-z-index' : '']"> <view v-if="showPopup||onceRender" v-show="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"> :show="showTrans" @click="onTap" :once-render="onceRender">
<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>
</uni-transition> </uni-transition>
</view> </view>
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<keypress v-if="maskShow" @esc="onTap" /> <keypress v-if="maskShow" @esc="onTap" />
<!-- #endif --> <!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
// #ifdef H5 // #ifdef H5
import keypress from './keypress.js' import keypress from './keypress.js'
// #endif // #endif
/** /**
* PopUp 弹出层 * PopUp 弹出层
* @description 弹出层组件为了解决遮罩弹层的问题 * @description 弹出层组件为了解决遮罩弹层的问题
* @tutorial https://ext.dcloud.net.cn/plugin?id=329 * @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} type = [top|center|bottom|left|right|message|dialog|share] 弹出方式 * @property {String} type = [top|center|bottom|left|right|message|dialog|share] 弹出方式
* @value top 顶部弹出 * @value top 顶部弹出
* @value center 中间弹出 * @value center 中间弹出
* @value bottom 底部弹出 * @value bottom 底部弹出
* @value left 左侧弹出 * @value left 左侧弹出
* @value right 右侧弹出 * @value right 右侧弹出
* @value message 消息提示 * @value message 消息提示
* @value dialog 对话框 * @value dialog 对话框
* @value share 底部分享示例 * @value share 底部分享示例
* @property {Boolean} animation = [true|false] 是否开启动画 * @property {Boolean} animation = [true|false] 是否开启动画
* @property {Boolean} maskClick = [true|false] 蒙版点击是否关闭弹窗(废弃) * @property {Boolean} maskClick = [true|false] 蒙版点击是否关闭弹窗(废弃)
* @property {Boolean} isMaskClick = [true|false] 蒙版点击是否关闭弹窗 * @property {Boolean} isMaskClick = [true|false] 蒙版点击是否关闭弹窗
* @property {String} backgroundColor 主窗口背景色 * @property {String} backgroundColor 主窗口背景色
* @property {String} maskBackgroundColor 蒙版颜色 * @property {String} maskBackgroundColor 蒙版颜色
* @property {Boolean} safeArea 是否适配底部安全区 * @property {Boolean} safeArea 是否适配底部安全区
* @event {Function} change 打开关闭弹窗触发e={show: false} * @event {Function} change 打开关闭弹窗触发e={show: false}
* @event {Function} maskClick 点击遮罩触发 * @event {Function} maskClick 点击遮罩触发
*/ */
export default { export default {
name: 'uniPopup', name: 'uniPopup',
components: { components: {
// #ifdef H5 // #ifdef H5
keypress keypress
// #endif // #endif
}, },
emits: ['change', 'maskClick'], emits: ['change', 'maskClick'],
props: { props: {
// //
animation: { animation: {
type: Boolean, type: Boolean,
default: true default: true
}, },
// top: bottomcenter // top: bottomcenter
// message: ; dialog : // message: ; dialog :
type: { type: {
type: String, type: String,
default: 'center' default: 'center'
}, },
// maskClick // maskClick
isMaskClick: { isMaskClick: {
type: Boolean, type: Boolean,
default: null default: null
}, },
// TODO 2 使 isMaskClick // TODO 2 使 isMaskClick
maskClick: { maskClick: {
type: Boolean, type: Boolean,
default: null default: null
}, },
backgroundColor: { backgroundColor: {
type: String, type: String,
default: 'none' default: 'none'
}, },
safeArea: { safeArea: {
type: Boolean, type: Boolean,
default: true default: true
}, },
maskBackgroundColor: { maskBackgroundColor: {
type: String, type: String,
default: 'rgba(0, 0, 0, 0.4)' default: 'rgba(0, 0, 0, 0.4)'
}, },
}, // 使v-showPop
onceRender:{
watch: { type:Boolean,
/** default:false
* 监听type类型 },
*/ },
type: {
handler: function(type) { watch: {
if (!this.config[type]) return /**
this[this.config[type]](true) * 监听type类型
}, */
immediate: true type: {
}, handler: function(type) {
isDesktop: { if (!this.config[type]) return
handler: function(newVal) { this[this.config[type]](true)
if (!this.config[newVal]) return },
this[this.config[this.type]](true) immediate: true
}, },
immediate: true isDesktop: {
}, handler: function(newVal) {
/** if (!this.config[newVal]) return
* 监听遮罩是否可点击 this[this.config[this.type]](true)
* @param {Object} val },
*/ immediate: true
maskClick: { },
handler: function(val) { /**
this.mkclick = val * 监听遮罩是否可点击
}, * @param {Object} val
immediate: true */
}, maskClick: {
isMaskClick: { handler: function(val) {
handler: function(val) { this.mkclick = val
this.mkclick = val },
}, immediate: true
immediate: true },
}, isMaskClick: {
// H5 handler: function(val) {
showPopup(show) { this.mkclick = val
// #ifdef H5 },
// fix by mehaotian h5 穿 immediate: true
document.getElementsByTagName('body')[0].style.overflow = show ? 'hidden' : 'visible' },
// #endif // H5
} showPopup(show) {
}, // #ifdef H5
data() { // fix by mehaotian h5 穿
return { document.getElementsByTagName('body')[0].style.overflow = show ? 'hidden' : 'visible'
duration: 300, // #endif
ani: [], }
showPopup: false, },
showTrans: false, data() {
popupWidth: 0, return {
popupHeight: 0, duration: 300,
config: { ani: [],
top: 'top', showPopup: false,
bottom: 'bottom', showTrans: false,
center: 'center', popupWidth: 0,
left: 'left', popupHeight: 0,
right: 'right', config: {
message: 'top', top: 'top',
dialog: 'center', bottom: 'bottom',
share: 'bottom' center: 'center',
}, left: 'left',
maskClass: { right: 'right',
position: 'fixed', message: 'top',
bottom: 0, dialog: 'center',
top: 0, share: 'bottom'
left: 0, },
right: 0, maskClass: {
backgroundColor: 'rgba(0, 0, 0, 0.4)' position: 'fixed',
}, bottom: 0,
transClass: { top: 0,
position: 'fixed', left: 0,
left: 0, right: 0,
right: 0 backgroundColor: 'rgba(0, 0, 0, 0.4)'
}, },
maskShow: true, transClass: {
mkclick: true, position: 'fixed',
popupstyle: this.isDesktop ? 'fixforpc-top' : 'top' left: 0,
} right: 0
}, },
computed: { maskShow: true,
isDesktop() { mkclick: true,
return this.popupWidth >= 500 && this.popupHeight >= 500 popupstyle: this.isDesktop ? 'fixforpc-top' : 'top'
}, }
bg() { },
if (this.backgroundColor === '' || this.backgroundColor === 'none') { computed: {
return 'transparent' isDesktop() {
} return this.popupWidth >= 500 && this.popupHeight >= 500
return this.backgroundColor },
} bg() {
}, if (this.backgroundColor === '' || this.backgroundColor === 'none') {
mounted() { return 'transparent'
const fixSize = () => { }
const { return this.backgroundColor
windowWidth, }
windowHeight, },
windowTop, mounted() {
safeArea, const fixSize = () => {
screenHeight, const {
safeAreaInsets windowWidth,
} = uni.getSystemInfoSync() windowHeight,
this.popupWidth = windowWidth windowTop,
this.popupHeight = windowHeight + (windowTop || 0) safeArea,
// TODO fix by mehaotian ,ios app ios screenHeight,
if (safeArea && this.safeArea) { safeAreaInsets
// #ifdef MP-WEIXIN } = uni.getSystemInfoSync()
this.safeAreaInsets = screenHeight - safeArea.bottom this.popupWidth = windowWidth
// #endif this.popupHeight = windowHeight + (windowTop || 0)
// #ifndef MP-WEIXIN // TODO fix by mehaotian ,ios app ios
this.safeAreaInsets = safeAreaInsets.bottom if (safeArea && this.safeArea) {
// #endif // #ifdef MP-WEIXIN
} else { this.safeAreaInsets = screenHeight - safeArea.bottom
this.safeAreaInsets = 0 // #endif
} // #ifndef MP-WEIXIN
} this.safeAreaInsets = safeAreaInsets.bottom
fixSize() // #endif
// #ifdef H5 } else {
// window.addEventListener('resize', fixSize) this.safeAreaInsets = 0
// this.$once('hook:beforeDestroy', () => { }
// window.removeEventListener('resize', fixSize) }
// }) fixSize()
// #endif // #ifdef H5
}, // window.addEventListener('resize', fixSize)
// #ifndef VUE3 // this.$once('hook:beforeDestroy', () => {
// TODO vue2 // window.removeEventListener('resize', fixSize)
destroyed() { // })
this.setH5Visible() // #endif
}, },
// #endif // #ifndef VUE3
// #ifdef VUE3 // TODO vue2
// TODO vue3 destroyed() {
unmounted() { this.setH5Visible()
this.setH5Visible() },
}, // #endif
// #endif // #ifdef VUE3
created() { // TODO vue3
// this.mkclick = this.isMaskClick || this.maskClick unmounted() {
if (this.isMaskClick === null && this.maskClick === null) { this.setH5Visible()
this.mkclick = true },
} else { // #endif
this.mkclick = this.isMaskClick !== null ? this.isMaskClick : this.maskClick created() {
} // this.mkclick = this.isMaskClick || this.maskClick
if (this.animation) { if (this.isMaskClick === null && this.maskClick === null) {
this.duration = 300 this.mkclick = true
} else { } else {
this.duration = 0 this.mkclick = this.isMaskClick !== null ? this.isMaskClick : this.maskClick
} }
// TODO message if (this.animation) {
this.messageChild = null this.duration = 300
// TODO } else {
this.clearPropagation = false this.duration = 0
this.maskClass.backgroundColor = this.maskBackgroundColor }
}, // TODO message
methods: { this.messageChild = null
setH5Visible() { // TODO
// #ifdef H5 this.clearPropagation = false
// fix by mehaotian h5 穿 this.maskClass.backgroundColor = this.maskBackgroundColor
document.getElementsByTagName('body')[0].style.overflow = 'visible' },
// #endif methods: {
}, setH5Visible() {
/** // #ifdef H5
* 公用方法不显示遮罩层 // fix by mehaotian h5 穿
*/ document.getElementsByTagName('body')[0].style.overflow = 'visible'
closeMask() { // #endif
this.maskShow = false },
}, /**
/** * 公用方法不显示遮罩层
* 公用方法遮罩层禁止点击 */
*/ closeMask() {
disableMask() { this.maskShow = false
this.mkclick = false },
}, /**
// TODO nvue * 公用方法遮罩层禁止点击
clear(e) { */
// #ifndef APP-NVUE disableMask() {
e.stopPropagation() this.mkclick = false
// #endif },
this.clearPropagation = true // TODO nvue
}, clear(e) {
// #ifndef APP-NVUE
open(direction) { e.stopPropagation()
// fix by mehaotian // #endif
if (this.showPopup) { this.clearPropagation = true
clearTimeout(this.timer) },
this.showPopup = false
} open(direction) {
let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share'] // fix by mehaotian
if (!(direction && innerType.indexOf(direction) !== -1)) { if (this.showPopup) {
direction = this.type clearTimeout(this.timer)
} this.showPopup = false
if (!this.config[direction]) { }
console.error('缺少类型:', direction) let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share']
return if (!(direction && innerType.indexOf(direction) !== -1)) {
} direction = this.type
this[this.config[direction]]() }
this.$emit('change', { if (!this.config[direction]) {
show: true, console.error('缺少类型:', direction)
type: direction return
}) }
}, this[this.config[direction]]()
close(type) { this.$emit('change', {
this.showTrans = false show: true,
this.$emit('change', { type: direction
show: false, })
type: this.type },
}) close(type) {
clearTimeout(this.timer) this.showTrans = false
// // this.$emit('change', {
// this.customOpen && this.customClose() show: false,
this.timer = setTimeout(() => { type: this.type
this.showPopup = false })
}, 300) clearTimeout(this.timer)
}, // //
// TODO // this.customOpen && this.customClose()
touchstart() { this.timer = setTimeout(() => {
this.clearPropagation = false this.showPopup = false
}, }, 300)
},
onTap() { // TODO
if (this.clearPropagation) { touchstart() {
// fix by mehaotian nvue this.clearPropagation = false
this.clearPropagation = false },
return
} onTap() {
this.$emit('maskClick') if (this.clearPropagation) {
if (!this.mkclick) return // fix by mehaotian nvue
this.close() this.clearPropagation = false
}, return
/** }
* 顶部弹出样式处理 this.$emit('maskClick')
*/ if (!this.mkclick) return
top(type) { this.close()
this.popupstyle = this.isDesktop ? 'fixforpc-top' : 'top' },
this.ani = ['slide-top'] /**
this.transClass = { * 顶部弹出样式处理
position: 'fixed', */
left: 0, top(type) {
right: 0, this.popupstyle = this.isDesktop ? 'fixforpc-top' : 'top'
backgroundColor: this.bg this.ani = ['slide-top']
} this.transClass = {
// TODO type position: 'fixed',
if (type) return left: 0,
this.showPopup = true right: 0,
this.showTrans = true backgroundColor: this.bg
this.$nextTick(() => { }
if (this.messageChild && this.type === 'message') { // TODO type
this.messageChild.timerClose() if (type) return
} this.showPopup = true
}) this.showTrans = true
}, this.$nextTick(() => {
/** if (this.messageChild && this.type === 'message') {
* 底部弹出样式处理 this.messageChild.timerClose()
*/ }
bottom(type) { })
this.popupstyle = 'bottom' },
this.ani = ['slide-bottom'] /**
this.transClass = { * 底部弹出样式处理
position: 'fixed', */
left: 0, bottom(type) {
right: 0, this.popupstyle = 'bottom'
bottom: 0, this.ani = ['slide-bottom']
paddingBottom: this.safeAreaInsets + 'px', this.transClass = {
backgroundColor: this.bg position: 'fixed',
} left: 0,
// TODO type right: 0,
if (type) return bottom: 0,
this.showPopup = true paddingBottom: this.safeAreaInsets + 'px',
this.showTrans = true backgroundColor: this.bg
}, }
/** // TODO type
* 中间弹出样式处理 if (type) return
*/ this.showPopup = true
center(type) { this.showTrans = true
this.popupstyle = 'center' },
this.ani = ['zoom-out', 'fade'] /**
this.transClass = { * 中间弹出样式处理
position: 'fixed', */
/* #ifndef APP-NVUE */ center(type) {
display: 'flex', this.popupstyle = 'center'
flexDirection: 'column', this.ani = ['zoom-out', 'fade']
/* #endif */ this.transClass = {
bottom: 0, position: 'fixed',
left: 0, /* #ifndef APP-NVUE */
right: 0, display: 'flex',
top: 0, flexDirection: 'column',
justifyContent: 'center', /* #endif */
alignItems: 'center' bottom: 0,
} left: 0,
// TODO type right: 0,
if (type) return top: 0,
this.showPopup = true justifyContent: 'center',
this.showTrans = true alignItems: 'center'
}, }
left(type) { // TODO type
this.popupstyle = 'left' if (type) return
this.ani = ['slide-left'] this.showPopup = true
this.transClass = { this.showTrans = true
position: 'fixed', },
left: 0, left(type) {
bottom: 0, this.popupstyle = 'left'
top: 0, this.ani = ['slide-left']
backgroundColor: this.bg, this.transClass = {
/* #ifndef APP-NVUE */ position: 'fixed',
display: 'flex', left: 0,
flexDirection: 'column' bottom: 0,
/* #endif */ top: 0,
} backgroundColor: this.bg,
// TODO type /* #ifndef APP-NVUE */
if (type) return display: 'flex',
this.showPopup = true flexDirection: 'column'
this.showTrans = true /* #endif */
}, }
right(type) { // TODO type
this.popupstyle = 'right' if (type) return
this.ani = ['slide-right'] this.showPopup = true
this.transClass = { this.showTrans = true
position: 'fixed', },
bottom: 0, right(type) {
right: 0, this.popupstyle = 'right'
top: 0, this.ani = ['slide-right']
backgroundColor: this.bg, this.transClass = {
/* #ifndef APP-NVUE */ position: 'fixed',
display: 'flex', bottom: 0,
flexDirection: 'column' right: 0,
/* #endif */ top: 0,
} backgroundColor: this.bg,
// TODO type /* #ifndef APP-NVUE */
if (type) return display: 'flex',
this.showPopup = true flexDirection: 'column'
this.showTrans = true /* #endif */
} }
} // TODO type
} if (type) return
</script> this.showPopup = true
<style lang="scss"> this.showTrans = true
.uni-popup { }
position: fixed; }
/* #ifndef APP-NVUE */ }
z-index: 99; </script>
<style lang="scss">
/* #endif */ .uni-popup {
&.top, position: fixed;
&.left, /* #ifndef APP-NVUE */
&.right { z-index: 99;
/* #ifdef H5 */
top: var(--window-top); /* #endif */
/* #endif */ &.top,
/* #ifndef H5 */ &.left,
top: 0; &.right {
/* #endif */ /* #ifdef H5 */
} top: var(--window-top);
/* #endif */
.uni-popup__wrapper { /* #ifndef H5 */
/* #ifndef APP-NVUE */ top: 0;
display: block; /* #endif */
/* #endif */ }
position: relative;
.uni-popup__wrapper {
/* iphonex 等安全区设置,底部安全区适配 */ /* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */ display: block;
// padding-bottom: constant(safe-area-inset-bottom); /* #endif */
// padding-bottom: env(safe-area-inset-bottom); position: relative;
/* #endif */
&.left, /* iphonex 等安全区设置,底部安全区适配 */
&.right { /* #ifndef APP-NVUE */
/* #ifdef H5 */ // padding-bottom: constant(safe-area-inset-bottom);
padding-top: var(--window-top); // padding-bottom: env(safe-area-inset-bottom);
/* #endif */ /* #endif */
/* #ifndef H5 */ &.left,
padding-top: 0; &.right {
/* #endif */ /* #ifdef H5 */
flex: 1; padding-top: var(--window-top);
} /* #endif */
} /* #ifndef H5 */
} padding-top: 0;
/* #endif */
.fixforpc-z-index { flex: 1;
/* #ifndef APP-NVUE */ }
z-index: 999; }
/* #endif */ }
}
.fixforpc-z-index {
.fixforpc-top { /* #ifndef APP-NVUE */
top: 0; z-index: 999;
} /* #endif */
}
.fixforpc-top {
top: 0;
}
</style> </style>

View File

@ -125,7 +125,7 @@ export default {
} else { } else {
startIndex = theadChildren.rowspan - 1 startIndex = theadChildren.rowspan - 1
} }
let isHaveData = this.data && this.data.length.length > 0 let isHaveData = this.data && this.data.length > 0
theadChildren.checked = true theadChildren.checked = true
theadChildren.indeterminate = false theadChildren.indeterminate = false
this.trChildren.forEach((item, index) => { this.trChildren.forEach((item, index) => {

View File

@ -1,277 +1,281 @@
<template> <template>
<view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view> <view v-if="isShow||onceRender" v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view>
</template> </template>
<script> <script>
import { createAnimation } from './createAnimation' import { createAnimation } from './createAnimation'
/** /**
* Transition 过渡动画 * Transition 过渡动画
* @description 简单过渡动画组件 * @description 简单过渡动画组件
* @tutorial https://ext.dcloud.net.cn/plugin?id=985 * @tutorial https://ext.dcloud.net.cn/plugin?id=985
* @property {Boolean} show = [false|true] 控制组件显示或隐藏 * @property {Boolean} show = [false|true] 控制组件显示或隐藏
* @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型 * @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型
* @value fade 渐隐渐出过渡 * @value fade 渐隐渐出过渡
* @value slide-top 由上至下过渡 * @value slide-top 由上至下过渡
* @value slide-right 由右至左过渡 * @value slide-right 由右至左过渡
* @value slide-bottom 由下至上过渡 * @value slide-bottom 由下至上过渡
* @value slide-left 由左至右过渡 * @value slide-left 由左至右过渡
* @value zoom-in 由小到大过渡 * @value zoom-in 由小到大过渡
* @value zoom-out 由大到小过渡 * @value zoom-out 由大到小过渡
* @property {Number} duration 过渡动画持续时间 * @property {Number} duration 过渡动画持续时间
* @property {Object} styles 组件样式 css 样式注意带-连接符的属性需要使用小驼峰写法如`backgroundColor:red` * @property {Object} styles 组件样式 css 样式注意带-连接符的属性需要使用小驼峰写法如`backgroundColor:red`
*/ */
export default { export default {
name: 'uniTransition', name: 'uniTransition',
emits:['click','change'], emits:['click','change'],
props: { props: {
show: { show: {
type: Boolean, type: Boolean,
default: false default: false
}, },
modeClass: { modeClass: {
type: [Array, String], type: [Array, String],
default() { default() {
return 'fade' return 'fade'
} }
}, },
duration: { duration: {
type: Number, type: Number,
default: 300 default: 300
}, },
styles: { styles: {
type: Object, type: Object,
default() { default() {
return {} return {}
} }
}, },
customClass:{ customClass:{
type: String, type: String,
default: '' default: ''
} },
}, onceRender:{
data() { type:Boolean,
return { default:false
isShow: false, },
transform: '', },
opacity: 1, data() {
animationData: {}, return {
durationTime: 300, isShow: false,
config: {} transform: '',
} opacity: 1,
}, animationData: {},
watch: { durationTime: 300,
show: { config: {}
handler(newVal) { }
if (newVal) { },
this.open() watch: {
} else { show: {
// close, handler(newVal) {
if (this.isShow) { if (newVal) {
this.close() this.open()
} } else {
} // close,
}, if (this.isShow) {
immediate: true this.close()
} }
}, }
computed: { },
// immediate: true
stylesObject() { }
let styles = { },
...this.styles, computed: {
'transition-duration': this.duration / 1000 + 's' //
} stylesObject() {
let transform = '' let styles = {
for (let i in styles) { ...this.styles,
let line = this.toLine(i) 'transition-duration': this.duration / 1000 + 's'
transform += line + ':' + styles[i] + ';' }
} let transform = ''
return transform for (let i in styles) {
}, let line = this.toLine(i)
// transform += line + ':' + styles[i] + ';'
transformStyles() { }
return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject return transform
} },
}, //
created() { transformStyles() {
// return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject
this.config = { }
duration: this.duration, },
timingFunction: 'ease', created() {
transformOrigin: '50% 50%', //
delay: 0 this.config = {
} duration: this.duration,
this.durationTime = this.duration timingFunction: 'ease',
}, transformOrigin: '50% 50%',
methods: { delay: 0
/** }
* ref 触发 初始化动画 this.durationTime = this.duration
*/ },
init(obj = {}) { methods: {
if (obj.duration) { /**
this.durationTime = obj.duration * ref 触发 初始化动画
} */
this.animation = createAnimation(Object.assign(this.config, obj),this) init(obj = {}) {
}, if (obj.duration) {
/** this.durationTime = obj.duration
* 点击组件触发回调 }
*/ this.animation = createAnimation(Object.assign(this.config, obj),this)
onClick() { },
this.$emit('click', { /**
detail: this.isShow * 点击组件触发回调
}) */
}, onClick() {
/** this.$emit('click', {
* ref 触发 动画分组 detail: this.isShow
* @param {Object} obj })
*/ },
step(obj, config = {}) { /**
* ref 触发 动画分组
* @param {Object} obj
*/
step(obj, config = {}) {
if (!this.animation) return if (!this.animation) return
for (let i in obj) { for (let i in obj) {
try { try {
if(typeof obj[i] === 'object'){ if(typeof obj[i] === 'object'){
this.animation[i](...obj[i]) this.animation[i](...obj[i])
}else{ }else{
this.animation[i](obj[i]) this.animation[i](obj[i])
} }
} catch (e) { } catch (e) {
console.error(`方法 ${i} 不存在`) console.error(`方法 ${i} 不存在`)
} }
} }
this.animation.step(config) this.animation.step(config)
return this return this
}, },
/** /**
* ref 触发 执行动画 * ref 触发 执行动画
*/ */
run(fn) { run(fn) {
if (!this.animation) return if (!this.animation) return
this.animation.run(fn) this.animation.run(fn)
}, },
// //
open() { open() {
clearTimeout(this.timer) clearTimeout(this.timer)
this.transform = '' this.transform = ''
this.isShow = true this.isShow = true
let { opacity, transform } = this.styleInit(false) let { opacity, transform } = this.styleInit(false)
if (typeof opacity !== 'undefined') { if (typeof opacity !== 'undefined') {
this.opacity = opacity this.opacity = opacity
} }
this.transform = transform this.transform = transform
// nextTick wx // nextTick wx
this.$nextTick(() => { this.$nextTick(() => {
// TODO // TODO
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.animation = createAnimation(this.config, this) this.animation = createAnimation(this.config, this)
this.tranfromInit(false).step() this.tranfromInit(false).step()
this.animation.run() this.animation.run()
this.$emit('change', { this.$emit('change', {
detail: this.isShow detail: this.isShow
}) })
}, 20) }, 20)
}) })
}, },
// //
close(type) { close(type) {
if (!this.animation) return if (!this.animation) return
this.tranfromInit(true) this.tranfromInit(true)
.step() .step()
.run(() => { .run(() => {
this.isShow = false this.isShow = false
this.animationData = null this.animationData = null
this.animation = null this.animation = null
let { opacity, transform } = this.styleInit(false) let { opacity, transform } = this.styleInit(false)
this.opacity = opacity || 1 this.opacity = opacity || 1
this.transform = transform this.transform = transform
this.$emit('change', { this.$emit('change', {
detail: this.isShow detail: this.isShow
}) })
}) })
}, },
// //
styleInit(type) { styleInit(type) {
let styles = { let styles = {
transform: '' transform: ''
} }
let buildStyle = (type, mode) => { let buildStyle = (type, mode) => {
if (mode === 'fade') { if (mode === 'fade') {
styles.opacity = this.animationType(type)[mode] styles.opacity = this.animationType(type)[mode]
} else { } else {
styles.transform += this.animationType(type)[mode] + ' ' styles.transform += this.animationType(type)[mode] + ' '
} }
} }
if (typeof this.modeClass === 'string') { if (typeof this.modeClass === 'string') {
buildStyle(type, this.modeClass) buildStyle(type, this.modeClass)
} else { } else {
this.modeClass.forEach(mode => { this.modeClass.forEach(mode => {
buildStyle(type, mode) buildStyle(type, mode)
}) })
} }
return styles return styles
}, },
// //
tranfromInit(type) { tranfromInit(type) {
let buildTranfrom = (type, mode) => { let buildTranfrom = (type, mode) => {
let aniNum = null let aniNum = null
if (mode === 'fade') { if (mode === 'fade') {
aniNum = type ? 0 : 1 aniNum = type ? 0 : 1
} else { } else {
aniNum = type ? '-100%' : '0' aniNum = type ? '-100%' : '0'
if (mode === 'zoom-in') { if (mode === 'zoom-in') {
aniNum = type ? 0.8 : 1 aniNum = type ? 0.8 : 1
} }
if (mode === 'zoom-out') { if (mode === 'zoom-out') {
aniNum = type ? 1.2 : 1 aniNum = type ? 1.2 : 1
} }
if (mode === 'slide-right') { if (mode === 'slide-right') {
aniNum = type ? '100%' : '0' aniNum = type ? '100%' : '0'
} }
if (mode === 'slide-bottom') { if (mode === 'slide-bottom') {
aniNum = type ? '100%' : '0' aniNum = type ? '100%' : '0'
} }
} }
this.animation[this.animationMode()[mode]](aniNum) this.animation[this.animationMode()[mode]](aniNum)
} }
if (typeof this.modeClass === 'string') { if (typeof this.modeClass === 'string') {
buildTranfrom(type, this.modeClass) buildTranfrom(type, this.modeClass)
} else { } else {
this.modeClass.forEach(mode => { this.modeClass.forEach(mode => {
buildTranfrom(type, mode) buildTranfrom(type, mode)
}) })
} }
return this.animation return this.animation
}, },
animationType(type) { animationType(type) {
return { return {
fade: type ? 1 : 0, fade: type ? 1 : 0,
'slide-top': `translateY(${type ? '0' : '-100%'})`, 'slide-top': `translateY(${type ? '0' : '-100%'})`,
'slide-right': `translateX(${type ? '0' : '100%'})`, 'slide-right': `translateX(${type ? '0' : '100%'})`,
'slide-bottom': `translateY(${type ? '0' : '100%'})`, 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
'slide-left': `translateX(${type ? '0' : '-100%'})`, 'slide-left': `translateX(${type ? '0' : '-100%'})`,
'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`, 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})` 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
} }
}, },
// //
animationMode() { animationMode() {
return { return {
fade: 'opacity', fade: 'opacity',
'slide-top': 'translateY', 'slide-top': 'translateY',
'slide-right': 'translateX', 'slide-right': 'translateX',
'slide-bottom': 'translateY', 'slide-bottom': 'translateY',
'slide-left': 'translateX', 'slide-left': 'translateX',
'zoom-in': 'scale', 'zoom-in': 'scale',
'zoom-out': 'scale' 'zoom-out': 'scale'
} }
}, },
// 线 // 线
toLine(name) { toLine(name) {
return name.replace(/([A-Z])/g, '-$1').toLowerCase() return name.replace(/([A-Z])/g, '-$1').toLowerCase()
} }
} }
} }
</script> </script>
<style></style> <style></style>